Trading via Etherscan
Last updated
Last updated
Pika Protocol is a fully decentralized and permission-less exchange, operated not by team, but by unstoppable code. In the rare case when the website server is down, you can always trade directly with the smart contract from block explorers like Etherscan.
If you have previously approved the contract in Pika UI, you can skip this step.
To approve the contract, you first open the USDC contract on Etherscan:
Then clicks Connect to Web
to connect to your Metamask wallet.
You need to click the Approve function 4 times to approve these 4 addresses:
PikaPerpV4 address: 0x9b86B2Be8eDB2958089E522Fe0eB7dD5935975AB
PositionManager address: 0xb67c152e69217b5acb85a2e19df13423351b0e27
OrderBook address: 0x835a179a9E1A57f15823eFc82bC460Eb2D9d2E7C
PositionRouter address: 0xa78Cd820b198A943199deb0506E77d655b5078cC
The amount
is your intended trade amount. If you want to trade 100 USDC, the input amount should be 10000000000(100*1e8).
You need to open the PikaPerpV4 contract: and call setAccountManager
twice to enable the trading for market, limit and stop orders:
Call setAccountManager
function by setting _manager
as the PositionManager contract address(0xb67c152e69217b5acb85a2e19df13423351b0e27) and _isActive
is true.
Call the setAccountManager
function by setting _manager
as the OrderBook contract address(0x835a179a9E1A57f15823eFc82bC460Eb2D9d2E7C) and _isActive
is true.
To enable placing market orders together with take profit and stop loss orders, you need to send two additional transactions:
createOpenPosition
The ether to pay for execution fee. The input should be 0.00025.
account
Your wallet address
productId
margin
It is the USDC margin for the position. Note the intended margin amount needs to multiply 1e8 for the input. For example: 50 USDC margin's input is 5000000000.
leverage
It is the leverage of the position. The value needs to multiply 1e8 for the input (1000000000 represents 10x leverage).
isLong
It is the direction of the position. If you want to close a long position, the input is "true". If you want to close a short position, the input is "false"
acceptablePrice
It is the lowest acceptable price for open short or close long order, and highest acceptable price for open long or close short order. The order will be cancelled if the current price does not satisfy the acceptable price. Note the intended price needs to multiply 1e8 for the input.
executionFee
It is the execution fee paid to keepers to cover the gas fee of executing the order. The input amount should be 25000 (representing 0.00025ETH).
referralCode
It is the referral code of the trade. Put 0x0000000000000000000000000000000000000000000000000000000000000000
before the launch of referral program
account
User wallet address
productId
isLong
It is the direction for the position. If it is "true", your position is long. If it is "false", your position is short.
The values in the return array represent: productId
, leverage
, entryPrice
, oraclePriceAtTheEntry
(can be ignored), margin
, ownerOfPosition
, entryTimestamp
, direction
, and fundingAtTheEntry
(can be ignored).
For example, the position below is a 2x ETH Long with the margin of 30 USDC, with enty price at 1847.867, opened at the timestamp of 1691810315.
If your open order is not executed successfully, your active position will show up as 0s.
createOpenOrder
The ether to pay for execution fee. The input should be 0.00025.
productId
margin
It is the USDC margin for the position. Note the intended margin amount needs to multiply 1e8 for the input. For example: 50 USDC margin's input is 5000000000.
leverage
It is the leverage of the position. The value needs to multiply 1e8 for the input (1000000000 represents 10x leverage).
isLong
It is the direction of the position. If you want to close a long position, the input is "true". If you want to close a short position, the input is "false"
triggerPrice
It is the price at which the order will be triggerred. Note the trigger has high success rate but not 100% if the price moves cross the price and then goes back quickly before the keeper is able to trigger it. Note the intended price needs to multiply 1e8 for the input.
triggerAboveThreshold
If you want the order to be triggered when the price is above triggerPrice, the input is "true". If you want the order to be triggered when the price is below triggerPrice, the input is "false".
executionFee
It is the execution fee paid to keepers to cover the gas fee of executing the order. The input amount should be 25000 (representing 0.00025ETH).
createOpenMarketOrderWithCloseTriggerOrders
The ether to pay for execution fee. The input should be 0.00075 if you are open a market order with both take profit and stop loss orders. The input is 0.0005 if you are open a market order with either take proft or stop loss order.
productId
margin
It is the USDC margin for the position. Note the intended margin amount needs to multiply 1e8 for the input. For example: 50 USDC margin's input is 5000000000.
leverage
It is the leverage of the position. The value needs to multiply 1e8 for the input (1000000000 represents 10x leverage).
isLong
It is the direction of the position. If you want to close a long position, the input is "true". If you want to close a short position, the input is "false"
acceptablePrice
It is the lowest acceptable price for open short or close long order, and highest acceptable price for open long or close short order. The order will be cancelled if the current price does not satisfy the acceptable price. Note the intended price needs to multiply 1e8 for the input.
executionFee
It is the execution fee paid to keepers to cover the gas fee of executing the order. The input amount should be 75000 (representing 0.00075ETH) if you open a market order with both take profit and stop loss orders. The input is 50000 if you are open a market order with either take proft or stop loss order.
stopLossPrice
It is the price below which the close long order will get triggered, and above which the close short order will get triggerred. Put 0 if do not want to place stop loss order.
takeProfitPrice
It is the price above which the close long order will get triggered, and below which the close short order will get triggerred. Put 0 if do not want to place take profit order.
referralCode
Put 0x0000000000000000000000000000000000000000
before the referral program is launched.
Open the positionManager contract: and call setAccountManager
function, _manager
is the positionRouter contract: 0xa78Cd820b198A943199deb0506E77d655b5078cC
Open the orderbook contract: and call setAccountManager
function, _manager
is the positionRouter contract: 0xa78Cd820b198A943199deb0506E77d655b5078cC
Open the PositionManager contract at and fill in the parameters for createOpenPosition
function. The parameters are described below. Then you can click the Write
button to confirm the transaction.
The number represents the intended trading pair. Please refer to for the productId of each trading pair.
In around 10 seconds after submitting the open order, you can check your position on Pika from PikaPerpV4 contract's getPosition
function: . Below is the description of each parameters.
The number represents the trading pair. Please refer to for the productId of each trading pair.
Open the PositionManager contract at and fill in the parameters for createClosePosition
function. The parameters are the same as those for createOpenPosition
mentioned above. Then you can click the Write
button to confirm the transaction.
Open the OrderBook contract at and fill in the parameters for createOpenOrder
function. Fill in the parameters using the description provided below. Once all the parameters are entered, click the Write
button to confirm the transaction.
The number represents the intended trading pair. Please refer to for the productId of each trading pair.
Open the OrderBook contract at and fill in the parameters for createCloseOrder
function. These parameters are the same as those for createOpenOrder
mentioned above, except for the `size, which refers to the position size you wish to close. The intended size needs to multiply 1e8 for the input. Then you can click the Write
button to confirm the transaction.
Open the PositionRouter contract at and fill in the parameters for createOpenMarketOrderWithCloseTriggerOrders
function. The parameters are described below. After entering all the necessary information, click the Write
button to confirm the transaction.
The number represents the intended trading pair. Please refer to for the productId of each trading pair.
Open the PositionRouter contract at and fill in the parameters for createCloseTriggerOrders
function. These parameters are the same as those for createOpenMarketOrderWithCloseTriggerOrders
mentioned above. Then you can click the Write
button to confirm the transaction.
First, open the PikaPerpV4 contract at . Call the getPositionId
function to retrieve the positionId
using your address, productId
, and position direction.
Next, navigate to . Call the modifyMargin
function, inputting the positionId
from the previous step, the margin amount you wish to add or remove, and specify true
for adding margin or false
for removing margin in the shouldIncrease
field.