Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added gm-token EA #3123

Merged
merged 6 commits into from
Jan 2, 2024
Merged

Added gm-token EA #3123

merged 6 commits into from
Jan 2, 2024

Conversation

karen-stepanyan
Copy link
Contributor

@karen-stepanyan karen-stepanyan commented Dec 15, 2023

Closes DF-19319

Description

Added new gm-token composite EA to get a price of GM tokens. GM tokens (GM market pools) represent a market pool of a particular market for a specified asset pair.

A GM pool (GMX Market pool) consists of:

  • Index Price Feed: Long and short tokens will be opened / closed based on this price feed
  • Long Token: This is the token that will back long positions
  • Short Token: This is the token that will back short positions

For example, a market could be ETH/USD[WETH-USDC], in this case:

  • Index Price Feed: ETH/USD
  • Long Token: WETH tokens back long positions
  • Short Token: USDC tokens back short positions

The EA is made generic so that it can fetch the price of every possible GMToken.
In summary this is how gm-token EA works

  1. Based on input request fetches bid/ask data for every asset from 3 source providers
  2. Based on received data calculates the median bid/ask per asset
  3. Fixes the prices to get rid of decimal points
  4. Uses calculated median prices alongside with other config data to get the price of gmToken from GMX Reader contract

To test the EA, first run 3 source EAs that the gm-token is using for price data. Provide relevant env variables
TIINGO_ADAPTER_URL,
NCFX_ADAPTER_URL
COINMETRICS_ADAPTER_URL
Provide ARBITRUM_RPC_URL.

Run the gm-token EA. To get the gmToken price use one of following request data. The list of gmTokens and their prices can be found here.

  1. gmETH
{
  "data": {
    "index":"ETH",
    "long": "WETH",
    "short": "USDC",
    "market": "0x70d95587d40A2caf56bd97485aB3Eec10Bee6336"
  }
}
  1. gmBTC
{
  "data": {
    "index":"BTC",
    "long": "WBTC.b",
    "short": "USDC",
    "market": "0x47c031236e19d024b42f8AE6780E44A573170703"
  }
}
  1. gmARB
{
  "data": {
    "index":"ARB",
    "long": "ARB",
    "short": "USDC",
    "market": "0xC25cEf6061Cf5dE5eb761b50E4743c1F5D7E5407"
  }
}
  1. gmSOL
{
  "data": {
    "index":"SOL",
    "long": "SOL",
    "short": "USDC",
    "market": "0x09400D9DB990D5ed3f35D7be61DfAEB900Af03C9"
  }
}
  1. gmLINK
{
  "data": {
    "index":"LINK",
    "long": "LINK",
    "short": "USDC",
    "market": "0x7f1fa204bb700853D36994DA19F830b6Ad18455C"
  }
}
  1. gmXRP
{
  "data": {
    "index":"XRP",
    "long": "WETH",
    "short": "USDC",
    "market": "0x0CCB4fAa6f1F1B30911619f1184082aB4E25813c"
  }
}
  1. gmDOGE
{
  "data": {
    "index":"DOGE",
    "long": "WETH",
    "short": "USDC",
    "market": "0x6853EA96FF216fAb11D2d930CE3C508556A4bdc4"
  }
}
  1. gmUNI
{
  "data": {
    "index":"UNI",
    "long": "UNI",
    "short": "USDC",
    "market": "0xc7Abb2C5f3BF3CEB389dF0Eecd6120D451170B50"
  }
}
  1. gmLTC
{
  "data": {
    "index":"LTC",
    "long": "WETH",
    "short": "USDC",
    "market": "0xD9535bB5f58A1a75032416F2dFe7880C30575a41"
  }
}

Quality Assurance

  • If a new adapter was made, or an existing one was modified so that its environment variables have changed, update the relevant infra-k8s configuration file.
  • If a new adapter was made, or an existing one was modified so that its environment variables have changed, update the relevant adapter-secrets configuration file or update the soak testing blacklist.
  • If a new adapter was made, or a new endpoint was added, update the test-payload.json file with relevant requests.
  • The branch naming follows git flow (feature/x, chore/x, release/x, hotfix/x, fix/x) or is created from Jira.
  • This is related to a maximum of one Jira story or GitHub issue.
  • Types are safe (avoid TypeScript/TSLint features like any and disable, instead use more specific types).
  • All code changes have 100% unit and integration test coverage. If testing is not applicable or too difficult to justify doing, the reasoning should be documented explicitly in the PR.

Copy link

changeset-bot bot commented Dec 15, 2023

🦋 Changeset detected

Latest commit: f00fb44

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@chainlink/gm-token-adapter Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

alecgard
alecgard previously approved these changes Dec 19, 2023
Copy link
Contributor

@alecgard alecgard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thanks!

Left a couple of minor comments, but all are non-blocking

@alecgard alecgard requested a review from a team December 19, 2023 10:27
Copy link
Contributor

@alecgard alecgard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - thanks for adding the sources in the response!

Left a minor change to an error message - other than that looks good to go!

alecgard
alecgard previously approved these changes Dec 20, 2023
@karen-stepanyan karen-stepanyan merged commit 1379810 into main Jan 2, 2024
@karen-stepanyan karen-stepanyan deleted the feature/DF-19319 branch January 2, 2024 15:17
@github-actions github-actions bot mentioned this pull request Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants