Skip to content

Commit

Permalink
Merge pull request #1994 from DefiLlama/13oct-patches
Browse files Browse the repository at this point in the history
13oct patches
  • Loading branch information
waynebruce0x authored Oct 13, 2024
2 parents 4781fb1 + 45b3ed2 commit 147621c
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 75 deletions.
24 changes: 2 additions & 22 deletions dexs/horiza/index.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,12 @@
import { SimpleAdapter } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";
import { DEFAULT_TOTAL_VOLUME_FIELD, getGraphDimensions2 } from "../../helpers/getUniSubgraph";

const endpointV3 = {
[CHAIN.ARBITRUM]: 'https://subgraph-prod.goerli.horiza.io/subgraphs/name/retro-arbitrum-one-uniswap-v3'
}

const v3Graphs = getGraphDimensions2({
graphUrls: endpointV3,
totalVolume: {
factory: "factories",
field: DEFAULT_TOTAL_VOLUME_FIELD,
},
feesPercent: {
type: "fees",
ProtocolRevenue: 10,
HoldersRevenue: 0,
UserFees: 100,
SupplySideRevenue: 90,
Revenue: 10,
}
});
import { getUniV3LogAdapter } from '../../helpers/uniswap'

const adapters: SimpleAdapter = {
version: 2,
adapter: {
[CHAIN.ARBITRUM]: {
fetch: v3Graphs(CHAIN.ARBITRUM),
fetch: getUniV3LogAdapter({ factory: '0x5b1C257B88537d1Ce2AF55a1760336288CcD28B6', }),
start: 1704585600,
}
}
Expand Down
23 changes: 12 additions & 11 deletions fees/frax-amo.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as sdk from "@defillama/sdk";
import { gql, GraphQLClient } from "graphql-request";
import { FetchOptions, SimpleAdapter } from "../adapters/types";
import { FetchOptions, FetchResult, SimpleAdapter } from "../adapters/types";
import { CHAIN } from "../helpers/chains";

const query = (amo: string, timestamp: number) => gql`
Expand Down Expand Up @@ -38,26 +38,27 @@ const findRevenue = (timedData: any) =>
Number(timedData.depositedAmount) +
Number(timedData.profitTaken);

const fetch = async ({ createBalances, chain, toTimestamp }: FetchOptions) => {
const { amos, graph, FRAX } = config[chain];
const fetch = async (timestamp: number, _: any, options: FetchOptions): Promise<FetchResult> => {
const { amos, graph, FRAX } = config[options.chain];
const client = getGQLClient(graph);
const dailyRevenue = createBalances();
const totalRevenue = createBalances();
const dailyFees = createBalances();
const dailyRevenue = options.createBalances();
const totalRevenue = options.createBalances();

await Promise.all(
amos.map(async (amo: string) => {
const data = (await client.request(query(amo, toTimestamp))).amos[0];
data.positions.map((p: any) => {
const latest = findRevenue(p.fraxAccountingPerDay[0]);
const previous = findRevenue(p.fraxAccountingPerDay[1]);
const data = (await client.request(query(amo, timestamp))).amos[0];
data.positions.map(({ fraxAccountingPerDay: days }: any) => {
if (days.length < 2) return
const latest = findRevenue(days[0]);
const previous = findRevenue(days[1]);
dailyRevenue.add(FRAX, latest - previous);
totalRevenue.add(FRAX, latest);
});
}),
);

return {
timestamp,
dailyRevenue,
totalRevenue,
dailyFees: dailyRevenue,
Expand Down Expand Up @@ -100,7 +101,7 @@ const adapter: SimpleAdapter = {
},
};
}, {}),
version: 2,
version: 1,
};

export default adapter;
49 changes: 19 additions & 30 deletions fees/honeyswap.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,24 @@
import { Adapter } from "../adapters/types";
import { CHAIN } from "../helpers/chains";
import { univ2DimensionAdapter2 } from "../helpers/getUniSubgraph";
import { getUniV2LogAdapter } from "../helpers/uniswap";

const adapters = univ2DimensionAdapter2({
graphUrls: {
[CHAIN.POLYGON]: " https://api.thegraph.com/subgraphs/name/1hive/honeyswap-polygon",
[CHAIN.XDAI]: "https://api.thegraph.com/subgraphs/name/1hive/honeyswap-xdai"
const adapter: Adapter = {
version: 2,
adapter: {
[CHAIN.POLYGON]: {
fetch: getUniV2LogAdapter({
factory: "0x03daa61d8007443a6584e3d8f85105096543c19c",
}),
start: 1622173831,
},
[CHAIN.XDAI]: {
fetch: getUniV2LogAdapter({
factory: "0xa818b4f111ccac7aa31d0bcc0806d64f2e0737d7",
}),
start: 1599191431,
},
},
totalVolume: {
factory: "honeyswapFactories"
},
feesPercent: {
type: 'volume',
Fees: 0.3,
UserFees: 0.3,
SupplySideRevenue: 0.25,
HoldersRevenue: 0,
ProtocolRevenue: 0.05,
Revenue: 0.05
}
}, {
methodology: {
UserFees: "A 0.3% fee is charged for token swaps",
Fees: "Trading fees are 0.3% of each swap",
SupplySideRevenue: "A 0.25% of each swap is distributed to liquidity providers",
Revenue: "A 0.05% trading fee goes to treasury",
HoldersRevenue: "There's no revenue from trading fees for token holders",
ProtocolRevenue: "A 0.05% goes to the protocol treasury"
}
});
adapters.adapter.polygon.start = 1622173831;
adapters.adapter.xdai.start = 1599191431;
};


export default adapters;
export default adapter;
2 changes: 1 addition & 1 deletion fees/junoswap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const adapter: Adapter = {
fetch: fetch,
start: 1646784000,
},
}
},
}

export default adapter;
21 changes: 10 additions & 11 deletions fees/shibaswap.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import { Adapter } from "../adapters/types";
import volumeAdapter from "../dexs/shibaswap";
import { getDexChainFees } from "../helpers/getUniSubgraphFees";

const TOTAL_FEES = 0.003;

const feeAdapter = getDexChainFees({
totalFees: TOTAL_FEES,
volumeAdapter
});
import { CHAIN } from "../helpers/chains";
import { getUniV2LogAdapter } from "../helpers/uniswap";

const adapter: Adapter = {
version: 2,
adapter: feeAdapter
adapter: {
[CHAIN.ETHEREUM]: {
fetch: getUniV2LogAdapter({
factory: "0x115934131916c8b277dd010ee02de363c09d037c",
}),
start: 1625566975,
},
},
};


export default adapter;

0 comments on commit 147621c

Please sign in to comment.