From fb0730e82b095f6e93ebdd33b8a033c70701f8ff Mon Sep 17 00:00:00 2001 From: daedboi <87483308+daedboi@users.noreply.github.com> Date: Thu, 18 Jul 2024 19:58:37 +0300 Subject: [PATCH 1/2] Add Mode, staking, and add Freestyle separately --- projects/bmx/index.js | 23 +++++++++++++++---- projects/freestyle/index.js | 46 +++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 4 deletions(-) create mode 100644 projects/freestyle/index.js diff --git a/projects/bmx/index.js b/projects/bmx/index.js index 3be3d0e836..3885387b72 100644 --- a/projects/bmx/index.js +++ b/projects/bmx/index.js @@ -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. BMX Freestyle TVL is calculated by the value of USDC deposited for trading. 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) + } }; diff --git a/projects/freestyle/index.js b/projects/freestyle/index.js new file mode 100644 index 0000000000..4aadb02a6e --- /dev/null +++ b/projects/freestyle/index.js @@ -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 } +}) \ No newline at end of file From 1d4d228a539f628407e33a79c7ca1f3a66a1d9f9 Mon Sep 17 00:00:00 2001 From: daedboi <87483308+daedboi@users.noreply.github.com> Date: Thu, 18 Jul 2024 20:02:37 +0300 Subject: [PATCH 2/2] Update index.js --- projects/bmx/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/bmx/index.js b/projects/bmx/index.js index 3885387b72..727c569a47 100644 --- a/projects/bmx/index.js +++ b/projects/bmx/index.js @@ -15,7 +15,7 @@ const tokenAddresses = { }; module.exports = { - methodology: "BMX Classic liquidity is calculated by the value of tokens in the BLT/MLT pool. BMX Freestyle TVL is calculated by the value of USDC deposited for trading. TVL also includes BMX staked.", + 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: vaultAddresses.base }), staking: staking(stakingAddresses.base, tokenAddresses.base)