Direct
SetReserveId
reserveId
is set in the constructor
by emitting this event, an indexer will be able to keep track of what reserve is used.
Parameters
reserveId
address
identifier of this contract's reserve when using a router. This is indexed so that RPC calls can filter on it.
RESERVE_ID
identifier of this contract's reserve when using a router
two contracts using the same RESERVE_ID will share funds, therefore strat builder must make sure this contract is allowed to pull into the given reserve Id.
a safe value for RESERVE_ID
is address(this)
in which case the funds will never be shared with another maker contract.
constructor
Direct
's constructor.
reserveId==address(0) will set RESERVE_ID to address(this).
Parameters
mgv
contract IMangrove
The Mangrove deployment that is allowed to call this
for trade execution and posthook.
router_
contract AbstractRouter
the router that this contract will use to pull/push liquidity from offer maker's reserve. This can be NO_ROUTER
.
reserveId
address
identifier of this contract's reserve when using a router.
_newOffer
Inserts a new offer in Mangrove Offer List.
Parameters
args
struct IOfferLogic.OfferArgs
Function arguments stored in memory.
Return Values
offerId
uint256
Identifier of the newly created offer. Returns 0 if offer creation was rejected by Mangrove and args.noRevert
is set to true
.
status
bytes32
NEW_OFFER_SUCCESS if the offer was successfully posted on Mangrove. Returns Mangrove's revert reason otherwise.
_updateOffer
Updates the offer specified by offerId
on Mangrove with the parameters in args
.
Parameters
args
struct IOfferLogic.OfferArgs
A memory struct containing the offer parameters to update.
offerId
uint256
An unsigned integer representing the identifier of the offer to be updated.
Return Values
status
bytes32
status a bytes32
value representing either REPOST_SUCCESS
if the update is successful, or an error message if an error occurs and OfferArgs.noRevert
is true
. If OfferArgs.noRevert
is false
, the function reverts with the error message as the reason.
_retractOffer
Retracts an offer from an Offer List of Mangrove.
An offer that is retracted without deprovision
is retracted from the offer list, but still has its provisions locked by Mangrove.
Calling this function, with the deprovision
flag, on an offer that is already retracted must be used to retrieve the locked provisions.
Parameters
olKey
struct OLKey
the offer list key.
offerId
uint256
the identifier of the offer in the offer list
deprovision
bool
if set to true
if offer admin wishes to redeem the offer's provision.
Return Values
freeWei
uint256
the amount of native tokens (in WEI) that have been retrieved by retracting the offer.
provisionOf
computes the amount of native tokens that can be redeemed when deprovisioning a given offer.
Parameters
olKey
struct OLKey
the offer list key.
offerId
uint256
the identifier of the offer in the offer list
Return Values
provision
uint256
the amount of native tokens that can be redeemed when deprovisioning the offer
put
direct contract do not need to do anything specific with incoming funds during trade
one should override this function if one wishes to leverage taker's fund during trade execution
Parameters
uint256
struct MgvLib.SingleOrder
Return Values
[0]
uint256
get
__get__
hook for Direct
is to ask the router to pull liquidity from reserveId
if strat is using a router
otherwise the function simply returns what's missing in the local balance
if the last nested call to __get__
returns a non zero value, trade execution will revert
Parameters
amount
uint256
of outbound
tokens that still needs to be brought to the balance of this
contract when entering this function
order
struct MgvLib.SingleOrder
is a recall of the taker order that is at the origin of the current trade.
Return Values
[0]
uint256
posthookSuccess
Direct posthook flushes outbound and inbound token back to the router (if any)
Parameters
order
struct MgvLib.SingleOrder
is a recall of the taker order that is at the origin of the current trade.
makerData
bytes32
is the returned value of the __lastLook__
hook, triggered during trade execution. The special value "lastLook/retract"
should be treated as an instruction not to repost the offer on the list.
Return Values
[0]
bytes32
checkList
if strat has a router, verifies that the router is ready to pull/push on behalf of reserve id
Parameters
token
contract IERC20
a token that is traded by this contract