Delegation
Takers may provide allowances on specific offer lists, so other addresses (called "delegate takers") can execute market orders in their name. Allowance may be set using the approve
function, or through an EIP712 permit using the permit
function.
Allowances are set on a token pair (A, B) without specifying tickSpacing
, meaning "delegate taker has the right to trade token A against token B at any tickSpacing
".
Setting Allowanceβ
To set allowance, use either the permit
or approve
function:
- Signature
function permit(
address outbound_tkn,
address inbound_tkn,
address owner,
address spender,
uint value,
uint deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
function approve(
address outbound_tkn,
address inbound_tkn,
address spender,
uint value
) external returns (bool);
Inputsβ
permit()
β
(outbound_tkn, inbound_tkn)
the outbound and inbound tokens of the offer lists on which the Delegate Taker will be permitted to execute market orders.owner
the address of the taker providing the permit.spender
the address of the Delegate Taker.value
the maximal amount of inbound tokens the Delegate Taker is permitted to spend.deadline
the block number beyond which the delegator's signature can no longer be used to obtain permission.(v,r,s)
thesecp256k1
signature identifying theowner
.
approve()
β
(outbound_tkn, inbound_tkn)
the outbound and inbound tokens of the offer lists on which the Delegate Taker will be permitted to execute market orders.spender
the address of the Delegate Taker.value
the maximal amount of inbound tokens the Delegate Taker is permitted to spend.
msg.sender
is the taker who is approving spender
.
Delegated Order Takingβ
Once a Delegate Taker has an allowance from a taker, she can use the delegated market order variants marketOrderFor*
which work identically to the standard market order functions but require an additional taker
address:
function marketOrderForByTick(
OLKey memory olKey,
Tick maxTick,
uint fillVolume,
bool fillWants,
address taker
) external returns (uint takerGot, uint takerGave, uint bounty, uint feePaid);
function marketOrderForByVolume(
OLKey memory olKey,
uint takerWants,
uint takerGives,
bool fillWants,
address taker
) external returns (uint takerGot, uint takerGave, uint bounty, uint feePaid);