diff --git a/src/strategies/index.ts b/src/strategies/index.ts index 8942c8f8f..8fdf9b5df 100644 --- a/src/strategies/index.ts +++ b/src/strategies/index.ts @@ -434,6 +434,7 @@ import * as izumiVeiZi from './izumi-veizi'; import * as lqtyProxyStakers from './lqty-proxy-stakers'; import * as echelonWalletPrimeAndCachedKeyGated from './echelon-wallet-prime-and-cached-key-gated'; import * as rdntCapitalVoting from './rdnt-capital-voting'; +import * as richquackStakedAmount from './richquack-staked-amount'; const strategies = { 'izumi-veizi': izumiVeiZi, @@ -874,7 +875,8 @@ const strategies = { 'lqty-proxy-stakers': lqtyProxyStakers, 'echelon-wallet-prime-and-cached-key-gated': echelonWalletPrimeAndCachedKeyGated, - 'rdnt-capital-voting': rdntCapitalVoting + 'rdnt-capital-voting': rdntCapitalVoting, + 'richquack-staked-amount': richquackStakedAmount, }; Object.keys(strategies).forEach(function (strategyName) { diff --git a/src/strategies/richquack-staked-amount/README.md b/src/strategies/richquack-staked-amount/README.md new file mode 100644 index 000000000..56041ea93 --- /dev/null +++ b/src/strategies/richquack-staked-amount/README.md @@ -0,0 +1,17 @@ +# richquack-staked-amount + +This strategy returns voting power for RichQuack stakers. + +The voting power is based on the amount of staked tokensbalance, rather than delegated voting power. + +## Params + +- `stakingAddress` - (**Required**, `string`) Address of RichQuack Staking contract + +Here is an example of parameters: + +```json +{ + "stakingAddress": "0x24E1FB7a781d255EdC40e80C89d9289dC61925F2", +} +``` diff --git a/src/strategies/richquack-staked-amount/examples.json b/src/strategies/richquack-staked-amount/examples.json new file mode 100644 index 000000000..eb5cf09d9 --- /dev/null +++ b/src/strategies/richquack-staked-amount/examples.json @@ -0,0 +1,20 @@ +[ + { + "name": "Example query", + "strategy": { + "name": "richquack-staked-amount", + "params": { + "stakingAddress": "0x24E1FB7a781d255EdC40e80C89d9289dC61925F2" + } + }, + "network": "56", + "addresses": [ + "0x8575697851F5A11494a725FF43534e859BF49710", + "0xB4433e91F287a6E116aBaF413E64B4E0697DdCce", + "0x4089bd5C7544de334b0FBc125654cEFBB9B62cDE", + "0xc2d06aD1063d895405f2243D0c79b15e676b9Db0", + "0x523D44c7E7557C724b34BABba2A931410634173B" + ], + "snapshot": 27084195 + } +] diff --git a/src/strategies/richquack-staked-amount/index.ts b/src/strategies/richquack-staked-amount/index.ts new file mode 100644 index 000000000..9157bcca9 --- /dev/null +++ b/src/strategies/richquack-staked-amount/index.ts @@ -0,0 +1,57 @@ +import { BigNumberish } from '@ethersproject/bignumber'; +import { formatUnits } from '@ethersproject/units'; +import { Multicaller } from '../../utils'; + +export const author = 'ephdtrg'; +export const version = '0.1.0'; + +const abi = [ + { + inputs: [ + { + internalType: 'address', + name: '', + type: 'address' + } + ], + name: 'stakeInfo', + outputs: [ + { + internalType: 'uint256', + name: 'level', + type: 'uint256' + }, + { + internalType: 'uint256', + name: 'totalStakedForUser', + type: 'uint256' + } + ], + stateMutability: 'view', + type: 'function' + } +]; + +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.stakingAddress, 'stakeInfo', [address]) + ); + const result: Record = await multi.execute(); + + return Object.fromEntries( + Object.entries(result).map(([address]) => [ + address, + parseFloat(formatUnits(result[address][0], 18)) + ]) + ); +} diff --git a/src/strategies/richquack-staked-amount/schema.json b/src/strategies/richquack-staked-amount/schema.json new file mode 100644 index 000000000..ef4c73923 --- /dev/null +++ b/src/strategies/richquack-staked-amount/schema.json @@ -0,0 +1,22 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$ref": "#/definitions/Strategy", + "definitions": { + "Strategy": { + "title": "Strategy", + "type": "object", + "properties": { + "stakingAddress": { + "type": "string", + "title": "Staking address", + "examples": ["e.g. 0x24E1FB7a781d255EdC40e80C89d9289dC61925F2"], + "pattern": "^0x[a-fA-F0-9]{40}$", + "minLength": 42, + "maxLength": 42 + } + }, + "required": ["stakingAddress"], + "additionalProperties": false + } + } +}