Swap
swap_simple swaps between two assets on one DEX, with a minimum output or a maximum input.
This page is also Markdown, for agents: /intear-dex.md, and /llms.txt lists every page.
Intear DEX is a NEAR smart contract, the engine, that runs many DEXs inside one contract. It’s deployed at:
dex.intear.nearEach DEX is a small WebAssembly program stored in the engine. The engine runs it when you swap or call it, holds the tokens of every user and DEX, and moves them between balances once the DEX has done its math. Swaps don’t need cross-contract calls, so a swap through several DEXs happens in one receipt, and a failed swap leaves no tokens in flight. Only a DEX that needs an oracle waits: the oracle responds in a later receipt, and the engine holds the assets until then.
Plach, the constant-product AMM, is one of the DEXs that run on the engine, and has docs of its own. Qoq (slimedragon.near/amp), a StableSwap AMM whose pools price their assets with an oracle or a fixed rate, is another. This section covers the engine itself.
near, nep141:<contract>, nep171:<contract>:<token id> and nep245:<contract>:<token id>. See Types.<deployer account>/<name>, for example slimedragon.near/xyk for Plach. See DEXs on the engine.referral_fees, and keep what a swap gives above its quote with quote_improvement_fee. See Referral fees.Swap
swap_simple swaps between two assets on one DEX, with a minimum output or a maximum input.
Chain swaps
execute_operations runs several swaps and withdrawals in one call, each step using the output of the last one.
Swap on deposit
Put operations in the msg of ft_transfer_call: deposit, swap and withdraw in one transaction.
Call a DEX
dex_call and dex_view reach any other method of a DEX, such as adding liquidity or reading pools.