IPoolTrade

Git Source

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

NameTypeDescription
takeraddressThe taker of the trade
sizeUD60x18The number of contracts being traded (18 decimals)
isBuyboolWhether the taker is buying or selling

Returns

NameTypeDescription
premiumNetuint256The premium which has to be paid to complete the trade (Net of fees) (poolToken decimals)
takerFeeuint256The 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

NameTypeDescription
quoteOBQuoteOBThe OB quote given by the provider
sizeUD60x18The size to fill from the OB quote (18 decimals)
signatureSignaturesecp256k1 'r', 's', and 'v' value
referreraddressThe referrer of the user filling the OB quote

Returns

NameTypeDescription
premiumTakeruint256The premium paid or received by the taker for the trade (poolToken decimals)
deltaPosition.DeltaThe 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

NameTypeDescription
sizeUD60x18The number of contracts being traded (18 decimals)
isBuyboolWhether the taker is buying or selling
premiumLimituint256Tx will revert if total premium is above this value when buying, or below this value when selling. (poolToken decimals)
referreraddressThe referrer of the user doing the trade

Returns

NameTypeDescription
totalPremiumuint256The premium paid or received by the taker for the trade (poolToken decimals)
deltaPosition.DeltaThe 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

NameTypeDescription
hashesbytes32[]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

NameTypeDescription
useraddressThe address of the user that will call the fillQuoteOB function to fill the OB quote
quoteOBQuoteOBThe OB quote to check
sizeUD60x18Size to fill from the OB quote (18 decimals)
sigSignaturesecp256k1 Signature

getQuoteOBFilledAmount

Returns the size already filled for a given OB quote

function getQuoteOBFilledAmount(address provider, bytes32 quoteOBHash) external view returns (UD60x18);

Parameters

NameTypeDescription
provideraddressProvider of the OB quote
quoteOBHashbytes32Hash of the OB quote

Returns

NameTypeDescription
<none>UD60x18The size already filled (18 decimals)