Skip to content

Commit

Permalink
Merge branch 'DefiLlama:main' into linea-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
0xChupaCabra authored Jul 20, 2024
2 parents 088ab19 + 05cd12a commit 3b6f72a
Show file tree
Hide file tree
Showing 23 changed files with 234 additions and 150 deletions.
3 changes: 1 addition & 2 deletions projects/DropCopy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ const { sumTokens2 } = require('../helper/solana')

const DROP = 'DropTpWcDmP7kVRUEoKSJaMVi62hGo9jp19Hz19JVsjh';
const PARIMUTUEL_WALLET = 'DCa1Xir4zDEtz78beFcXCHUNXdeBnrxBiRuuapHrBE3F';
const PARIMUTUEL_ACCOUNT = 'mD62sAqPAiVbHGPTTeEianTYa1AytkKqqcxMvQxF3S3';

async function tvl() {
return sumTokens2({ owner: PARIMUTUEL_WALLET, getAllTokenAccounts: true, solOwners: [PARIMUTUEL_WALLET], blacklistedTokens: [DROP]})
return sumTokens2({ owner: PARIMUTUEL_WALLET, solOwners: [PARIMUTUEL_WALLET], blacklistedTokens: [DROP]})
}

module.exports = {
Expand Down
2 changes: 1 addition & 1 deletion projects/apricot.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { sumTokens2 } = require('./helper/solana')

async function tvl() {
const owner = '7Ne6h2w3LpTNTa7CNYcUs7UkjeJT3oW7jcrXWfVScTXW'
return sumTokens2({ owner, getAllTokenAccounts: true })
return sumTokens2({ owner })
}

module.exports = {
Expand Down
2 changes: 1 addition & 1 deletion projects/atrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { sumTokens2, getConnection , getProvider} = require('./helper/solana')

async function tvl() {
// previously we were incorrectly counting all tokens in serum pools as atrix tvl
return sumTokens2({ owner: '3uTzTX5GBSfbW7eM9R9k95H7Txe32Qw3Z25MtyD2dzwC', getAllTokenAccounts: true, })
return sumTokens2({ owner: '3uTzTX5GBSfbW7eM9R9k95H7Txe32Qw3Z25MtyD2dzwC', })
/* const connection = getConnection()
const provider = getProvider()
const program = new Program(idl, 'HvwYjjzPbXWpykgVZhqvvfeeaSraQVnTiQibofaFw9M7', provider)
Expand Down
2 changes: 1 addition & 1 deletion projects/cropper.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { PublicKey } = require('@solana/web3.js')
const DEX_PROGRAM_ID = 'CTMAxxk34HjKWxQ3QLZK1HpaLXmBveao3ESePXbiyfzh'

async function fetchStaking() {
return sumTokens2({ owners: ['5mEH7a7abQwUEXqfusVepc3z9cHVQg8uhqTXdq47J91o'], getAllTokenAccounts: true });
return sumTokens2({ owners: ['5mEH7a7abQwUEXqfusVepc3z9cHVQg8uhqTXdq47J91o'] });
}

async function getTokenAccounts() {
Expand Down
44 changes: 7 additions & 37 deletions projects/drift.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
const { PublicKey } = require("@solana/web3.js");
const anchor = require("@project-serum/anchor");
const { sumTokens2, } = require("./helper/solana");
const DRIFT_PROGRAM_ID = new PublicKey('dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH')
const { getConfig } = require('./helper/cache')

module.exports = {
timetravel: false,
Expand All @@ -12,37 +8,11 @@ module.exports = {
},
};

async function tvl(api) {

const legacyVaults = [
'6W9yiHDCW9EpropkFV8R3rPiL8LVWUHSiys3YeW6AT6S', // legacy usdc vault
'Bzjkrm1bFwVXUaV9HTnwxFrPtNso7dnwPQamhqSxtuhZ', // legacy usdc insurance fund
];
const getSpotMarketVaultPublicKey = marketIndex => getVaultPublicKey('spot_market_vault', marketIndex)
const getInsuranceFundVaultPublicKey = marketIndex => getVaultPublicKey('insurance_fund_vault', marketIndex)
let configFile = await getConfig('drift-config', 'https://raw.githubusercontent.com/drift-labs/protocol-v2/master/sdk/src/constants/spotMarkets.ts')
const marketIndices = [];
configFile = configFile.slice(configFile.indexOf('MainnetSpotMarkets:'))

const regex = /marketIndex:\s*(\d+),/g
let match;
while ((match = regex.exec(configFile))) {
marketIndices.push(parseInt(match[1]));
}

const vaults = [
...legacyVaults,
...marketIndices.map(getSpotMarketVaultPublicKey),
...marketIndices.map(getInsuranceFundVaultPublicKey),
]

return sumTokens2({ tokenAccounts: vaults })
}

function getVaultPublicKey(seed, marketIndex) {
return PublicKey.findProgramAddressSync(
[
Buffer.from(anchor.utils.bytes.utf8.encode(seed)),
new anchor.BN(marketIndex).toArrayLike(Buffer, 'le', 2),
], DRIFT_PROGRAM_ID)[0].toBase58()
async function tvl() {
return sumTokens2({
owners: [
'CU4eFxpyCGNDEXN27Jonn7RfgwBt3cnp7TcTrJF6EW9Q', // legacy
'JCNCMFXo5M5qwUPg2Utu1u6YWp3MbygxqBsBeXXJfrw', // Drift vault
],
})
}
2 changes: 1 addition & 1 deletion projects/flashtrade/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { sumTokens2 } = require("../helper/solana");

async function tvl() {
return sumTokens2({ owner: '81xGAvJ27ZeRThU2JEfKAUeT4Fx6qCCd8WHZpujZbiiG', getAllTokenAccounts: true, });
return sumTokens2({ owner: '81xGAvJ27ZeRThU2JEfKAUeT4Fx6qCCd8WHZpujZbiiG', });
}

module.exports = {
Expand Down
8 changes: 7 additions & 1 deletion projects/fyde/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const ADDRESSES = require('../helper/coreAssets.json')

const FYDE_CONTRACT = "0x87Cc45fFF5c0933bb6aF6bAe7Fc013b7eC7df2Ee";
const RESTAKING_AGGREGATOR = "0x3f69F62e25441Cf72E362508f4d6711d53B05341";
const DEPOSIT_ESCROW = "0x63ec950633Eb85797477166084AD0a7121910470";
const ORACLE = "0x05198327206123E89c24ABd9A482316449bD2aEe"
const WETH = ADDRESSES.ethereum.WETH;

Expand Down Expand Up @@ -33,10 +35,14 @@ async function tvl(api) {
} else
api.add(tokens[i], bals[i])
}

// add assets in the deposit escrow
const tokensEscrow = await api.fetchList({ lengthAbi: 'getAssetListLength', itemAbi: 'assetList', target: DEPOSIT_ESCROW })
return api.sumTokens({ tokens: tokensEscrow, owner: DEPOSIT_ESCROW })
}

module.exports = {
methodology: 'Read out balances from internal accounting for each asset in Fyde in the YieldModule. Add ETH staked in LRT Aggregator.',
methodology: 'Read out balances from internal accounting for each asset in Fyde, the YieldModule and the DepositEscrow. Add ETH staked in LRT Aggregator.',
ethereum: {
tvl
}
Expand Down
11 changes: 4 additions & 7 deletions projects/goblingold.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const { getProvider, transformBalances, } = require('./helper/solana')
const sdk = require('@defillama/sdk')
const { getProvider, } = require('./helper/solana')
const { Program, } = require("@project-serum/anchor");
const vaults = {
"BTC": "FvqYV2Cg7s7iWKUBTWkyybKuz1m85ny6ijDqDXEXVyNv",
Expand All @@ -17,16 +16,14 @@ const vaults = {
"stSOL": "47hnvWxWo4PpPNqPF78cJ4abjpT45qY9of8hokeLzEUX"
}

async function tvl() {
async function tvl(api) {

const provider = getProvider()
const programId = 'GGo1dnYpjKfe9omzUaFtaCyizvwpAMf3NhxSCMD61F3A'
const idl = await Program.fetchIdl(programId, provider)
const program = new Program(idl, programId, provider)
const data = await program.account.vaultAccount.fetchMultiple(Object.values(vaults))
const tokenBalances = {}
data.forEach((i, idx) =>
sdk.util.sumSingleBalance(tokenBalances, i.inputMintPubkey.toString(), +i.currentTvl))
return transformBalances({ tokenBalances })
data.forEach(i => api.add(i.inputMintPubkey.toString(), i.currentTvl))
}

module.exports = {
Expand Down
3 changes: 1 addition & 2 deletions projects/helper/solana.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,13 @@ async function sumTokens2({
solOwners = [],
blacklistedTokens = [],
allowError = false,
getAllTokenAccounts = false,
}) {
blacklistedTokens.push(...blacklistedTokens_default)
if (!tokensAndOwners.length) {
if (owner) tokensAndOwners = tokens.map(t => [t, owner])
if (owners.length) tokensAndOwners = tokens.map(t => owners.map(o => [t, o])).flat()
}
if (!tokensAndOwners.length && !tokens.length && (owner || owners.length > 0) && getAllTokenAccounts) {
if (!tokensAndOwners.length && !tokens.length && (owner || owners.length > 0)) {
const _owners = getUniqueAddresses([...owners, owner].filter(i => i), 'solana')
for (const _owner of _owners) {
const data = await getOwnerAllAccount(_owner)
Expand Down
1 change: 0 additions & 1 deletion projects/helper/treasury.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ function treasuryExports(config) {
const tvlConfig = { permitFailure: true, ...config[chain], }
if (chain === 'solana') {
tvlConfig.solOwners = owners
tvlConfig.getAllTokenAccounts = true
} else if (config[chain].fetchCoValentTokens !== false) {
if (ankrChainMapping[chain]) {
tvlConfig.fetchCoValentTokens = true
Expand Down
2 changes: 1 addition & 1 deletion projects/invariant/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { sumTokens2 } = require('../helper/solana')

async function tvl() {
return sumTokens2({ owner: 'J4uBbeoWpZE8fH58PM1Fp9n9K6f1aThyeVCyRdJbaXqt', getAllTokenAccounts: true })
return sumTokens2({ owner: 'J4uBbeoWpZE8fH58PM1Fp9n9K6f1aThyeVCyRdJbaXqt' })
}

module.exports = {
Expand Down
2 changes: 1 addition & 1 deletion projects/invictus/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ async function staking() {

const treasury = "6qfyGvoUqGB6AQ7xLc4pVwFNdgJSbAMkTtKkBXhLRiV1"
async function tvl() {
return sumTokens2({ owner: treasury, getAllTokenAccounts: true })
return sumTokens2({ owner: treasury })
}


Expand Down
12 changes: 2 additions & 10 deletions projects/jupiter-perpetual.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@ module.exports = {
},
};

async function tvl(api) {
const vaults = [
"BUvduFTd2sWFagCunBPLupG8fBTJqweLw9DuhruNFSCm", // SOL
"WzWUoCmtVv7eqAbU3BfKPU3fhLP6CXR8NCJH78UK9VS", // USDC
"Gex24YznvguMad1mBzTQ7a64U1CJy59gvsStQmNnnwAd", // USDT
"Bgarxg65CEjN3kosjCW5Du3wEqvV3dpCGDR3a2HRQsYJ", // ETH
"FgpXg2J3TzSs7w3WGYYE7aWePdrxBVLCXSxmAKnCZNtZ", // BTC
];

return sumTokens2({ tokenAccounts: vaults });
async function tvl() {
return sumTokens2({ owner: 'AVzP2GeRmqGphJsMxWoqjpUifPpCret7LqWhD8NWQK49' });
}
6 changes: 3 additions & 3 deletions projects/larix.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { getConnection, sumTokens2, decodeAccount, } = require("./helper/solana");
const { getConnection, decodeAccount, } = require("./helper/solana");
const { PublicKey, } = require("@solana/web3.js");
const sdk = require('@defillama/sdk');
let programs = {
Expand Down Expand Up @@ -34,11 +34,11 @@ async function getAllData() {
}

const tokenAccounts = []
data.forEach(({ liquidity: { mintPubkey, borrowedAmountWads, supplyPubkey } }) => {
data.forEach(({ liquidity: { mintPubkey, borrowedAmountWads, supplyPubkey, availableAmount, } }) => {
tokenAccounts.push(supplyPubkey)
sdk.util.sumSingleBalance(balances.tvl, mintPubkey.toString(), availableAmount, 'solana')
sdk.util.sumSingleBalance(balances.borrowed, mintPubkey.toString(), borrowedAmountWads / 1e18, 'solana')
})
balances.tvl = await sumTokens2({ tokenAccounts })
return balances
}
}
Expand Down
18 changes: 14 additions & 4 deletions projects/limitless/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ const config = {
linea: { postionManager: '0x726e3116AE07f43A7E1921c635352B75e2DEa4Ad', factory: '0x31FAfd4889FA1269F7a13A66eE0fB458f27D72A9', limWETH: '0x5188b47Cb80D1A3E22Cc6221792F199f1Fb0DD3c', },
}
const liquidityProvidedQuery = `
query {
liquidityProvideds(first:1000 orderBy: blockTimestamp orderDirection: desc) {
query($lastId: String, $block: Int) {
liquidityProvideds(
first:1000
block: { number: $block }
where: { id_gt: $lastId }
) {
id
pool
recipient
liquidity
Expand All @@ -22,8 +27,13 @@ query {
`

const liquidityWithdrawnQuery = `
query {
liquidityWithdrawns(first:1000 orderBy: blockTimestamp orderDirection: desc) {
query($lastId: String, $block: Int) {
liquidityWithdrawns(
first:1000
block: { number: $block }
where: { id_gt: $lastId }
) {
id
pool
recipient
liquidity
Expand Down
2 changes: 1 addition & 1 deletion projects/oxygen/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { sumTokens2 } = require('../helper/solana')


async function tvl(api) {
return sumTokens2({ owner: '4ncyWnbG22vqEmyxTfBsEdbNuQhBphaasg5q5YgoiPgq', getAllTokenAccounts: true})
return sumTokens2({ owner: '4ncyWnbG22vqEmyxTfBsEdbNuQhBphaasg5q5YgoiPgq'})
}

module.exports = {
Expand Down
18 changes: 18 additions & 0 deletions projects/phoenix-hub/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const utils = require("../helper/utils");
const {toUSDTBalances} = require("../helper/balances");

async function tvl() {
// Fetch all tickers
const tickers = await utils.fetchURL("https://api-phoenix.decentrio.ventures/tickers");

// Sum up the tvl
const totalTVL = tickers.data.reduce((acc, t) => acc + t.liquidity_in_usd, 0);
return toUSDTBalances(totalTVL);
}

module.exports = {
methodology: 'counts the liquidity on all Phoenix Hub AMM Pools.',
stellar: {
tvl,
}
};
2 changes: 1 addition & 1 deletion projects/portfinance/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ async function tvl() {
'8x2uay8UgrLiX8AAYyF6AkK9z91nNtN6aLwfqPkf6TAQ', // Main Pool
'GU1nCjN7mcLiSX1dtBw2t9agYCw3ybXfu1me41Q2tGT3', // Hubble Innovation Zone
'Hy6gCkJyMmWMaoxLyzELRReLzdBdZ1YEjNGjQzF9LDPa', // UXD Innovation Zone
], getAllTokenAccounts: true, })
], })
}

module.exports = {
Expand Down
61 changes: 61 additions & 0 deletions projects/probit/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
const { cexExports } = require('../helper/cex')

const config = {
ethereum: {
owners: [
"0x72e5263ff33d2494692d7f94a758aa9f82062f73",
"0xaD285fDEDFC0D5f944A33e478356524293c7eC68",
"0xf71afe21cd32959113fc47ae2ef886b43a9413d5"
],
},
bsc: {
owners: [
"0xd6a4452eebde830888cee4a395126831ab16250c",
"0xf4be044ba7461d8444ed53f9ec7490781e08e3b7",
"0x898fce2414a1347c0e12bde6b28b75843fd9bbad"
],
},
bitcoin: {
owners: [
"19EgVpboqNjortWyhJSDAGRvHDtduqiSfr",
"19AtrEvJv7UY75tvWkXMxLUAYibxpZhFfN",
"17PpCEuQUT7xxP1ocfhvFdwQyrB5dG1dQP"
],
},
fantom: {
owners: [
"0xc78600a92caf0fcf6990e7ea7381bf4297054f86",
"0x06ffd89a07b078d4a1a1d9947a28e95825f9c35c",
"0x813e711993fc8ec29e9e45fb3a7e47f8c33ca64f"
],
},
polygon: {
owners: [
"0xfaef9cc9bf46c386c58a3e86ffffbf77969ca149",
"0x29b6e9abf51fc7d4581f6cbd1a9d5392fa7fa78f",
"0xdba24f19bce0f32ea4273faea7c01d7f9d4f91d6"
],
},
tron: {
owners: [
"TPkn5zpxXr8jaNqvgVoFanTsvXCbNXJ8GB",
"TGEwJxVErWagXnriZATPMBFFbbeuad9m3h",
"TYiFSQG4dfdWh8RWETsvJn4fvXdZ8bEL7t"
],
},
ripple: {
owners: [
"rwXEHNNuf3nctzXLtvL5JnQJGMyUZYGrVc",
"rsA9ijHjo7hAkitc9GsXsiwXzqGs7eoeqr",
"rEa9cAYavjfxvmdJExr1PMGxoPYzAUZXGb"
],
},
solana: {
owners: [
"BX145kKanqBmeud72ir44iMFVAfaak4y933rgbMc2H52",
"FavWP1KXVVNZLTYjfSBWPanxbVeCW4A3pJ96hn2GRWGR",
],
},
}

module.exports = cexExports(config)
Loading

0 comments on commit 3b6f72a

Please sign in to comment.