Skip to content

Commit 2047f36

Browse files
committed
sophon
1 parent 8d61b5e commit 2047f36

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

projects/sophon-bridge/index.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const { sumTokens2 } = require("../helper/unwrapLPs");
2+
3+
const target = "0xD7f9f54194C633F36CCD5F3da84ad4a1c38cB2cB"
4+
const gasQuery = '0x0000000000000000000000000000000000000001'
5+
const gasAddress = '0x0000000000000000000000000000000000000000'
6+
const chainId = 50104
7+
8+
module.exports = {
9+
ethereum: {
10+
tvl: async (api) => {
11+
const totalBalances = await sumTokens2({
12+
api,
13+
owner: target,
14+
fetchCoValentTokens: true,
15+
})
16+
const balances = await api.multiCall({
17+
calls: [gasQuery, ...Object.keys(totalBalances)].map(token => ({
18+
target, params: [chainId, token.substring(token.indexOf(':') + 1)]
19+
})),
20+
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" },
21+
permitFailure: true,
22+
withMetadata: true
23+
})
24+
api._balances._balances = {}
25+
balances.map(call => {
26+
const token = call.input.params[1]
27+
api.add(token == gasQuery ? gasAddress : token, call.output)
28+
})
29+
}
30+
},
31+
};

0 commit comments

Comments
 (0)