From 914d067cb235fc58762f98fbbc76c87f7af24d70 Mon Sep 17 00:00:00 2001 From: CronosLabsDev <106642922+CronosLabsDev@users.noreply.github.com> Date: Thu, 26 Sep 2024 10:04:15 +0200 Subject: [PATCH 1/2] fix: venofinance tvl --- projects/venofinance/index.js | 41 +++++++++++++++-------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/projects/venofinance/index.js b/projects/venofinance/index.js index 16765dd6a7..aed4c19234 100644 --- a/projects/venofinance/index.js +++ b/projects/venofinance/index.js @@ -1,13 +1,13 @@ const { staking } = require("../helper/staking.js"); +const sdk = require('@defillama/sdk') const fountain_contract_address = "0xb4be51216f4926ab09ddf4e64bc20f499fd6ca95"; const reservoir_contract_address = "0x21179329c1dcfd36ffe0862cca2c7e85538cca07"; const vno_contract_address = "0xdb7d0a1ec37de1de924f8e8adac6ed338d4404e9"; const zkCRO_contract_address = "0x28Ff2E4dD1B58efEB0fC138602A28D5aE81e44e2"; -const ybETH_contract_address = "0x76bf2D1e6dFda645c0c17440B17Eccc181dfC351"; -const ybUSD_contract_address = "0xFA59075DfCE274E028b58BdDFcC3D709960F594a"; const vETH_contract_address = "0x271602A97027ee1dd03b1E6e5dB153eB659A80b1"; const vUSD_contract_address = "0x5b91e29Ae5A71d9052620Acb813d5aC25eC7a4A2"; +const lcro_contract_address = "0x9fae23a2700feecd5b93e43fdbc03c76aa7c08a6" async function tvlCronos(api) { @@ -30,24 +30,24 @@ async function tvlEra(api) { return api.getBalances() } -async function tvlEthereum(api) { - const cro_pooled = await api.call({ abi: "uint256:totalPooledCro", target: zkCRO_contract_address }); - api.addCGToken('crypto-com-chain', cro_pooled / 1e8); - const eth_pooled = await api.call({ abi: "uint256:totalPooledEth", target: ybETH_contract_address }); - api.addCGToken('ethereum', eth_pooled / 1e18); - const usd_pooled = await api.call({ abi: "uint256:totalUsdValue", target: ybUSD_contract_address }); - api.addCGToken('dai', usd_pooled / 1e18); - return api.getBalances(); -} +async function tvlCronosZkEVM(zkEvmApi) { + const totalVEth = await zkEvmApi.call({ abi: "uint256:ybEthValue", target: vETH_contract_address }); + zkEvmApi.addCGToken('ethereum', totalVEth / 1e18); + const totalVUsd = await zkEvmApi.call({ abi: "uint256:ybUsdValue", target: vUSD_contract_address }); + zkEvmApi.addCGToken('dai', totalVUsd / 1e18); -async function tvlCronosZkEVM(api) { - const totalVEth = await api.call({ abi: "uint256:ybEthValue", target: vETH_contract_address }); - api.addCGToken('ethereum', totalVEth / 1e18); - const totalVUsd = await api.call({ abi: "uint256:ybUsdValue", target: vUSD_contract_address }); - api.addCGToken('dai', totalVUsd / 1e18); + const ethApi = new sdk.ChainApi({ chain: 'ethereum' }); + const cro_pooled = await ethApi.call({ abi: "uint256:totalPooledCro", target: zkCRO_contract_address }); + const cronosApi = new sdk.ChainApi({ chain: 'cronos' }); + const totalLcro = await cronosApi.call({ + abi: 'function convertToShare(uint256 assets) view returns (uint256 shares)', + target: lcro_contract_address, + params: [cro_pooled] + }); - return api.getBalances(); + zkEvmApi.addCGToken('liquid-cro', totalLcro / 1e8); + return zkEvmApi.getBalances(); } module.exports = { @@ -62,10 +62,5 @@ module.exports = { era: { tvl: tvlEra, }, - ethereum: { - tvl: tvlEthereum, - }, - cronos_zkevm: { - tvl: tvlCronosZkEVM, - }, + cronos_zkevm: {tvl: tvlCronosZkEVM} }; From c259a12777bb0deda77e0ae129692bd100c97b44 Mon Sep 17 00:00:00 2001 From: CronosLabsDev <106642922+CronosLabsDev@users.noreply.github.com> Date: Fri, 27 Sep 2024 11:47:59 +0200 Subject: [PATCH 2/2] get total zkCRO supply from Cronos zkEVM chain --- projects/venofinance/index.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/projects/venofinance/index.js b/projects/venofinance/index.js index aed4c19234..4e875ec89a 100644 --- a/projects/venofinance/index.js +++ b/projects/venofinance/index.js @@ -8,6 +8,7 @@ const zkCRO_contract_address = "0x28Ff2E4dD1B58efEB0fC138602A28D5aE81e44e2"; const vETH_contract_address = "0x271602A97027ee1dd03b1E6e5dB153eB659A80b1"; const vUSD_contract_address = "0x5b91e29Ae5A71d9052620Acb813d5aC25eC7a4A2"; const lcro_contract_address = "0x9fae23a2700feecd5b93e43fdbc03c76aa7c08a6" +const l2_base_token_address = "0x000000000000000000000000000000000000800a" async function tvlCronos(api) { @@ -32,18 +33,24 @@ async function tvlEra(api) { async function tvlCronosZkEVM(zkEvmApi) { + const ethApi = new sdk.ChainApi({ chain: 'ethereum' }); + const cronosApi = new sdk.ChainApi({ chain: 'cronos' }); + const totalVEth = await zkEvmApi.call({ abi: "uint256:ybEthValue", target: vETH_contract_address }); zkEvmApi.addCGToken('ethereum', totalVEth / 1e18); const totalVUsd = await zkEvmApi.call({ abi: "uint256:ybUsdValue", target: vUSD_contract_address }); zkEvmApi.addCGToken('dai', totalVUsd / 1e18); - const ethApi = new sdk.ChainApi({ chain: 'ethereum' }); - const cro_pooled = await ethApi.call({ abi: "uint256:totalPooledCro", target: zkCRO_contract_address }); - const cronosApi = new sdk.ChainApi({ chain: 'cronos' }); + const totalZkCro = await zkEvmApi.call({ abi: "uint256:totalSupply", target: l2_base_token_address }); + const croOfZkCroContract = await ethApi.call({ + abi: 'function convertToAsset(uint256 shares) view returns (uint256 assets)', + target: zkCRO_contract_address, + params: [`${totalZkCro}`] + }); const totalLcro = await cronosApi.call({ abi: 'function convertToShare(uint256 assets) view returns (uint256 shares)', target: lcro_contract_address, - params: [cro_pooled] + params: [croOfZkCroContract] }); zkEvmApi.addCGToken('liquid-cro', totalLcro / 1e8);