StakeZap
Convenience wrapper around LT and LiquidityGauge.
StakeZap.vy lets a user combine LT deposit with gauge staking, or gauge unstaking with LT withdrawal, in one call. It is a helper, not a separate accounting layer: LT still mints yb-LP and LiquidityGauge still holds the staked position.
Functions
deposit_and_stake
def deposit_and_stake(
gauge: LiquidityGauge,
assets: uint256,
debt: uint256,
min_shares: uint256,
receiver: address = msg.sender
) -> uint256
Flow:
- Reads the LT from
gauge.LP_TOKEN(). - Pulls the underlying asset from the caller.
- Calls
LT.deposit(assets, debt, min_shares). - Stakes the received LT tokens into the gauge for
receiver.
withdraw_and_unstake
def withdraw_and_unstake(
gauge: LiquidityGauge,
shares: uint256,
min_assets: uint256,
receiver: address = msg.sender
) -> uint256
Flow:
- Redeems gauge shares into LT tokens.
- Calls
LT.withdraw(lt_tokens, min_assets, receiver). - Returns the underlying asset amount received.
Approvals
StakeZap caches max approvals per gauge. The first call for a gauge approves the LT to pull the underlying asset and approves the gauge to pull LT tokens; later calls reuse those approvals.