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

Avalanche Integration & Fixes #83

Merged
merged 1 commit into from
Aug 29, 2023
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"license": "BSD-3-Clause",
"dependencies": {
"@pangolindex/sdk": "5.3.4",
"@pangolindex/sdk": "5.3.5",
"worktop": "0.8.0-next.5"
},
"devDependencies": {
Expand Down
6 changes: 4 additions & 2 deletions src/handlers/pangolin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@
export const average: Handler = async (_, context) => {
const chainInfo = getChainInfo(context.params.chain);

const entityName = chainInfo.chainId === '43114' ? 'factories' : 'pangolinFactories';

const result = await gql.request(

Check failure on line 52 in src/handlers/pangolin.ts

View workflow job for this annotation

GitHub Actions / Lint

Replace `⏎····QUERIES._FACTORY(entityName),⏎····chainInfo.subgraph_exchange,⏎··` with `QUERIES._FACTORY(entityName),·chainInfo.subgraph_exchange`
QUERIES._FACTORY(chainInfo.factory),
QUERIES._FACTORY(entityName),
chainInfo.subgraph_exchange,
);
const {totalVolumeUSD, txCount} = result.pangolinFactories[0];
const {totalVolumeUSD, txCount} = result[entityName][0];

const text = (Number.parseFloat(totalVolumeUSD) / Number.parseInt(txCount, 10)).toFixed(2);

Expand Down
12 changes: 8 additions & 4 deletions src/handlers/png.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
export const tvl: Handler = async (_, context) => {
const chainInfo = getChainInfo(context.params.chain);

const entityName = chainInfo.chainId === '43114' ? 'factories' : 'pangolinFactories';

const result = await gql.request(

Check failure on line 15 in src/handlers/png.ts

View workflow job for this annotation

GitHub Actions / Lint

Replace `⏎····QUERIES._FACTORY(entityName),⏎····chainInfo.subgraph_exchange,⏎··` with `QUERIES._FACTORY(entityName),·chainInfo.subgraph_exchange`
QUERIES._FACTORY(chainInfo.factory),
QUERIES._FACTORY(entityName),
chainInfo.subgraph_exchange,
);

const text = Number.parseFloat(result.pangolinFactories[0].totalLiquidityUSD).toFixed(2);
const text = Number.parseFloat(result[entityName][0].totalLiquidityUSD).toFixed(2);

return send(200, text, {
'Cache-Control': 'public,s-maxage=300',
Expand All @@ -25,12 +27,14 @@
export const volume: Handler = async (_, context) => {
const chainInfo = getChainInfo(context.params.chain);

const entityName = chainInfo.chainId === '43114' ? 'factories' : 'pangolinFactories';

const result = await gql.request(

Check failure on line 32 in src/handlers/png.ts

View workflow job for this annotation

GitHub Actions / Lint

Replace `⏎····QUERIES._FACTORY(entityName),⏎····chainInfo.subgraph_exchange,⏎··` with `QUERIES._FACTORY(entityName),·chainInfo.subgraph_exchange`
QUERIES._FACTORY(chainInfo.factory),
QUERIES._FACTORY(entityName),
chainInfo.subgraph_exchange,
);

const text = Number.parseFloat(result.pangolinFactories[0].totalVolumeUSD).toFixed(2);
const text = Number.parseFloat(result[entityName][0].totalVolumeUSD).toFixed(2);

return send(200, text, {
'Cache-Control': 'public,s-maxage=300',
Expand Down
6 changes: 3 additions & 3 deletions src/utils/queries.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const _FACTORY = (FACTORY_ADDRESS: string) => `
query pangolinFactories {
pangolinFactories(where: { id: "${FACTORY_ADDRESS}" }) {
export const _FACTORY = (ENTITY_NAME: string) => `
query ${ENTITY_NAME} {
${ENTITY_NAME}(where: { id: "1" }) {
id
totalVolumeUSD
totalLiquidityUSD
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -623,10 +623,10 @@
"@nodelib/fs.scandir" "2.1.5"
fastq "^1.6.0"

"@pangolindex/[email protected].4":
version "5.3.4"
resolved "https://registry.yarnpkg.com/@pangolindex/sdk/-/sdk-5.3.4.tgz#b48aebd063ae6f4abd9930199fb118b58246d159"
integrity sha512-Xj2pLgI0EK9DNEhuMQVchmmk6UC6G27hdzjiL71AnNYpB+abt7ZB5Ou6SdjeeHQJIxsxfVhV/BRY096XDGquog==
"@pangolindex/[email protected].5":
version "5.3.5"
resolved "https://registry.yarnpkg.com/@pangolindex/sdk/-/sdk-5.3.5.tgz#6cf491976493bd24444eae3f24a05ad7c867f36b"
integrity sha512-YMhAwJhvj7U4bpLXCw/X5ePWmNcxrbDCUSFpIN84L04dM8qWTFCF3FXGtYkQRJwoK7Gfqg8XusKIFTEWGwJbrA==
dependencies:
big.js "^5.2.2"
decimal.js-light "^2.5.0"
Expand Down
Loading