Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add new chain #11243

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 47 additions & 6 deletions projects/kalax/index.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,71 @@
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)
.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{
pools
.filter((i) => i.assets !== kalax)
.forEach((i)=>{
if(i.assets === '0x0000000000000000000000000000000000000001'){
i.assets ='0x0000000000000000000000000000000000000000'
}
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 * 10**6
api.add(usdt,usdtNum)
}
}

module.exports = {
blast: {
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)"
}
Loading