Skip to content

Commit

Permalink
Merge pull request DefiLlama#1429 from glyph-exchange/master
Browse files Browse the repository at this point in the history
glyph-exchange add fees and revenue
  • Loading branch information
dtmkeng authored Apr 22, 2024
2 parents 0367458 + 9f2f2a2 commit 43acb6c
Showing 1 changed file with 65 additions and 7 deletions.
72 changes: 65 additions & 7 deletions dexs/glyph-exchange/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,69 @@
import { BreakdownAdapter } from "../../adapters/types";
import { Chain } from "@defillama/sdk/build/general";
import { CHAIN } from "../../helpers/chains";
import { univ2Adapter } from "../../helpers/getUniSubgraphVolume";
import { getGraphDimensions } from "../../helpers/getUniSubgraph";
import { getStartTimestamp } from "../../helpers/getStartTimestamp";

const adapters = univ2Adapter({
const endpointsClassic = {
[CHAIN.CORE]: "https://thegraph.coredao.org/subgraphs/name/glyph/glyph-tvl"
}, {
factoriesName: "glyphFactories",
dayData: "glyphDayData"
};

const VOLUME_FIELD = "totalVolumeUSD";
const DEFAULT_DAILY_VOLUME_FIELD = "dailyVolumeUSD";

//0.3 swap fee, 6/10 to lp, 4/10 to treasury
const feesPercent = {
type: "volume" as "volume",
Fees: 0.3,
UserFees: 0.3,
Revenue: 0.12,
ProtocolRevenue: 0.12,
SupplySideRevenue: 0.18
}

const graphsClassic = getGraphDimensions({
graphUrls: endpointsClassic,
totalVolume: {
factory: "glyphFactories",
field: VOLUME_FIELD,
},
dailyVolume: {
factory: "glyphDayData",
field: DEFAULT_DAILY_VOLUME_FIELD,
},
feesPercent
});
adapters.adapter.core.start = 1710806400;
export default adapters;

const startTimeQueryClassic = {
endpoints: endpointsClassic,
dailyDataField: "glyphDayData",
};

const classic = Object.keys(endpointsClassic).reduce(
(acc, chain) => ({
...acc,
[chain]: {
fetch: graphsClassic(chain as Chain),
start: getStartTimestamp({ ...startTimeQueryClassic, chain }),
meta: {
methodology: {
Fees: "GlyphExchange charges a flat 0.3% fee",
UserFees: "Users pay a 0.3% fee on each trade",
Revenue: "A 0.12% of each trade goes to treasury",
ProtocolRevenue: "Treasury receives a share of the fees",
SupplySideRevenue: "Liquidity providers get 6/10 of all trades in their pools"
}
}
},
}),
{}
) as any;

const adapter: BreakdownAdapter = {
version: 2,
breakdown: {
classic: classic,
}
}

export default adapter

0 comments on commit 43acb6c

Please sign in to comment.