Skip to main content

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:

  1. Reads the LT from gauge.LP_TOKEN().
  2. Pulls the underlying asset from the caller.
  3. Calls LT.deposit(assets, debt, min_shares).
  4. 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:

  1. Redeems gauge shares into LT tokens.
  2. Calls LT.withdraw(lt_tokens, min_assets, receiver).
  3. 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.