Skip to content

Commit 2761af5

Browse files
authored
Merge pull request #371 from lidofinance/feat/lol-et
[HOLESKY] Change the limits & period for ET for LOL
2 parents e20f420 + 2c153fc commit 2761af5

File tree

2 files changed

+266
-0
lines changed

2 files changed

+266
-0
lines changed
+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
"""
2+
Voting 03/04/2025 [HOLESKY].
3+
4+
I. Change the limits & period for ET for LOL
5+
1: - Increase the limit from 210 to 500 USDC/USDT/DAI - set 500 limit on LOL registry `0x55B304a585D540421F1fD3579Ef12Abab7304492`
6+
- Increase the period from 3 months to 6 months - set 6 months period on LOL registry `0x55B304a585D540421F1fD3579Ef12Abab7304492`
7+
8+
"""
9+
10+
import time
11+
12+
from typing import Dict
13+
14+
from brownie import interface
15+
from brownie.network.transaction import TransactionReceipt
16+
from utils.voting import bake_vote_items, confirm_vote_script, create_vote
17+
from utils.ipfs import upload_vote_ipfs_description, calculate_vote_ipfs_description
18+
19+
from utils.config import (
20+
get_deployer_account,
21+
get_is_live,
22+
get_priority_fee,
23+
)
24+
25+
from utils.allowed_recipients_registry import (
26+
set_limit_parameters,
27+
)
28+
29+
from utils.agent import agent_forward
30+
31+
description = """
32+
I. Change the limits & period for ET for LOL
33+
1: - Increase the limit from 210 to 500 USDC/USDT/DAI - set 500 limit on LOL registry `0x55B304a585D540421F1fD3579Ef12Abab7304492`
34+
- Increase the period from 3 months to 6 months - set 6 months period on LOL registry `0x55B304a585D540421F1fD3579Ef12Abab7304492`
35+
"""
36+
37+
def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | TransactionReceipt | None]:
38+
"""Prepare and run voting."""
39+
40+
lol_registry = interface.AllowedRecipientRegistry("0x55B304a585D540421F1fD3579Ef12Abab7304492")
41+
42+
vote_desc_items, call_script_items = zip(
43+
#
44+
# I. Change the limits & period for ET for LOL
45+
#
46+
(
47+
"""1: - Increase the limit from 210 to 500 USDC/USDT/DAI - set 500 limit on LOL registry `0x55B304a585D540421F1fD3579Ef12Abab7304492`
48+
- Increase the period from 3 months to 6 months - set 6 months period on LOL registry `0x55B304a585D540421F1fD3579Ef12Abab7304492`""",
49+
agent_forward(
50+
[
51+
set_limit_parameters(
52+
registry_address=lol_registry,
53+
limit=500 * 10 ** 18,
54+
period_duration_months=6
55+
),
56+
]
57+
),
58+
),
59+
)
60+
61+
vote_items = bake_vote_items(list(vote_desc_items), list(call_script_items))
62+
63+
if silent:
64+
desc_ipfs = calculate_vote_ipfs_description(description)
65+
else:
66+
desc_ipfs = upload_vote_ipfs_description(description)
67+
68+
return confirm_vote_script(vote_items, silent, desc_ipfs) and list(
69+
create_vote(vote_items, tx_params, desc_ipfs=desc_ipfs)
70+
)
71+
72+
73+
def main():
74+
tx_params = {"from": get_deployer_account()}
75+
76+
if get_is_live():
77+
tx_params["priority_fee"] = get_priority_fee()
78+
79+
vote_id, _ = start_vote(tx_params=tx_params, silent=False)
80+
81+
vote_id >= 0 and print(f"Vote created: {vote_id}.")
82+
83+
time.sleep(5) # hack for waiting thread #2.
+183
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
"""
2+
Tests for voting 03/04/2025 [HOLESKY].
3+
"""
4+
5+
from scripts.vote_2024_12_17_holesky import start_vote
6+
from brownie import interface, reverts, chain
7+
from utils.test.tx_tracing_helpers import *
8+
from utils.config import contracts, LDO_HOLDER_ADDRESS_FOR_TESTS
9+
from utils.config import contracts
10+
from utils.test.easy_track_helpers import create_and_enact_payment_motion
11+
from utils.test.event_validators.allowed_recipients_registry import (
12+
validate_set_limit_parameter_event,
13+
)
14+
15+
def test_vote(helpers, accounts, vote_ids_from_env, stranger):
16+
17+
# common values
18+
STETH = interface.StETH("0x3F1c547b21f65e10480dE3ad8E19fAAC46C95034")
19+
easy_track = interface.EasyTrack("0x1763b9ED3586B08AE796c7787811a2E1bc16163a")
20+
lol_allowed_recipients_registry = interface.AllowedRecipientRegistry("0x55B304a585D540421F1fD3579Ef12Abab7304492")
21+
lol_allowed_recipient = accounts.at("0x1580881349e214Bab9f1E533bF97351271DB95a9", force=True)
22+
lol_trusted_caller_acc = accounts.at("0x96d2Ff1C4D30f592B91fd731E218247689a76915", force=True)
23+
lol_top_up_evm_script_factory = interface.TopUpAllowedRecipients("0xBB06DD9a3C7eE8cE093860094e769a1E3D6F97F6")
24+
25+
# before values
26+
lol_budget_limit_before_exptected = 210 * 10**18
27+
lol_period_duration_months_before_expected = 3
28+
lol_period_start_before_exptected = 1704067200 # Mon Jan 01 2024 00:00:00 GMT+0000
29+
lol_period_end_before_exptected = 1711929600 # Mon Apr 01 2024 00:00:00 GMT+0000
30+
31+
# after values
32+
lol_budget_limit_after_expected = 500 * 10**18
33+
lol_period_duration_months_after_expected = 6
34+
lol_period_start_after_exptected = 1735689600 # Wed Jan 01 2025 00:00:00 GMT+0000
35+
lol_period_end_after_exptected = 1751328000 # Tue Jul 01 2025 00:00:00 GMT+0000
36+
37+
#scenario test values
38+
h2_motion_time = 1751328001 # Tue Jul 01 2025 00:00:01 GMT+0000
39+
h2_period_start = 1751328000 # Tue Jul 01 2025 00:00:00 GMT+0000
40+
h2_period_end = 1767225600 # Thu Jan 01 2026 00:00:00 GMT+0000
41+
42+
43+
# checks before
44+
lol_budget_limit_before, lol_period_duration_months_before = interface.AllowedRecipientRegistry(lol_allowed_recipients_registry).getLimitParameters()
45+
_, _, lol_period_start_before, lol_period_end_before = lol_allowed_recipients_registry.getPeriodState()
46+
lol_spendable_balance_before = interface.AllowedRecipientRegistry(lol_allowed_recipients_registry).spendableBalance()
47+
assert lol_budget_limit_before == lol_budget_limit_before_exptected
48+
assert lol_period_duration_months_before == lol_period_duration_months_before_expected
49+
assert lol_period_start_before == lol_period_start_before_exptected
50+
assert lol_period_end_before == lol_period_end_before_exptected
51+
52+
53+
# START VOTE
54+
if len(vote_ids_from_env) > 0:
55+
(vote_id,) = vote_ids_from_env
56+
else:
57+
tx_params = {"from": LDO_HOLDER_ADDRESS_FOR_TESTS}
58+
vote_id, _ = start_vote(tx_params, silent=True)
59+
vote_tx = helpers.execute_vote(accounts, vote_id, contracts.voting)
60+
print(f"voteId = {vote_id}, gasUsed = {vote_tx.gas_used}")
61+
62+
63+
# checks after
64+
lol_budget_limit_after, lol_period_duration_months_after = interface.AllowedRecipientRegistry(lol_allowed_recipients_registry).getLimitParameters()
65+
_, _, lol_period_start_after, lol_period_end_after = interface.AllowedRecipientRegistry(lol_allowed_recipients_registry).getPeriodState()
66+
lol_spendable_balance_after = interface.AllowedRecipientRegistry(lol_allowed_recipients_registry).spendableBalance()
67+
assert lol_period_start_after == lol_period_start_after_exptected
68+
assert lol_period_end_after == lol_period_end_after_exptected
69+
assert lol_budget_limit_after == lol_budget_limit_after_expected
70+
assert lol_period_duration_months_after == lol_period_duration_months_after_expected
71+
assert lol_spendable_balance_before + (lol_budget_limit_after_expected - lol_budget_limit_before_exptected) == lol_spendable_balance_after
72+
73+
74+
# check events
75+
display_voting_events(vote_tx)
76+
evs = group_voting_events(vote_tx)
77+
78+
assert count_vote_items_by_events(vote_tx, contracts.voting) == 1, "Incorrect voting items count"
79+
80+
validate_set_limit_parameter_event(
81+
evs[0],
82+
limit=lol_budget_limit_after_expected,
83+
period_duration_month=lol_period_duration_months_after_expected,
84+
period_start_timestamp=lol_period_start_after_exptected,
85+
)
86+
87+
# scenario tests
88+
89+
# full withdrawal in H1'2025
90+
limit_test(easy_track,
91+
interface.AllowedRecipientRegistry(lol_allowed_recipients_registry).spendableBalance(),
92+
lol_trusted_caller_acc,
93+
lol_top_up_evm_script_factory,
94+
lol_allowed_recipient,
95+
stranger,
96+
STETH,
97+
100 * 10**18
98+
)
99+
100+
# partial withdrawal of 300 steth in H2'2025
101+
102+
# wait until H2'2025
103+
chain.sleep(h2_motion_time - chain.time())
104+
chain.mine()
105+
assert chain.time() == h2_motion_time
106+
107+
# pay 100 steth
108+
create_and_enact_payment_motion(
109+
easy_track,
110+
lol_trusted_caller_acc,
111+
lol_top_up_evm_script_factory,
112+
STETH,
113+
[lol_allowed_recipient],
114+
[100 * 10**18],
115+
stranger,
116+
)
117+
118+
# pay 100 steth
119+
create_and_enact_payment_motion(
120+
easy_track,
121+
lol_trusted_caller_acc,
122+
lol_top_up_evm_script_factory,
123+
STETH,
124+
[lol_allowed_recipient],
125+
[100 * 10**18],
126+
stranger,
127+
)
128+
129+
# pay 100 steth
130+
create_and_enact_payment_motion(
131+
easy_track,
132+
lol_trusted_caller_acc,
133+
lol_top_up_evm_script_factory,
134+
STETH,
135+
[lol_allowed_recipient],
136+
[100 * 10**18],
137+
stranger,
138+
)
139+
140+
lol_already_spent_h2, _, lol_period_start_h2, lol_period_end_h2 = lol_allowed_recipients_registry.getPeriodState()
141+
assert lol_already_spent_h2 == 300 * 10**18
142+
assert lol_period_start_h2 == h2_period_start
143+
assert lol_period_end_h2 == h2_period_end
144+
assert interface.AllowedRecipientRegistry(lol_allowed_recipients_registry).spendableBalance() == 200 * 10**18
145+
146+
def limit_test(easy_track, to_spend, trusted_caller_acc, top_up_evm_script_factory, send_to, stranger, token, max_spend_at_once):
147+
148+
# check that there is no way to spend more then expected
149+
with reverts("SUM_EXCEEDS_SPENDABLE_BALANCE"):
150+
create_and_enact_payment_motion(
151+
easy_track,
152+
trusted_caller_acc,
153+
top_up_evm_script_factory,
154+
token,
155+
[send_to],
156+
[to_spend + 1],
157+
stranger,
158+
)
159+
160+
# spend all step by step
161+
while to_spend > 0:
162+
create_and_enact_payment_motion(
163+
easy_track,
164+
trusted_caller_acc,
165+
top_up_evm_script_factory,
166+
token,
167+
[send_to],
168+
[min(max_spend_at_once, to_spend)],
169+
stranger,
170+
)
171+
to_spend -= min(max_spend_at_once, to_spend)
172+
173+
# make sure there is nothing left so that you can't spend anymore
174+
with reverts("SUM_EXCEEDS_SPENDABLE_BALANCE"):
175+
create_and_enact_payment_motion(
176+
easy_track,
177+
trusted_caller_acc,
178+
top_up_evm_script_factory,
179+
token,
180+
[send_to],
181+
[1],
182+
stranger,
183+
)

0 commit comments

Comments
 (0)