Skip to content

Commit

Permalink
Merge branch 'DefiLlama:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
libaice authored Dec 24, 2024
2 parents e492e64 + 2677144 commit 42e2433
Show file tree
Hide file tree
Showing 65 changed files with 2,400 additions and 605 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/commentResult.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { readFileSync } = require('fs');
const axios = require('axios');
const junk = 'VPTOH1X0B7rf8od7BGNsQ1z0BJk8iMNLxqrD';
const junk = 'rmicl\x1Eefn]JsfjoHoGRpWOt3_u@L_LpTUc_BLf0T/i/mXC';

async function main() {
const [, , log, author, repo, pr, adapterNameKey ] = process.argv;
Expand Down Expand Up @@ -34,12 +34,14 @@ async function main() {
`https://api.github.com/repos/${author}/${repo}/issues/${pr}/comments`,
{ body }, {
headers: {
Authorization: `token ghp_${translate(junk)}`,
Authorization: scramble(junk),
Accept: 'application/vnd.github.v3+json'
}
});
};
function translate(input) {
return input ? translate(input.substring(1)) + input[0] : input;
};
function scramble(str) {
return str.split('').reduce((a, b) => {
return a + String.fromCharCode(b.charCodeAt(0) + 2);
}, '');
}
main();
2 changes: 1 addition & 1 deletion .github/workflows/getFileList.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const ALLOWED_ROOTS = ['volumes', 'dexs', 'options', 'derivatives', 'incentives', 'fees', 'options', 'protocols', 'aggregators','aggregator-derivatives']
const ALLOWED_ROOTS = ['volumes', 'dexs', 'options', 'derivatives', 'incentives', 'fees', 'options', 'protocols', 'aggregators','aggregator-derivatives','bridge-aggregators']
const MODIFIED = parse(process.env.MODIFIED)
const ADDED = parse(process.env.ADDED)
const fileSet = new Set();
Expand Down
3 changes: 2 additions & 1 deletion aggregators/bitgetwallet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ const CHAINS: Array<CHAIN> = [
CHAIN.BASE,
CHAIN.TON,
CHAIN.TRON,
CHAIN.BITCOIN
CHAIN.BITCOIN,
CHAIN.SUI
];


Expand Down
3 changes: 2 additions & 1 deletion aggregators/cowswap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const abis = {
"Trade": "event Trade(address indexed owner, address sellToken, address buyToken, uint256 sellAmount, uint256 buyAmount, uint256 feeAmount, bytes orderUid)", // gnosis
}

const fetch = async (timestamp: number, _: ChainBlocks, { createBalances, getLogs, chain, api }: FetchOptions) => {
const fetch = async (timestamp: number, _: ChainBlocks, { createBalances, getLogs, }: FetchOptions) => {
const dailyVolume = createBalances()

const logs = await getLogs({ target: '0x9008d19f58aabd9ed0d60971565aa8510560ab41', eventAbi: abis.Trade, })
Expand All @@ -19,6 +19,7 @@ const adapter: any = {
ethereum: { fetch, start: '2023-05-31', },
xdai: { fetch, start: '2023-05-31', },
arbitrum: { fetch, start: '2024-04-26', },
base: { fetch, start: '2024-12-10', },
},
};

Expand Down
16 changes: 10 additions & 6 deletions aggregators/eisen/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,31 @@ type TPool = {
};

const FEE_COLLECTORS: TPool = {
[CHAIN.MODE]: ["0x37Cb37b752DBDcd08A872e7dfec256A216C7144C"],
[CHAIN.SCROLL]: ["0xA06568773A247657E7b89BBA465014CF85702093"],
[CHAIN.ZIRCUIT]: ["0x6bD912872B9e704a70f10226ab01A2Db87D0dd1C"],
[CHAIN.LINEA]: ["0x206168f099013b9eAb979d3520cA00aAD453De55"],
[CHAIN.MANTLE]: ["0x31d6F212142D3B222EF11c9eBB6AF3569b8442EE"],
[CHAIN.BLAST]: ["0xd57Ed7F46D64Ec7b6f04E4A8409D88C55Ef8AA3b"],
[CHAIN.BASE]: ["0x14C3B68e5855B60263b10eC0fCE54DE3e28AD880"],
[CHAIN.CORE]: ["0x6bD912872B9e704a70f10226ab01A2Db87D0dd1C"],
// [CHAIN.BITLAYER]: ["0x5722c0B501e7B9880F9bB13A14217851e45C454f"],
[CHAIN.LINEA]: ["0x206168f099013b9eAb979d3520cA00aAD453De55"],
[CHAIN.CRONOS]: ["0x0C15c845C4A970b284c0dd61Bcf01c4DC1117d0F"],
[CHAIN.CORE]: ["0x6bD912872B9e704a70f10226ab01A2Db87D0dd1C"],
[CHAIN.TAIKO]: ["0xFA0e9251503DaE51670d10288e6962d63191731d"],
[CHAIN.MODE]: ["0x37Cb37b752DBDcd08A872e7dfec256A216C7144C"],
};

const START_BLOCKS = {
[CHAIN.MODE]: 1704067200,
[CHAIN.SCROLL]: 1704067200,
[CHAIN.ZIRCUIT]: 1704067200,
[CHAIN.LINEA]: 1704067200,
[CHAIN.MANTLE]: 1704067200,
[CHAIN.BLAST]: 1704067200,
[CHAIN.BASE]: 1704067200,
[CHAIN.BITLAYER]: 1704067200,
[CHAIN.LINEA]: 1704067200,
[CHAIN.CRONOS]: 1704067200,
[CHAIN.CORE]: 1704067200,
[CHAIN.CRONOS]: 1704067200,
[CHAIN.TAIKO]: 1704067200,
[CHAIN.MODE]: 1704067200,
};

async function fetch({ getLogs, createBalances, chain }: FetchOptions) {
Expand Down
12 changes: 6 additions & 6 deletions aggregators/swing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { CHAIN } from "../../helpers/chains";
import { FetchOptions, SimpleAdapter } from "../../adapters/types";
import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphVolume";

const baseURL = 'https://swap.prod.swing.xyz'
const chains: Record<string, string> = {
[CHAIN.SOLANA]: 'solana',
[CHAIN.ETHEREUM]: 'ethereum',
Expand Down Expand Up @@ -40,7 +41,6 @@ const chains: Record<string, string> = {
};

const fetch = async (_a: any, _b: any, options: FetchOptions) => {
// get the start of the day timestamp
const unixTimestamp = getUniqStartOfTodayTimestamp(
new Date(options.startOfDay * 1000)
);
Expand All @@ -50,23 +50,23 @@ const fetch = async (_a: any, _b: any, options: FetchOptions) => {
new Date(options.startOfDay * 1000 + 24 * 60 * 60 * 1000)
);

const dailyRes = await httpGet("https://swap.prod.swing.xyz/v0/metrics/stats", {
const dailyRes = await httpGet(`${baseURL}/v0/metrics/stats`, {
headers: {
'Content-Type': 'application/json',
},
params: { startDate: unixTimestamp, endDate: unixEndDayTimestamp },
});

const chainVolumes = dailyRes?.historicalVolumeByChain?.map((history: any) => {
const chainVol = history?.volume.find((vol: any) => {
return vol?.chainSlug.toLowerCase() === chains[options.chain].toLowerCase();
const sameChainVolumes = dailyRes?.historicalVolumeSamechain?.map((history: any) => {
const chainVol = history?.volume?.find((vol: any) => {
return vol?.chainSlug?.toLowerCase() === chains[options.chain].toLowerCase();
})

return chainVol;
});

// calculate the total volume
const chainVol = chainVolumes?.reduce((acc: number, curr: any) => {
const chainVol = sameChainVolumes?.reduce((acc: number, curr: any) => {
return acc + Number(curr?.value || 0);
}, 0);

Expand Down
2 changes: 2 additions & 0 deletions aggregators/wolfswap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const contracts = {
avax: '0x643dEB007DfA43c0D7BeA2155E97E61279d9a56F',
sei: '0x1AD805e80b59C802f9D8059f904DCA6AC153de30',
blast: '0xb86a6e5702C327c5C051Bf5323Cb2bAb5E628d0c',
sonic: '0x222680A4fCcFE131acAf7a26301FC929364a881E',
}

const fetch = async (timestamp: number, _: ChainBlocks, { createBalances, getLogs, chain, api }: FetchOptions) => {
Expand All @@ -32,6 +33,7 @@ const adapter: any = {
avax: { fetch, start: '2024-05-31', },
//sei: { fetch, start: '2024-05-31', },
blast: { fetch, start: '2024-03-07', },
sonic: { fetch, start: '2024-12-16', },
},
};

Expand Down
77 changes: 77 additions & 0 deletions bridge-aggregators/bitgetwallet/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { CHAIN } from "../../helpers/chains";
import { FetchOptions } from "../../adapters/types";
import {getUniqStartOfTodayTimestamp} from "../../helpers/getUniSubgraphVolume";
import { httpGet } from "../../utils/fetchURL";


const CHAINS: Array<CHAIN> = [
CHAIN.ETHEREUM,
CHAIN.POLYGON,
CHAIN.SOLANA,
CHAIN.BSC,
CHAIN.OPTIMISM,
CHAIN.BASE,
CHAIN.TON,
CHAIN.TRON,
CHAIN.BITCOIN,
CHAIN.MANTA,
CHAIN.LINEA,
CHAIN.SUI,
CHAIN.SCROLL,
CHAIN.ARBITRUM,
CHAIN.CORE,
CHAIN.MERLIN,
CHAIN.BLAST,
CHAIN.APTOS
];




interface IVolumeBridge {
volume: string;
date: string;
}

async function queryDataByApi(timestamp:string, path:string){
const historicalVolumeEndpoint = "https://new-swapopen.bitapi.vip/st";
let info = await httpGet(`${historicalVolumeEndpoint}${path}`);
const data : IVolumeBridge[] = (info)?.data.list;
return data
}

const fetch = async (_t: number, _b: any, options: FetchOptions) => {
const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(options.startOfDay * 1000))
const path = `/getOrderDayList?bridge=1&chain=${options.chain}&timestamp=${dayTimestamp}`
const data = await queryDataByApi(dayTimestamp.toString(), path)
const dateString = new Date(dayTimestamp * 1000).toISOString().split("T")[0];
let dailyVolume = data.find(dayItem => dayItem.date === dateString)?.volume
dailyVolume = dailyVolume || undefined;
return {
dailyBridgeVolume: dailyVolume,
timestamp: options.endTimestamp,
};
};

const adapter: any = {
version: 1, // api supports other timestamps but if you try using current timestamps, it breaks, so sticking to v1 even though it should be able to support v2
adapter: {
...CHAINS.map(chain => {
return {

[chain]: {
fetch: fetch,
start: '2024-01-01'
}

}
}).reduce((acc, item) => {
return {
...acc,
...item
}
})
},
};

export default adapter;
9 changes: 5 additions & 4 deletions bridge-aggregators/swing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { httpGet } from "../../utils/fetchURL";
import { FetchOptions, SimpleAdapter } from "../../adapters/types";
import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphFees";

const baseURL = 'https://swap.prod.swing.xyz'
const chains: Record<string, string> = {
[CHAIN.SOLANA]: 'solana',
[CHAIN.ETHEREUM]: 'ethereum',
Expand Down Expand Up @@ -49,16 +50,16 @@ const fetchVolume = async (_t: any, _b: any, options: FetchOptions) => {
new Date(options.startOfDay * 1000 + 24 * 60 * 60 * 1000)
);

const dailyRes = await httpGet("https://swap.prod.swing.xyz/v0/metrics/stats", {
const dailyRes = await httpGet(`${baseURL}/v0/metrics/stats`, {
headers: {
'Content-Type': 'application/json',
},
params: { startDate: unixTimestamp, endDate: unixEndDayTimestamp },
});

const chainVolumes = dailyRes?.historicalVolumeByChain?.map((history: any) => {
const chainVol = history?.volume.find((vol: any) => {
return vol?.chainSlug.toLowerCase() === chains[options.chain].toLowerCase();
const chainVolumes = dailyRes?.historicalVolumeCrossChainChain?.map((history: any) => {
const chainVol = history?.volume?.find((vol: any) => {
return vol?.chainSlug?.toLowerCase() === chains[options.chain].toLowerCase();
})

return chainVol;
Expand Down
65 changes: 65 additions & 0 deletions bridge-aggregators/teleswap/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { FetchOptions, SimpleAdapter } from '../../adapters/types';
import { httpGet } from '../../utils/fetchURL';
import { CHAIN } from '../../helpers/chains';
import { getUniqStartOfTodayTimestamp } from '../../helpers/getUniSubgraphVolume';

const chains: Record<string, string> = {
[CHAIN.BITCOIN]: 'bitcoin',
[CHAIN.ETHEREUM]: 'ethereum',
[CHAIN.SUI]: 'sui',
[CHAIN.TRON]: 'tron',
[CHAIN.BASE]: 'base',
[CHAIN.BSC]: 'bsc',
[CHAIN.TARA]: 'tara',
[CHAIN.AVAX]: 'avax',
[CHAIN.LITECOIN]: 'litecoin',
[CHAIN.ARBITRUM]: 'arbitrum',
[CHAIN.NEAR]: 'near',
[CHAIN.POLYGON]: 'polygon',
[CHAIN.TON]: 'ton',
[CHAIN.SOLANA]: 'solana',
};

let data: any;
const fetchVolume = async (_t: any, _b: any, options: FetchOptions) => {
const unixTimestamp = getUniqStartOfTodayTimestamp(
new Date(options.startOfDay * 1000)
);
if (!data) {
data = await httpGet('https://api.teleswap.io/stats/volume', {
headers: {
'Content-Type': 'application/json',
},
});
}

const chainVolume = data?.find(
(item: any) =>
item.chain.toLowerCase() === chains[options.chain].toLowerCase()
);

return {
dailyBridgeVolume: chainVolume?.dailyVolume || 0,
totalBridgeVolume: chainVolume?.totalVolume || 0,
timestamp: unixTimestamp,
};
};

const adapter: SimpleAdapter = {
adapter: {
...Object.entries(chains).reduce((acc, chain) => {
const [key, value] = chain;

return {
...acc,
[key]: {
fetch: fetchVolume,
start: '2024-09-18',
},
};
}, {}),
},
version: 1,
};

export default adapter;
Loading

0 comments on commit 42e2433

Please sign in to comment.