-
Notifications
You must be signed in to change notification settings - Fork 1k
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 #1969 from hetao8/master
add jeton
- Loading branch information
Showing
2 changed files
with
151 additions
and
0 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,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; |
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,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; |