diff --git a/constants/ambient.py b/constants/ambient.py index c633dfd..3b57b32 100644 --- a/constants/ambient.py +++ b/constants/ambient.py @@ -1,2 +1,3 @@ AMBIENT_SCROLL_DEPLOYMENT_BLOCK = 267408 -AMBIENT_SCROLL_API_URL = "https://ethena.liquidity.tools" +AMBIENT_SWELL_DEPLOYMENT_BLOCK = 334175 +AMBIENT_API_URL = "https://ethena.liquidity.tools" diff --git a/constants/chains.py b/constants/chains.py index 7b0c8d3..e565d64 100644 --- a/constants/chains.py +++ b/constants/chains.py @@ -11,3 +11,4 @@ class Chain(Enum): MODE = "Mode" OPTIMISM = "Optimism" Lyra = "Lyra" + SWELL = "Swell" diff --git a/constants/summary_columns.py b/constants/summary_columns.py index e0c35b4..cdaef4b 100644 --- a/constants/summary_columns.py +++ b/constants/summary_columns.py @@ -17,6 +17,7 @@ class SummaryColumn(Enum): ) AMBIENT_SCROLL_SHARDS = ("ambient_scroll_shards", SummaryColumnType.ETHENA_PTS) + AMBIENT_SWELL_SHARDS = ("ambient_swell_shards", SummaryColumnType.ETHENA_PTS) NURI_SHARDS = ("nuri_shards", SummaryColumnType.ETHENA_PTS) LENDLE_MANTLE_SHARDS = ("lendle_mantle_shards", SummaryColumnType.ETHENA_PTS) diff --git a/integrations/ambient_scroll.py b/integrations/ambient_scroll.py index f83972f..ca05fec 100644 --- a/integrations/ambient_scroll.py +++ b/integrations/ambient_scroll.py @@ -3,7 +3,7 @@ from integrations.integration_ids import IntegrationID from integrations.integration import Integration from constants.summary_columns import SummaryColumn -from constants.ambient import AMBIENT_SCROLL_DEPLOYMENT_BLOCK, AMBIENT_SCROLL_API_URL +from constants.ambient import AMBIENT_SCROLL_DEPLOYMENT_BLOCK, AMBIENT_API_URL class Ambient(Integration): @@ -21,7 +21,7 @@ def get_balance(self, user: str, block: int) -> float: """ Get the balance of a user at a given block """ - url = f"{AMBIENT_SCROLL_API_URL}/sats/scroll/balance" + url = f"{AMBIENT_API_URL}/sats/scroll/balance" params = {"user": str(user), "block": str(block)} response = requests.get(url, params=params) # type: ignore data = response.json() @@ -32,7 +32,7 @@ def get_participants(self, blocks: list[int] | None) -> set[str]: Get all participants of the protocol, ever. This function should only be called once and should cache the results by setting self.participants """ - url = f"{AMBIENT_SCROLL_API_URL}/sats/scroll/participants" + url = f"{AMBIENT_API_URL}/sats/scroll/participants" response = requests.get(url) data = response.json() return data["data"] diff --git a/integrations/ambient_swell.py b/integrations/ambient_swell.py new file mode 100644 index 0000000..3cd9aae --- /dev/null +++ b/integrations/ambient_swell.py @@ -0,0 +1,46 @@ +import requests +from constants.chains import Chain +from integrations.integration_ids import IntegrationID +from integrations.integration import Integration +from constants.summary_columns import SummaryColumn +from constants.ambient import AMBIENT_SWELL_DEPLOYMENT_BLOCK, AMBIENT_API_URL + + +class Ambient(Integration): + def __init__(self): + super().__init__( + IntegrationID.AMBIENT_SWELL_LP, + AMBIENT_SWELL_DEPLOYMENT_BLOCK, + Chain.SWELL, + [SummaryColumn.AMBIENT_SWELL_SHARDS], + 20, # TODO: Change 20 to the sats multiplier for the protocol that has been agreed upon + 1, + ) + + def get_balance(self, user: str, block: int) -> float: + """ + Get the balance of a user at a given block + """ + url = f"{AMBIENT_API_URL}/sats/swell/balance" + params = {"user": str(user), "block": str(block)} + response = requests.get(url, params=params) # type: ignore + data = response.json() + return data["data"] + + def get_participants(self, blocks: list[int] | None) -> set[str]: + """ + Get all participants of the protocol, ever. + This function should only be called once and should cache the results by setting self.participants + """ + url = f"{AMBIENT_API_URL}/sats/swell/participants" + response = requests.get(url) + data = response.json() + return data["data"] + + +if __name__ == "__main__": + # Simple tests for the integration + ambient = Ambient() + print(ambient.get_participants(None)) + print(ambient.get_balance( + list(ambient.get_participants(None))[2], 978000)) diff --git a/integrations/integration_ids.py b/integrations/integration_ids.py index 86e9618..99b75e7 100644 --- a/integrations/integration_ids.py +++ b/integrations/integration_ids.py @@ -245,6 +245,7 @@ class IntegrationID(Enum): VELODROME_MODE_SUSDE = ("velodrome_mode_susde", "Velodrome Mode sUSDe", Token.SUSDE) # Ambient AMBIENT_SCROLL_LP = ("ambient_usde_scroll_lp_bal", "Ambient Scroll LP", Token.USDE) + AMBIENT_SWELL_LP = ("ambient_usde_swell_lp_bal", "Ambient Swell LP", Token.USDE) # Balancer BALANCER_ARBITRUM_GHO_USDE = (