Skip to content

Commit 48d5d15

Browse files
authored
Merge pull request #82 from murka/feat/evaa-protocol
feat: add EVAA Protocol L2 integration
2 parents 2e506e3 + 74c710f commit 48d5d15

File tree

5 files changed

+165
-2
lines changed

5 files changed

+165
-2
lines changed

campaign/campaign.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from typing import List
2-
from web3 import Web3
2+
33
from integrations.beefy_cached_balance_example_integration import (
44
BeefyCachedBalanceIntegration,
55
)
@@ -10,11 +10,18 @@
1010
from integrations.ratex_l2_delegation_example_integration import (
1111
RatexL2DelegationExampleIntegration,
1212
)
13+
14+
from constants.chains import Chain
15+
from constants.pendle import PENDLE_USDE_JULY_DEPLOYMENT_BLOCK
16+
from constants.summary_columns import SummaryColumn
17+
from web3 import Web3
18+
from constants.evaa import EVAA_USDE_START_BLOCK, EVAA_SUSDE_START_BLOCK
1319
from integrations.stonfi_integration import StonFiIntegration
1420
from integrations.integration import Integration
1521
from integrations.integration_ids import IntegrationID
1622
from integrations.pendle_lpt_integration import PendleLPTIntegration
1723
from integrations.pendle_yt_integration import PendleYTIntegration
24+
from integrations.evaa_integration import EvaaIntegration
1825
from integrations.template import ProtocolNameIntegration
1926
from utils import pendle
2027

@@ -53,6 +60,20 @@
5360
},
5461
end_block=40000000,
5562
),
63+
EvaaIntegration(
64+
integration_id=IntegrationID.EVAA_TON_USDE,
65+
start_block=EVAA_USDE_START_BLOCK,
66+
summary_cols=[SummaryColumn.EVAA_USDE_PTS],
67+
chain=Chain.TON,
68+
reward_multiplier=20,
69+
),
70+
EvaaIntegration(
71+
integration_id=IntegrationID.EVAA_TON_SUSDE,
72+
start_block=EVAA_SUSDE_START_BLOCK,
73+
summary_cols=[SummaryColumn.EVAA_SUSDE_PTS],
74+
chain=Chain.TON,
75+
reward_multiplier=5,
76+
),
5677
# Example integration using cached user balances for improved performance,
5778
# reads from previous balance snapshots
5879
ClaimedEnaIntegration(

constants/evaa.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from constants.integration_token import Token
2+
3+
EVAA_USDE_START_BLOCK=22382834
4+
EVAA_SUSDE_START_BLOCK=22382834
5+
6+
EVAA_ENDPOINT="https://api.evaa.space"
7+
8+
EVAA_POOLS_MAP = {
9+
Token.USDE: [
10+
"EQC8rUZqR_pWV1BylWUlPNBzyiTYVoBEmQkMIQDZXICfnuRr"
11+
],
12+
Token.SUSDE: [
13+
"EQC8rUZqR_pWV1BylWUlPNBzyiTYVoBEmQkMIQDZXICfnuRr"
14+
]
15+
}

constants/summary_columns.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,13 @@ class SummaryColumn(Enum):
6161

6262
VENUS_SUSDE_PTS = ("venus_susde_pts", SummaryColumnType.ETHENA_PTS)
6363

64+
# EVAA Protocol
65+
EVAA_USDE_PTS = ("evaa_usde_pts", SummaryColumnType.ETHENA_PTS)
66+
EVAA_SUSDE_PTS = ("evaa_susde_pts", SummaryColumnType.ETHENA_PTS)
67+
6468
# Sentiment
6569
SENTIMENT_USDE_PTS = ("sentiment_usde_pts", SummaryColumnType.ETHENA_PTS)
6670

67-
6871
def __init__(self, column_name: str, col_type: SummaryColumnType):
6972
self.column_name = column_name
7073
self.col_type = col_type

integrations/evaa_integration.py

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
from typing import Dict, List, Optional, Tuple
2+
3+
from constants.evaa import EVAA_POOLS_MAP, EVAA_ENDPOINT, EVAA_USDE_START_BLOCK, EVAA_SUSDE_START_BLOCK
4+
5+
from integrations.l2_delegation_integration import L2DelegationIntegration
6+
from integrations.integration_ids import IntegrationID
7+
from utils.web3_utils import get_block_date
8+
from utils.request_utils import requests_retry_session
9+
from utils.slack import slack_message
10+
from constants.summary_columns import SummaryColumn
11+
from constants.chains import Chain
12+
class EvaaIntegration(L2DelegationIntegration):
13+
def __init__(
14+
self,
15+
integration_id: IntegrationID,
16+
start_block: int,
17+
summary_cols: Optional[List[SummaryColumn]] = None,
18+
chain: Chain = Chain.TON,
19+
reward_multiplier: int = 1,
20+
end_block: Optional[int] = None,
21+
):
22+
super().__init__(
23+
integration_id=integration_id,
24+
start_block=start_block,
25+
chain=chain,
26+
summary_cols=summary_cols if summary_cols else [SummaryColumn.EVAA_USDE_PTS],
27+
reward_multiplier=reward_multiplier,
28+
end_block=end_block,
29+
)
30+
31+
def get_l2_block_balances(
32+
self,
33+
cached_data: Dict[int, Dict[str, float]],
34+
blocks: List[int]
35+
) -> Dict[int, Dict[str, float]]:
36+
"""
37+
Returns a dict of the form: { block_number: { ton_address: balance } }
38+
"""
39+
try:
40+
block_balances: Dict[int, Dict[str, float]] = {}
41+
42+
for block_number in blocks:
43+
block_balances[block_number] = {}
44+
block_data = self.get_participants_data(block_number)
45+
for participant in block_data:
46+
ton_address = participant["ton_address"]
47+
balance = participant["balance"]
48+
block_balances[block_number][ton_address] = balance
49+
50+
return block_balances
51+
except Exception as e:
52+
err_msg = f"Error fetching EVAA balances at block {block_number}: {e}"
53+
print(err_msg)
54+
slack_message(err_msg)
55+
56+
def get_token_symbol(self):
57+
return self.integration_id.get_token()
58+
59+
def get_participants_data(self, block: int) -> Dict[str, float]:
60+
"""
61+
Returns a list of "ton_address": "balance"
62+
"""
63+
64+
token = self.get_token_symbol()
65+
pools_list = EVAA_POOLS_MAP[token]
66+
block_data: Dict[str, float] = {}
67+
target_date = get_block_date(block, self.chain, adjustment=3600, fmt="%Y-%m-%dT%H:%M:%S")
68+
69+
70+
try:
71+
for pool in pools_list:
72+
res = requests_retry_session().get(
73+
EVAA_ENDPOINT + "/query/adapters/ethena",
74+
params={
75+
"pool_address": pool,
76+
"timestamp": target_date,
77+
"token": token.value
78+
},
79+
80+
timeout=60,
81+
)
82+
payload = res.json()
83+
84+
if payload is None:
85+
raise Exception(f"Error getting participants data for EVAA Protocol token {token} at block {block}: {e}")
86+
87+
block_data = payload
88+
89+
except Exception as e:
90+
err_msg = f"Error getting participants data for EVAA Protocol at block {block}: {e}"
91+
slack_message(err_msg)
92+
93+
return block_data
94+
95+
96+
if __name__ == "__main__":
97+
evaa_integration_usde = EvaaIntegration(
98+
integration_id=IntegrationID.EVAA_TON_USDE,
99+
start_block=EVAA_USDE_START_BLOCK,
100+
summary_cols=[SummaryColumn.EVAA_USDE_PTS],
101+
chain=Chain.TON,
102+
reward_multiplier=20
103+
)
104+
evaa_integration_susde = EvaaIntegration(
105+
integration_id=IntegrationID.EVAA_TON_SUSDE,
106+
start_block=EVAA_SUSDE_START_BLOCK,
107+
summary_cols=[SummaryColumn.EVAA_SUSDE_PTS],
108+
chain=Chain.TON,
109+
reward_multiplier=5
110+
)
111+
112+
balances_usde = evaa_integration_usde.get_l2_block_balances(
113+
cached_data={}, blocks=[22596292]
114+
)
115+
balances_susde = evaa_integration_susde.get_l2_block_balances(
116+
cached_data={}, blocks=[22596292]
117+
)
118+
119+
print("Balances USDe:", balances_usde)
120+
print("Balances sUSDe:", balances_susde)

integrations/integration_ids.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,10 @@ class IntegrationID(Enum):
475475
# Venus
476476
VENUS_SUSDE = ("venus_susde", "Venus sUSDe", Token.SUSDE)
477477

478+
# EVAA Protocol
479+
EVAA_TON_USDE = ("evaa_ton_usde", "EVAA TON USDe", Token.USDE)
480+
EVAA_TON_SUSDE = ("evaa_ton_susde", "EVAA TON sUSDe", Token.SUSDE)
481+
478482
# Bulbaswap
479483
BULBASWAP = (
480484
"bulbaswap",

0 commit comments

Comments
 (0)