-
Notifications
You must be signed in to change notification settings - Fork 1.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 #2323 from lnfi-network/master
add lnexchange
- Loading branch information
Showing
3 changed files
with
106 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,36 @@ | ||
import type { SimpleAdapter } from "../../adapters/types"; | ||
import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphVolume"; | ||
import { httpPost } from "../../utils/fetchURL"; | ||
import BigNumber from "bignumber.js"; | ||
import { CHAIN } from "../../helpers/chains"; | ||
|
||
const URL = | ||
"https://test-futures-api.ln.exchange/napi/common/getDayTradeAmount"; | ||
|
||
interface Response { | ||
dayNtlVlm: number; | ||
} | ||
const fetch = async (timestamp: number) => { | ||
const respose: Response[] = ( | ||
await httpPost(URL, { dayTimestamp: timestamp * 1000 }) | ||
).data; | ||
const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)); | ||
const dailyVolume = respose.reduce((acc, item) => { | ||
return acc.plus(item.dayNtlVlm); | ||
}, new BigNumber(0)); | ||
return { | ||
dailyVolume: dailyVolume?.toString(), | ||
timestamp: dayTimestamp, | ||
}; | ||
}; | ||
|
||
const adapter: SimpleAdapter = { | ||
adapter: { | ||
[CHAIN.BITCOIN]: { | ||
fetch, | ||
start: "2024-10-20", | ||
}, | ||
}, | ||
}; | ||
|
||
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,36 @@ | ||
import type { SimpleAdapter } from "../../adapters/types"; | ||
import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphVolume"; | ||
import { httpPost } from "../../utils/fetchURL"; | ||
import BigNumber from "bignumber.js"; | ||
import { CHAIN } from "../../helpers/chains"; | ||
|
||
const URL = | ||
"https://test-spots-api.ln.exchange/napi/common/getDayTradeAmount"; | ||
|
||
interface Response { | ||
dayNtlVlm: number; | ||
} | ||
const fetch = async (timestamp: number) => { | ||
const respose: Response[] = ( | ||
await httpPost(URL, { dayTimestamp: timestamp * 1000 }) | ||
).data; | ||
const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)); | ||
const dailyVolume = respose.reduce((acc, item) => { | ||
return acc.plus(item.dayNtlVlm); | ||
}, new BigNumber(0)); | ||
return { | ||
dailyVolume: dailyVolume?.toString(), | ||
timestamp: dayTimestamp, | ||
}; | ||
}; | ||
|
||
const adapter: SimpleAdapter = { | ||
adapter: { | ||
[CHAIN.BITCOIN]: { | ||
fetch, | ||
start: "2024-08-30", | ||
}, | ||
}, | ||
}; | ||
|
||
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,34 @@ | ||
import { CHAIN } from "../helpers/chains"; | ||
import { Adapter, FetchOptions } from "../adapters/types"; | ||
import { httpPost } from "../utils/fetchURL"; | ||
|
||
const fetchFees = async (options: FetchOptions) => { | ||
const respose = await httpPost( | ||
`https://test-futures-api.ln.exchange/napi/common/getTradeFee`, | ||
{ | ||
startTimestamp: options.startTimestamp * 1000, | ||
endTimestamp: options.endTimestamp * 1000, | ||
} | ||
); | ||
|
||
const dailyFees = respose.data.dailyFees; | ||
const totalFees = respose.data.totalFees; | ||
|
||
return { | ||
dailyFees, | ||
dailyRevenue: dailyFees, | ||
totalFees, | ||
totalRevenue: totalFees, | ||
}; | ||
}; | ||
|
||
const adapter: Adapter = { | ||
version: 2, | ||
adapter: { | ||
[CHAIN.BITCOIN]: { | ||
fetch: fetchFees, | ||
start: "2024-10-20", | ||
}, | ||
}, | ||
}; | ||
export default adapter; |