Skip to content

Commit

Permalink
Merge pull request #1969 from hetao8/master
Browse files Browse the repository at this point in the history
add jeton
  • Loading branch information
dtmkeng authored Oct 8, 2024
2 parents 4ab20d8 + 6a48e04 commit b198cf5
Show file tree
Hide file tree
Showing 2 changed files with 151 additions and 0 deletions.
74 changes: 74 additions & 0 deletions aggregators/jeton/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { Adapter, FetchResultVolume } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";
import { httpGet } from "../../utils/fetchURL";

const url = "https://api.echooo.xyz/tenant/defillama/data/v2";

const chains = [
CHAIN.ETHEREUM,
CHAIN.POLYGON,
CHAIN.OPTIMISM,
CHAIN.BSC,
CHAIN.ARBITRUM,
CHAIN.AVAX,
CHAIN.SCROLL,
CHAIN.ERA,
CHAIN.BASE,
];
type Responce = {
timestamp: number;
protocol: {
daily: {
revenue: string;
volume: string;
};
total: {
revenue: string;
volume: string;
};
};
chains: {
[chain: string]: {
daily: {
revenue: string;
volume: string;
};
total: {
revenue: string;
volume: string;
};
};
};
};

const fetch =
(chain: string) =>
async (timestamp: number): Promise<FetchResultVolume> => {
const resp: Responce = await httpGet(`${url}?timestamp=${timestamp}`);
const data = resp.chains[chain];
if (!data || !data.daily || !data.total) {
return {} as FetchResultVolume;
}
return {
dailyVolume: data.daily.volume,
totalVolume: data.total.volume,
timestamp
};
};

const adapter: Adapter = {
adapter: {
...Object.entries(chains).reduce((acc, chain) => {
const key = chain[1];
return {
...acc,
[key]: {
fetch: fetch(key),
start: 1693785600,
},
};
}, {}),
},
};

export default adapter;
77 changes: 77 additions & 0 deletions fees/jeton/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { Adapter, FetchResultFees } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";
import { httpGet } from "../../utils/fetchURL";

const url = "https://api.echooo.xyz/tenant/defillama/data/v2";

const chains = [
CHAIN.ETHEREUM,
CHAIN.POLYGON,
CHAIN.OPTIMISM,
CHAIN.BSC,
CHAIN.ARBITRUM,
CHAIN.AVAX,
CHAIN.SCROLL,
CHAIN.ERA,
CHAIN.BASE,
];

type Responce = {
timestamp: number;
protocol: {
daily: {
revenue: string;
volume: string;
};
total: {
revenue: string;
volume: string;
};
};
chains: {
[chain: string]: {
daily: {
revenue: string;
volume: string;
};
total: {
revenue: string;
volume: string;
};
};
};
};

const fetch =
(chain: string) =>
async (timestamp: number): Promise<FetchResultFees> => {
const resp: Responce = await httpGet(`${url}?timestamp=${timestamp}`);
const data = resp.chains[chain];
if (!data || !data.daily || !data.total) {
return {} as FetchResultFees;
}
return {
dailyFees: data.daily.revenue,
dailyRevenue: data.daily.revenue,
totalFees: data.total.revenue,
totalRevenue: data.total.revenue,
timestamp
};
};

const adapter: Adapter = {
adapter: {
...Object.entries(chains).reduce((acc, chain) => {
const key = chain[1];
return {
...acc,
[key]: {
fetch: fetch(key),
start: 1693785600,
},
};
}, {}),
},
};

export default adapter;

0 comments on commit b198cf5

Please sign in to comment.