-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[UPDATE] BMX by Morphex: Add TVL tracking for staking and Mode networ…
…k; Add tracking for Freestyle on Base (#11041) * Add Mode, staking, and add Freestyle separately * Update index.js
- Loading branch information
Showing
2 changed files
with
65 additions
and
4 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,12 +1,27 @@ | ||
const { staking } = require("../helper/staking"); | ||
const { gmxExports } = require("../helper/gmx"); | ||
const sdk = require('@defillama/sdk') | ||
|
||
const vaultAddress = "0xec8d8D4b215727f3476FF0ab41c406FA99b4272C"; | ||
const vaultAddresses = { | ||
base: "0xec8d8D4b215727f3476FF0ab41c406FA99b4272C", | ||
mode: "0xff745bdB76AfCBa9d3ACdCd71664D4250Ef1ae49" | ||
}; | ||
const stakingAddresses = { | ||
base: "0x3085F25Cbb5F34531229077BAAC20B9ef2AE85CB", | ||
mode: "0x773F34397d5F378D993F498Ee646FFe4184E00A3" | ||
}; | ||
const tokenAddresses = { | ||
base: "0x548f93779fBC992010C07467cBaf329DD5F059B7", | ||
mode: "0x66eEd5FF1701E6ed8470DC391F05e27B1d0657eb" | ||
}; | ||
|
||
module.exports = { | ||
methodology: "BMX liquidity is calculated by the value of tokens in the BLT pool.", | ||
methodology: "BMX Classic liquidity is calculated by the value of tokens in the BLT/MLT pool. TVL also includes BMX staked.", | ||
base: { | ||
tvl: gmxExports({ vault: vaultAddress }) | ||
tvl: gmxExports({ vault: vaultAddresses.base }), | ||
staking: staking(stakingAddresses.base, tokenAddresses.base) | ||
}, | ||
mode: { | ||
tvl: gmxExports({ vault: vaultAddresses.mode }), | ||
staking: staking(stakingAddresses.mode, tokenAddresses.mode) | ||
} | ||
}; |
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,46 @@ | ||
const ADDRESSES = require('../helper/coreAssets.json') | ||
const { request, } = require("graphql-request"); | ||
|
||
const freestyleConfig = { | ||
base: { | ||
token: ADDRESSES.base.USDC, | ||
start: 1700006400, | ||
graphUrl: "https://api.studio.thegraph.com/query/62454/analytics_base_8_2/version/latest", | ||
accountSource: '0x6D63921D8203044f6AbaD8F346d3AEa9A2719dDD' | ||
}, | ||
} | ||
|
||
async function tvl(api) { | ||
const { token, graphUrl, start, accountSource } = freestyleConfig[api.chain] | ||
|
||
const query = ` | ||
query stats($from: String!, $to: String!) { | ||
dailyHistories( | ||
where: { | ||
timestamp_gte: $from | ||
timestamp_lte: $to | ||
accountSource: "${accountSource}" | ||
} | ||
) { | ||
timestamp | ||
platformFee | ||
accountSource | ||
tradeVolume | ||
deposit | ||
withdraw | ||
} | ||
} | ||
` | ||
const { dailyHistories } = await request(graphUrl, query, { | ||
from: start.toString(), | ||
to: api.timestamp.toString(), | ||
}); | ||
|
||
let total = dailyHistories.reduce((acc, cur) => acc + (Number(cur.deposit) - Number(cur.withdraw)), 0); | ||
|
||
api.add(token, total) | ||
} | ||
|
||
Object.keys(freestyleConfig).forEach(chain => { | ||
module.exports[chain] = { tvl } | ||
}) |