Links

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.

Closing your position

  • Head over to an assets writeContract tool on etherscan (We are using the ETH futures market contract found here.)
  • Connect your wallet, and call the #2 close position function.
  • Withdraw available sUSD by using the #13 WithdrawAllMargin function.
Steps:
  1. 1.
    Connect the wallet that holds the open perps position on the assets contract page on etherscan.
  2. 2.
    When connected, the connect to Web3 button will display connected as well as the connect eth address. (Make sure you are connected to the correct wallet)
  3. 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. 4.
    To close a position, call function 2. closePositions, select write and submit the transactions through metamask. After clicking the Write button and confirming your transaction on Metamask, the position will be closed.
  5. 5.
    Next, you’ll be able to withdraw all of your margin within the specified contract by calling function 13. withdrawAllMargin selecting write and submitting the transaction. After clicking the Write button 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 .

Querying Position Information

  • Head over to your assets readContract tool on etherscan (We are using ETH).
  • Have your ETH address ready to paste
Steps:
  1. 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. 2.
    You can query the current asset oracle price by calling the function #3 AssetPrice and 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. 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.
​