/
check_deployment_just_as_an_old_one.py
73 lines (53 loc) · 2.77 KB
/
check_deployment_just_as_an_old_one.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import os
from brownie import PurchaseExecutor
from purchase_config import (
ETH_TO_LDO_RATE_PRECISION,
ETH_TO_LDO_RATE,
LDO_PURCHASERS,
ALLOCATIONS_TOTAL
)
DIRECT_TRANSFER_GAS_LIMIT = 400_000
SEC_IN_A_DAY = 60 * 60 * 24
OLD_EXECUTOR_ADDRESS = '0x489f04eeff0ba8441d42736549a1f1d6cca74775'
def main():
if 'EXECUTOR_ADDRESS' not in os.environ:
raise EnvironmentError('Please set the EXECUTOR_ADDRESS environment variable')
executor_address = os.environ['EXECUTOR_ADDRESS']
print(f'Using deployed executor at address {executor_address}')
print(f'Using old executor at address {OLD_EXECUTOR_ADDRESS}')
executor = PurchaseExecutor.at(executor_address)
old_executor = PurchaseExecutor.at(OLD_EXECUTOR_ADDRESS)
check_config_equals_old_one(executor, old_executor)
check_allocations_equal_old_ones(executor, old_executor)
print(f'[ok] Executor is configured just as an old one')
print(f'All good!')
def check_config_equals_old_one(executor, old_executor):
old_rate = old_executor.eth_to_ldo_rate()
print(f'Previous ETHLDO rate: {old_rate}')
assert executor.eth_to_ldo_rate() == old_rate
old_offer_expiration_delay = old_executor.offer_expiration_delay()
print(f'Previous Offer expiration delay: {old_offer_expiration_delay} days')
assert executor.offer_expiration_delay() == old_offer_expiration_delay
old_vesting_start_delay = old_executor.vesting_start_delay()
print(f'Previous Vesting start delay: {old_vesting_start_delay} days')
assert executor.vesting_start_delay() == old_vesting_start_delay
old_vesting_end_delay = old_executor.vesting_end_delay()
print(f'Previous Vesting end delay: {old_vesting_end_delay} days')
assert executor.vesting_end_delay() == old_vesting_end_delay
print(f'[ok] Global config equals an old one')
def check_allocations_equal_old_ones(executor, old_executor):
print(f'Total allocation: {ALLOCATIONS_TOTAL / 10**18} LDO')
assert executor.ldo_allocations_total() == ALLOCATIONS_TOTAL
sum_old_allocations = 0
for (purchaser, expected_allocation) in LDO_PURCHASERS:
(allocation, eth_cost) = executor.get_allocation(purchaser)
(old_allocation, old_eth_cost) = old_executor.get_allocation(purchaser)
print(f' {purchaser}: {expected_allocation / 10**18} LDO, {eth_cost} wei')
expected_cost = expected_allocation * ETH_TO_LDO_RATE_PRECISION // ETH_TO_LDO_RATE
sum_old_allocations = sum_old_allocations + allocation
assert allocation == expected_allocation
assert allocation == old_allocation
assert eth_cost == expected_cost
assert eth_cost == old_eth_cost
assert executor.ldo_allocations_total() == sum_old_allocations
print(f'[ok] Allocations equal the old ones & no other are included')