forked from DefiLlama/dimension-adapters
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request DefiLlama#1429 from glyph-exchange/master
glyph-exchange add fees and revenue
- Loading branch information
Showing
1 changed file
with
65 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |