Skip to content

Commit

Permalink
[UPDATE] BMX by Morphex: Add TVL tracking for staking and Mode networ…
Browse files Browse the repository at this point in the history
…k; Add tracking for Freestyle on Base (#11041)

* Add Mode, staking, and add Freestyle separately

* Update index.js
  • Loading branch information
daedboi authored Jul 19, 2024
1 parent 9f1af43 commit 2e60b7e
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 4 deletions.
23 changes: 19 additions & 4 deletions projects/bmx/index.js
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)
}
};
46 changes: 46 additions & 0 deletions projects/freestyle/index.js
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 }
})

0 comments on commit 2e60b7e

Please sign in to comment.