v2
STON.fi v2 smart contract API - advanced contracts with vault architecture and gas optimization
API reference
Overview
The section contains separate documents for each smart contract used in AMM:
Example schemes
Example schemes can be found here:
Op code list
A table with DEX v2 op codes:
New DEX v2 features:
Swap
custom payload & nested operations after swaps
chain multiple swaps on the same
Routerchain multiple swaps on different v2
Routerscustom refund address and payload on swap failure
deadline for tx completion
Liquidity
custom payload after liquidly provision
improved initial liquidity locking management, no coins are lost anymore
now always mints a maximum possible amount of lp tokens to user even if provision ratio is different from current one in
Poolsingle side liquidity provision
deadline for tx completion
Referral
referral fees are stored in
Vaultcontractcustom referral fee value in each swap (maximum 1%)
Note: Protocol fees in DEX v2 are collected in ASK jetton.
Referral Fees
DEX v2 accumulates each swap's referral portion in a dedicated Vault contract (one per referrer × token pair). Fees can be configured in the 0.01 %–1 % range and must later be withdrawn by the referrer. See the Omniston referral fees guide (note: although the guide is Omniston-oriented, the referenced paragraph explains in detail how DEX V2 referral fees work).
You can inspect vault balances and accrual history using the Stats & Vaults REST API:
GET /v1/wallets/{addr_str}/fee_vaults– lists all known vaults per referrerGET /v1/stats/fee_accruals– shows all operations that led to fee accrual for the referrer, filterable by periodGET /v1/stats/fee_withdrawals– lists all withdrawals from the referrer's vaults, filterable by periodGET /v1/stats/fees– returns aggregated referral fee metrics (for example, total accrued USD value) by time frame
All endpoints are documented in the Swagger UI.
pTON v2
now uses a custom op code for ton transfers
ton transfer to user is non-bouncable
improved gas management
can chain ton transfers between 2 pTON wallets (to chain pTON swaps on v2
Routers)
Other
LpAccountandVaultare deleted if they have 0 tokens on balance to avoid paying storage costbetter error management: no coins are lost if
Pooldoesn't exist / payload is not correctcomplete refactoring of the codebase and usage of libs in masterchain to make all operations cheaper
fixed various excesses issues
fixed some
Poolshaving brokenget_jetton_data
Removed
Pool
off-chain
get_expected_outputsoff-chain
get_expected_tokensoff-chain
get_expected_liquidityon-chain
getter_expected_outputson-chain
getter_expected_tokenson-chain
getter_expected_liquidityuser-called
collect_fees
Last updated