AtomicSolverV2

Git Source

Inherits: IAtomicSolver, Auth

Author: crispymangoes

State Variables

eETH

ERC20 internal constant eETH = ERC20(0x35fA164735182de50811E8e2E824cFb9B6118ac2);

weETH

ERC20 internal constant weETH = ERC20(0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee);

Functions

constructor

constructor(address _owner, Authority _authority) Auth(_owner, _authority);

p2pSolve

Solver wants to exchange p2p share.asset() for withdraw queue shares.

Solver should approve this contract to spend share.asset().

function p2pSolve(
    AtomicQueue queue,
    ERC20 offer,
    ERC20 want,
    address[] calldata users,
    uint256 minOfferReceived,
    uint256 maxAssets
)
    external
    requiresAuth;

redeemSolve

Solver wants to redeem withdraw offer shares, to help cover withdraw.

offer MUST be an ERC4626 vault.

function redeemSolve(
    AtomicQueue queue,
    ERC20 offer,
    ERC20 want,
    address[] calldata users,
    uint256 minAssetDelta,
    uint256 maxAssets
)
    external
    requiresAuth;

redeemLiquidSolve

Solver wants to redeem withdraw offer shares, to help cover withdraw.

offer MUST be an ERC4626 vault.

function redeemLiquidSolve(
    AtomicQueue queue,
    ERC20 offer,
    ERC20 want,
    address[] calldata users,
    uint256 minAssetDelta,
    uint256 maxAssets
)
    external
    requiresAuth;

finishSolve

Implement the finishSolve function WithdrawQueue expects to call.

nonReentrant is not needed on this function because it is impossible to reenter, because the above solve functions have the nonReentrant modifier. The only way to have the first 2 checks pass is if the msg.sender is the queue, and this contract is msg.sender of Queue.solve(), which is only called in the above functions.

function finishSolve(
    bytes calldata runData,
    address initiator,
    ERC20 offer,
    ERC20 want,
    uint256 offerReceived,
    uint256 wantApprovalAmount
)
    external
    requiresAuth;

_p2pSolve

Helper function containing the logic to handle p2p solves.

function _p2pSolve(
    address queue,
    bytes memory runData,
    ERC20 offer,
    ERC20 want,
    uint256 offerReceived,
    uint256 wantApprovalAmount
)
    internal;

_redeemSolve

Helper function containing the logic to handle redeem solves.

function _redeemSolve(
    address queue,
    bytes memory runData,
    ERC20 offer,
    ERC20 want,
    uint256 offerReceived,
    uint256 wantApprovalAmount
)
    internal;

_redeemLiquidSolve

Helper function containing the logic to handle redeem solves.

function _redeemLiquidSolve(
    address queue,
    bytes memory runData,
    ERC20 offer,
    ERC20 want,
    uint256 offerReceived,
    uint256 wantApprovalAmount
)
    internal;

Errors

AtomicSolverV2___WrongInitiator

error AtomicSolverV2___WrongInitiator();

AtomicSolverV2___AlreadyInSolveContext

error AtomicSolverV2___AlreadyInSolveContext();

AtomicSolverV2___FailedToSolve

error AtomicSolverV2___FailedToSolve();

AtomicSolverV2___SolveMaxAssetsExceeded

error AtomicSolverV2___SolveMaxAssetsExceeded(uint256 actualAssets, uint256 maxAssets);

AtomicSolverV2___P2PSolveMinSharesNotMet

error AtomicSolverV2___P2PSolveMinSharesNotMet(uint256 actualShares, uint256 minShares);

AtomicSolverV2___RedeemSolveMinAssetDeltaNotMet

error AtomicSolverV2___RedeemSolveMinAssetDeltaNotMet(uint256 actualDelta, uint256 minDelta);

Enums

SolveType

The Solve Type, used in finishSolve to determine the logic used.

P2P Solver wants to swap share.asset() for user(s) shares

REDEEM Solver needs to redeem shares, then can cover user(s) required assets.

enum SolveType {
    P2P,
    REDEEM,
    REDEEM_LIQUID
}