Skip to main content
Facet #8: Callbacks (to execute actions after receiving median price from price aggregator)

constructor

constructor() public

initializeCallbacks

function initializeCallbacks(uint8 _vaultClosingFeeP) external

Parameters

NameTypeDescription
_vaultClosingFeePuint8the % of closing fee going to vault

initializeTreasuryAddress

function initializeTreasuryAddress(address _treasury) external
Initialize the treasury address

Parameters

NameTypeDescription
_treasuryaddressthe treasury address

updateVaultClosingFeeP

function updateVaultClosingFeeP(uint8 _valueP) external
Update the % of closing fee going to vault

Parameters

NameTypeDescription
_valuePuint8the % of closing fee going to vault

updateTreasuryAddress

function updateTreasuryAddress(address _treasury) external
Updates the treasury address

Parameters

NameTypeDescription
_treasuryaddressthe new treasury address

claimPendingGovFees

function claimPendingGovFees() external
Claim the pending gov fees for all collaterals

openTradeMarketCallback

function openTradeMarketCallback(struct ITradingCallbacks.AggregatorAnswer _a) external virtual
Executes a pending open trade market order

Parameters

NameTypeDescription
_aITradingCallbacks.AggregatorAnswerthe price aggregator answer (order id, price, etc.)

closeTradeMarketCallback

function closeTradeMarketCallback(struct ITradingCallbacks.AggregatorAnswer _a) external virtual
Executes a pending close trade market order

Parameters

NameTypeDescription
_aITradingCallbacks.AggregatorAnswerthe price aggregator answer (order id, price, etc.)

executeTriggerOpenOrderCallback

function executeTriggerOpenOrderCallback(struct ITradingCallbacks.AggregatorAnswer _a) external virtual
Executes a pending open trigger order (for limit/stop orders)

Parameters

NameTypeDescription
_aITradingCallbacks.AggregatorAnswerthe price aggregator answer (order id, price, etc.)

executeTriggerCloseOrderCallback

function executeTriggerCloseOrderCallback(struct ITradingCallbacks.AggregatorAnswer _a) external virtual
Executes a pending close trigger order (for tp/sl/liq orders)

Parameters

NameTypeDescription
_aITradingCallbacks.AggregatorAnswerthe price aggregator answer (order id, price, etc.)

getVaultClosingFeeP

function getVaultClosingFeeP() external view returns (uint8)
Returns the current vaultClosingFeeP value (%)

getPendingGovFeesCollateral

function getPendingGovFeesCollateral(uint8 _collateralIndex) external view returns (uint256)
Returns the current pending gov fees for a collateral index (collateral precision)

updateLeverageCallback

function updateLeverageCallback(struct ITradingCallbacks.AggregatorAnswer _a) external virtual
Executes a pending update leverage order

Parameters

NameTypeDescription
_aITradingCallbacks.AggregatorAnswerthe price aggregator answer (order id, price, etc.)

increasePositionSizeMarketCallback

function increasePositionSizeMarketCallback(struct ITradingCallbacks.AggregatorAnswer _a) external virtual
Executes a pending increase position size market order

Parameters

NameTypeDescription
_aITradingCallbacks.AggregatorAnswerthe price aggregator answer (order id, price, etc.)

decreasePositionSizeMarketCallback

function decreasePositionSizeMarketCallback(struct ITradingCallbacks.AggregatorAnswer _a) external virtual
Executes a pending decrease position size market order

Parameters

NameTypeDescription
_aITradingCallbacks.AggregatorAnswerthe price aggregator answer (order id, price, etc.)

validateTriggerOpenOrderCallback

function validateTriggerOpenOrderCallback(struct ITradingStorage.Id _tradeId, enum ITradingStorage.PendingOrderType _orderType, uint64 _open, uint64 _high, uint64 _low) external view returns (struct ITradingStorage.Trade t, enum ITradingCallbacks.CancelReason cancelReason, struct ITradingCallbacks.Values v)
Makes open trigger (STOP/LIMIT) checks like slippage, price impact, missed targets and returns cancellation reason if any

Parameters

NameTypeDescription
_tradeIdITradingStorage.Idthe id of the trade
_orderTypeenum ITradingStorage.PendingOrderTypethe pending order type
_openuint64the open value from an aggregator answer
_highuint64the high value from an aggregator answer
_lowuint64the low value from an aggregator answer

validateTriggerCloseOrderCallback

function validateTriggerCloseOrderCallback(struct ITradingStorage.Id _tradeId, enum ITradingStorage.PendingOrderType _orderType, uint64 _open, uint64 _high, uint64 _low) external view returns (struct ITradingStorage.Trade t, enum ITradingCallbacks.CancelReason cancelReason, struct ITradingCallbacks.Values v)
Makes close trigger (SL/TP/LIQ) checks like slippage and price impact and returns cancellation reason if any

Parameters

NameTypeDescription
_tradeIdITradingStorage.Idthe id of the trade
_orderTypeenum ITradingStorage.PendingOrderTypethe pending order type
_openuint64the open value from an aggregator answer
_highuint64the high value from an aggregator answer
_lowuint64the low value from an aggregator answer