-
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 #899 from tacanslabs/master
Add dx25 adapter
- Loading branch information
Showing
1 changed file
with
49 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,49 @@ | ||
import axios from 'axios' | ||
import type { SimpleAdapter } from '../../adapters/types' | ||
import { CHAIN } from "../../helpers/chains"; | ||
|
||
const POOLS_SERVICE_URL = 'https://liquidity-pool.dx25.com/v1/rpc' | ||
|
||
const rpc = (url: string, method: string, params: any) => | ||
axios.post( | ||
url, | ||
{ | ||
jsonrpc: '2.0', | ||
method, | ||
params, | ||
id: '0', | ||
}, | ||
{ | ||
headers: { | ||
'Content-Type': 'application/json', | ||
} | ||
} | ||
) | ||
.then(res => { | ||
if (res.data.error) { | ||
throw new Error(res.data.error.message) | ||
} | ||
return res.data.result | ||
}); | ||
|
||
|
||
|
||
const adapter: SimpleAdapter = { | ||
adapter: { | ||
[CHAIN.ELROND]: { | ||
start: async () => 1697544000, | ||
fetch: async (ts) => { | ||
const data = await rpc(POOLS_SERVICE_URL, 'volumes_statistic', { | ||
timestamp: ts, | ||
}) | ||
return { | ||
timestamp: ts, | ||
dailyVolume: data.daily_volume, | ||
totalVolume: data.total_volume, | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
|
||
export default adapter; |