From c331745564bad5dfe41c9a950ea536febc2591cd Mon Sep 17 00:00:00 2001 From: ArmandLobster Date: Tue, 20 Aug 2024 11:51:56 +0200 Subject: [PATCH 1/6] Create index.js --- projects/lobster-protocol/index.js | 40 ++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 projects/lobster-protocol/index.js diff --git a/projects/lobster-protocol/index.js b/projects/lobster-protocol/index.js new file mode 100644 index 000000000000..d7853b8025a9 --- /dev/null +++ b/projects/lobster-protocol/index.js @@ -0,0 +1,40 @@ +const { DHEDGE_FACTORY_ABI, LOBSTER_POOL_ABI } = require("./abis"); +const { CONFIG_DATA } = require("./config"); + +async function tvl(api) { + const { chain, } = api + const { dhedgeFactory, lobsterManager } = CONFIG_DATA[chain]; + + const pools = await api.call({ + abi: DHEDGE_FACTORY_ABI, + target: dhedgeFactory, + params: [lobsterManager], + }); + + const poolSummaries = await api.multiCall({ + abi: LOBSTER_POOL_ABI, + calls: pools, + }); + + const totalValue = poolSummaries.reduce( + (acc, i) => acc + +i.totalFundValue, + 0 + ); + + return { + tether: totalValue / 1e18, + }; +} + +module.exports = { + misrepresentedTokens: true, + start: 1704067199, // Sunday 31 December 2023 23:59:59 + methodology: + "Aggregates total value of Lobster protocol vaults on Arbitrum", + arbitrum: { + tvl, + }, + hallmarks: [ + [171097151, "First Arbitrum Vault Release"], + ], +}; From fa2c44b41f675837b3d96c4833cd19845bcb9ab0 Mon Sep 17 00:00:00 2001 From: ArmandLobster Date: Tue, 20 Aug 2024 11:52:42 +0200 Subject: [PATCH 2/6] Create config.js --- ...cB\", } }; module.exports = { CONFIG_DATA, };" | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 "projects/lobster-protocol/config.jsconst CONFIG_DATA = { arbitrum: { dhedgeFactory: \"0xffFb5fB14606EB3a548C113026355020dDF27535\", lobsterManager: \"0x6EBb1B5Be9bc93858f71714eD03f67BF237473cB\", } }; module.exports = { CONFIG_DATA, };" diff --git "a/projects/lobster-protocol/config.jsconst CONFIG_DATA = { arbitrum: { dhedgeFactory: \"0xffFb5fB14606EB3a548C113026355020dDF27535\", lobsterManager: \"0x6EBb1B5Be9bc93858f71714eD03f67BF237473cB\", } }; module.exports = { CONFIG_DATA, };" "b/projects/lobster-protocol/config.jsconst CONFIG_DATA = { arbitrum: { dhedgeFactory: \"0xffFb5fB14606EB3a548C113026355020dDF27535\", lobsterManager: \"0x6EBb1B5Be9bc93858f71714eD03f67BF237473cB\", } }; module.exports = { CONFIG_DATA, };" new file mode 100644 index 000000000000..4738cea5f2d9 --- /dev/null +++ "b/projects/lobster-protocol/config.jsconst CONFIG_DATA = { arbitrum: { dhedgeFactory: \"0xffFb5fB14606EB3a548C113026355020dDF27535\", lobsterManager: \"0x6EBb1B5Be9bc93858f71714eD03f67BF237473cB\", } }; module.exports = { CONFIG_DATA, };" @@ -0,0 +1,10 @@ +const CONFIG_DATA = { + arbitrum: { + dhedgeFactory: "0xffFb5fB14606EB3a548C113026355020dDF27535", + lobsterManager: "0x6EBb1B5Be9bc93858f71714eD03f67BF237473cB", + } +}; + +module.exports = { + CONFIG_DATA, +}; From 0f0e1a5172adf9ecbb1e719ba684625c2b8501a3 Mon Sep 17 00:00:00 2001 From: ArmandLobster Date: Tue, 20 Aug 2024 11:54:21 +0200 Subject: [PATCH 3/6] Delete projects/lobster-protocol/config.js --- ...cB\", } }; module.exports = { CONFIG_DATA, };" | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 "projects/lobster-protocol/config.jsconst CONFIG_DATA = { arbitrum: { dhedgeFactory: \"0xffFb5fB14606EB3a548C113026355020dDF27535\", lobsterManager: \"0x6EBb1B5Be9bc93858f71714eD03f67BF237473cB\", } }; module.exports = { CONFIG_DATA, };" diff --git "a/projects/lobster-protocol/config.jsconst CONFIG_DATA = { arbitrum: { dhedgeFactory: \"0xffFb5fB14606EB3a548C113026355020dDF27535\", lobsterManager: \"0x6EBb1B5Be9bc93858f71714eD03f67BF237473cB\", } }; module.exports = { CONFIG_DATA, };" "b/projects/lobster-protocol/config.jsconst CONFIG_DATA = { arbitrum: { dhedgeFactory: \"0xffFb5fB14606EB3a548C113026355020dDF27535\", lobsterManager: \"0x6EBb1B5Be9bc93858f71714eD03f67BF237473cB\", } }; module.exports = { CONFIG_DATA, };" deleted file mode 100644 index 4738cea5f2d9..000000000000 --- "a/projects/lobster-protocol/config.jsconst CONFIG_DATA = { arbitrum: { dhedgeFactory: \"0xffFb5fB14606EB3a548C113026355020dDF27535\", lobsterManager: \"0x6EBb1B5Be9bc93858f71714eD03f67BF237473cB\", } }; module.exports = { CONFIG_DATA, };" +++ /dev/null @@ -1,10 +0,0 @@ -const CONFIG_DATA = { - arbitrum: { - dhedgeFactory: "0xffFb5fB14606EB3a548C113026355020dDF27535", - lobsterManager: "0x6EBb1B5Be9bc93858f71714eD03f67BF237473cB", - } -}; - -module.exports = { - CONFIG_DATA, -}; From d5c712c668aacbd7b70a37587aeaf998083ae10d Mon Sep 17 00:00:00 2001 From: ArmandLobster Date: Tue, 20 Aug 2024 11:54:38 +0200 Subject: [PATCH 4/6] Create config.js --- projects/lobster-protocol/config.js | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 projects/lobster-protocol/config.js diff --git a/projects/lobster-protocol/config.js b/projects/lobster-protocol/config.js new file mode 100644 index 000000000000..4738cea5f2d9 --- /dev/null +++ b/projects/lobster-protocol/config.js @@ -0,0 +1,10 @@ +const CONFIG_DATA = { + arbitrum: { + dhedgeFactory: "0xffFb5fB14606EB3a548C113026355020dDF27535", + lobsterManager: "0x6EBb1B5Be9bc93858f71714eD03f67BF237473cB", + } +}; + +module.exports = { + CONFIG_DATA, +}; From 2785b7c34af1907c374ca1a4aadee6685f1de04b Mon Sep 17 00:00:00 2001 From: ArmandLobster Date: Tue, 20 Aug 2024 11:55:00 +0200 Subject: [PATCH 5/6] Create abis.js --- projects/lobster-protocol/abis.js | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 projects/lobster-protocol/abis.js diff --git a/projects/lobster-protocol/abis.js b/projects/lobster-protocol/abis.js new file mode 100644 index 000000000000..3d8aff0a660f --- /dev/null +++ b/projects/lobster-protocol/abis.js @@ -0,0 +1,10 @@ +const DHEDGE_FACTORY_ABI = + "function getManagedPools(address manager) view returns (address[] managedPools)"; + +const LOBSTER_POOL_ABI = + "function getFundSummary() view returns (tuple(string name, uint256 totalSupply, uint256 totalFundValue))"; + +module.exports = { + DHEDGE_FACTORY_ABI, + LOBSTER_POOL_ABI, +}; From cb47d13fe6cceb4cef38c70ad48c08ff0f154c17 Mon Sep 17 00:00:00 2001 From: g1nt0ki <99907941+g1nt0ki@users.noreply.github.com> Date: Tue, 20 Aug 2024 13:37:37 +0200 Subject: [PATCH 6/6] code refactor --- projects/lobster-protocol/abis.js | 10 -------- projects/lobster-protocol/config.js | 10 -------- projects/lobster-protocol/index.js | 40 +++++++++++------------------ 3 files changed, 15 insertions(+), 45 deletions(-) delete mode 100644 projects/lobster-protocol/abis.js delete mode 100644 projects/lobster-protocol/config.js diff --git a/projects/lobster-protocol/abis.js b/projects/lobster-protocol/abis.js deleted file mode 100644 index 3d8aff0a660f..000000000000 --- a/projects/lobster-protocol/abis.js +++ /dev/null @@ -1,10 +0,0 @@ -const DHEDGE_FACTORY_ABI = - "function getManagedPools(address manager) view returns (address[] managedPools)"; - -const LOBSTER_POOL_ABI = - "function getFundSummary() view returns (tuple(string name, uint256 totalSupply, uint256 totalFundValue))"; - -module.exports = { - DHEDGE_FACTORY_ABI, - LOBSTER_POOL_ABI, -}; diff --git a/projects/lobster-protocol/config.js b/projects/lobster-protocol/config.js deleted file mode 100644 index 4738cea5f2d9..000000000000 --- a/projects/lobster-protocol/config.js +++ /dev/null @@ -1,10 +0,0 @@ -const CONFIG_DATA = { - arbitrum: { - dhedgeFactory: "0xffFb5fB14606EB3a548C113026355020dDF27535", - lobsterManager: "0x6EBb1B5Be9bc93858f71714eD03f67BF237473cB", - } -}; - -module.exports = { - CONFIG_DATA, -}; diff --git a/projects/lobster-protocol/index.js b/projects/lobster-protocol/index.js index d7853b8025a9..f136ccff46ab 100644 --- a/projects/lobster-protocol/index.js +++ b/projects/lobster-protocol/index.js @@ -1,29 +1,19 @@ -const { DHEDGE_FACTORY_ABI, LOBSTER_POOL_ABI } = require("./abis"); -const { CONFIG_DATA } = require("./config"); +const DHEDGE_FACTORY_ABI = "function getManagedPools(address manager) view returns (address[] managedPools)"; +const LOBSTER_POOL_ABI = "function getFundSummary() view returns (tuple(string name, uint256 totalSupply, uint256 totalFundValue))"; -async function tvl(api) { - const { chain, } = api - const { dhedgeFactory, lobsterManager } = CONFIG_DATA[chain]; - - const pools = await api.call({ - abi: DHEDGE_FACTORY_ABI, - target: dhedgeFactory, - params: [lobsterManager], - }); - - const poolSummaries = await api.multiCall({ - abi: LOBSTER_POOL_ABI, - calls: pools, - }); +const CONFIG_DATA = { + arbitrum: { + dhedgeFactory: "0xffFb5fB14606EB3a548C113026355020dDF27535", + lobsterManager: "0x6EBb1B5Be9bc93858f71714eD03f67BF237473cB", + } +} - const totalValue = poolSummaries.reduce( - (acc, i) => acc + +i.totalFundValue, - 0 - ); +async function tvl(api) { + const { dhedgeFactory, lobsterManager } = CONFIG_DATA[api.chain]; - return { - tether: totalValue / 1e18, - }; + const pools = await api.call({ abi: DHEDGE_FACTORY_ABI, target: dhedgeFactory, params: lobsterManager, }); + const poolSummaries = await api.multiCall({ abi: LOBSTER_POOL_ABI, calls: pools, }) + api.addCGToken('tether', poolSummaries.reduce((acc, p) => acc + +p.totalFundValue/1e18, 0)) } module.exports = { @@ -35,6 +25,6 @@ module.exports = { tvl, }, hallmarks: [ - [171097151, "First Arbitrum Vault Release"], + [1710971510, "First Arbitrum Vault Release"], ], -}; +} \ No newline at end of file