Skip to content

Commit

Permalink
RewardsSugar: added forRoot helper.
Browse files Browse the repository at this point in the history
  • Loading branch information
stas committed Nov 13, 2024
1 parent a9b68fb commit 341393a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
20 changes: 20 additions & 0 deletions contracts/RewardsSugar.vy
Original file line number Diff line number Diff line change
Expand Up @@ -347,3 +347,23 @@ def _pool_rewards(_venft_id: uint256, _pool: address, _gauge: address) \
)

return col


@external
@view
def forRoot(_root_pool: address) -> address[3]:
"""
@notice Returns rewards addresses for the root pool
@param _root_pool the root pool address to map to
@return Array with the root gauge, fee and incentive addresses
"""
if chain.id not in lp_shared.ROOT_CHAIN_IDS:
return empty(address[3])

gauge: address = staticcall lp_shared.voter.gauges(_root_pool)

return [
gauge,
staticcall lp_shared.voter.gaugeToFees(gauge),
staticcall lp_shared.voter.gaugeToBribe(gauge)
]
2 changes: 1 addition & 1 deletion env.optimism
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ TEST_ADDRESS_10=0x892ff98a46e5bd141e2d12618f4b2fe6284debac
TEST_ALM_ADDRESS_10=0x892ff98a46e5bd141e2d12618f4b2fe6284debac

LP_SUGAR_ADDRESS_10=0x5B3B370C85c8816cBB4BCE5f647dCa3e06c421d7
REWARDS_SUGAR_ADDRESS_10=0x30A6cA7305Cb8a53A530533a680A06f5cB7f11Fd
REWARDS_SUGAR_ADDRESS_10=0x62CCFB2496f49A80B0184AD720379B529E9152fB
VE_SUGAR_ADDRESS_10=0x94f913362b232e31daB49a1aFB775cfd25DaA6a1
RELAY_SUGAR_ADDRESS_10=0xb8307e5842B9aeE75C704183F0355076aa74b4e2
15 changes: 15 additions & 0 deletions tests/test_rewards_sugar.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,18 @@ def test_epochsLatest_limit_offset(

assert lepoch.lp == pepoch.lp
assert lepoch.ts == pepoch.ts


@pytest.mark.skipif(int(CHAIN_ID) not in [10], reason="Only Optimism")
def test_forRoot(sugar_contract, lp_sugar_contract, LpStruct):
first_lp = LpStruct(*lp_sugar_contract.byIndex(1))

# Use `lp` instead of `root` for testing
addresses = sugar_contract.forRoot(first_lp.lp)

assert addresses is not None

assert len(addresses) == 3
assert addresses[0] == first_lp.gauge
assert addresses[1] == first_lp.fee
assert addresses[2] == first_lp.bribe

0 comments on commit 341393a

Please sign in to comment.