# Trading ABI and Documentation

## ABI&#x20;

<https://github.com/wowswap-io/evm-sdk-public>

### Structs

### **ClosePositionRequest**

📄 Configuration parameters for a closing position transaction

Developer should use `pragma experimental ABIEncoderV2`; to pack struct to calldata with struct

All positions tokens support EIP-2612 for disbursement via an offchain signature, not a approve of transaction

**Fields:**

➡ **short** should be true if a short position is closed (false if a long position)&#x20;

➡ **amountIn** the number of position tokens to close (can pass `type(uint256).max` to close the all position)&#x20;

➡ **amountOutMin** minimum allowed number of tokens to be received lendable after closing (if the exchange returns less during the closing process - the transaction will be rejected)&#x20;

➡ **lendable** is an address of lendable token&#x20;

➡ **proxy** is an address of proxy token (should be address(0) if direct swap)&#x20;

➡ **tradable** is an address of tradable token if position is long, overwise is shortable&#x20;

➡ **trader** is an address of position holder&#x20;

➡ **deadline** deadline of permit on spending position tokens for Router instance&#x20;

➡ **referrer** is an address of position holder referrer (should be address(0) if no referrer)&#x20;

➡ **permit** is a structure of **v , r , s** with ERC-2612 permit&#x20;

➡ **convertToNative** should be true if lendable is wrapped native currency and expect unwrapping to native at the end of transaction

### OpenPositionRequest

📄 Transaction configuration parameters for opening a long position

Developer should use `pragma experimental ABIEncoderV2`; to pack struct to calldata with struct Developer should call **PriceSigner** service to obtain guarded field data before call open position

➡ **amountIn** the number of lendable tokens to open a position and to be used as collateral for the position&#x20;

➡ **leverageFactor** determines the leverage of the position (specified in decimals, i.e. x1 is 10000 and x1.5 is 15000)&#x20;

➡ **amountOutMin** minimum allowed number of received position tokens after opening (if the exchange returns less during the opening - the transaction will be rejected)&#x20;

➡ **lendable** is an address of lendable token&#x20;

➡ **proxy** is an address of proxy token (should be address(0) if direct swap)&#x20;

➡ **tradable** is an address of tradable token if position is long, overwise is shortable&#x20;

➡ **trader** is an address of position holder&#x20;

➡ **deadline** deprecated field&#x20;

➡ **referrer** is an address of position holder referrer (should be address(0) if no referrer)&#x20;

➡ **guarded** a signed message from the oracle with the expected value of the asset (protection against flash-loan attacks)&#x20;

➡ **terminationConditions** user-signed position auto termination conditions (can be initialized with zeros to cancel auto termination)&#x20;

➡ **terminationReward** amount in native tokens to compensate for the gas and work of the termination bot (must be added to `msg.value`)&#x20;

➡ **convertFromNative** If lendable token is wrapped native currency (e.g. BNB in BNB Chain), can pass the amount as transaction value and setting convertFromNative as true to wrap the native currency into ERC20 token

### OpenShortPositionRequest

📄 Transaction configuration parameters of short position opening

Developer should use pragma experimental ABIEncoderV2; to pack struct to calldata with struct\
Developer should call `PriceSigner` service to obtain guarded field data before call open position

➡ **amountIn** number of lendable tokens (stablecoin) to open a position and to be used as collateral for the position&#x20;

➡ **baseBorrowAmount** base loan. Calculated as baseBorrowAmount \*leverageFactor = loan, where loan \* tradablePrice <= `amountInleverageFactor` determines the leverage of the position (specified in decimals, i.e. x1 is 10000 and x1.5 - 15000)&#x20;

➡ **amountOutMin** minimum allowed number of received position tokens after opening (if the exchange returns less during the opening - the transaction will be rejected)&#x20;

➡ **lendable** is an address of lendable token&#x20;

➡ **proxy** is an address of proxy token (should be address(0) if direct swap)&#x20;

➡ **tradable** is an address of tradable token if position is long, overwise is shortable&#x20;

➡ **trader** is an address of position holder&#x20;

➡ deadline deprecated field referrer is an address of position holder&#x20;

➡ **referrer** (should be address(0) if no referrer)&#x20;

➡ **guarded** a signed message from the oracle with the expected value of the asset (protection against flash-loan attacks)&#x20;

➡ **terminationConditions** user-signed position auto termination conditions (can be initialized with zeros to cancel auto termination)&#x20;

➡ **terminationReward** amount in native tokens to compensate for the gas and work of the termination bot (must be added to `msg.value`)&#x20;

➡ **convertFromNative** If lendable token is wrapped native currency (e.g. BNB in BNB Chain), can pass the amount as transaction value and setting `convertFromNative` as true to wrap the native currency into ERC20 token

**WithdrawRequest**

📄 Withdrawal parameters from the reserve All ib tokens support EIP-2612 for disbursement via offchain signature, not approve transaction
