diff --git a/src/strategies/derpdex-xderp-yield-booster/README.md b/src/strategies/derpdex-xderp-yield-booster/README.md new file mode 100644 index 000000000..43723da62 --- /dev/null +++ b/src/strategies/derpdex-xderp-yield-booster/README.md @@ -0,0 +1,13 @@ +# derpdex-xderp-yield-booster + +This is the DerpDEX xDERP strategy for yield booster users, it returns the balances of the allocated tokens in yield booster for the users. + +Here is an example of parameters: + +```json +{ + "address": "0xd377088F3026536682Bf58Cc74448a5B31490C46", + "symbol": "xDERP", + "decimals": 18 +} +``` diff --git a/src/strategies/derpdex-xderp-yield-booster/examples.json b/src/strategies/derpdex-xderp-yield-booster/examples.json new file mode 100644 index 000000000..317632c96 --- /dev/null +++ b/src/strategies/derpdex-xderp-yield-booster/examples.json @@ -0,0 +1,20 @@ +[ + { + "name": "Example query", + "strategy": { + "name": "derpdex-xderp-yield-booster", + "params": { + "address": "0xd377088F3026536682Bf58Cc74448a5B31490C46", + "symbol": "xDERP", + "decimals": 18 + } + }, + "network": "324", + "addresses": [ + "0x440097Cebd3b8C20ec43bA4A9395e252BF41dcCc", + "0x945bB7BD5AD143279647825544Ab94395D435d15", + "0x01043868e5079cE26ba2694638B2282Ccae7BA53" + ], + "snapshot": 21537650 + } +] diff --git a/src/strategies/derpdex-xderp-yield-booster/index.ts b/src/strategies/derpdex-xderp-yield-booster/index.ts new file mode 100644 index 000000000..e10815954 --- /dev/null +++ b/src/strategies/derpdex-xderp-yield-booster/index.ts @@ -0,0 +1,34 @@ +import { BigNumberish } from '@ethersproject/bignumber'; +import { formatUnits } from '@ethersproject/units'; +import { Multicaller } from '../../utils'; + +export const author = 'bonustrack'; +export const version = '0.1.1'; + +const abi = [ + 'function userTotalAllocations(address account) external view returns (uint256)' +]; + +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.address, 'userTotalAllocations', [address]) + ); + const result: Record = await multi.execute(); + + return Object.fromEntries( + Object.entries(result).map(([address, balance]) => [ + address, + parseFloat(formatUnits(balance, options.decimals)) + ]) + ); +} diff --git a/src/strategies/derpdex-xderp-yield-booster/schema.json b/src/strategies/derpdex-xderp-yield-booster/schema.json new file mode 100644 index 000000000..7aa94f032 --- /dev/null +++ b/src/strategies/derpdex-xderp-yield-booster/schema.json @@ -0,0 +1,33 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$ref": "#/definitions/Strategy", + "definitions": { + "Strategy": { + "title": "Strategy", + "type": "object", + "properties": { + "symbol": { + "type": "string", + "title": "Symbol", + "examples": ["e.g. xDERP"], + "maxLength": 16 + }, + "address": { + "type": "string", + "title": "Contract address", + "examples": ["e.g. 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984"], + "pattern": "^0x[a-fA-F0-9]{40}$", + "minLength": 42, + "maxLength": 42 + }, + "decimals": { + "type": "number", + "title": "Decimals", + "examples": ["e.g. 18"] + } + }, + "required": ["address", "decimals"], + "additionalProperties": false + } + } +} diff --git a/src/strategies/index.ts b/src/strategies/index.ts index d9b454d1c..c521bf446 100644 --- a/src/strategies/index.ts +++ b/src/strategies/index.ts @@ -406,6 +406,7 @@ import * as totalAxionShares from './total-axion-shares'; import * as unipoolSameToken from './unipool-same-token'; import * as voltVotingPower from './volt-voting-power'; import * as xdaiStakersAndHolders from './xdai-stakers-and-holders'; +import * as derpdexxDERPYieldBooster from './derpdex-xderp-yield-booster'; const strategies = { 'cap-voting-power': capVotingPower, @@ -818,7 +819,8 @@ const strategies = { 'total-axion-shares': totalAxionShares, 'unipool-same-token': unipoolSameToken, 'volt-voting-power': voltVotingPower, - 'xdai-stakers-and-holders': xdaiStakersAndHolders + 'xdai-stakers-and-holders': xdaiStakersAndHolders, + 'derpdex-xderp-yield-booster': derpdexxDERPYieldBooster, }; Object.keys(strategies).forEach(function (strategyName) {