Router

Git Source

State Variables

PERMIT2

IPermit2 public immutable PERMIT2;

Functions

constructor

constructor(IPermit2 permit2);

depositWithPermit2

Deposits amount of lender.asset() to lender using {nonce, deadline, signature} for Permit2, and gives courierId a cut of future interest earned by msg.sender. v, r, and s are used with lender.permit in order to (a) achieve 0 balance if necessary and (b) set the courier.

This innoculates Lender against a potential courier frontrunning attack by redeeming all shares (if any are present) before assigning the new courierId. Lender then clears the permited allowance in deposit, meaning this contract is left with no special permissions.

function depositWithPermit2(
    Lender lender,
    uint256 amount,
    uint16 transmittance,
    uint256 nonce,
    uint256 deadline,
    bytes calldata signature,
    uint32 courierId,
    uint8 v,
    bytes32 r,
    bytes32 s
) external payable returns (uint256 shares);

depositWithPermit2

function depositWithPermit2(
    Lender lender,
    uint256 amount,
    uint16 transmittance,
    uint256 nonce,
    uint256 deadline,
    bytes calldata signature
) external payable returns (uint256 shares);

repayWithPermit2

function repayWithPermit2(
    Lender lender,
    bool max,
    uint256 amount,
    address beneficiary,
    uint256 nonce,
    uint256 deadline,
    bytes calldata signature
) external returns (uint256 units);