Trading Futures on Etherscan
On-chain perpetual futures have the benefit of allowing users to execute trades directly through the futures contracts if they are unable to access the Kwenta frontend, safeguarding them from not being able to interact with the market.
In the event Kwenta becomes unavailable, you can still manage positions directly on etherscan. Each futures market has a corresponding smart contract that can be accessed regardless of the state of Kwenta, with an up-to-date list of contracts available at docs.kwenta.io.
The most likely need for this is the ability to close a position, which we will cover first. Available futures contracts can be found at L2 Perpetual Contracts . These steps must be completed on every assets contract with an open position you wish to interact with.
- Connect your wallet, and call the
#2 close positionfunction.
- Withdraw available sUSD by using the
- 1.Connect the wallet that holds the open perps position on the assets contract page on etherscan.
- 2.When connected, the
connect to Web3button will display connected as well as the connect eth address. (Make sure you are connected to the correct wallet)
- 3.Users will see a number of functions available to them for our purposes, we will focus on the
#2 close position function&
#13 WithdrawAllMargin function.
- 4.To close a position, call function
2. closePositions, select
writeand submit the transactions through metamask. After clicking the
Writebutton and confirming your transaction on Metamask, the position will be closed.
- 5.Next, you’ll be able to withdraw all of your margin within the specified contract by calling function
writeand submitting the transaction. After clicking the
Writebutton and confirming your transaction on Metamask, the sUSD will be sent back to your wallet. Repeat these steps for every asset with an open position you wish exit. Available futures contracts can be found at L2 Perpetual Contracts .
- 1.Select a read function that corresponds to the position information you wish to retrieve. We will cover a few like the current oracle price, position liquidation price, and a few others.
- 2.You can query the current asset oracle price by calling the function
#3 AssetPriceand selecting
query. This will query the assets contract for the current oracle price and return a uint256 value. Since Ethereum works on 18 decimal places, we will need to count back 18 places to get a usable number. Turning 1341680000000000000000 into a current Ethereum price of $1341.68.
- 3.You can query your open positions liquidation price by calling function
#13 LiquidationPrice, entering your ETH address, and selecting
query.This will return a uint256 value. Counting back 18 decimal places (Ethereum works with 18 decimal places), we see the position will be liquidated when the price of Ethereum reaches $132,235.08.
All position stats can be queried in a similar fashion in case the Kwenta frontend becomes inaccessible.