Skip to content

Intear DEX

Intear DEX is a NEAR smart contract, the engine, that runs many DEXs inside one contract. It’s deployed at:

dex.intear.near

Each 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.

Plach, the AMM, is one of the DEXs that run on the engine, and has docs of its own. This section covers the engine itself.

  • Inner balances. You deposit tokens to the engine once and trade from your balance inside it. Withdraw them to your wallet when you’re done. See Inner balances.
  • Assets. NEAR, NEP-141 fungible tokens, NEP-171 NFTs and NEP-245 multi tokens, written as near, nep141:<contract>, nep171:<contract>:<token id> and nep245:<contract>:<token id>. See Types.
  • DEX IDs. Every DEX has an ID of <deployer account>/<name>, for example slimedragon.near/xyk for Plach. See DEXs on the engine.
  • Registration and storage. Before you can hold an asset, it has to be registered for you, and that costs storage that you pay for with a storage deposit. See Storage.
  • Operations. A list of steps (swap, withdraw, transfer and more) that run in one call, either from your inner balance or right inside a token deposit. See Operations.

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.