Skip to content

Commit

Permalink
cronos zk bridge
Browse files Browse the repository at this point in the history
  • Loading branch information
waynebruce0x committed Dec 24, 2024
1 parent a20e090 commit f14256a
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 8 deletions.
31 changes: 31 additions & 0 deletions projects/cronos-zk/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const { sumTokens2 } = require("../helper/unwrapLPs");

const target = "0xD7f9f54194C633F36CCD5F3da84ad4a1c38cB2cB"
const gasQuery = '0x0000000000000000000000000000000000000001'
const gasAddress = '0x0000000000000000000000000000000000000000'
const chainId = 388

module.exports = {
ethereum: {
tvl: async (api) => {
const totalBalances = await sumTokens2({
api,
owner: target,
fetchCoValentTokens: true,
})
const balances = await api.multiCall({
calls: [gasQuery, ...Object.keys(totalBalances)].map(token => ({
target, params: [chainId, token.substring(token.indexOf(':') + 1)]
})),
abi: { "inputs": [{ "internalType": "uint256", "name": "chainId", "type": "uint256" }, { "internalType": "address", "name": "l1Token", "type": "address" }], "name": "chainBalance", "outputs": [{ "internalType": "uint256", "name": "balance", "type": "uint256" }], "stateMutability": "view", "type": "function" },
permitFailure: true,
withMetadata: true
})
api._balances._balances = {}
balances.map(call => {
const token = call.input.params[1]
api.add(token == gasQuery ? gasAddress : token, call.output)
})
}
},
};
31 changes: 23 additions & 8 deletions projects/txBridge/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
const { sumTokens2 } = require("../helper/unwrapLPs");

const target = "0xD7f9f54194C633F36CCD5F3da84ad4a1c38cB2cB"
const gasQuery = '0x0000000000000000000000000000000000000001'
const gasAddress = '0x0000000000000000000000000000000000000000'
const chainId = 324

module.exports = {
ethereum: {
tvl: (api) =>
sumTokens2({
tvl: async (api) => {
const totalBalances = await sumTokens2({
api,
owners: [
"0x32400084C286CF3E17e7B677ea9583e60a000324",
"0x57891966931Eb4Bb6FB81430E6cE0A03AAbDe063",
"0xD7f9f54194C633F36CCD5F3da84ad4a1c38cB2cB"
],
owner: target,
fetchCoValentTokens: true,
}),
})
const balances = await api.multiCall({
calls: [gasQuery, ...Object.keys(totalBalances)].map(token => ({
target, params: [chainId, token.substring(token.indexOf(':') + 1)]
})),
abi: { "inputs": [{ "internalType": "uint256", "name": "chainId", "type": "uint256" }, { "internalType": "address", "name": "l1Token", "type": "address" }], "name": "chainBalance", "outputs": [{ "internalType": "uint256", "name": "balance", "type": "uint256" }], "stateMutability": "view", "type": "function" },
permitFailure: true,
withMetadata: true
})
api._balances._balances = {}
balances.map(call => {
const token = call.input.params[1]
api.add(token == gasQuery ? gasAddress : token, call.output)
})
}
},
};

0 comments on commit f14256a

Please sign in to comment.