Adapter

Osmosis Fees & Issuance

Fee data is pulled from the Osmosis indexer server, while issuance is calculated using the hardcoded issuance rate

Sub-Adapters 1

Preview and test each sub adapter.

Osmosis (osmosis)

Metadata

ID
osmosis
name

"Osmosis"

category

"dex"

icon
description

"Osmosis is an advanced AMM protocol built using the Cosmos SDK"

feeDescription

"Trading fees are paid to liquidity providers"

source

"Osmosis API"

tokenTicker

"OSMO"

tokenCoingecko

"osmosis"

website

"https://osmosis.zone"

protocolLaunch

"2021-06-24"

Queries

Adapter Code

Check the entire code written for the Adapter.

Source code

Showing TS source.
1export const name = 'Osmosis Fees & Issuance';
2export const version = '0.3.0';
3export const license = 'MIT';
4export const description = 'Fee data is pulled from the Osmosis indexer server, while issuance is calculated using the hardcoded issuance rate';
5
6const GENESIS_SUPPLY = 100_000_000;
7const GENESIS_TIME = '2021-06-18 18:00:00';
8const ISSUED_IN_FIRST_YEAR = 300_000_000;
9const ISSUED_IN_SECOND_YEAR = 200_000_000;
10const MS_IN_YEAR = 365 * 24 * 60 * 60 * 1000;
11
12export function setup(sdk: Context) {
13  // Cache the API result, so we only need to request it once
14  let feeDataPromise: Promise<any> | null = null;
15  const getFeeData = () => {
16    if (!feeDataPromise) {
17      feeDataPromise = sdk.http.get('https://api-osmosis.imperator.co/fees/v1/total/historical');
18    }
19    return feeDataPromise;
20  }
21
22  const getOsmosisFee = async (date: string): Promise<number> => {
23    const data = await getFeeData();
24
25    for (const day of data) {
26      if (day.time === date) {
27        return day.fees_spent;
28      }
29    }
30    return 0;
31  }
32
33  // In the first year, there will be a total of 300 million tokens released.
34  // After 365 days, this will be cut by ⅓, and thus there will be a total of
35  // 200 million tokens released in Year 2. In Year 3, there will be a total
36  // of 133 million tokens released. And so on.
37  // https://medium.com/osmosis/osmo-token-distribution-ae27ea2bb4db
38  const getIssuance = async () => {
39    const price = await sdk.coinGecko.getCurrentPrice('osmosis');
40    return ISSUED_IN_SECOND_YEAR / 365 * price;
41  }
42
43  const getIssuanceRate = async () => {
44    const msSinceGenesis = (new Date()).getTime() - (new Date(GENESIS_TIME)).getTime();
45    const yearsSinceGenesis = msSinceGenesis / MS_IN_YEAR;
46    const yearsSinceStartOfSecondYear = yearsSinceGenesis - 1;
47    const supply = ISSUED_IN_FIRST_YEAR + (yearsSinceStartOfSecondYear * ISSUED_IN_SECOND_YEAR) + GENESIS_SUPPLY;
48    const issuanceRate = ISSUED_IN_SECOND_YEAR / supply;
49    return issuanceRate;
50  }
51
52  sdk.register({
53    id: 'osmosis',
54    queries: {
55      oneDayTotalFees: getOsmosisFee,
56      oneDayIssuanceUSD: getIssuance,
57      issuance7DayAvgUSD: getIssuance,
58      issuanceRateCurrent: getIssuanceRate,
59    },
60    metadata: {
61      name: 'Osmosis',
62      category: 'dex',
63      icon: sdk.ipfs.getDataURILoader('QmaPe4CFwjoN3orMzYUhrXYfYdsbpJn497i2bHJJjzEgPL', 'image/svg+xml'),
64      description: 'Osmosis is an advanced AMM protocol built using the Cosmos SDK',
65      feeDescription: 'Trading fees are paid to liquidity providers',
66      source: 'Osmosis API',
67      tokenTicker: 'OSMO',
68      tokenCoingecko: 'osmosis',
69      website: 'https://osmosis.zone',
70      protocolLaunch: '2021-06-24',
71    },
72  })
73}
74

It's something off?

Report it to the discussion board on Discord, we will take care of it.

Adapter Info

Version

0.3.0

License

MIT

IPFS CID

QmVXkbfp4iMyZ7iGFejRvg7Ys2vZgtZ1XENXouHZdTQpyG

CID (source)

QmSdTUS1fSMeoAyobxGqFbaZAnaGTsfANLBvcEQj7L5aRC

Collections

Author

mihal.eth