-
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 #1867 from DefiLlama/sunswap
add sunswap fees
- Loading branch information
Showing
3 changed files
with
100 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,34 @@ | ||
import { time } from "console"; | ||
import { Adapter, FetchOptions, } from "../adapters/types"; | ||
import { CHAIN } from "../helpers/chains"; | ||
import { httpGet } from "../utils/fetchURL"; | ||
|
||
const api = "https://openapi.sun.io/open/api/feeData" | ||
interface IResponse { | ||
date: number; | ||
fee: number; | ||
} | ||
|
||
const adapter: Adapter = { | ||
version: 1, | ||
adapter: { | ||
[CHAIN.TRON]: { | ||
fetch: (async (_t: any, _a: any ,options: FetchOptions) => { | ||
const start = options.startOfDay * 1000; | ||
const end = start + 86400; | ||
const startStr = new Date(start).toISOString().split("T")[0]; | ||
const endStr = new Date(end).toISOString().split("T")[0]; | ||
const url = `${api}?fromDate=${startStr}&toDate=${endStr}&version=v1`; | ||
const res: IResponse[] = (await httpGet(url)).data; | ||
const dailyFees = options.createBalances(); | ||
const dayItem = res.find((item) => item.date === start); | ||
dailyFees.addGasToken((dayItem?.fee || 0) * 1e6); | ||
return { dailyFees, timestamp: options.startOfDay }; | ||
}) as any, | ||
start: 1704560436 | ||
}, | ||
}, | ||
|
||
} | ||
|
||
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,33 @@ | ||
import { time } from "console"; | ||
import { Adapter, FetchOptions, } from "../adapters/types"; | ||
import { CHAIN } from "../helpers/chains"; | ||
import { httpGet } from "../utils/fetchURL"; | ||
|
||
const api = "https://openapi.sun.io/open/api/feeData" | ||
interface IResponse { | ||
date: number; | ||
fee: number; | ||
} | ||
|
||
const adapter: Adapter = { | ||
version: 1, | ||
adapter: { | ||
[CHAIN.TRON]: { | ||
fetch: (async (_t: any, _a: any ,options: FetchOptions) => { | ||
const start = options.startOfDay * 1000; | ||
const end = start + 86400; | ||
const startStr = new Date(start).toISOString().split("T")[0]; | ||
const endStr = new Date(end).toISOString().split("T")[0]; | ||
const url = `${api}?fromDate=${startStr}&toDate=${endStr}&version=v2`; | ||
const res: IResponse[] = (await httpGet(url)).data; | ||
const dayItem = res.find((item) => item.date === start); | ||
const dailyFees = dayItem?.fee || 0; | ||
return { dailyFees, timestamp: options.startOfDay }; | ||
}) as any, | ||
start: 1704560436 | ||
}, | ||
}, | ||
|
||
} | ||
|
||
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,33 @@ | ||
import { time } from "console"; | ||
import { Adapter, FetchOptions, } from "../adapters/types"; | ||
import { CHAIN } from "../helpers/chains"; | ||
import { httpGet } from "../utils/fetchURL"; | ||
|
||
const api = "https://openapi.sun.io/open/api/feeData" | ||
interface IResponse { | ||
date: number; | ||
fee: number; | ||
} | ||
|
||
const adapter: Adapter = { | ||
version: 1, | ||
adapter: { | ||
[CHAIN.TRON]: { | ||
fetch: (async (_t: any, _a: any ,options: FetchOptions) => { | ||
const start = options.startOfDay * 1000; | ||
const end = start + 86400; | ||
const startStr = new Date(start).toISOString().split("T")[0]; | ||
const endStr = new Date(end).toISOString().split("T")[0]; | ||
const url = `${api}?fromDate=${startStr}&toDate=${endStr}&version=v3`; | ||
const res: IResponse[] = (await httpGet(url)).data; | ||
const dayItem = res.find((item) => item.date === start); | ||
const dailyFees = dayItem?.fee || 0; | ||
return { dailyFees, timestamp: options.startOfDay }; | ||
}) as any, | ||
start: 1704560436 | ||
}, | ||
}, | ||
|
||
} | ||
|
||
export default adapter; |