-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from ethena-labs/f/e-2069-clean-up-points-adap…
…ters-repo F/e 2069 clean up points adapters repo
- Loading branch information
Showing
111 changed files
with
2,687 additions
and
1,328 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# This workflow will install Python dependencies, run tests and lint with a single version of Python | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | ||
|
||
name: Python application | ||
|
||
on: | ||
push: | ||
branches: ["main"] | ||
pull_request: | ||
branches: ["main"] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python 3.10 | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: "3.10" | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install flake8 mypy | ||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | ||
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi | ||
- name: Lint with flake8 | ||
run: | | ||
# stop the build if there are Python syntax errors or undefined names | ||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | ||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | ||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | ||
- name: Type check with mypy | ||
run: mypy . --explicit-package-bases --pretty --check-untyped-defs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,30 @@ | ||
# Overview | ||
|
||
This repo offers a self service approach to Ethena Sats Campaign integrations. | ||
This repo offers a self service approach to Ethena Points Campaign integrations. | ||
|
||
# Instructions | ||
|
||
For your protocol to be included and your users to receive sats, you should submit a PR to this repo. Here some guidelines to follow: | ||
For your protocol to be included and your users to receive points, you should submit a PR to this repo. Here some guidelines to follow: | ||
|
||
1. Make a copy of `.env.example` and name it `.env`. | ||
2. Run `pip install -r requirements.txt` to install the required packages. | ||
3. Add your integration metadata to `constants/integration_ids.py`. | ||
4. Make a copy of `integrations/template.py`, naming the file `[protocol name].py` and place in the `integrations` directory. | ||
5. Your integration must be a class that inherits from `Integration` and implements the `get_balance` and `get_participants` methods. | ||
6. The `get_balance` method should return the balance of a given user at a given block. | ||
7. The `get_participants` method should return a list of all users that have interacted with the protocol. | ||
3. Add your integration metadata to `integrations/integration_ids.py`. | ||
4. Create a new summary column in `constants/summary_columns.py`. | ||
5. Make a copy of [Template](integrations/template.py), naming the file `[protocol name]_integration.py` and place in the `integrations` directory. | ||
6. Your integration must be a class that inherits from `CachedBalancesIntegration` and implements the `get_block_balances` method. | ||
7. The `get_block_balances` method should return a dict of block numbers to a dict of user addresses to balances at that block. (Note: Not all blocks are queried by this service in production- only a sampling, but your code should be capable of handling any block number.) | ||
8. Write some basic tests at the bottom of the file to ensure your integration is working correctly. | ||
9. Submit a PR to this repo with your integration and ping the Ethena team in Telegram. | ||
|
||
# Guidelines | ||
|
||
- Integrations must follow this architecture and be written in python. | ||
- Pendle integrations are included as examples of functioning integrations. Run `python -m integrations.pendle_lpt_integration` to see the output. | ||
- The `get_balance` and `get_participants` methods should be as efficient as possible. | ||
- We prefer that on chain RPC calls are used to get information as much as possible due to reliability and trustlessness. For example one could cycle through events for `get_participants` and read from a smart contract for `get_balance`. Off chain calls to apis or subgraphs are acceptable if necessary. If usage is not reasonable or the external service is not reliable, users may not receive their sats. | ||
- The `get_block_balances` method should be as efficient as possible. So the use of the cached data from previous blocks if possible is highly encouraged. | ||
- We prefer that on chain RPC calls are used to get information as much as possible due to reliability and trustlessness. Off chain calls to apis or subgraphs are acceptable if necessary. If usage is not reasonable or the external service is not reliable, users may not receive their points. | ||
|
||
# Example Integrations | ||
- [ClaimedEnaIntegration](integrations/claimed_ena_example_integration.py): This integration demonstrates how to track ENA token claims using cached balance snapshots for improved performance. It reads from previous balance snapshots to efficiently track user claim history. | ||
- [BeefyCachedBalanceExampleIntegration](integrations/beefy_cached_balance_example_integration.py): This integration is an example of a cached balance integration that is based on API calls. | ||
- [PendleLPTIntegration](integrations/pendle_lpt_integration.py): (Legacy Example) A basic integration showing Pendle LPT staking tracking. Note: This is a non-cached implementation included only for reference - new integrations should use the cached approach for better efficiency. | ||
- [PendleYTIntegration](integrations/pendle_yt_integration.py): (Legacy Example) A basic integration showing Pendle YT staking tracking. Note: This is a non-cached implementation included only for reference - new integrations should use the cached approach for better efficiency. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
from typing import List | ||
from constants.example_integrations import ( | ||
ACTIVE_ENA_START_BLOCK_EXAMPLE, | ||
BEEFY_ARBITRUM_START_BLOCK_EXAMPLE, | ||
) | ||
from integrations.beefy_cached_balance_example_integration import ( | ||
BeefyCachedBalanceIntegration, | ||
) | ||
from integrations.claimed_ena_example_integration import ClaimedEnaIntegration | ||
from utils import pendle | ||
from web3 import Web3 | ||
|
||
from constants.chains import Chain | ||
from constants.pendle import PENDLE_USDE_JULY_DEPLOYMENT_BLOCK | ||
from constants.summary_columns import SummaryColumn | ||
from integrations.integration import Integration | ||
from integrations.integration_ids import IntegrationID | ||
from integrations.pendle_lpt_integration import PendleLPTIntegration | ||
from integrations.pendle_yt_integration import PendleYTIntegration | ||
from integrations.template import ProtocolNameIntegration | ||
|
||
# TODO: Add your integration here | ||
INTEGRATIONS: List[Integration] = [ | ||
# Template integration | ||
ProtocolNameIntegration( | ||
integration_id=IntegrationID.EXAMPLE, | ||
start_block=20000000, | ||
summary_cols=[SummaryColumn.TEMPLATE_PTS], | ||
chain=Chain.ETHEREUM, | ||
reward_multiplier=20, | ||
excluded_addresses={ | ||
Web3.to_checksum_address("0x0000000000000000000000000000000000000000") | ||
}, | ||
end_block=40000000, | ||
), | ||
# Example integration using cached user balances for improved performance, | ||
# reads from previous balance snapshots | ||
ClaimedEnaIntegration( | ||
integration_id=IntegrationID.CLAIMED_ENA_EXAMPLE, | ||
start_block=ACTIVE_ENA_START_BLOCK_EXAMPLE, | ||
summary_cols=[SummaryColumn.CLAIMED_ENA_PTS_EXAMPLE], | ||
reward_multiplier=1, | ||
), | ||
# Cached balances integration example, based on API calls | ||
BeefyCachedBalanceIntegration( | ||
integration_id=IntegrationID.BEEFY_CACHED_BALANCE_EXAMPLE, | ||
start_block=BEEFY_ARBITRUM_START_BLOCK_EXAMPLE, | ||
summary_cols=[SummaryColumn.BEEFY_CACHED_BALANCE_EXAMPLE], | ||
chain=Chain.ARBITRUM, | ||
reward_multiplier=1, | ||
), | ||
# Simple Integration class examples (outdated), | ||
# don't use these anymore | ||
PendleLPTIntegration( | ||
integration_id=IntegrationID.PENDLE_USDE_LPT, | ||
start_block=PENDLE_USDE_JULY_DEPLOYMENT_BLOCK, | ||
sy_contract=pendle.sy_contract, | ||
lp_contract=pendle.lpt_contract, | ||
summary_cols=[SummaryColumn.PENDLE_SHARDS], | ||
chain=Chain.ETHEREUM, | ||
reward_multiplier=20, | ||
), | ||
PendleLPTIntegration( | ||
integration_id=IntegrationID.PENDLE_ARBITRUM_USDE_LPT, | ||
start_block=PENDLE_USDE_JULY_DEPLOYMENT_BLOCK, | ||
sy_contract=pendle.usde_arb_SY_contract, | ||
lp_contract=pendle.usde_arb_LPT_contract, | ||
summary_cols=[SummaryColumn.PENDLE_ARBITRUM_SHARDS], | ||
chain=Chain.ARBITRUM, | ||
reward_multiplier=20, | ||
), | ||
PendleYTIntegration( | ||
integration_id=IntegrationID.PENDLE_USDE_YT, | ||
start_block=PENDLE_USDE_JULY_DEPLOYMENT_BLOCK, | ||
summary_cols=[SummaryColumn.PENDLE_SHARDS], | ||
yt_contract=pendle.yt_contract, | ||
chain=Chain.ETHEREUM, | ||
reward_multiplier=20, | ||
), | ||
PendleYTIntegration( | ||
integration_id=IntegrationID.PENDLE_ARBITRUM_USDE_YT, | ||
start_block=PENDLE_USDE_JULY_DEPLOYMENT_BLOCK, | ||
summary_cols=[SummaryColumn.PENDLE_ARBITRUM_SHARDS], | ||
yt_contract=pendle.usde_arb_YT_contract, | ||
chain=Chain.ARBITRUM, | ||
reward_multiplier=20, | ||
), | ||
] | ||
|
||
|
||
def get_integrations() -> List[Integration]: | ||
return INTEGRATIONS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.