Skip to content

Commit b80cd6e

Browse files
authored
Merge pull request #50 from 0xStrobe/main
Add Ambient Swell adapter
2 parents 364e3e6 + 7d1a4f7 commit b80cd6e

File tree

5 files changed

+53
-4
lines changed

5 files changed

+53
-4
lines changed

constants/ambient.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
AMBIENT_SCROLL_DEPLOYMENT_BLOCK = 267408
2-
AMBIENT_SCROLL_API_URL = "https://ethena.liquidity.tools"
2+
AMBIENT_SWELL_DEPLOYMENT_BLOCK = 334175
3+
AMBIENT_API_URL = "https://ethena.liquidity.tools"

constants/summary_columns.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class SummaryColumn(Enum):
1717
)
1818

1919
AMBIENT_SCROLL_SHARDS = ("ambient_scroll_shards", SummaryColumnType.ETHENA_PTS)
20+
AMBIENT_SWELL_SHARDS = ("ambient_swell_shards", SummaryColumnType.ETHENA_PTS)
2021

2122
NURI_SHARDS = ("nuri_shards", SummaryColumnType.ETHENA_PTS)
2223
LENDLE_MANTLE_SHARDS = ("lendle_mantle_shards", SummaryColumnType.ETHENA_PTS)

integrations/ambient_scroll.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from integrations.integration_ids import IntegrationID
44
from integrations.integration import Integration
55
from constants.summary_columns import SummaryColumn
6-
from constants.ambient import AMBIENT_SCROLL_DEPLOYMENT_BLOCK, AMBIENT_SCROLL_API_URL
6+
from constants.ambient import AMBIENT_SCROLL_DEPLOYMENT_BLOCK, AMBIENT_API_URL
77

88

99
class Ambient(Integration):
@@ -21,7 +21,7 @@ def get_balance(self, user: str, block: int) -> float:
2121
"""
2222
Get the balance of a user at a given block
2323
"""
24-
url = f"{AMBIENT_SCROLL_API_URL}/sats/scroll/balance"
24+
url = f"{AMBIENT_API_URL}/sats/scroll/balance"
2525
params = {"user": str(user), "block": str(block)}
2626
response = requests.get(url, params=params) # type: ignore
2727
data = response.json()
@@ -32,7 +32,7 @@ def get_participants(self, blocks: list[int] | None) -> set[str]:
3232
Get all participants of the protocol, ever.
3333
This function should only be called once and should cache the results by setting self.participants
3434
"""
35-
url = f"{AMBIENT_SCROLL_API_URL}/sats/scroll/participants"
35+
url = f"{AMBIENT_API_URL}/sats/scroll/participants"
3636
response = requests.get(url)
3737
data = response.json()
3838
return data["data"]

integrations/ambient_swell.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import requests
2+
from constants.chains import Chain
3+
from integrations.integration_ids import IntegrationID
4+
from integrations.integration import Integration
5+
from constants.summary_columns import SummaryColumn
6+
from constants.ambient import AMBIENT_SWELL_DEPLOYMENT_BLOCK, AMBIENT_API_URL
7+
8+
9+
class Ambient(Integration):
10+
def __init__(self):
11+
super().__init__(
12+
IntegrationID.AMBIENT_SWELL_LP,
13+
AMBIENT_SWELL_DEPLOYMENT_BLOCK,
14+
Chain.SWELL,
15+
[SummaryColumn.AMBIENT_SWELL_SHARDS],
16+
20, # TODO: Change 20 to the sats multiplier for the protocol that has been agreed upon
17+
1,
18+
)
19+
20+
def get_balance(self, user: str, block: int) -> float:
21+
"""
22+
Get the balance of a user at a given block
23+
"""
24+
url = f"{AMBIENT_API_URL}/sats/swell/balance"
25+
params = {"user": str(user), "block": str(block)}
26+
response = requests.get(url, params=params) # type: ignore
27+
data = response.json()
28+
return data["data"]
29+
30+
def get_participants(self, blocks: list[int] | None) -> set[str]:
31+
"""
32+
Get all participants of the protocol, ever.
33+
This function should only be called once and should cache the results by setting self.participants
34+
"""
35+
url = f"{AMBIENT_API_URL}/sats/swell/participants"
36+
response = requests.get(url)
37+
data = response.json()
38+
return data["data"]
39+
40+
41+
if __name__ == "__main__":
42+
# Simple tests for the integration
43+
ambient = Ambient()
44+
print(ambient.get_participants(None))
45+
print(ambient.get_balance(
46+
list(ambient.get_participants(None))[2], 978000))

integrations/integration_ids.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ class IntegrationID(Enum):
245245
VELODROME_MODE_SUSDE = ("velodrome_mode_susde", "Velodrome Mode sUSDe", Token.SUSDE)
246246
# Ambient
247247
AMBIENT_SCROLL_LP = ("ambient_usde_scroll_lp_bal", "Ambient Scroll LP", Token.USDE)
248+
AMBIENT_SWELL_LP = ("ambient_usde_swell_lp_bal", "Ambient Swell LP", Token.USDE)
248249

249250
# Balancer
250251
BALANCER_ARBITRUM_GHO_USDE = (

0 commit comments

Comments
 (0)