Methods
This page is also Markdown, for agents: /plach/reference/methods.md, and /llms.txt lists every page.
Swaps go through the engine’s swap_simple, which calls Plach’s swap with a route as message. All other methods are called through the engine on "dex_id": "slimedragon.near/xyk": 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 Plach uses what the call stores and sends the rest to the caller’s wallet.
| Method | Arguments | Attach | Response | Who |
|---|---|---|---|---|
create_pool |
CreatePoolArgs |
NEAR for storage, the initial liquidity or the launched token | CreatePoolResponse { pool_id: u32 } |
Anyone |
edit_fees |
EditFeesArgs { pool_id: u32, fees: FeeConfiguration } |
NEAR for the storage the new configuration adds, or nothing | nothing | The owner of an unlocked private pool |
lock_pool |
LockPoolArgs { pool_id: u32 } |
Nothing | nothing | The owner of a private pool |
See Pools.
Liquidity
Section titled “Liquidity”| Method | Arguments | Attach | Response | Who |
|---|---|---|---|---|
register_liquidity |
RegisterLiquidityArgs { pool_id: u32 } |
NEAR for storage | nothing | Anyone, for a public pool |
add_liquidity |
AddLiquidityArgs { pool_id: u32, min_shares_received: Option<u128> } |
Both assets of the pool | nothing | Registered accounts in public pools, the owner in private pools |
remove_liquidity |
RemoveLiquidityArgs { pool_id: u32, shares_to_remove: Option<u128>, min_assets_received: Option<(u128, u128)> } |
Nothing | nothing | Shareholders of public pools, the owner of an unlocked private pool |
set_liquidity_fee_payout |
SetLiquidityFeePayoutArgs { pool_id: u32, payout_type: FeePayoutType } |
NEAR for storage, or nothing | nothing | Registered accounts in public pools |
collect_liquidity_fees |
CollectLiquidityFeesArgs { pool_id: u32 } |
Nothing | nothing | Registered accounts in public pools |
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. See Liquidity.
| Method | Arguments | Attach | Response | Who |
|---|---|---|---|---|
register_fee_assets |
RegisterFeeAssetsArgs { asset_ids: Vec<AssetId> } |
NEAR for storage | nothing | Anyone, for themselves |
withdraw_fees |
WithdrawFeesArgs { assets: Vec<AssetId> } |
Nothing | nothing | Anyone, for themselves |
claim_fees_anyone |
ClaimFeesArgs { account_id: AccountId, asset_ids: Vec<AssetId> } |
Nothing | nothing | Anyone, for any account |
withdraw_fees moves the caller’s collected fees to their inner balance. claim_fees_anyone sends the fees of an Account receiver with claim_mode: Anyone to its wallet. See Fees.
set_fee_discount_signer (SetFeeDiscountSignerArgs { fee_discount_signer_public_key: Option<PublicKey> }) sets the key that signs fee discounts, or turns them off. Only slimedragon.near can call it.
| 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 or not a public pool. 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 or not a public pool. 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, for the registered fee assets |
get_claimable_fees |
GetClaimableFeesArgs { account_id: AccountId, asset_ids: Vec<AssetId> } |
HashMap<AssetId, u128>: fees anyone can claim for the account, for its assets |
get_fee_discount_signer |
none | Option<PublicKey>: the key that signs fee discounts. See PublicKey for its layout |
contract_source_metadata |
none | NEP-330 metadata, in JSON: the version |
For views without arguments, pass "" as args.