Adapter

Terraswap Fees

Terraswap is a decentralized exchange on the Terra blockchain

Sub-Adapters 1

Preview and test each sub adapter.

Terraswap (terraswap)

Metadata

ID
terraswap
name

"Terraswap"

category

"dex"

icon
blockchain

"Terra"

description

"Terraswap is a decentralized exchange on the Terra blockchain"

feeDescription

"Trading fees are paid by traders to liquidity providers"

source

"ALPAC4"

website

"https://terraswap.io"

protocolLaunch

"2020-11-13"

protocolShutdown

"2022-04-13"

Queries

Adapter Code

Check the entire code written for the Adapter.

Source code

Showing TS source.
1export const name = 'Terraswap Fees';
2export const version = '0.1.1';
3export const license = 'MIT';
4
5const UST_DECIMALS = 1e6;
6const TERRASWAP_FEE = 0.003;
7
8export function setup(sdk: Context) {
9  const getTerraswapFee = async (date: string): Promise<number> => {
10    const startOfDay = sdk.date.dateToTimestamp(date);
11    const endOfDay = startOfDay + 84600;
12
13    const query = `{
14      terraswap {
15        historicalData(from: ${startOfDay}, to: ${endOfDay}) {
16          volumeUST
17        }
18      }
19    }`;
20    const data = await sdk.http.get(`https://terraswap-graph.terra.dev/graphql?query=${encodeURIComponent(query)}`);
21
22    const volume = data.data.terraswap.historicalData[0].volumeUST;
23    return volume * TERRASWAP_FEE / UST_DECIMALS;
24  }
25
26  sdk.register({
27    id: 'terraswap',
28    queries: {
29      oneDayTotalFees: getTerraswapFee,
30    },
31    metadata: {
32      name: 'Terraswap',
33      category: 'dex',
34      icon: sdk.ipfs.getDataURILoader('Qmdqw9Pb3FEzcmPUF2xYkQPjBkcYdZvGi6K1kYFKeUwu1q', 'image/svg+xml'),
35      blockchain: 'Terra',
36      description: 'Terraswap is a decentralized exchange on the Terra blockchain',
37      feeDescription: 'Trading fees are paid by traders to liquidity providers',
38      source: 'ALPAC4',
39      website: 'https://terraswap.io',
40      protocolLaunch: '2020-11-13',
41      protocolShutdown: '2022-04-13',
42    },
43  })
44}
45

It's something off?

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

Adapter Info

Version

0.1.1

License

MIT

IPFS CID

QmVBrf7XdXKj4e9SBCuEgqwzdRzwoUuTuqG8E4ych34VfW

CID (source)

QmUGZVkEesNT3s6kQu1TQMeh4NYuKDr9bbvQwfRuYm7wrD

Collections

Author

mihal.eth