Skip to content

Commit

Permalink
Merge pull request #899 from tacanslabs/master
Browse files Browse the repository at this point in the history
Add dx25 adapter
  • Loading branch information
dtmkeng authored Oct 18, 2023
2 parents 35ca282 + b28fcc6 commit 83adb92
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions dexs/dx25/index.ts
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;

0 comments on commit 83adb92

Please sign in to comment.