Skip to content
alexander-nechaiev edited this page Jun 24, 2021 · 8 revisions

Laminar Chain

Laminar Chain Implementation

The Laminar Chain contains the following modules

  • orml-oracle: is part of the Open Runtime Module Library, takes price feed, and allows other modules to get price for particular currency

    // Dispatchable methods
    fn feed_value(origin, key: T::Key, value: T::Value)
    fn feed_values(origin, values: Vec<(T::Key, T::Value)>)
    // Module callable methods
    fn read_raw_values(key: &T::Key)
    fn get(key: &T::Key)
    
  • orml-currencies: is part of the Open Runtime Module Library, supports MultiCurrency and native token via balance

    // Dispatchable methods
    pub fn transfer(origin,
    		dest: <T::Lookup as StaticLookup>::Source,
    		currency_id: CurrencyIdOf<T>,
    		#[compact] amount: BalanceOf<T>,)
    pub fn transfer_native_currency(origin,
    		dest: <T::Lookup as StaticLookup>::Source,
    		#[compact] amount: BalanceOf<T>,)
    
  • margin_liquidity_pools: assets in the liquidity pool are used as collaterals in margin trading. Anyone can create_pool and deposit_liquidity, only owner can remove_pool and disable_pool, owner can set spread, additional_swap and min_leveraged_amount, and specify which trades are supported by this pool

    // Dispatchable methods
    fn create_pool(origin)
    fn disable_pool(origin, pool: LiquidityPoolId)
    fn remove_pool(origin, pool: LiquidityPoolId)
    fn deposit_liquidity(origin, pool: LiquidityPoolId, amount: Balance)
    fn withdraw_liquidity(origin, pool: LiquidityPoolId, amount: Balance)
    fn set_spread(origin, pool: LiquidityPoolId, pair: TradingPair, bid: Permill, ask: Permill)
    fn liquidity_pool_enable_trading_pair(origin, pool_id: LiquidityPoolId, pair: TradingPair)
    fn liquidity_pool_disable_trading_pair(origin, pool_id: LiquidityPoolId, pair: TradingPair)
    fn set_min_leveraged_amount(origin, pool_id: LiquidityPoolId, amount: Balance)
    
    // Dispatchable methods by ROOT or financial council
    fn set_swap_rate(origin, pair: TradingPair, rate: SwapRate)
    fn set_max_spread(origin, pair: TradingPair, max_spread: Permill)
    fn enable_trading_pair(origin, pair: TradingPair)
    fn disable_trading_pair(origin, pair: TradingPair)
    fn set_default_min_leveraged_amount(origin, amount: Balance)
    
  • synthetic_liquidity_pools: assets in the liquidity pool are used as collaterals in synthetic asset. Anyone can create_pool and deposit_liquidity, only owner can remove_pool and disable_pool, owner can set spread and additional_collateral_ratio, and specify enabled synthetics

    // Dispatchable methods
    fn create_pool(origin)
    fn disable_pool(origin, pool: LiquidityPoolId)
    fn remove_pool(origin, pool: LiquidityPoolId)
    fn deposit_liquidity(origin, pool: LiquidityPoolId, amount: Balance)
    fn withdraw_liquidity(origin, pool: LiquidityPoolId, amount: Balance)
    fn set_spread(origin, pool: LiquidityPoolId, currency_id: CurrencyId, bid: Permill, ask: Permill)
    fn set_additional_collateral_ratio(origin, pool: LiquidityPoolId, currency_id: CurrencyId, ratio: Option<Permill>)
    fn set_synthetic_enabled(origin, pool_id: LiquidityPoolId, currency_id: CurrencyId, enabled: bool)
    
    // Dispatchable methods by ROOT or financial council
    fn set_min_additional_collateral_ratio(origin, ratio: Permill)
    fn set_max_spread(origin, currency_id: CurrencyId, max_spread: Permill)
    
  • synthetic_tokens: represents synthetic assets like fEUR. It is an implementation of MultiCurrency from our Open Runtime Module Library

    // Storage
    ExtremeRatio: CurrencyId => Option<Permill>
    LiquidationRatio: CurrencyId => Option<Permill>
    CollateralRatio: CurrencyId => Option<Permill>
    Positions: map (LiquidityPoolId, CurrencyId) => Position
    // Module callable methods
    addPosition(who: AccountId, pool: LiquidityPoolId, collaterals: Balance, minted: Balance)
    removePosition(who: AccountId, pool: LiquidityPoolId, collaterals: Balance, minted: Balance)
    
  • synthetic_protocol: it is the entry/proxy module for people to trade 1:1 with synthetic assets. You can mint and redeem a particular synthetic asset, liquidate a position that's below required collateral ratio. Later version we will use off-chain worker to implement liquidation process to improve responsiveness to risks.

    // Dispatchable methods
    fn mint(origin, currency_id: CurrencyId, pool: LiquidityPoolId, base_amount: Balance, max_slippage: fn Permill)
    fn redeem(origin, currency_id: CurrencyId, pool: LiquidityPoolId, flow_amount: Balance, max_slippage: Permill)
    fn liquidate(origin, currency_id: CurrencyId, pool: LiquidityPoolId, flow_amount: Balance)
    
  • margin_protocol: people can use this module to openPosition and closePosition for leveraged long or short trades

    // Dispatchable methods
    fn open_position(origin, pool: LiquidityPoolId, pair: TradingPair, leverage: Leverage, #[compact] leveraged_amount: Balance, price: Price)
    fn close_position(origin, position_id: PositionId, price: Price)
    fn deposit(origin, #[compact] amount: Balance)
    fn withdraw(origin, #[compact] amount: Balance)
    
    // RPC methods
    #[rpc(name = "marginProtocol_equity_of_trader")]
    fn equity_of_trader(who: AccountId) -> Option<Fixed128>
    
    #[rpc(name = "marginProtocol_margin_level")]
    fn margin_level(who: AccountId) -> Option<Fixed128>
    
    #[rpc(name = "marginProtocol_free_margin")]
    fn free_margin(who: AccountId) -> Option<Fixed128>;
    
    #[rpc(name = "marginProtocol_margin_held")]
    fn margin_held(who: AccountId) -> Fixed128;
    
    #[rpc(name = "marginProtocol_unrealized_pl_of_trader")]
    fn unrealized_pl_of_trader(who: AccountId) -> Option<Fixed128>
    
  • primitives: constants for supported leverages, currencies etc

Our margin trading protocol is currently under review by financial advisors. While the MVP testnet will implement the current version of margin trading protocol, it is expected that the next version will be upgraded to a more elaborated margin trading mechanisms. More details on the upgrade will be disclosed as we progress.

See more details here

Clone this wiki locally