Pools
This page is also Markdown, for agents: /qoq/guides/pools.md, and /llms.txt lists every page.
A pool holds two different assets, NEAR, NEP-141 or NEP-245, and swaps between them on a StableSwap curve around a price. Pool IDs are counted from 0 in the order pools were created.
What a pool has
Section titled “What a pool has”| Field | Description |
|---|---|
assets |
The two assets and the pool’s balance of each |
decimals |
The decimals of each asset, at most 38. The price is of whole tokens, so these turn amounts into whole tokens |
amplification |
A of the StableSwap curve, from 1 to 1000000. The higher it is, the closer the pool keeps to its price as it gets out of balance |
rate_source |
Where the price of a whole token of the first asset in the second comes from: an Oracle, with the key of the oracle and the price of the last swap, or Fixed. Prices have 18 decimals |
fee |
Out of 1000000, so 750 is 0.075%. 20% of it goes to Qoq. Less than 100% |
total_shares |
The shares of all liquidity providers. None when all liquidity was removed |
See How prices are computed for how these make a swap’s price.
A pool’s rate source can’t change between Oracle and Fixed, and a fixed price can’t change. An oracle pool can get another oracle.
Read pools
Section titled “Read pools”get_pool takes a pool ID, a Borsh u32, and returns a Borsh Option<PoolView>, None if there’s no such pool. get_pool_count returns the number of pools, and get_pools takes a start_index and a limit and returns the pools from there, so the ID of each is start_index plus its position. For views without arguments, pass "" as args.
near contract call-function as-read-only dex.intear.near dex_view \ json-args '{"dex_id": "slimedragon.near/amp", "method": "get_pool_count", "args": ""}' \ network-config mainnet now
near contract call-function as-read-only dex.intear.near dex_view \ json-args '{"dex_id": "slimedragon.near/amp", "method": "get_pool", "args": "AQAAAA=="}' \ network-config mainnet nowA PoolView is a struct with the fields above, not an enum like Plach’s.
Owner settings
Section titled “Owner settings”Only Qoq’s owner, slimedragon.near, which deployed it, can create pools and change them. Changes take effect at once.
| Method | Arguments | What it does |
|---|---|---|
create_pool |
CreatePoolArgs |
Creates a pool with its first liquidity, for which the owner gets 1018 shares. Attach the liquidity and NEAR for storage |
set_amplification |
SetAmplificationArgs { pool_id: u32, amplification: u32 } |
Changes A, from 1 to 1000000 |
set_fee |
SetFeeArgs { pool_id: u32, fee: u32 } |
Changes the fee, to less than 100% |
set_oracle_key |
SetOracleKeyArgs { pool_id: u32, oracle_key: PublicKey } |
Gives a pool that an oracle prices another oracle. Attach NEAR if the new key takes more storage |
Each change logs a PoolUpdated event.