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
- Fungible Token
near call $TONIC_CONTRACT_ID mint_lp_near '{}' --deposit 10 --accountId $ACCOUNT_ID
near call $TOKEN_CONTRACT_ID ft_transfer_call '{"receiver_id": "'$TONIC_CONTRACT_ID'", "amount": "1000000000", "msg": "{\"action\": \"MintLp\", \"params\": {}}"}' --depositYocto 1 --gas 300000000000000 --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
- Fungible Token
near call $TONIC_CONTRACT_ID swap_near '{}' --deposit 10 --accountId $ACCOUNT_ID
❯ NEAR_ENV=mainnet near call $TOKEN_CONTRACT ft_transfer_call '{"receiver_id": "'$TONIC_CONTRACT_ID'", "amount": "1000000", "msg": "{\"action\": \"Swap\", \"params\": {\"output_token_id\": \"aurora\"}}"}' --depositYocto 1 --gas 300000000000000
Increase Position
- NEAR
- Fungible Token
near call $TONIC_CONTRACT_ID increase_position '{"params": {"underlying_id": "near", "size_delta": "2500000000", "is_long": true}}' --deposit 50
near call $TOKEN_CONTRACT ft_transfer_call '{"receiver_id": "'$TONIC_CONTRACT_ID'", "amount": "1000000", "msg": "{\"action\": \"IncreasePosition\", \"params\": {\"underlying_id\": \"underlying_token_id\", \"size_delta\": \"1000000000\", \"is_long\": true}}"}' --depositYocto 1 --gas 300000000000000 --accountId $ACCOUNT_ID
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 Collateral or Decrease
- Fungible Token Collateral
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
near call $TOKEN_CONTRACT_ID ft_transfer_call '{"receiver_id": "'$TONIC_CONTRACT_ID'", "amount": "1000000000", "msg": "{\"action\": \"PlaceLimitOrder\", \"params\": {}}"}' --depositYocto 1 --gas 300000000000000 --accountId $ACCOUNT_ID