Skip to main content

IOfferLogic

IOfferLogic​

It is an IMaker for Mangrove.

LogIncident​

event LogIncident(contract IMangrove mangrove, contract IERC20 outbound_tkn, contract IERC20 inbound_tkn, uint256 offerId, bytes32 makerData, bytes32 mgvData)

Log incident (during post trade execution)

Parameters​

NameTypeDescription
mangrovecontract IMangroveThe mangrove deployment.
outbound_tkncontract IERC20the outbound token of the offer list.
inbound_tkncontract IERC20the inbound token of the offer list.
offerIduint256the Mangrove offer id.
makerDatabytes32from the maker.
mgvDatabytes32from Mangrove.

SetRouter​

event SetRouter(contract AbstractRouter router)

Logging change of router address

Parameters​

NameTypeDescription
routercontract AbstractRouterthe new router address

offerGasreq​

function offerGasreq() external view returns (uint256 total)

Actual gas requirement when posting offers via this strategy. Returned value may change if this contract's router is updated.

Return Values​

NameTypeDescription
totaluint256gas cost including router specific costs (if any).

setRouter​

function setRouter(contract AbstractRouter router_) external

sets a new router to pull outbound tokens from contract's reserve to this and push inbound tokens to reserve.

new router needs to be approved by this to push funds to reserve (see activate function). It also needs to be approved by reserve to pull from it.

Parameters​

NameTypeDescription
router_contract AbstractRouterthe new router contract that this contract should use. Use NO_ROUTER for no router.

approve​

function approve(contract IERC20 token, address spender, uint256 amount) external returns (bool)

Approves a spender to transfer a certain amount of tokens on behalf of this.

admin may use this function to revoke specific approvals of this that are set after a call to activate.

Parameters​

NameTypeDescription
tokencontract IERC20the ERC20 token contract
spenderaddressthe approved spender
amountuint256the spending amount

Return Values​

NameTypeDescription
[0]boolresult of token approval.

provisionOf​

function provisionOf(contract IERC20 outbound_tkn, contract IERC20 inbound_tkn, uint256 offerId) external view returns (uint256 provision)

computes the amount of native tokens that can be redeemed when deprovisioning a given offer.

Parameters​

NameTypeDescription
outbound_tkncontract IERC20the outbound token of the offer list
inbound_tkncontract IERC20the inbound token of the offer list
offerIduint256the identifier of the offer in the offer list

Return Values​

NameTypeDescription
provisionuint256the amount of native tokens that can be redeemed when deprovisioning the offer

checkList​

function checkList(contract IERC20[] tokens) external view

verifies that this contract's current state is ready to be used to post offers on Mangrove

throws with a reason if something (e.g. an approval) is missing.

Parameters​

NameTypeDescription
tokenscontract IERC20[]the list of tokens that are traded by this contract

activate​

function activate(contract IERC20[] tokens) external

performs the required approvals so as to allow this to interact with Mangrove on a set of assets.

Parameters​

NameTypeDescription
tokenscontract IERC20[]the ERC20 this will approve to be able to trade on Mangrove's corresponding markets.

withdrawFromMangrove​

function withdrawFromMangrove(uint256 amount, address payable receiver) external

withdraws native tokens from this balance on Mangrove.

Since a call is made to the receiver, this function is subject to reentrancy.

Parameters​

NameTypeDescription
amountuint256the amount of WEI one wishes to withdraw.
receiveraddress payablethe address of the receiver of the funds.

OfferArgs​

struct OfferArgs {
contract IERC20 outbound_tkn;
contract IERC20 inbound_tkn;
uint256 wants;
uint256 gives;
uint256 gasreq;
uint256 gasprice;
uint256 pivotId;
uint256 fund;
bool noRevert;
}

router​

function router() external view returns (contract AbstractRouter)

Contract's router getter.

if contract has a no router, function returns NO_ROUTER.

Return Values​

NameTypeDescription
[0]contract AbstractRouterthe router.

MGV​

function MGV() external view returns (contract IMangrove)

Contract's Mangrove getter

Return Values​

NameTypeDescription
[0]contract IMangrovethe Mangrove contract.