Skip to content

Commit

Permalink
Revert "Revert "Add CarthageDEX ""
Browse files Browse the repository at this point in the history
  • Loading branch information
samisbakedham authored Jul 20, 2022
1 parent 1513cfd commit daf3917
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 3 deletions.
50 changes: 50 additions & 0 deletions dexVolumes/carthage/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { DexBreakdownAdapter } from "../dexVolume.type";

const {
getChainVolume,
DEFAULT_DAILY_VOLUME_FACTORY,
DEFAULT_TOTAL_VOLUME_FIELD,
} = require("../helper/getUniSubgraphVolume");

const { CANDLE } = require("../helper/chains");

const { getStartTimestamp } = require("../helper/getStartTimestamp");


const v3Endpoints = {
[CANDLE]:
"https://thegraph.cndlchain.com/subgraphs/name/ianlapham/uniswap-v3-test",
};

const VOLUME_USD = "volumeUSD";

const v3Graphs = getChainVolume({
graphUrls: {
...v3Endpoints,
},
totalVolume: {
factory: "factories",
field: DEFAULT_TOTAL_VOLUME_FIELD,
},
dailyVolume: {
factory: DEFAULT_DAILY_VOLUME_FACTORY,
field: VOLUME_USD,
},
});

const adapter: DexBreakdownAdapter = {
breakdown: {
v3: {
[CANDLE]: {
fetch: v3Graphs(CANDLE),
start: getStartTimestamp({
endpoints: v3Endpoints,
chain: CANDLE,
volumeField: VOLUME_USD,
})
}
},
},
};

export default adapter;
2 changes: 2 additions & 0 deletions dexVolumes/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import oneInch from "./1inch";
import balancer from "./balancer";
import bancor from "./bancor";
import carthage from "./carthage";
import champagneswap from "./champagneswap";
import curve from "./curve";
import dodo from "./dodo";
Expand All @@ -25,6 +26,7 @@ export default {
"1inch": oneInch,
balancer,
bancor,
carthage,
champagneswap,
curve,
dodo,
Expand Down
38 changes: 38 additions & 0 deletions projects/carthage/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const { request, gql } = require("graphql-request");
const { toUSDTBalances } = require('../helper/balances');
const graphUrl = 'https://thegraph.cndlchain.com/subgraphs/name/ianlapham/uniswap-v3-test'

const graphQuery = gql`
query get_tvl($block: Int, $number_gte: Int = 10) {
factory(
id: "0x5Bb7BAE25728e9e51c25466D2A15FaE97834FD95"
block: {number_gte: $number_gte}
) {
totalValueLockedETHUntracked
totalValueLockedETH
totalValueLockedUSD
totalValueLockedUSDUntracked
}
}
`;

async function tvl(timestamp, ethBlock, chainBlocks) {
const response = await request(
graphUrl,
graphQuery,
{
block:chainBlocks.cndl,
}
);

return toUSDTBalances(Number(response.factory.totalValueLockedUSD));
}

module.exports = {
misrepresentedTokens: true,
methodology: 'The Carthage subgraph and the Carthage factory contract address are used to obtain the balance held in every LP pair.',
candle:{
tvl,
},
start: 1612715300, // 7th-Feb-2021
}
6 changes: 3 additions & 3 deletions speedTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function createProvider(name, url, chainId) {
name.toUpperCase() + '_RPC',
url
].join('='));

return new ethers.providers.JsonRpcProvider(url,
{
name: name,
Expand Down Expand Up @@ -45,7 +45,7 @@ function createProvider(name, url, chainId) {
const spend = Date.now() - start
console.log(name, "spend", spend / 1000, "s", "block", lastBlockNumber);
}

console.log('.env')
console.log(allNetworks.join("\n"))
})();
})();
3 changes: 3 additions & 0 deletions volume.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ https://api.thegraph.com/subgraphs/name/balancer-labs/balancer
#### Bancor
https://thegraph.com/explorer/subgraph/blocklytics/bancor

#### Carthage
https://thegraph.cndlchain.com/subgraphs/name/ianlapham/uniswap-v3-test

#### Curve
https://www.curve.fi/raw-stats/ren-1440m.json //where ren is the pool name

Expand Down

0 comments on commit daf3917

Please sign in to comment.