Skip to content

Methods

Swaps go through the engine’s swap_simple or operations, which call Qoq’s swap with routes as message. Swaps through a pool that an oracle prices start with an oracle request. All other methods are called through the engine on "dex_id": "slimedragon.near/amp": calls with dex_call, and views with dex_view. Arguments and responses are Borsh, in base64. Types are in Types.

Every call has to come directly from the caller: a dex_call, or a DexCall in execute_operations, not in the operations of a deposit.

“Attach” is the attached_assets of the dex_call, from the caller’s inner balance. “NEAR for storage” means Qoq uses what the call stores and sends the rest to the caller’s wallet.

Method Arguments Attach Response Who
register_liquidity RegisterLiquidityArgs { pool_id: u32 } NEAR for storage nothing Anyone
add_liquidity AddLiquidityArgs { pool_id: u32, min_shares_received: Option<u128> } Both assets of the pool nothing Registered accounts
remove_liquidity RemoveLiquidityArgs { pool_id: u32, shares_to_remove: Option<u128>, min_assets_received: Option<(u128, u128)> } Nothing nothing Shareholders
set_liquidity_fee_payout SetLiquidityFeePayoutArgs { pool_id: u32, payout_type: FeePayoutType } NEAR for storage, or nothing nothing Registered accounts
collect_liquidity_fees CollectLiquidityFeesArgs { pool_id: u32 } Nothing nothing Registered accounts
withdraw_fees WithdrawFeesArgs { assets: Vec<AssetId> } Nothing nothing Anyone, for themselves

What an addition doesn’t use, and the assets of removed liquidity, are sent to the caller’s wallet. Adding, removing, set_liquidity_fee_payout and collect_liquidity_fees collect the provider’s part of the pool’s fees to its collected fees, which withdraw_fees moves to its inner balance. See Liquidity.

Only Qoq’s owner, slimedragon.near, can call these. See Owner settings.

Method Arguments Attach Response
create_pool CreatePoolArgs NEAR for storage, and the initial liquidity CreatePoolResponse { pool_id: u32 }
set_amplification SetAmplificationArgs { pool_id: u32, amplification: u32 } Nothing nothing
set_fee SetFeeArgs { pool_id: u32, fee: u32 } Nothing nothing
set_oracle_key SetOracleKeyArgs { pool_id: u32, oracle_key: PublicKey } NEAR for storage, or nothing nothing

migrate, with no arguments, updates the state of Qoq for a new version of its code, after it’s deployed.

Method Arguments Response
get_pool GetPoolArgs { pool_id: u32 } Option<PoolView>
get_pools GetPoolsArgs { start_index: u32, limit: u32 } Vec<PoolView>: the pools from start_index, so each one’s ID is start_index plus its position
get_pool_count none u32
get_pool_shares GetPoolSharesArgs { pool_ids: Vec<u32>, account_id: AccountId } Vec<Option<u128>>: shares in each pool, None if not registered. Fails with Pool <id> not found for an unknown pool
get_liquidity_position GetLiquidityPositionArgs { pool_id: u32, account_id: AccountId } Option<LiquidityPositionView>: the provider’s payout and its fees not collected yet, None if not registered. Fails with Pool <id> not found for an unknown pool
get_pending_fees GetPendingFeesArgs { account_id: AccountId, asset_ids: Vec<AssetId> } HashMap<AssetId, u128>: collected fees, in the assets the account can be paid in
contract_source_metadata none NEP-330 metadata, in JSON: the version

For views without arguments, pass "" as args.