From 1b56dc90457ccdbe7f2a7f48c1c082ffaa2bee3d Mon Sep 17 00:00:00 2001 From: claibornej <> Date: Mon, 10 Apr 2023 13:37:23 +0800 Subject: [PATCH 1/2] Add babywealthyclub-multi strategy --- .../babywealthyclub-multi/examples.json | 67 +++++++++++++++++++ src/strategies/babywealthyclub-multi/index.ts | 56 ++++++++++++++++ 2 files changed, 123 insertions(+) create mode 100644 src/strategies/babywealthyclub-multi/examples.json create mode 100644 src/strategies/babywealthyclub-multi/index.ts diff --git a/src/strategies/babywealthyclub-multi/examples.json b/src/strategies/babywealthyclub-multi/examples.json new file mode 100644 index 000000000..399320c25 --- /dev/null +++ b/src/strategies/babywealthyclub-multi/examples.json @@ -0,0 +1,67 @@ +[ + { + "name": "Example query", + "strategy": { + "name": "babywealthyclub-multi", + "params": { + "strategies": [ + { + "name": "erc721", + "network": "1", + "params": { + "address": "0x75009fB6e3d4401b8C64548d33e9a3A9415F5d70", + "symbol": "BWC" + } + }, + { + "name": "erc721", + "network": "42161", + "params": { + "address": "0x75009fB6e3d4401b8C64548d33e9a3A9415F5d70", + "symbol": "BWC" + } + }, + { + "name": "erc721", + "network": "137", + "params": { + "address": "0x75009fB6e3d4401b8C64548d33e9a3A9415F5d70", + "symbol": "BWC" + } + }, + { + "name": "erc721", + "network": "43114", + "params": { + "address": "0x75009fB6e3d4401b8C64548d33e9a3A9415F5d70", + "symbol": "BWC" + } + }, + { + "name": "erc721", + "network": "10", + "params": { + "address": "0x75009fB6e3d4401b8C64548d33e9a3A9415F5d70", + "symbol": "BWC" + } + }, + { + "name": "erc721", + "network": "56", + "params": { + "address": "0x75009fB6e3d4401b8C64548d33e9a3A9415F5d70", + "symbol": "BWC" + } + } + ] + } + }, + "network": "56", + "addresses": [ + "0xe0e4f69A250b10c4e9ce1334fcA51599eA39C0e4", + "0x9feab70f3c4a944b97b7565bac4991df5b7a69ff", + "0xaca39b187352d9805deced6e73a3d72abf86e7a0" + ], + "snapshot": 26920121 + } +] diff --git a/src/strategies/babywealthyclub-multi/index.ts b/src/strategies/babywealthyclub-multi/index.ts new file mode 100644 index 000000000..c4d169e54 --- /dev/null +++ b/src/strategies/babywealthyclub-multi/index.ts @@ -0,0 +1,56 @@ +import { getProvider, getSnapshots } from '../../utils'; +import strategies from '..'; + +export const author = 'claibornej'; +export const version = '0.1.0'; + +export async function strategy( + space, + network, + provider, + addresses, + options, + snapshot +) { + const promises: any = []; + const blocks = await getSnapshots( + network, + snapshot, + provider, + options.strategies.map((s) => s.network || network) + ); + + for (const strategy of options.strategies) { + // If snapshot is taken before a network is activated then ignore its strategies + if ( + options.startBlocks && + blocks[strategy.network] < options.startBlocks[strategy.network] + ) { + continue; + } + + promises.push( + strategies[strategy.name].strategy( + space, + strategy.network, + getProvider(strategy.network), + addresses, + strategy.params, + blocks[strategy.network] + ) + ); + } + + const results = await Promise.all(promises); + const resp = results.reduce((finalResults: any, strategyResult: any) => { + for (const [address, value] of Object.entries(strategyResult)) { + if (!finalResults[address]) { + finalResults[address] = 0; + } + finalResults[address] += value; + } + return finalResults; + }, {}); + + return resp; +} From b562a337bd48f0af4b44df5059117869336d56e0 Mon Sep 17 00:00:00 2001 From: claibornej <> Date: Mon, 10 Apr 2023 13:43:08 +0800 Subject: [PATCH 2/2] Add babywealthyclub-multi strategy --- src/strategies/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/strategies/index.ts b/src/strategies/index.ts index 8942c8f8f..f097667c7 100644 --- a/src/strategies/index.ts +++ b/src/strategies/index.ts @@ -424,6 +424,7 @@ import * as lodestarStakedLp from './lodestar-staked-lp'; import * as jpegdLockedJpegOf from './jpegd-locked-jpeg-of'; import * as litDaoGovernance from './lit-dao-governance'; import * as babywealthyclub from './babywealthyclub'; +import * as babywealthyclubMulti from './babywealthyclub-multi'; import * as battleflyVGFLYAndStakedGFLY from './battlefly-vgfly-and-staked-gfly'; import * as nexonArmyNFT from './nexon-army-nft'; import * as moonbeamFreeBalance from './moonbeam-free-balance'; @@ -865,6 +866,7 @@ const strategies = { 'lodestar-vesting': lodestarVesting, 'lodestar-staked-lp': lodestarStakedLp, babywealthyclub, + 'babywealthyclub-multi': babywealthyclubMulti, 'battlefly-vgfly-and-staked-gfly': battleflyVGFLYAndStakedGFLY, 'nexon-army-nft': nexonArmyNFT, 'moonbeam-free-balance': moonbeamFreeBalance,