Connector Contracts
You can find the contract address here . If you are using AA wallets according to previous guide, calling these contract functions will be the quickest way to integrate with Perps trading.
unit128 accountId
bool weiToSend
bytes memory updateOracle
Create Account
function createAccountAddCollateral(
uint128 accountId,
bool updateOracle,
uint8 weiToSend,
bytes memory oracleData,
uint128 spotSynthMarketId,
uint128 perpSynthMarketId,
uint256 collateralAmount
) public payable
updateOracle: Oracle data to be updated. For more details pyth-oracle <TODO>
spotSynthMarketId
USDC 1n
perpSynthMarketId
USDC 0n
collaeralAmount
Amount to be send as collateral
Add collateral to trade
function addCollateralFromSCW(
uint128 accountId,
uint128 spotSynthMarketId,
uint128 perpSynthMarketId,
uint256 collateralAmount,
bool updateOracle,
uint8 weiToSend,
bytes memory oracleData
) public payable
Remove collateral from trade
function removeCollateralToSCW(
uint128 accountId,
uint128 spotSynthMarketId,
uint128 perpSynthMarketId,
uint256 collateralAmount,
bool updateOracle,
uint8 weiToSend,
bytes memory oracleData
) public payable
Long Market Order
function long(
uint128 accountId,
bool updateOracle,
uint8 weiToSend,
bytes memory oracleData,
uint128 marketId,
uint256 size,
uint256 acceptablePrice,
bytes calldata vipUpgradeData
) public payable
size
Market order size
vipUpgradeData
0x
Short Market Order
function short(
uint128 accountId,
bool updateOracle,
uint8 weiToSend,
bytes memory oracleData,
uint128 marketId,
uint256 size,
uint256 acceptablePrice,
bytes calldata vipUpgradeData
) public payable
Reduce Position Size
function reduceSize(
uint128 accountId,
bool updateOracle,
uint8 weiToSend,
bytes memory oracleData,
uint128 marketId,
int128 sizeDelta,
uint256 acceptablePrice,
bytes calldata vipUpgradeData
) public
acceptablePrice
You can pass any minimum required price for closing the position on market price. For the order to always pass through, you can pass worst case prices. For example
position.long ? 1n : 10000000000000000000000000000000000000n
sizeDelta
Use any size less than or equal to the position size
Close a Position
function close(
uint128 accountId,
bool updateOracle,
uint8 weiToSend,
bytes memory oracleData,
uint128 marketId,
uint256 acceptablePrice,
uint256 limitOrderId,
bytes calldata vipUpgradeData
) public
limitOrderId
Pass in the full position TP/SL order Id
Reverse Trade Position
function reversePosition(
uint128 accountId,
bool updateOracle,
uint8 weiToSend,
bytes memory oracleData,
uint128 marketId,
uint256 acceptablePrice,
uint256 limitOrderId,
bytes calldata vipUpgradeData
) public
Manuall Settle Trade
function settleTrade(uint128 accountId, uint8 weiToSend, bytes memory oracleData) public
Short with TPSL
function shortAddTPSL(
uint128 accountId,
bool updateOracle,
uint8 weiToSend,
bytes memory oracleData,
uint128 marketId,
uint256 size,
uint256 acceptablePrice,
IFxAutomationsProxy.OrderRequest memory tpslOrder,
bytes calldata vipUpgradeData
) public payable
tpslOrder
ILimitOrder
export interface IPriceRange {
priceA: bigint;
priceB: bigint;
acceptablePrice: bigint;
}
export interface ILimitOrder {
user: Address;
price: IPriceRange;
tpPrice: IPriceRange;
slPrice: IPriceRange;
accountId: bigint;
marketId: bigint;
size: bigint;
expiry: bigint;
}
Long with TPSL
function longAddTPSL(
uint128 accountId,
bool updateOracle,
uint8 weiToSend,
bytes memory oracleData,
uint128 marketId,
uint256 size,
uint256 acceptablePrice,
IFxAutomationsProxy.OrderRequest memory tpslOrder,
bytes calldata vipUpgradeData
) public payable
Create Limit Order
function placeLimitOrder(uint128 accountId, IFxAutomationsProxy.OrderRequest memory order) public
Modify Limit Order
function modifyLimitOrder(uint128 accountId, uint256 oldOrderId, IFxAutomationsProxy.OrderRequest memory order)
public
Cancel Limit Order
Last updated
Was this helpful?