Skip to content

Commit

Permalink
add debank
Browse files Browse the repository at this point in the history
  • Loading branch information
0xngmi committed Nov 24, 2024
1 parent c3fb8ad commit 221ed86
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 24 deletions.
9 changes: 9 additions & 0 deletions fees/debank.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Adapter } from "../adapters/types";
import { generateCBCommerceExports } from "../helpers/coinbase-commerce";

const adapter: Adapter = {
version: 2,
adapter: generateCBCommerceExports('0x3c6923D09ec77648ca923fFB4e50251120756faa'),
}

export default adapter;
29 changes: 5 additions & 24 deletions fees/dexscreener.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
import { Adapter, FetchOptions } from "../adapters/types";
import { generateCBCommerceExports } from "../helpers/coinbase-commerce";
import { getSolanaReceived } from '../helpers/token';
import { CHAIN } from "../helpers/chains";
import coreAssets from "../helpers/coreAssets.json";
import { addTokensReceived, getSolanaReceived } from '../helpers/token';

const USDC = {
ethereum: coreAssets.ethereum.USDC,
polygon: coreAssets.polygon.USDC_CIRCLE,
base: coreAssets.base.USDC,
} as any

const eth = async (options: FetchOptions) => {
const dailyFees = await addTokensReceived({ options, tokens: [USDC[options.chain]], target: '0xbf07aFF5114BAd83720A8b9Fc7585aFd2ef9E4C2' })
return {
dailyFees,
dailyRevenue: dailyFees,
}
}

// TODO: check whether 5qR17nnyyBjoHPiGiAD4ZHFCSJixebJCYymArGgZiDnh was an older address where they received payments
const sol = async (options: FetchOptions) => {
Expand All @@ -25,17 +11,12 @@ const sol = async (options: FetchOptions) => {

const adapter: Adapter = {
version: 2,
adapter: [CHAIN.ETHEREUM, CHAIN.BASE, CHAIN.POLYGON].reduce((all, chain) => ({
...all,
[chain]: {
fetch: eth,
}
}), {
adapter: {
...generateCBCommerceExports('0xbf07aFF5114BAd83720A8b9Fc7585aFd2ef9E4C2'),
[CHAIN.SOLANA]: {
fetch: sol,
}
}),
isExpensiveAdapter: true
}
}

export default adapter;
29 changes: 29 additions & 0 deletions helpers/coinbase-commerce.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@


import { FetchOptions } from "../adapters/types";
import { CHAIN } from "./chains";
import coreAssets from "./coreAssets.json";
import { addTokensReceived } from './token';

const USDC = {
[CHAIN.ETHEREUM]: coreAssets.ethereum.USDC,
[CHAIN.POLYGON]: coreAssets.polygon.USDC_CIRCLE,
[CHAIN.BASE]: coreAssets.base.USDC,
} as any

export function generateCBCommerceExports(receivingAddress:string) {
const receivedOnEVMChain = async (options: FetchOptions) => {
const dailyFees = await addTokensReceived({ options, tokens: [USDC[options.chain]], target: receivingAddress })
return {
dailyFees,
dailyRevenue: dailyFees,
}
}

return [CHAIN.ETHEREUM, CHAIN.BASE, CHAIN.POLYGON].reduce((all, chain) => ({
...all,
[chain]: {
fetch: receivedOnEVMChain,
}
}), {})
}

0 comments on commit 221ed86

Please sign in to comment.