forked from DefiLlama/DefiLlama-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.
- Loading branch information
1 parent
1513cfd
commit daf3917
Showing
5 changed files
with
96 additions
and
3 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 |
---|---|---|
@@ -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; |
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
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 |
---|---|---|
@@ -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 | ||
} |
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
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