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 payableupdateOracle: 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 payableRemove collateral from trade
function removeCollateralToSCW(
uint128 accountId,
uint128 spotSynthMarketId,
uint128 perpSynthMarketId,
uint256 collateralAmount,
bool updateOracle,
uint8 weiToSend,
bytes memory oracleData
) public payableLong Market Order
function long(
uint128 accountId,
bool updateOracle,
uint8 weiToSend,
bytes memory oracleData,
uint128 marketId,
uint256 size,
uint256 acceptablePrice,
bytes calldata vipUpgradeData
) public payablesize
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 payableReduce Position Size
function reduceSize(
uint128 accountId,
bool updateOracle,
uint8 weiToSend,
bytes memory oracleData,
uint128 marketId,
int128 sizeDelta,
uint256 acceptablePrice,
bytes calldata vipUpgradeData
) publicacceptablePrice
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
) publiclimitOrderId
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
) publicManuall Settle Trade
function settleTrade(uint128 accountId, uint8 weiToSend, bytes memory oracleData) publicShort 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 payabletpslOrder
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 payableCreate Limit Order
function placeLimitOrder(uint128 accountId, IFxAutomationsProxy.OrderRequest memory order) publicModify Limit Order
function modifyLimitOrder(uint128 accountId, uint256 oldOrderId, IFxAutomationsProxy.OrderRequest memory order)
publicCancel Limit Order
Last updated
Was this helpful?