diff --git a/src/strategies/index.ts b/src/strategies/index.ts index 80a5c6f71..51b1cdffc 100644 --- a/src/strategies/index.ts +++ b/src/strategies/index.ts @@ -150,6 +150,7 @@ import * as flexaCapacityStaking from './flexa-capacity-staking'; import * as sunriseGamingUniv2Lp from './sunrisegaming-univ2-lp'; import * as sunriseGamingStaking from './sunrisegaming-staking'; import * as singleStakingPoolsBalanceOf from './single-staking-pools-balanceof' +import * as occStakeOf from './occ-stake-of' const strategies = { coordinape, @@ -301,7 +302,8 @@ const strategies = { 'flexa-capacity-staking': flexaCapacityStaking, 'sunrisegaming-univ2-lp': sunriseGamingUniv2Lp, 'sunrisegaming-staking': sunriseGamingStaking, - 'single-staking-pools-balanceof': singleStakingPoolsBalanceOf + 'single-staking-pools-balanceof': singleStakingPoolsBalanceOf, + 'occ-stake-of': occStakeOf }; Object.keys(strategies).forEach(function (strategyName) { diff --git a/src/strategies/occ-stake-of/README.md b/src/strategies/occ-stake-of/README.md new file mode 100644 index 000000000..cb9137756 --- /dev/null +++ b/src/strategies/occ-stake-of/README.md @@ -0,0 +1,15 @@ +# occ-stake-of + +This is the OCC staking strategy, it returns the OCC staking balances of the voters. + +Here is an example of parameters: + +```json +{ + "stakingContractAddress": [ + "0xeBC86Fb12ab0fFaC6CBcaFCe2f049BfE7eFAda0D" + ], + "symbol": "OCC", + "decimals": 18 +} +``` diff --git a/src/strategies/occ-stake-of/examples.json b/src/strategies/occ-stake-of/examples.json new file mode 100644 index 000000000..f8a1a0e2a --- /dev/null +++ b/src/strategies/occ-stake-of/examples.json @@ -0,0 +1,28 @@ +[ + { + "name": "Example query", + "strategy": { + "name": "occ-stake-of", + "params": { + "stakingContractAddress": [ + "0xeBC86Fb12ab0fFaC6CBcaFCe2f049BfE7eFAda0D" + ], + "symbol": "OCC", + "decimals": 18 + } + }, + "network": "1", + "addresses": [ + "0xa95f8f54dc55281852b5c972e4874264c7b5d3de", + "0x77752aE2Cb765BDd09568E69B740a2276187F052", + "0xd3aecf9e0856822bd320873e905ae9f78a2977e7", + "0x2C2ADD1C863551A0644876be227604C8E458dD7e", + "0x8af630f68dd02c589b9449158455735814b452a3", + "0x252e2e0e4cc5bd7391acb47634fb6bb382d08586", + "0x4bf455074e67848dc7e1c55b45a32aafca2e9c9c", + "0xb623964e5761C1b04A4a46b9aE8D1809dEFa7efB" + ], + "snapshot": 12381658 + } +] + diff --git a/src/strategies/occ-stake-of/index.ts b/src/strategies/occ-stake-of/index.ts new file mode 100644 index 000000000..9a5028cf8 --- /dev/null +++ b/src/strategies/occ-stake-of/index.ts @@ -0,0 +1,36 @@ +import { BigNumberish } from '@ethersproject/bignumber'; +import { formatUnits } from '@ethersproject/units'; +import { Multicaller } from '../../utils'; + +export const author = 'OccamFi'; +export const version = '0.1.0'; + +const abi = [ + 'function getStake(address user) public view returns (uint stake)' +]; + +export async function strategy( + space, + network, + provider, + addresses, + options, + snapshot +): Promise> { + const blockTag = typeof snapshot === 'number' ? snapshot : 'latest'; + + const multi = new Multicaller(network, provider, abi, { blockTag }); + + addresses.forEach((address) => + multi.call(address, options.stakingContractAddress[0], 'getStake', [address]) + ); + + const result: Record = await multi.execute(); + + return Object.fromEntries( + Object.entries(result).map(([address, stake]) => [ + address, + parseFloat(formatUnits(stake, options.decimals)) + ]) + ); +}