IPoolTrade
Inherits: IPoolInternal, IERC3156FlashLender
Functions
getQuoteAMM
Gives a quote for an AMM trade
function getQuoteAMM(address taker, UD60x18 size, bool isBuy)
external
view
returns (uint256 premiumNet, uint256 takerFee);
Parameters
| Name | Type | Description |
|---|---|---|
taker | address | The taker of the trade |
size | UD60x18 | The number of contracts being traded (18 decimals) |
isBuy | bool | Whether the taker is buying or selling |
Returns
| Name | Type | Description |
|---|---|---|
premiumNet | uint256 | The premium which has to be paid to complete the trade (Net of fees) (poolToken decimals) |
takerFee | uint256 | The taker fees to pay (Included in premiumNet) (poolToken decimals) |
fillQuoteOB
Functionality to support the OB / OTC system. An LP can create a OB quote for which he will do an OTC trade through the exchange. Takers can buy from / sell to the LP partially or fully while having the price guaranteed.
function fillQuoteOB(QuoteOB calldata quoteOB, UD60x18 size, Signature calldata signature, address referrer)
external
returns (uint256 premiumTaker, Position.Delta memory delta);
Parameters
| Name | Type | Description |
|---|---|---|
quoteOB | QuoteOB | The OB quote given by the provider |
size | UD60x18 | The size to fill from the OB quote (18 decimals) |
signature | Signature | secp256k1 'r', 's', and 'v' value |
referrer | address | The referrer of the user filling the OB quote |
Returns
| Name | Type | Description |
|---|---|---|
premiumTaker | uint256 | The premium paid or received by the taker for the trade (poolToken decimals) |
delta | Position.Delta | The net collateral / longs / shorts change for taker of the trade. |
trade
Completes a trade of size on side via the AMM using the liquidity in the Pool.
Tx will revert if total premium is above totalPremium when buying, or below totalPremium when
selling.
function trade(UD60x18 size, bool isBuy, uint256 premiumLimit, address referrer)
external
returns (uint256 totalPremium, Position.Delta memory delta);
Parameters
| Name | Type | Description |
|---|---|---|
size | UD60x18 | The number of contracts being traded (18 decimals) |
isBuy | bool | Whether the taker is buying or selling |
premiumLimit | uint256 | Tx will revert if total premium is above this value when buying, or below this value when selling. (poolToken decimals) |
referrer | address | The referrer of the user doing the trade |
Returns
| Name | Type | Description |
|---|---|---|
totalPremium | uint256 | The premium paid or received by the taker for the trade (poolToken decimals) |
delta | Position.Delta | The net collateral / longs / shorts change for taker of the trade. |
cancelQuotesOB
Cancel given OB quotes
No check is done to ensure the given hash correspond to a OB quote provider by msg.sender, but as we register the cancellation in a mapping provider -> hash, it is not possible to cancel a OB quote created by another provider
function cancelQuotesOB(bytes32[] calldata hashes) external;
Parameters
| Name | Type | Description |
|---|---|---|
hashes | bytes32[] | The hashes of the OB quotes to cancel |
isQuoteOBValid
Returns whether or not an OB quote is valid, given a fill size
function isQuoteOBValid(address user, QuoteOB calldata quoteOB, UD60x18 size, Signature calldata sig)
external
view
returns (bool, InvalidQuoteOBError);
Parameters
| Name | Type | Description |
|---|---|---|
user | address | The address of the user that will call the fillQuoteOB function to fill the OB quote |
quoteOB | QuoteOB | The OB quote to check |
size | UD60x18 | Size to fill from the OB quote (18 decimals) |
sig | Signature | secp256k1 Signature |
getQuoteOBFilledAmount
Returns the size already filled for a given OB quote
function getQuoteOBFilledAmount(address provider, bytes32 quoteOBHash) external view returns (UD60x18);
Parameters
| Name | Type | Description |
|---|---|---|
provider | address | Provider of the OB quote |
quoteOBHash | bytes32 | Hash of the OB quote |
Returns
| Name | Type | Description |
|---|---|---|
<none> | UD60x18 | The size already filled (18 decimals) |