Skip to main content

Perps Contract Specification

Contracts

Testnet

dev-1671051706222-37641057408636

Mainnet

v1.tonic-perps.near

Conventions

All dollar amounts go to 6 decimals. LP tokens have 18 decimals.

List Assets

Get a paginated list of all tradable assets.

near view $TONIC_CONTRACT get_assets

Mint LP tokens

near call $TONIC_CONTRACT_ID mint_lp_near '{}' --deposit 10 --accountId $ACCOUNT_ID

Burn LP Token

Burn LP token and receive assets from the pool.

near call $TONIC_CONTRACT_ID burn_lp_token '{"amount": "10000000000000000000", "output_token_id": "near", "min_out": "0"}'

Get LP Price

near view $TONIC_CONTRACT_ID get_lp_price

Swap Tokens

near call $TONIC_CONTRACT_ID swap_near '{}' --deposit 10 --accountId $ACCOUNT_ID

Increase Position

near call $TONIC_CONTRACT_ID increase_position '{"params": {"underlying_id": "near", "size_delta": "2500000000", "is_long": true}}' --deposit 50

Decrease Position

near call $TONIC_CONTRACT_ID decrease_position '{"params": {"position_id": "", "size_delta": "1000000", "collateral_delta": "0"}}'

Get Positions

near view $TONIC_CONTRACT_ID get_positions '{"account_id": ""}'

Get Position by ID

near view $TONIC_CONTRACT_ID get_position '{"position_id": ""}'

Create Referral Code

near call $TONIC_CONTRACT_ID create_referral_code '{"referral_code": ""}' --deposit 0.05

Create Limit Order

near call $TONIC_CONTRACT add_limit_order '{"params": {"price": "1590000", "size_delta": "2100000000", "collateral_delta": "417900000", "collateral_id": "near", "underlying_id": "near", "is_long": true, "order_type": "Decrease"}}' --accountId $ACCOUNT_ID