From 273528b65922b103ebf5e73d30268466626305d2 Mon Sep 17 00:00:00 2001 From: ChaituVR Date: Tue, 19 Nov 2024 10:45:18 +0700 Subject: [PATCH 1/2] [delegation] fix add delegatioNetwork param --- src/strategies/delegation/examples.json | 42 ++++++++++++++++++++----- src/strategies/delegation/index.ts | 15 +++++++-- 2 files changed, 47 insertions(+), 10 deletions(-) diff --git a/src/strategies/delegation/examples.json b/src/strategies/delegation/examples.json index e2f824d51..05eab6d19 100644 --- a/src/strategies/delegation/examples.json +++ b/src/strategies/delegation/examples.json @@ -4,13 +4,15 @@ "strategy": { "name": "delegation", "params": { - "symbol": "POH (delegated)", + "symbol": "APE (delegated)", + "delegationSpace": "apecoin.eth", "strategies": [ { "name": "erc20-balance-of", "params": { - "address": "0x1dAD862095d40d43c2109370121cf087632874dB", - "decimals": 0 + "symbol": "APE", + "address": "0x4d224452801aced8b2f0aebe155379bb5d594381", + "decimals": 18 } } ] @@ -18,10 +20,36 @@ }, "network": "1", "addresses": [ - "0x3c13f2B56AF614aC6381265EcB3B619bA26CC641", - "0x048fee7c3279a24af0790b6b002ded42be021d2b", - "0x139a9032a46c3afe3456eb5f0a35183b5f189cae" + "0x33924aFFe6BC352C246d7f384988f7b4Ad5f9cf2", + "0x56ee461fd756c416c5d2149b3976A019D3b44cc9", + "0x5c4a0fa9Ab5cfc27d198Cab40EC079210902A948" ], - "snapshot": 15705816 + "snapshot": 21218777 + }, + { + "name": "Example query", + "strategy": { + "name": "delegation", + "params": { + "symbol": "APE (delegated)", + "delegationSpace": "apecoin.eth", + "delegationNetwork": "1", + "strategies": [ + { + "name": "eth-balance", + "params": { + "symbol": "APE" + } + } + ] + } + }, + "network": "33139", + "addresses": [ + "0x56ee461fd756c416c5d2149b3976A019D3b44cc9", + "0x68Afd61E37267Fd2898F0f965B580182e8D20e6d", + "0xCD02c8b722c8E286fbb353Fd7Bf814Bd38490C27" + ], + "snapshot": 4631281 } ] diff --git a/src/strategies/delegation/index.ts b/src/strategies/delegation/index.ts index 7ea2d7ff5..dac829af2 100644 --- a/src/strategies/delegation/index.ts +++ b/src/strategies/delegation/index.ts @@ -1,5 +1,5 @@ import { getDelegations } from '../../utils/delegation'; -import { getScoresDirect } from '../../utils'; +import { getScoresDirect, getSnapshots } from '../../utils'; export const author = 'bonustrack'; export const version = '0.1.0'; @@ -24,11 +24,20 @@ export async function strategy( ) return {}; const delegationSpace = options.delegationSpace || space; + const delegationNetwork = options.delegationNetwork || network; + let delegationSnapshot = snapshot; + if (delegationNetwork !== network) { + const snapshots = await getSnapshots(network, snapshot, provider, [ + delegationNetwork + ]); + delegationSnapshot = snapshots[delegationNetwork]; + } + const delegations = await getDelegations( delegationSpace, - network, + delegationNetwork, addresses, - snapshot + delegationSnapshot ); if (Object.keys(delegations).length === 0) return {}; From 802a91708457b7a88f09edffabc21cec4547e6e3 Mon Sep 17 00:00:00 2001 From: Chaitanya Date: Tue, 19 Nov 2024 09:16:28 +0530 Subject: [PATCH 2/2] Apply suggestions from code review --- src/strategies/delegation/examples.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/strategies/delegation/examples.json b/src/strategies/delegation/examples.json index 05eab6d19..54972f513 100644 --- a/src/strategies/delegation/examples.json +++ b/src/strategies/delegation/examples.json @@ -27,7 +27,7 @@ "snapshot": 21218777 }, { - "name": "Example query", + "name": "Example query with delegationNetwork", "strategy": { "name": "delegation", "params": {