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 Delegation 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()
permit()(outbound_tkn, inbound_tkn)the outbound and inbound tokens of the offer lists on which theDelegate Takerwill be permitted to execute market orders.ownerthe address of the taker providing the permit.spenderthe address of theDelegate Taker.valuethe maximal amount of inbound tokens theDelegate Takeris permitted to spend.deadlinethe block number beyond which the delegator's signature can no longer be used to obtain permission.(v,r,s)thesecp256k1signature identifying theowner.
approve()
approve()(outbound_tkn, inbound_tkn)the outbound and inbound tokens of the offer lists on which theDelegate Takerwill be permitted to execute market orders.spenderthe address of theDelegate Taker.valuethe maximal amount of inbound tokens theDelegate Takeris permitted to spend.
msg.sender is the taker who is approving spender.
Executing Delegated Orders
Once granted, a delegate taker can execute market orders via the marketOrderFor* functions:
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);These behave identically to their non-delegated versions, except that the funds and results are attributed to the specified taker address.
Last updated