Skip to content

Commit 341393a

Browse files
committed
RewardsSugar: added forRoot helper.
1 parent a9b68fb commit 341393a

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

contracts/RewardsSugar.vy

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,3 +347,23 @@ def _pool_rewards(_venft_id: uint256, _pool: address, _gauge: address) \
347347
)
348348

349349
return col
350+
351+
352+
@external
353+
@view
354+
def forRoot(_root_pool: address) -> address[3]:
355+
"""
356+
@notice Returns rewards addresses for the root pool
357+
@param _root_pool the root pool address to map to
358+
@return Array with the root gauge, fee and incentive addresses
359+
"""
360+
if chain.id not in lp_shared.ROOT_CHAIN_IDS:
361+
return empty(address[3])
362+
363+
gauge: address = staticcall lp_shared.voter.gauges(_root_pool)
364+
365+
return [
366+
gauge,
367+
staticcall lp_shared.voter.gaugeToFees(gauge),
368+
staticcall lp_shared.voter.gaugeToBribe(gauge)
369+
]

env.optimism

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ TEST_ADDRESS_10=0x892ff98a46e5bd141e2d12618f4b2fe6284debac
1414
TEST_ALM_ADDRESS_10=0x892ff98a46e5bd141e2d12618f4b2fe6284debac
1515

1616
LP_SUGAR_ADDRESS_10=0x5B3B370C85c8816cBB4BCE5f647dCa3e06c421d7
17-
REWARDS_SUGAR_ADDRESS_10=0x30A6cA7305Cb8a53A530533a680A06f5cB7f11Fd
17+
REWARDS_SUGAR_ADDRESS_10=0x62CCFB2496f49A80B0184AD720379B529E9152fB
1818
VE_SUGAR_ADDRESS_10=0x94f913362b232e31daB49a1aFB775cfd25DaA6a1
1919
RELAY_SUGAR_ADDRESS_10=0xb8307e5842B9aeE75C704183F0355076aa74b4e2

tests/test_rewards_sugar.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,18 @@ def test_epochsLatest_limit_offset(
110110

111111
assert lepoch.lp == pepoch.lp
112112
assert lepoch.ts == pepoch.ts
113+
114+
115+
@pytest.mark.skipif(int(CHAIN_ID) not in [10], reason="Only Optimism")
116+
def test_forRoot(sugar_contract, lp_sugar_contract, LpStruct):
117+
first_lp = LpStruct(*lp_sugar_contract.byIndex(1))
118+
119+
# Use `lp` instead of `root` for testing
120+
addresses = sugar_contract.forRoot(first_lp.lp)
121+
122+
assert addresses is not None
123+
124+
assert len(addresses) == 3
125+
assert addresses[0] == first_lp.gauge
126+
assert addresses[1] == first_lp.fee
127+
assert addresses[2] == first_lp.bribe

0 commit comments

Comments
 (0)