Skip to content

Commit

Permalink
[delegation] fix add delegatioNetwork param
Browse files Browse the repository at this point in the history
  • Loading branch information
ChaituVR committed Nov 19, 2024
1 parent 692821f commit 273528b
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 10 deletions.
42 changes: 35 additions & 7 deletions src/strategies/delegation/examples.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,52 @@
"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
}
}
]
}
},
"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
}
]
15 changes: 12 additions & 3 deletions src/strategies/delegation/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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 {};

Expand Down

0 comments on commit 273528b

Please sign in to comment.