Skip to content

Commit

Permalink
Uni v2 adapters refactor (#1925)
Browse files Browse the repository at this point in the history
* code refactor

* bugfix
  • Loading branch information
g1nt0ki authored Sep 19, 2024
1 parent 9b9db24 commit c6798ff
Show file tree
Hide file tree
Showing 42 changed files with 291 additions and 1,007 deletions.
18 changes: 4 additions & 14 deletions dexs/Scale/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
import { SimpleAdapter } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";
import { getDexVolumeExports } from "../../helpers/dexVolumeLogs";
import { uniV2Exports } from "../../helpers/uniswap";

const FACTORY_ADDRESS = '0xEd8db60aCc29e14bC867a497D94ca6e3CeB5eC04';

const adapter: SimpleAdapter = {
adapter: {
[CHAIN.BASE]: {
fetch: getDexVolumeExports({ chain: CHAIN.BASE, factory: FACTORY_ADDRESS }),
start: 1695458888,
},
}
};

export default adapter;
export default uniV2Exports({
[CHAIN.BASE]: { factory: '0xEd8db60aCc29e14bC867a497D94ca6e3CeB5eC04', },
})
19 changes: 4 additions & 15 deletions dexs/Viridian/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
import { FetchOptions, SimpleAdapter } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";
import { getDexVolumeExports } from "../../helpers/dexVolumeLogs";
import { uniV2Exports } from "../../helpers/uniswap";

const FACTORY_ADDRESS = '0xb54a83cfEc6052E05BB2925097FAff0EC22893F3'

const adapter: SimpleAdapter = {
version: 2,
adapter: {
[CHAIN.CORE]: {
fetch: async (options: FetchOptions) => getDexVolumeExports({ chain: CHAIN.CORE, factory: FACTORY_ADDRESS, })(options.startOfDay, null, options),
start: 1715904000,
},
}
};

export default adapter;
export default uniV2Exports({
[CHAIN.CORE]: { factory: '0xb54a83cfEc6052E05BB2925097FAff0EC22893F3', },
})
23 changes: 6 additions & 17 deletions dexs/abcdefx/index.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
import { SimpleAdapter } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";
import { Chain } from "@defillama/sdk/build/general";
import { getDexVolumeExports } from "../../helpers/dexVolumeLogs";
import { uniV2Exports } from "../../helpers/uniswap";

const FACTORY_ADDRESS = '0x01f43d2a7f4554468f77e06757e707150e39130c';

const graph = (_chain: Chain) =>
getDexVolumeExports({ chain: _chain, factory: FACTORY_ADDRESS })


const adapter: SimpleAdapter = {
adapter: {
[CHAIN.KCC]: { fetch: graph(CHAIN.KCC), start: 1670188701 },
//[CHAIN.MULTIVAC]: { fetch: graph(CHAIN.MULTIVAC), start: 1670226950 }, /// ! typeof CHAIN
[CHAIN.FANTOM]: { fetch: graph(CHAIN.FANTOM), start: 1671580916 },
//[CHAIN.ECHELON]: { fetch: graph(CHAIN.ECHELON), start: 1671608400 }, /// ded!?
[CHAIN.KAVA]: { fetch: graph(CHAIN.KAVA), start: 1676855943 }
}
};

export default adapter;
export default uniV2Exports({
[CHAIN.FANTOM]: { factory: FACTORY_ADDRESS, },
[CHAIN.KCC]: { factory: FACTORY_ADDRESS, },
[CHAIN.KAVA]: { factory: FACTORY_ADDRESS, },
})
117 changes: 25 additions & 92 deletions dexs/archly-finance-v2/index.ts
Original file line number Diff line number Diff line change
@@ -1,98 +1,31 @@
import { SimpleAdapter } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";
import { getDexVolumeExports } from "../../helpers/dexVolumeLogs";
import { uniV2Exports } from "../../helpers/uniswap";

const FACTORY_ADDRESS = '0x12508dd9108Abab2c5fD8fC6E4984E46a3CF7824';
const factory = '0x12508dd9108Abab2c5fD8fC6E4984E46a3CF7824';
const FACTORY_ADDRESS_ZKSYNC = '0x30A0DD3D0D9E99BD0E67b323FB706788766dCff2';
const FACTORY_ADDRESS_ETHERUEM = '0xE8E2b714C57937E0b29c6ABEAF00B52388cAb598';

const adapter: SimpleAdapter = {
adapter: {
[CHAIN.ARBITRUM_NOVA]: {
fetch: getDexVolumeExports({ chain: CHAIN.ARBITRUM_NOVA, factory: FACTORY_ADDRESS }),
start: 1700784000,
},
[CHAIN.ARBITRUM]: {
fetch: getDexVolumeExports({ chain: CHAIN.ARBITRUM, factory: FACTORY_ADDRESS }),
start: 1700784000,
},
[CHAIN.AVAX]: {
fetch: getDexVolumeExports({ chain: CHAIN.AVAX, factory: FACTORY_ADDRESS }),
start: 1708473600,
},
[CHAIN.BASE]: {
fetch: getDexVolumeExports({ chain: CHAIN.BASE, factory: FACTORY_ADDRESS }),
start: 1700784000,
},
[CHAIN.BLAST]: {
fetch: getDexVolumeExports({ chain: CHAIN.BLAST, factory: FACTORY_ADDRESS }),
start: 1710720000,
},
[CHAIN.BSC]: {
fetch: getDexVolumeExports({ chain: CHAIN.BSC, factory: FACTORY_ADDRESS }),
start: 1700784000,
},
[CHAIN.CRONOS]: {
fetch: getDexVolumeExports({ chain: CHAIN.CRONOS, factory: FACTORY_ADDRESS }),
start: 1708473600,
},
[CHAIN.ETHEREUM]: {
fetch: getDexVolumeExports({ chain: CHAIN.ETHEREUM, factory: FACTORY_ADDRESS_ETHERUEM }),
start: 1713070800,
},
[CHAIN.FANTOM]: {
fetch: getDexVolumeExports({ chain: CHAIN.FANTOM, factory: FACTORY_ADDRESS }),
start: 1700784000,
},
[CHAIN.FILECOIN]: {
fetch: getDexVolumeExports({ chain: CHAIN.FILECOIN, factory: FACTORY_ADDRESS }),
start: 1710979200,
},
[CHAIN.FRAXTAL]: {
fetch: getDexVolumeExports({ chain: CHAIN.FRAXTAL, factory: FACTORY_ADDRESS }),
start: 1710720000,
},
[CHAIN.KAVA]: {
fetch: getDexVolumeExports({ chain: CHAIN.KAVA, factory: FACTORY_ADDRESS }),
start: 1700784000,
},
[CHAIN.MANTLE]: {
fetch: getDexVolumeExports({ chain: CHAIN.MANTLE, factory: FACTORY_ADDRESS }),
start: 1708473600,
},
[CHAIN.METIS]: {
fetch: getDexVolumeExports({ chain: CHAIN.METIS, factory: FACTORY_ADDRESS }),
start: 1708473600,
},
[CHAIN.MODE]: {
fetch: getDexVolumeExports({ chain: CHAIN.MODE, factory: FACTORY_ADDRESS }),
start: 1711792800,
},
[CHAIN.NEON]: {
fetch: getDexVolumeExports({ chain: CHAIN.NEON, factory: FACTORY_ADDRESS }),
start: 1708473600,
},
[CHAIN.OPTIMISM]: {
fetch: getDexVolumeExports({ chain: CHAIN.OPTIMISM, factory: FACTORY_ADDRESS }),
start: 1700784000,
},
[CHAIN.POLYGON]: {
fetch: getDexVolumeExports({ chain: CHAIN.POLYGON, factory: FACTORY_ADDRESS }),
start: 1700784000,
},
[CHAIN.TELOS]: {
fetch: getDexVolumeExports({ chain: CHAIN.TELOS, factory: FACTORY_ADDRESS }),
start: 1700784000,
},
[CHAIN.ERA]: {
fetch: getDexVolumeExports({ chain: CHAIN.ERA, factory: FACTORY_ADDRESS_ZKSYNC }),
start: 1708473600,
},
[CHAIN.ZORA]: {
fetch: getDexVolumeExports({ chain: CHAIN.ZORA, factory: FACTORY_ADDRESS }),
start: 1711929600,
},
}
};

export default adapter;
export default uniV2Exports({
[CHAIN.ARBITRUM_NOVA]: { factory },
[CHAIN.ARBITRUM]: { factory },
[CHAIN.AVAX]: { factory },
[CHAIN.BASE]: { factory },
[CHAIN.BLAST]: { factory },
[CHAIN.BSC]: { factory },
[CHAIN.CRONOS]: { factory },
[CHAIN.ETHEREUM]: { factory: FACTORY_ADDRESS_ETHERUEM },
[CHAIN.FANTOM]: { factory },
[CHAIN.FILECOIN]: { factory },
[CHAIN.FRAXTAL]: { factory },
[CHAIN.KAVA]: { factory },
[CHAIN.MANTLE]: { factory },
[CHAIN.METIS]: { factory },
[CHAIN.MODE]: { factory },
[CHAIN.NEON]: { factory },
[CHAIN.OPTIMISM]: { factory },
[CHAIN.POLYGON]: { factory },
[CHAIN.TELOS]: { factory },
[CHAIN.ERA]: { factory: FACTORY_ADDRESS_ZKSYNC },
[CHAIN.ZORA]: { factory },
})
34 changes: 5 additions & 29 deletions dexs/auroraswap/index.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,6 @@
import { SimpleAdapter } from "../../adapters/types"
import { CHAIN } from "../../helpers/chains"
import { getDexVolumeExports } from "../../helpers/dexVolumeLogs";
import { CHAIN } from "../../helpers/chains";
import { uniV2Exports } from "../../helpers/uniswap";


const pools: string[] = [
'0xf3de9dc38f62608179c45fe8943a0ca34ba9cefc',
'0xc57ecc341ae4df32442cf80f34f41dc1782fe067',
'0x480a68ba97d70495e80e11e05d59f6c659749f27',
'0xec538fafafcbb625c394c35b11252cef732368cd',
'0xdb0363ee28a5b40bdc2f4701e399c63e00f91aa8',
'0xefcf518ca36dc3362f539965807b42a77dc26be0',
'0x5bdac608cd38c5c8738f5be20813194a3150d4ff',
'0xcb8584360dc7a4eac4878b48fb857aa794e46fa8',
'0x865c59d555e59c9f35487bbdfb22d617c67aeabd',
'0xe11a3f2bab372d88d133b64487d1772847eec4ea',
'0x23524a789f93b798a6e7011b276edf09083cfde6',
'0x30c3d6c114a350026ea0aa770788374ad6c6f765'
].map((address: string) => address.toLowerCase());

const adapters: SimpleAdapter = {
adapter: {
[CHAIN.AURORA]: {
fetch: getDexVolumeExports({ chain: CHAIN.AURORA, pools }),
start: 1678838400,
}
}
}

export default adapters
export default uniV2Exports({
[CHAIN.AURORA]: { factory: '0xC5E1DaeC2ad401eBEBdd3E32516d90Ab251A3aA3', },
})
25 changes: 4 additions & 21 deletions dexs/canto-dex/index.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,6 @@
import { SimpleAdapter } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";
import { getDexVolumeExports } from "../../helpers/dexVolumeLogs";
import { uniV2Exports } from "../../helpers/uniswap";

const lpAddress = [
'0x9571997a66d63958e1b3de9647c22bd6b9e7228c',
'0x1d20635535307208919f0b67c3b2065965a85aa9',
'0x30838619c55b787bafc3a4cd9aea851c1cfb7b19',
'0x216400ba362d8fce640085755e47075109718c8b',
'0x35db1f3a6a6f07f82c76fcc415db6cfb1a7df833',
'0x830fbc440a0a61b429b9ece5b7a4af003537fad2',
];

const adapter: SimpleAdapter = {
adapter: {
[CHAIN.CANTO]: {
fetch: getDexVolumeExports({ chain: CHAIN.CANTO, pools: lpAddress }),
start: 1668988800,
},
}
};

export default adapter;
export default uniV2Exports({
[CHAIN.CANTO]: { factory: '0xE387067f12561e579C5f7d4294f51867E0c1cFba', },
})
19 changes: 5 additions & 14 deletions dexs/chronos-v2/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
import { Fetch, SimpleAdapter } from "../../adapters/types"
import { CHAIN } from "../../helpers/chains"
import { getDexVolumeExportsV3 } from "../../helpers/dexVolumeLogs";
import { uniV3Exports } from "../../helpers/uniswap";

const poolFactoryAddress = '0x4Db9D624F67E00dbF8ef7AE0e0e8eE54aF1dee49';

const adapters: SimpleAdapter = {
adapter: {
[CHAIN.ARBITRUM]: {
fetch: getDexVolumeExportsV3({ factory: poolFactoryAddress, factoryFromBlock: 114041129, chain: CHAIN.ARBITRUM, }) as Fetch,
start: 1690070400,
}
export default uniV3Exports({
arbitrum: {
factory: '0x4Db9D624F67E00dbF8ef7AE0e0e8eE54aF1dee49',
}
}

export default adapters;
})
15 changes: 4 additions & 11 deletions dexs/chronos/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import { SimpleAdapter } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";
import { getDexVolumeExports } from "../../helpers/dexVolumeLogs";
import { uniV2Exports } from "../../helpers/uniswap";

const FACTORY_ADDRESS = '0xCe9240869391928253Ed9cc9Bcb8cb98CB5B0722';

const adapter: SimpleAdapter = {
adapter: {
[CHAIN.ARBITRUM]: {
fetch: getDexVolumeExports({ chain: CHAIN.ARBITRUM, factory: FACTORY_ADDRESS }),
start: 1679702400,
},
}
};
export default uniV2Exports({
[CHAIN.ARBITRUM]: { factory: FACTORY_ADDRESS, },
})

export default adapter;
25 changes: 6 additions & 19 deletions dexs/deltaswap/index.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
import { SimpleAdapter } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";
import { getDexVolumeExports } from "../../helpers/dexVolumeLogs";
import { uniV2Exports } from "../../helpers/uniswap";

const adapters: SimpleAdapter = {
adapter: {
[CHAIN.ARBITRUM]: {
fetch: getDexVolumeExports({ chain: CHAIN.ARBITRUM, factory: '0xcb85e1222f715a81b8edaeb73b28182fa37cffa8' }),
start: 1705968000,
},
[CHAIN.BASE]: {
fetch: getDexVolumeExports({ chain: CHAIN.BASE, factory: '0x9a9a171c69cc811dc6b59bb2f9990e34a22fc971' }),
start: 1715644800,
},
[CHAIN.ETHEREUM]: {
fetch: getDexVolumeExports({ chain: CHAIN.ETHEREUM, factory: '0x5fbe219e88f6c6f214ce6f5b1fcaa0294f31ae1b' }),
start: 1716854400,
}
}
}
export default adapters;
export default uniV2Exports({
[CHAIN.ARBITRUM]: { factory: '0xcb85e1222f715a81b8edaeb73b28182fa37cffa8', },
[CHAIN.BASE]: { factory: '0x9a9a171c69cc811dc6b59bb2f9990e34a22fc971', },
[CHAIN.ETHEREUM]: { factory: '0x5fbe219e88f6c6f214ce6f5b1fcaa0294f31ae1b', },
})
10 changes: 8 additions & 2 deletions dexs/dexswap/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as sdk from "@defillama/sdk";
import { FetchOptions } from "../../adapters/types"
import { exportDexVolumeAndFees } from "../../helpers/dexVolumeLogs";
import request, { gql } from "graphql-request";
import { SimpleAdapter } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";
import BigNumber from "bignumber.js";
import { uniV2Exports } from "../../helpers/uniswap";

const FACTORY_ADDRESS = '0x3e40739d8478c58f9b973266974c58998d4f9e8b';

Expand All @@ -14,6 +14,12 @@ const endpoints = {

const startDate = 1684702800;


const feeAdapter = uniV2Exports({
[CHAIN.ARBITRUM]: { factory: FACTORY_ADDRESS, },
}).adapter[CHAIN.ARBITRUM].fetch


const fetch = async (options: FetchOptions) => {
const dataFactory = await request(endpoints[options.chain], gql
`{
Expand Down Expand Up @@ -44,7 +50,7 @@ const fetch = async (options: FetchOptions) => {
})
if (dataFees.dexSwapFees.length < 1000) break;
}
const dailyData = await exportDexVolumeAndFees({ chain: CHAIN.ARBITRUM, factory: FACTORY_ADDRESS })(options.endTimestamp, {}, options);
const dailyData = await feeAdapter(options as any, {}, options);
return {
...dailyData,
totalVolume,
Expand Down
18 changes: 4 additions & 14 deletions dexs/equalizer-exchange/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
import { SimpleAdapter } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";
import { getDexVolumeExports } from "../../helpers/dexVolumeLogs";
import { uniV2Exports } from "../../helpers/uniswap";

const FACTORY_ADDRESS = '0xc6366efd0af1d09171fe0ebf32c7943bb310832a';

const adapter: SimpleAdapter = {
adapter: {
[CHAIN.FANTOM]: {
fetch: getDexVolumeExports({ chain: CHAIN.FANTOM, factory: FACTORY_ADDRESS }),
start: 1670544000,
},
}
};

export default adapter;
export default uniV2Exports({
[CHAIN.FANTOM]: { factory: '0xc6366efd0af1d09171fe0ebf32c7943bb310832a', },
})
Loading

0 comments on commit c6798ff

Please sign in to comment.