Skip to content

Commit

Permalink
LpSugar: account for ALM temper strategy.
Browse files Browse the repository at this point in the history
  • Loading branch information
stas committed Dec 19, 2024
1 parent 810b14f commit c4c7fe0
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions contracts/LpSugar.vy
Original file line number Diff line number Diff line change
Expand Up @@ -699,21 +699,36 @@ def _positions(
nfpm.address
)

# For the Temper strategy we might have a second position to add up
if len(alm_pos.ammPositionIds) > 1:
pos2: Position = self._cl_position(
alm_pos.ammPositionIds[1],
# Account is the ALM Core contract here...
alm_core.address,
pool_addr,
gauge.address if staked else empty(address),
factory.address,
nfpm.address
)
pos.amount0 += pos2.amount0
pos.amount1 += pos2.amount1
pos.staked0 += pos2.staked0
pos.staked1 += pos2.staked1

alm_liq: uint256 = staticcall alm_staking.totalSupply()
# adjust user share of the vault...
pos.amount0 = (alm_user_liq * pos.amount0) // alm_liq
pos.amount1 = (alm_user_liq * pos.amount1) // alm_liq
pos.staked0 = (alm_user_liq * pos.staked0) // alm_liq
pos.staked1 = (alm_user_liq * pos.staked1) // alm_liq

pos.emissions_earned = staticcall alm_staking.earned(_account)
# ignore dust as the rebalancing might report "fees"
pos.unstaked_earned0 = 0
pos.unstaked_earned1 = 0

pos.liquidity = (alm_user_liq * pos.liquidity) // alm_liq
pos.staked = (alm_user_liq * pos.staked) // alm_liq

pos.emissions_earned = staticcall alm_staking.earned(_account)
pos.liquidity = alm_user_liq
pos.staked = alm_user_liq
pos.alm = alm_staking.address

if len(positions) < MAX_POSITIONS:
Expand Down

0 comments on commit c4c7fe0

Please sign in to comment.