From 2047f364827e87354d00d2e264934e41cd136eec Mon Sep 17 00:00:00 2001 From: waynebruce0x Date: Thu, 9 Jan 2025 12:57:48 +0000 Subject: [PATCH 1/3] sophon --- projects/sophon-bridge/index.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 projects/sophon-bridge/index.js diff --git a/projects/sophon-bridge/index.js b/projects/sophon-bridge/index.js new file mode 100644 index 0000000000..8e73b8c5b7 --- /dev/null +++ b/projects/sophon-bridge/index.js @@ -0,0 +1,31 @@ +const { sumTokens2 } = require("../helper/unwrapLPs"); + +const target = "0xD7f9f54194C633F36CCD5F3da84ad4a1c38cB2cB" +const gasQuery = '0x0000000000000000000000000000000000000001' +const gasAddress = '0x0000000000000000000000000000000000000000' +const chainId = 50104 + +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) + }) + } + }, +}; From 2159984a694d463971f500bd19eb8fb72d3c83cd Mon Sep 17 00:00:00 2001 From: waynebruce0x Date: Fri, 10 Jan 2025 08:17:53 +0000 Subject: [PATCH 2/3] swapx --- projects/SwapX-v2/index.js | 44 +++----------------------------------- 1 file changed, 3 insertions(+), 41 deletions(-) diff --git a/projects/SwapX-v2/index.js b/projects/SwapX-v2/index.js index a01635704a..54438ef295 100644 --- a/projects/SwapX-v2/index.js +++ b/projects/SwapX-v2/index.js @@ -1,47 +1,9 @@ -const { transformDexBalances } = require("../helper/portedTokens"); -const { getLogs } = require("../helper/cache/getLogs"); - -const SWAPX_V2_FACTORY = "0x05c1be79d3aC21Cc4B727eeD58C9B2fF757F5663" -const PAIR_CREATED_TOPIC_1 = "0xc4805696c66d7cf352fc1d6bb633ad5ee82f6cb577c453024b6e0eb8306c6fc9"; // keccak256 hash of the event signature -const PAIR_CREATED_EVENT_ABI_1 = "event PairCreated(address indexed token0, address indexed token1, bool stable, address pair, uint)"; -const fromBlock = 1333667; -const erc20Abi = "erc20:balanceOf"; - -async function tvl(api) { - const getPairs = (logs) => { - return logs.map(log => ({ - token0: log.token0, - token1: log.token1, - pair: log.pair - })); - } - - const logs = getPairs(await getLogs({ - api, - target: SWAPX_V2_FACTORY, - fromBlock, - topic: PAIR_CREATED_TOPIC_1, - onlyArgs: true, - eventAbi: PAIR_CREATED_EVENT_ABI_1 - })); - - const tok0Bals = await api.multiCall({ abi: erc20Abi, calls: logs.map(log => ({ target: log.token0, params: log.pair })) }) - const tok1Bals = await api.multiCall({ abi: erc20Abi, calls: logs.map(log => ({ target: log.token1, params: log.pair })) }) - - return transformDexBalances({ - chain: api.chain, - data: logs.map((log, i) => ({ - token0: log.token0, - token0Bal: tok0Bals[i], - token1: log.token1, - token1Bal: tok1Bals[i], - })) - }) -} +const { uniTvlExport } = require("../helper/calculateUniTvl"); module.exports = { misrepresentedTokens: true, sonic: { - tvl + tvl: uniTvlExport("0x05c1be79d3aC21Cc4B727eeD58C9B2fF757F5663", undefined, undefined, { + }, { useDefaultCoreAssets: true, hasStablePools: true, }), } }; From 96b527d72742e8d5c023e57f956d0c141007c943 Mon Sep 17 00:00:00 2001 From: waynebruce0x Date: Fri, 10 Jan 2025 08:18:34 +0000 Subject: [PATCH 3/3] revert sophon --- projects/sophon-bridge/index.js | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 projects/sophon-bridge/index.js diff --git a/projects/sophon-bridge/index.js b/projects/sophon-bridge/index.js deleted file mode 100644 index 8e73b8c5b7..0000000000 --- a/projects/sophon-bridge/index.js +++ /dev/null @@ -1,31 +0,0 @@ -const { sumTokens2 } = require("../helper/unwrapLPs"); - -const target = "0xD7f9f54194C633F36CCD5F3da84ad4a1c38cB2cB" -const gasQuery = '0x0000000000000000000000000000000000000001' -const gasAddress = '0x0000000000000000000000000000000000000000' -const chainId = 50104 - -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) - }) - } - }, -};