Methods
This page is also Markdown, for agents: /intear-dex/reference/methods.md, and /llms.txt lists every page.
All methods are on dex.intear.near, with JSON arguments. Types like AssetId and AccountOrDexId are described in Types. Amounts (U128) are integer strings.
Methods marked 1 yocto need exactly 1 yoctoNEAR attached, which also means they must be signed with a full access key.
When the contract is paused, every change method fails with Contract is paused, and so does simulate_swap_simple. pause, unpause and set_trusted_code_deployer still work, and so do views and the callbacks of withdrawals. rescue works only while paused, and storage_unregister always fails with its own message.
Change methods
Section titled “Change methods”Balances
Section titled “Balances”| Method | Deposit | Arguments | Returns |
|---|---|---|---|
register_assets |
1 yocto | asset_ids: AssetId[], for?: AccountOrDexId |
nothing |
deposit_near |
The NEAR to deposit | operations?: DepositMessage |
nothing |
transfer_asset |
1 yocto | to: AccountOrDexId, asset_id: AssetId, amount: U128 |
nothing |
withdraw |
1 yocto | asset_id: AssetId, amount: DirectWithdrawAmount, withdraw_to?: AccountId |
bool |
register_assets: registers assets forfor(default: the caller), paid from the caller’s storage balance. See Register assets.deposit_near: withoutoperations, adds the attached NEAR to the caller’s inner balance. Withoperations, runs them on the attached NEAR. See Operations in a deposit.transfer_asset: moves assets from the caller’s inner balance to another inner balance. A transfer of 0 does nothing.withdraw: sends assets out of the engine. Returnstrueif the transfer succeeded,falseif it failed and the assets were refunded to an inner balance. A withdrawal of 0, such asFullof an empty balance, returnstruewithout a transfer. See Withdraw.
Swaps and DEX calls
Section titled “Swaps and DEX calls”| Method | Deposit | Arguments | Returns |
|---|---|---|---|
swap_simple |
1 yocto | dex_id: DexId, message: Base64, asset_in: AssetId, asset_out: AssetId, amount: SwapRequestAmount, referrer?: AccountId, referral_fees?: ReferralFees, constraint?: U128 |
[amount_in, amount_out] |
dex_call |
1 yocto | dex_id: DexId, method: string, args: Base64, attached_assets: { [AssetId]: U128 }, referrer?: AccountId |
Base64 |
execute_operations |
At least 1 yocto | operations: Operation[], referrer?: AccountId, referral_fees?: ReferralFees |
nothing |
swap_simple: see Swaps.referral_feesare the referral fees the swap pays out of its input, andamount_inincludes them.dex_call: see Calling a DEX.execute_operations: if more than 1 yoctoNEAR is attached, the whole deposit is added to the caller’s NEAR inner balance first.referral_feesare paid by the first swap only. See Operations.
Token receivers
Section titled “Token receivers”Token contracts call these when you transfer tokens to dex.intear.near with *_transfer_call. Don’t call them yourself.
| Method | Standard | msg |
|---|---|---|
ft_on_transfer |
NEP-141 | "" or a JSON DepositMessage |
nft_on_transfer |
NEP-171 | "" or a JSON DepositMessage |
mt_on_transfer |
NEP-245 | "" or a JSON DepositMessage |
With an empty msg the tokens go to the owner’s inner balance: sender_id for NEP-141, previous_owner_id for NFTs, and each of previous_owner_ids for multi tokens. Otherwise the operations in msg run on them. The engine keeps all tokens it accepts, and fails the call (so the token contract refunds them) if anything goes wrong.
Storage
Section titled “Storage”| Method | Deposit | Arguments | Returns |
|---|---|---|---|
storage_deposit |
At least 0.005 NEAR | account_id?: AccountId, registration_only?: bool |
StorageBalance |
storage_withdraw |
1 yocto | amount?: U128 |
StorageBalance |
storage_unregister |
1 yocto | force?: bool |
Always fails: not supported |
dex_storage_deposit |
At least 0.005 NEAR | dex_id: DexId, registration_only?: bool |
StorageBalance |
dex_storage_withdraw |
1 yocto | dex_id: DexId, amount?: U128 |
StorageBalance. Only the DEX’s deployer can call it |
See Storage.
DEX code
Section titled “DEX code”| Method | Deposit | Arguments | Returns |
|---|---|---|---|
deploy_dex_code |
1 yocto | last_part_of_id: string, code_base64: Base64 |
nothing |
set_trusted_code_deployer |
1 yocto | account_id: AccountId |
nothing |
deploy_dex_code: deploys or upgrades the DEX<caller>/<last_part_of_id>. Only the trusted code deployer can call it. See Deploying.set_trusted_code_deployer: hands the permission to deploy DEX code to another account. Only the current trusted code deployer can call it.
| Method | Deposit | Arguments | Returns |
|---|---|---|---|
pause |
1 yocto | none | nothing |
unpause |
1 yocto | none | nothing |
Only slimedragon.near and pause.slimedragon.near can pause and unpause. Pausing stops deposits, swaps, calls, transfers, withdrawals and storage changes. Withdrawals already in flight still finish or get refunded.
Rescue
Section titled “Rescue”rescue(asset_id: AssetId, amount?: U128, to: AccountId) sends out assets that the contract holds but doesn’t track, such as tokens sent with ft_transfer instead of ft_transfer_call. Only the engine’s own account can call it, and only while the contract is paused. Without amount, everything untracked is sent. It can never send assets that belong to users or DEXs.
View methods
Section titled “View methods”| Method | Arguments | Returns |
|---|---|---|
asset_balance_of |
of: AccountOrDexId, asset_id: AssetId |
U128, or null if not registered |
registered_assets_of |
account_id?: AccountId, dex_id?: DexId, from_index: u32, limit: u32 |
[AssetId, U128][] |
are_assets_registered |
asset_ids: AssetId[], for: AccountOrDexId |
bool: true if all of them are registered |
simulate_swap_simple |
dex_id: DexId, message: Base64, trader: AccountId, asset_in: AssetId, asset_out: AssetId, amount: SwapRequestAmount, referrer?: AccountId, referral_fees?: ReferralFees |
[amount_in, amount_out] |
dex_view |
dex_id: DexId, method: string, args: Base64 |
Base64 |
dex_code |
dex_id: DexId |
Base64: the DEX’s WebAssembly code. Fails with Dex code not found if there’s no such DEX |
storage_balance_of |
account_id: AccountId |
StorageBalance, or null |
storage_balance_bounds |
none | { "min": "5000000000000000000000", "max": null } |
dex_storage_balance_of |
dex_id: DexId |
StorageBalance, or null |
dex_storage_balance_bounds |
none | { "min": "5000000000000000000000", "max": null } |
total_storage_balances |
none | { "users": StorageBalance, "dexes": StorageBalance } |
total_in_custody |
asset_id: AssetId |
U128: the total of the asset held for all users and DEXs, or null if nobody ever registered it |
untracked_near |
none | U128: NEAR on the contract’s account that isn’t owed to anyone |
is_paused |
none | bool |
get_trusted_code_deployer |
none | AccountId |
contract_source_metadata |
none | NEP-330 metadata: the version, and a link to the source code of the deployed build |
In registered_assets_of, pass exactly one of account_id and dex_id. Assets come in the order they were registered.