Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/quickfix-schema-format' into kac…
Browse files Browse the repository at this point in the history
…per/tests/oct-2244/add-unit-tests-for-epochs
  • Loading branch information
kgarbacinski committed Dec 17, 2024
2 parents 84e7856 + 01d3e3c commit 0a7adad
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 1,131 deletions.
7 changes: 1 addition & 6 deletions backend/app/modules/user/events_generator/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
def unify_deposit_balances(events: List[DepositEvent]) -> List[DepositEvent]:
"""
Unify deposit balance for each event in the list of events. Events are expected to be sorted by timestamp.
The first event is always from Octant, but the first Sablier event may have a non-zero `deposit_before`, indicating a balance from the past.
The first event is taken from deposits, but it already includes deposit from Sablier from the past.
Returns:
List[DepositEvent]: A list of events with adjusted `deposit_before` and `deposit_after`.
Expand All @@ -17,12 +17,7 @@ def unify_deposit_balances(events: List[DepositEvent]) -> List[DepositEvent]:
acc_balance_sablier = 0
acc_balance_octant = events[0].deposit_before # balance from previous epoch

first_sablier_processed = False
for event in modified_events[1:]:
if event.source == DepositSource.SABLIER and not first_sablier_processed:
acc_balance_sablier = event.deposit_before
first_sablier_processed = True

combined_balance = acc_balance_sablier + acc_balance_octant
event.deposit_before = combined_balance

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
type=EventType.LOCK,
timestamp=2,
amount=1000,
deposit_before=1500,
deposit_before=500, # must be <= than the deposit_before from the first event
source=DepositSource.SABLIER,
),
],
Expand All @@ -79,7 +79,7 @@
type=EventType.LOCK,
timestamp=2,
amount=1000,
deposit_before=3000,
deposit_before=1500,
source=DepositSource.SABLIER,
),
],
Expand All @@ -99,7 +99,7 @@
type=EventType.LOCK,
timestamp=1,
amount=1000,
deposit_before=2000,
deposit_before=1000,
source=DepositSource.SABLIER,
),
DepositEvent(
Expand All @@ -108,7 +108,6 @@
timestamp=2,
amount=500,
deposit_before=1000,
# Takes the balance from the previous event from Octant, not Sablier
source=DepositSource.OCTANT,
),
],
Expand All @@ -125,15 +124,15 @@
type=EventType.LOCK,
timestamp=1,
amount=1000,
deposit_before=3000,
deposit_before=1000,
source=DepositSource.SABLIER,
),
DepositEvent(
user="0x123",
type=EventType.LOCK,
timestamp=2,
amount=500,
deposit_before=4000,
deposit_before=2000,
source=DepositSource.OCTANT,
),
],
Expand Down Expand Up @@ -162,16 +161,15 @@
type=EventType.LOCK,
timestamp=2,
amount=1000,
deposit_before=1000,
deposit_before=500, # must be <= than the deposit_before from the first event
source=DepositSource.SABLIER,
),
DepositEvent(
user="0x123",
type=EventType.UNLOCK,
timestamp=3,
amount=400,
deposit_before=2000,
# Takes the balance from the previous event from Sablier, not Octant
deposit_before=1500,
source=DepositSource.SABLIER,
),
DepositEvent(
Expand All @@ -180,7 +178,6 @@
timestamp=4,
amount=200,
deposit_before=1500,
# Takes the balance from the previous event from Octant, not Sablier
source=DepositSource.OCTANT,
),
],
Expand All @@ -206,23 +203,23 @@
type=EventType.LOCK,
timestamp=2,
amount=1000,
deposit_before=2000,
deposit_before=1000,
source=DepositSource.SABLIER,
),
DepositEvent(
user="0x123",
type=EventType.UNLOCK,
timestamp=3,
amount=400,
deposit_before=3000,
deposit_before=2000,
source=DepositSource.SABLIER,
),
DepositEvent(
user="0x123",
type=EventType.LOCK,
timestamp=4,
amount=200,
deposit_before=2600,
deposit_before=1600,
source=DepositSource.OCTANT,
),
],
Expand Down
10 changes: 5 additions & 5 deletions backend/v2/epochs/schemas.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
from pydantic import BaseModel
from v2.core.types import OctantModel


class CurrentEpochResponseV1(BaseModel):
class CurrentEpochResponseV1(OctantModel):
current_epoch: int


class IndexedEpochResponseV1(BaseModel):
class IndexedEpochResponseV1(OctantModel):
current_epoch: int
indexed_epoch: int


class EpochStatsResponseV1(BaseModel):
class EpochStatsResponseV1(OctantModel):
staking_proceeds: str
total_effective_deposit: str
total_rewards: str
Expand All @@ -25,5 +25,5 @@ class EpochStatsResponseV1(BaseModel):
donated_to_projects: str | None


class EpochRewardsRateResponseV1(BaseModel):
class EpochRewardsRateResponseV1(OctantModel):
rewards_rate: float
14 changes: 7 additions & 7 deletions ci/argocd/contracts/uat.env
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
BLOCK_NUMBER=7156082
BLOCK_NUMBER=7291555
GLM_CONTRACT_ADDRESS=0x71432DD1ae7DB41706ee6a22148446087BdD0906
AUTH_CONTRACT_ADDRESS=0xC09CddcF90F5aF074D9670682c980345D04a5b07
DEPOSITS_CONTRACT_ADDRESS=0x53BF7aB7d5130c2f085990f32b3975fFC724123d
EPOCHS_CONTRACT_ADDRESS=0x983d3c467d46b85858b65C4Fa72394Cc96F04762
PROPOSALS_CONTRACT_ADDRESS=0xA9361e7258Ee22B006dCB90Bf2A06D0edACdF31F
WITHDRAWALS_TARGET_CONTRACT_ADDRESS=0x6013d2240B7Ff82D7781786273ec6B73CfB90d79
VAULT_CONTRACT_ADDRESS=0x0f9D1aba589792B3a12F8e8823581c257C237B52
AUTH_CONTRACT_ADDRESS=0x69aB3a71Fd17c169e42a9fEae3bae980E5C1a382
DEPOSITS_CONTRACT_ADDRESS=0x94F32813b3e1fC71Ce8faE0C03534900B07EAd87
EPOCHS_CONTRACT_ADDRESS=0x232587C05598EbC929375d7B53B2B5d094f24ED2
PROPOSALS_CONTRACT_ADDRESS=0x21B43E2887a4FB445AA286b6E1D162A51439AD5f
WITHDRAWALS_TARGET_CONTRACT_ADDRESS=0x027Efff0c6E1128bEd03A9dF443a88C1DfC87024
VAULT_CONTRACT_ADDRESS=0x28ae8DDE97f46Bc5Fb0c9f104836361F79a082fB
Loading

0 comments on commit 0a7adad

Please sign in to comment.