Skip to content

Commit 00c11b5

Browse files
authored
Merge pull request #110 from ethena-labs/Add-Thruster-Example-Deposit-IDs
feat(thruster): add Thruster integration and related ABI files
2 parents 033b7ac + 1204765 commit 00c11b5

File tree

9 files changed

+738
-26
lines changed

9 files changed

+738
-26
lines changed

abi/thruster_nfp.json

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
[
2+
{
3+
"inputs": [
4+
{
5+
"internalType": "uint256",
6+
"name": "tokenId",
7+
"type": "uint256"
8+
}
9+
],
10+
"name": "positions",
11+
"outputs": [
12+
{
13+
"internalType": "uint96",
14+
"name": "nonce",
15+
"type": "uint96"
16+
},
17+
{
18+
"internalType": "address",
19+
"name": "operator",
20+
"type": "address"
21+
},
22+
{
23+
"internalType": "address",
24+
"name": "token0",
25+
"type": "address"
26+
},
27+
{
28+
"internalType": "address",
29+
"name": "token1",
30+
"type": "address"
31+
},
32+
{
33+
"internalType": "uint24",
34+
"name": "fee",
35+
"type": "uint24"
36+
},
37+
{
38+
"internalType": "int24",
39+
"name": "tickLower",
40+
"type": "int24"
41+
},
42+
{
43+
"internalType": "int24",
44+
"name": "tickUpper",
45+
"type": "int24"
46+
},
47+
{
48+
"internalType": "uint128",
49+
"name": "liquidity",
50+
"type": "uint128"
51+
},
52+
{
53+
"internalType": "uint256",
54+
"name": "feeGrowthInside0LastX128",
55+
"type": "uint256"
56+
},
57+
{
58+
"internalType": "uint256",
59+
"name": "feeGrowthInside1LastX128",
60+
"type": "uint256"
61+
},
62+
{
63+
"internalType": "uint128",
64+
"name": "tokensOwed0",
65+
"type": "uint128"
66+
},
67+
{
68+
"internalType": "uint128",
69+
"name": "tokensOwed1",
70+
"type": "uint128"
71+
}
72+
],
73+
"stateMutability": "view",
74+
"type": "function"
75+
},
76+
{
77+
"anonymous": false,
78+
"inputs": [
79+
{
80+
"indexed": true,
81+
"internalType": "uint256",
82+
"name": "tokenId",
83+
"type": "uint256"
84+
},
85+
{
86+
"indexed": false,
87+
"internalType": "uint128",
88+
"name": "liquidity",
89+
"type": "uint128"
90+
},
91+
{
92+
"indexed": false,
93+
"internalType": "uint256",
94+
"name": "amount0",
95+
"type": "uint256"
96+
},
97+
{
98+
"indexed": false,
99+
"internalType": "uint256",
100+
"name": "amount1",
101+
"type": "uint256"
102+
},
103+
{
104+
"indexed": false,
105+
"internalType": "int24",
106+
"name": "tickLower",
107+
"type": "int24"
108+
},
109+
{
110+
"indexed": false,
111+
"internalType": "int24",
112+
"name": "tickUpper",
113+
"type": "int24"
114+
},
115+
{
116+
"indexed": false,
117+
"internalType": "address",
118+
"name": "pool",
119+
"type": "address"
120+
}
121+
],
122+
"name": "DecreaseLiquidity",
123+
"type": "event"
124+
},
125+
{
126+
"anonymous": false,
127+
"inputs": [
128+
{
129+
"indexed": true,
130+
"internalType": "uint256",
131+
"name": "tokenId",
132+
"type": "uint256"
133+
},
134+
{
135+
"indexed": false,
136+
"internalType": "uint128",
137+
"name": "liquidity",
138+
"type": "uint128"
139+
},
140+
{
141+
"indexed": false,
142+
"internalType": "uint256",
143+
"name": "amount0",
144+
"type": "uint256"
145+
},
146+
{
147+
"indexed": false,
148+
"internalType": "uint256",
149+
"name": "amount1",
150+
"type": "uint256"
151+
},
152+
{
153+
"indexed": false,
154+
"internalType": "int24",
155+
"name": "tickLower",
156+
"type": "int24"
157+
},
158+
{
159+
"indexed": false,
160+
"internalType": "int24",
161+
"name": "tickUpper",
162+
"type": "int24"
163+
},
164+
{
165+
"indexed": false,
166+
"internalType": "address",
167+
"name": "pool",
168+
"type": "address"
169+
}
170+
],
171+
"name": "IncreaseLiquidity",
172+
"type": "event"
173+
},
174+
{
175+
"inputs": [
176+
{
177+
"internalType": "uint256",
178+
"name": "tokenId",
179+
"type": "uint256"
180+
}
181+
],
182+
"name": "ownerOf",
183+
"outputs": [
184+
{
185+
"internalType": "address",
186+
"name": "",
187+
"type": "address"
188+
}
189+
],
190+
"stateMutability": "view",
191+
"type": "function"
192+
}
193+
]

abi/thruster_pool.json

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
[
2+
{
3+
"inputs": [],
4+
"name": "slot0",
5+
"outputs": [
6+
{
7+
"internalType": "uint160",
8+
"name": "sqrtPriceX96",
9+
"type": "uint160"
10+
},
11+
{
12+
"internalType": "int24",
13+
"name": "tick",
14+
"type": "int24"
15+
},
16+
{
17+
"internalType": "uint16",
18+
"name": "observationIndex",
19+
"type": "uint16"
20+
},
21+
{
22+
"internalType": "uint16",
23+
"name": "observationCardinality",
24+
"type": "uint16"
25+
},
26+
{
27+
"internalType": "uint16",
28+
"name": "observationCardinalityNext",
29+
"type": "uint16"
30+
},
31+
{
32+
"internalType": "uint32",
33+
"name": "feeProtocol",
34+
"type": "uint32"
35+
},
36+
{
37+
"internalType": "bool",
38+
"name": "unlocked",
39+
"type": "bool"
40+
}
41+
],
42+
"stateMutability": "view",
43+
"type": "function"
44+
}
45+
]

constants/summary_columns.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ class SummaryColumn(Enum):
104104
SummaryColumnType.ETHENA_PTS,
105105
)
106106

107+
THRUSTER_POOL_PTS = ("thruster_pool_pts", SummaryColumnType.ETHENA_PTS)
108+
107109
def __init__(self, column_name: str, col_type: SummaryColumnType):
108110
self.column_name = column_name
109111
self.col_type = col_type

constants/thruster.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import json
2+
from web3 import Web3
3+
from web3.contract import Contract
4+
from utils.web3_utils import w3_blast
5+
6+
MAX_TICK_RANGE = 7000
7+
8+
THRUSTER_USDE_POOL_ADDRESS = Web3.to_checksum_address(
9+
"0x8C1bb76510D6873a4A156A9Cb394E74A3783BDB5"
10+
)
11+
12+
THRUSTER_NFP_ADDRESS = Web3.to_checksum_address(
13+
"0x434575EaEa081b735C985FA9bf63CD7b87e227F9"
14+
)
15+
16+
HYPERLOCK_DEPOSIT_ADDRESS = Web3.to_checksum_address(
17+
"0xc28EffdfEF75448243c1d9bA972b97e32dF60d06"
18+
)
19+
20+
JUICE_USDE_VAULT_ADDR = Web3.to_checksum_address(
21+
"0xc1B1aE2502D2cDEF4772FB4A4a6fcBf4fd9c1b80"
22+
)
23+
24+
PARTICLE_LEVERAGED_POOL_ADDRESS = Web3.to_checksum_address(
25+
"0x121B5ac4De4a3E6F4171956BC26ceda40Cb61a56"
26+
)
27+
28+
JUICE_TOKEN_ID = 111969
29+
30+
31+
THRUSTER_NFP_ABI = json.load(open("abi/thruster_nfp.json"))
32+
THRUSTER_POOL_ABI = json.load(open("abi/thruster_pool.json"))
33+
34+
thruster_nfp_contract: Contract = w3_blast.eth.contract(
35+
address=THRUSTER_NFP_ADDRESS, abi=THRUSTER_NFP_ABI
36+
)
37+
38+
thruster_usde_pool_contract: Contract = w3_blast.eth.contract(
39+
address=THRUSTER_USDE_POOL_ADDRESS, abi=THRUSTER_POOL_ABI
40+
)
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
from typing import Dict, List, Optional, Set
2+
3+
from eth_typing import ChecksumAddress
4+
from constants.summary_columns import SummaryColumn
5+
from constants.chains import Chain
6+
from integrations.integration import Integration
7+
from integrations.integration_ids import IntegrationID as IntID
8+
9+
10+
class DepositIdsIntegration(Integration):
11+
"""
12+
Some integrations require a deposit or token ID only obtainable from deposit events to get balances.
13+
We approach this by storing the deposit IDs on DB and overriding fetch_block_data.
14+
"""
15+
16+
def __init__(
17+
self,
18+
integration_id: IntID,
19+
start_block: int,
20+
chain: Chain = Chain.ETHEREUM,
21+
summary_cols: Optional[List[SummaryColumn]] = None,
22+
reward_multiplier: int = 1,
23+
excluded_addresses: Optional[Set[ChecksumAddress]] = None,
24+
):
25+
super().__init__(
26+
integration_id=integration_id,
27+
start_block=start_block,
28+
chain=chain,
29+
summary_cols=summary_cols,
30+
reward_multiplier=reward_multiplier,
31+
balance_multiplier=1,
32+
excluded_addresses=excluded_addresses,
33+
)
34+
35+
def fetch_participants(
36+
self, cache: Dict[int, Dict[ChecksumAddress, float]], blocks: List[int]
37+
) -> Set[ChecksumAddress]:
38+
"""Override fetch_participants to handle deposit IDs."""
39+
raise NotImplementedError
40+
41+
def get_deposit_ids_balances(
42+
self, deposit_ids: Set[int], user: ChecksumAddress, block: int
43+
) -> float:
44+
raise NotImplementedError
45+
46+
def get_participants_with_deposit_ids(
47+
self, blocks: List[int], cache: Optional[Dict[ChecksumAddress, Set[int]]] = None
48+
) -> Dict[ChecksumAddress, Set[int]]:
49+
raise NotImplementedError

integrations/integration_ids.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,6 @@ class IntegrationID(Enum):
511511
Token.SUSDE,
512512
)
513513

514-
515514
# Affluent
516515
AFFLUENT_USDE = ("affluent_usde", "Affluent TON USDe", Token.USDE)
517516
AFFLUENT_SUSDE = ("affluent_susde", "Affluent TON sUSDe", Token.SUSDE)
@@ -541,16 +540,19 @@ class IntegrationID(Enum):
541540
FELIX_USDE = ("felix_usde", "Felix USDe", Token.USDE)
542541

543542
# Terminal Finance
544-
TERMINAL_TUSDE = (
545-
"terminal_tusde",
546-
"Terminal Finance tUSDe",
547-
Token.USDE
548-
)
543+
TERMINAL_TUSDE = ("terminal_tusde", "Terminal Finance tUSDe", Token.USDE)
549544

550545
TERMINAL_TERMMAX_TUSDE = (
551546
"terminal_termmax_tusde",
552547
"Terminal Finance tUSDe on TermMax",
553-
Token.USDE
548+
Token.USDE,
549+
)
550+
551+
# Thruster
552+
THRUSTER_USDE_POOL = (
553+
"thruster_usde_pool",
554+
"Thruster USDe Pool",
555+
Token.USDE,
554556
)
555557

556558
def __init__(self, column_name: str, description: str, token: Token = Token.USDE):

0 commit comments

Comments
 (0)