From ebf4c9a401bd417e415acda717c667136cc6a7c4 Mon Sep 17 00:00:00 2001 From: kalax Date: Fri, 9 Aug 2024 11:19:14 +0800 Subject: [PATCH 1/3] add scroll chain --- projects/kalax/index.js | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/projects/kalax/index.js b/projects/kalax/index.js index ed945f180c71..739cf904c5cc 100644 --- a/projects/kalax/index.js +++ b/projects/kalax/index.js @@ -1,20 +1,44 @@ const { sumTokens2 } = require("../helper/unwrapLPs") -const KALAX = "0x2F67F59b3629Bf24962290DB9edE0CD4127e606D" -const farms = ['0xE63153C3360aCa0F4e7Ca7A1FC61c2215FAEF5A1', '0xFe899401A1d86cC1113020fb40878c76239142a5',"0x1CB8f6cecf7c8FBB9863417f8371Cb2A076C9115"] +const blastKalax = "0x2F67F59b3629Bf24962290DB9edE0CD4127e606D" +const blastfarms = ['0xE63153C3360aCa0F4e7Ca7A1FC61c2215FAEF5A1', '0xFe899401A1d86cC1113020fb40878c76239142a5',"0x1CB8f6cecf7c8FBB9863417f8371Cb2A076C9115"] +const scrollKalax = "0x1f4F171676f8cb3B1C3FD38867B3B160679F934A" +const scrollFarms = ['0xB99AeDd16714A7393768273F9AbFF4C4F48980eD'] async function tvl(api) { + let farms = api.chain === 'blast'?blastfarms:scrollFarms + let kalax = api.chain === 'blast'?blastKalax:scrollKalax + let pools = (await api.multiCall({ abi: abiInfo.poolInfos, calls: farms })).flat() pools - .filter((i) => i.assets !== KALAX) + .filter((i) => i.assets !== kalax) .forEach((i) => api.add(i.assets, i.tvl)) return sumTokens2({ api, resolveLP: true }) } + +const usdt = "0xf55BEC9cafDbE8730f096Aa55dad6D22d44099Df" +const scrollKalaLp = "0x4fc09BE6eB49764CcAE4e95Bd2B93f67a34c0188" async function staking(api) { + let farms = api.chain === 'blast'?blastfarms:scrollFarms + let kalax = api.chain === 'blast'?blastKalax:scrollKalax + let pools = (await api.multiCall({ abi: abiInfo.poolInfos, calls: farms })).flat() - pools.filter((i) => i.assets === KALAX).forEach((i) => api.add(i.assets, i.tvl)) + if(api.chain === 'blast'){ + pools.filter((i) => i.assets === kalax).forEach((i) => api.add(i.assets, i.tvl)) + }else{ + let pool = pools.find(i=>i.assets === kalax) + let poolTvl = pool.tvl + let sqrtPriceX96 =await api.call({ + abi:abiInfo.state, + target:scrollKalaLp + }) + let p = (sqrtPriceX96 / 2 ** 96) ** 2 + let rate = p * 10**12 + let usdtNum = poolTvl/10**18 * rate + api.add(usdt,usdtNum*10**6) + } } module.exports = { @@ -22,9 +46,15 @@ module.exports = { tvl, staking, }, + scroll:{ + tvl, + staking + } } const abiInfo = { poolInfos: "function getPoolTotalTvl() view returns (tuple(uint256 pid, address assets, uint256 tvl)[])", + state: + "function state()external view returns(uint160 sqrtPrice_96)" } From 68c79b5b5b745b4032e44b0807f20954f4589932 Mon Sep 17 00:00:00 2001 From: kalax Date: Fri, 9 Aug 2024 11:28:18 +0800 Subject: [PATCH 2/3] add scroll chain --- projects/kalax/index.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/projects/kalax/index.js b/projects/kalax/index.js index 739cf904c5cc..cd9100f6bfa3 100644 --- a/projects/kalax/index.js +++ b/projects/kalax/index.js @@ -10,9 +10,20 @@ async function tvl(api) { let kalax = api.chain === 'blast'?blastKalax:scrollKalax let pools = (await api.multiCall({ abi: abiInfo.poolInfos, calls: farms })).flat() - pools + if(api.chain === 'blast'){ + pools + .filter((i) => i.assets !== kalax) + .forEach((i) => api.add(i.assets, i.tvl)) + }else{ + pools .filter((i) => i.assets !== kalax) - .forEach((i) => api.add(i.assets, i.tvl)) + .forEach((i)=>{ + if(i.assets === '0x0000000000000000000000000000000000000001'){ + i.assets ='0x0000000000000000000000000000000000000000' + } + api.add(i.assets, i.tvl) + }) + } return sumTokens2({ api, resolveLP: true }) } From 09d73da738411476bf497cd7db86d40adf420b88 Mon Sep 17 00:00:00 2001 From: kalax Date: Fri, 9 Aug 2024 11:31:59 +0800 Subject: [PATCH 3/3] add scroll chain --- projects/kalax/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/kalax/index.js b/projects/kalax/index.js index cd9100f6bfa3..49a4905a40c5 100644 --- a/projects/kalax/index.js +++ b/projects/kalax/index.js @@ -47,8 +47,8 @@ async function staking(api) { }) let p = (sqrtPriceX96 / 2 ** 96) ** 2 let rate = p * 10**12 - let usdtNum = poolTvl/10**18 * rate - api.add(usdt,usdtNum*10**6) + let usdtNum = poolTvl/10**18 * rate * 10**6 + api.add(usdt,usdtNum) } }