Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added 9mm v3 & v2 in dexes #2127

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions dexs/9mm-v2/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import customBackfill from "../../helpers/customBackfill";
import {CHAIN} from "../../helpers/chains";
import type {ChainEndpoints, SimpleAdapter} from "../../adapters/types";
import type {Chain} from "@defillama/sdk/build/general";
import { getGraphDimensions2} from "../../helpers/getUniSubgraph";

// Subgraphs endpoints
const endpoints: ChainEndpoints = {
[CHAIN.PULSECHAIN]: "https://graph.9mm.pro/subgraphs/name/pulsechain/9mm",
[CHAIN.BASE]: "https://api.studio.thegraph.com/query/80328/9mmbasev2/version/latest",
};

// Fetch function to query the subgraphs
const graphs = getGraphDimensions2({
graphUrls: endpoints,
totalVolume: {
factory: "pancakeFactories",
field: "totalVolumeUSD",
},
feesPercent: {
type: "volume",
UserFees: 0.25,
SupplySideRevenue: 0.17,
ProtocolRevenue: 0.08,
Revenue: 0.25,
Fees: 0.25,
}
});

const methodology = {
UserFees: "User pays 0.25% fees on each swap.",
SupplySideRevenue: "LPs receive 0.17% of each swap.",
ProtocolRevenue: "Treasury receives 0.08% of each swap.",
Revenue: "All revenue generated comes from user fees.",
Fees: "All fees comes from the user.",
};

const adapter: SimpleAdapter = {
version: 2,
adapter: Object.keys(endpoints).reduce((acc, chain) => {
return {
...acc,
[chain]: {
fetch: graphs(chain as Chain),
start: async () =>
chain === CHAIN.PULSECHAIN ? 1698693960
: chain === CHAIN.BASE ? 1718210460
: 0,
customBackfill: customBackfill(chain, graphs),
meta: {methodology},
}
}
}, {})
};

export default adapter;
42 changes: 42 additions & 0 deletions dexs/9mm/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { IJSON, SimpleAdapter } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";
import { getGraphDimensions2 } from "../../helpers/getUniSubgraph";

const v3Endpoint = {
[CHAIN.PULSECHAIN]:
"https://graph.9mm.pro/subgraphs/name/pulsechain/9mm-v3",
[CHAIN.BASE]:
"https://api.studio.thegraph.com/query/80328/9mmbasev3/version/latest",
};

const v3Graph = getGraphDimensions2({
graphUrls: v3Endpoint,
totalVolume: {
factory: "factories",
},
totalFees: {
factory: "factories",
},
});

const v3StartTimes = {
[CHAIN.PULSECHAIN]: 1701128040,
[CHAIN.BASE]: 1718318340,

} as IJSON<number>;

const adapter: SimpleAdapter = {
adapter: {
[CHAIN.BASE]: {
fetch: v3Graph(CHAIN.BASE),
start: v3StartTimes[CHAIN.BASE]
},
[CHAIN.PULSECHAIN]: {
fetch: v3Graph(CHAIN.PULSECHAIN),
start: v3StartTimes[CHAIN.PULSECHAIN]
},
},
version: 2
};

export default adapter;
Loading