From baccd56a4ae476fa30300d2c0ffc3c232344a7b7 Mon Sep 17 00:00:00 2001 From: Velenir Date: Thu, 26 Jan 2023 18:27:20 +0100 Subject: [PATCH 01/10] outline strategy --- .../psp-in-sepsp2-balance/README.md | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 src/strategies/psp-in-sepsp2-balance/README.md diff --git a/src/strategies/psp-in-sepsp2-balance/README.md b/src/strategies/psp-in-sepsp2-balance/README.md new file mode 100644 index 000000000..661047a89 --- /dev/null +++ b/src/strategies/psp-in-sepsp2-balance/README.md @@ -0,0 +1,66 @@ +# psp-in-sepsp2-balance + +This is a strategy to get PSP balances staked in sePSP2 contract and multiply that by `options.multiplier`. + +It works like this: +1. Get BPT balance an account holds +```js +const sePSP_balance = BPT_balance = SPSP.PSPBalance(address) +``` + +2. Get tokens of the Balancer Pool +```js +const [tokens] = await Vault.getPoolTokens(poolId) +``` + +3. Construct an exit pool request the account would use if intending to unstake BPT balance +```js +const exitPoolRequest = { + assets: tokens, // Balancer Pools underlying tokens + minAmountsOut: [0,0], // minimal amounts received + userData, // endoded [1, BPT_balance], // ExitKind.EXACT_BPT_IN_FOR_TOKENS_OUT = 1 + toInternalBalance: false, // transfer tokens to recipient, as opposed to depositing to internal balance +} + ``` + +4. Find how many tokens the account would receive by unstaking its BPT balance +```js +const [amountsOut] = await BalancerHelpers.callStatic.queryExit( + poolId, + Zero_account, // sender + Zero_account, // recipient + exitPoolRequest + ) +// sender & recipient don't matter as we only getting an estimate +``` +`amountsOut` is a representation of BPT balance in the Balancer Pool's underlying tokens. Ordered the same as `assets` + +5. One of the `amountsOut` is PSP balance the account has locked in sePSP2. +```js +const PSP_balance = amountsOut[index_from_assets] +``` + +6. Multiply PSP_balance by score multiplier. +```js +const Vote_power = PSP_balance * 2.5 +``` + +Here is an example of parameters: + +```json +{ + "address": "0xcafe001067cdef266afb7eb5a286dcfd277f3de5", + "symbol": "PSP", + "decimals": 18, + "sePSP2": { + "address": "0x593F39A4Ba26A9c8ed2128ac95D109E8e403C485", + "decimals": 18 + }, + "balancer": { + "poolId": "0xcb0e14e96f2cefa8550ad8e4aea344f211e5061d00020000000000000000011a", + "BalancerHelpers": "0x5aDDCCa35b7A0D07C74063c48700C8590E87864E", + "Vault": "0xBA12222222228d8Ba445958a75a0704d566BF2C8" + }, + "multiplier": 2.5 +} +``` From 5ec249b6880e8a54608444a8bb863eac44887f1e Mon Sep 17 00:00:00 2001 From: Velenir Date: Thu, 26 Jan 2023 18:27:41 +0100 Subject: [PATCH 02/10] fill in example --- .../psp-in-sepsp2-balance/examples.json | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/strategies/psp-in-sepsp2-balance/examples.json diff --git a/src/strategies/psp-in-sepsp2-balance/examples.json b/src/strategies/psp-in-sepsp2-balance/examples.json new file mode 100644 index 000000000..9ccc11cfa --- /dev/null +++ b/src/strategies/psp-in-sepsp2-balance/examples.json @@ -0,0 +1,47 @@ +[ + { + "name": "Example query", + "strategy": { + "name": "psp-in-sepsp2-balance", + "params": { + "address": "0xcafe001067cdef266afb7eb5a286dcfd277f3de5", + "symbol": "PSP", + "decimals": 18, + "sePSP2": { + "address": "0x593F39A4Ba26A9c8ed2128ac95D109E8e403C485", + "decimals": 18 + }, + "balancer": { + "poolId": "0xcb0e14e96f2cefa8550ad8e4aea344f211e5061d00020000000000000000011a", + "BalancerHelpers": "0x5aDDCCa35b7A0D07C74063c48700C8590E87864E", + "Vault": "0xBA12222222228d8Ba445958a75a0704d566BF2C8" + }, + "multiplier": 2.5 + } + }, + "network": "1", + "addresses": [ + "0x05182E579FDfCf69E4390c3411D8FeA1fb6467cf", + "0x0DDC793680FF4f5793849c8c6992be1695CbE72A", + "0x0edefa91e99da1eddd1372c1743a63b1595fc413", + "0xd37f7b32a541d9e423f759dff1dd63181651bd04", + "0xf9aa0da6e2fa01a17e2f69e878e45bb26c1b34b7", + "0xc570429a39a93fd267d1047b2363cfba07198ff7", + "0x4e8ffddb1403cf5306c6c7b31dc72ef5f44bc4f5", + "0x0ddc793680ff4f5793849c8c6992be1695cbe72a", + "0xd880507d359af862a5f8f318c8e934ab478ca818", + "0x510a7cd4ba40f7b6643f566a5d45ea55f5cd8d0e", + "0x1ff3c4bfa745b72f942c5cf2b769b3d8a6610a5e", + "0x5577933afc0522c5ee71115df61512f49da0543e", + "0x6eb8d6bccceb84832725dcf792468dd8ba088449", + "0xe768FF81990E7Ac73C18a2eCbf038815023599Dc", + "0xB9E11C28617D46866c1D7d95EaebAC3AC12CDAD3", + "0xB5714084eeF0f02eFDD145DFB3Fe2e3290591D7b", + "0xCC6B30531DE603787a4D0305FC7eD404374Cf771", + "0xcb492647CB51E243Fb2582C0300C4c7573acdEBf", + "0xB8f6f3cc7b162d7E5b9196140Fb1878cdA316ba0", + "0x584BaA4b71b0A3fA522658128f36a6A4AbeAC2ae" + ], + "snapshot": 16492220 + } +] \ No newline at end of file From fd62c3713782597bb1994357e5a25cc10465be6c Mon Sep 17 00:00:00 2001 From: Velenir Date: Thu, 26 Jan 2023 18:27:57 +0100 Subject: [PATCH 03/10] write the strategy --- src/strategies/index.ts | 4 +- src/strategies/psp-in-sepsp2-balance/index.ts | 179 ++++++++++++++++++ 2 files changed, 182 insertions(+), 1 deletion(-) create mode 100644 src/strategies/psp-in-sepsp2-balance/index.ts diff --git a/src/strategies/index.ts b/src/strategies/index.ts index 88efa9320..11d786814 100644 --- a/src/strategies/index.ts +++ b/src/strategies/index.ts @@ -416,6 +416,7 @@ import * as jpegdLockedJpegOf from './jpegd-locked-jpeg-of'; import * as litDaoGovernance from './lit-dao-governance'; import * as babywealthyclub from './babywealthyclub'; import * as battleflyVGFLYAndStakedGFLY from './battlefly-vgfly-and-staked-gfly'; +import * as pspInSePSP2Balance from './psp-in-sepsp2-balance'; const strategies = { 'forta-shares': fortaShares, @@ -837,7 +838,8 @@ const strategies = { 'vsta-pool-staking': vstaPoolStaking, 'jpegd-locked-jpeg-of': jpegdLockedJpegOf, babywealthyclub, - 'battlefly-vgfly-and-staked-gfly': battleflyVGFLYAndStakedGFLY + 'battlefly-vgfly-and-staked-gfly': battleflyVGFLYAndStakedGFLY, + 'psp-in-sepsp2-balance': pspInSePSP2Balance }; Object.keys(strategies).forEach(function (strategyName) { diff --git a/src/strategies/psp-in-sepsp2-balance/index.ts b/src/strategies/psp-in-sepsp2-balance/index.ts new file mode 100644 index 000000000..3317d117c --- /dev/null +++ b/src/strategies/psp-in-sepsp2-balance/index.ts @@ -0,0 +1,179 @@ +import { BigNumberish, BigNumber } from '@ethersproject/bignumber'; +import { formatUnits, parseUnits } from '@ethersproject/units'; +import { Contract } from '@ethersproject/contracts'; +import { defaultAbiCoder } from '@ethersproject/abi'; +import { strategy as fetchERC20Balances } from '../erc20-balance-of'; +import { Multicaller } from '../../utils'; +import { getAddress } from '@ethersproject/address'; + +export const author = 'paraswap'; +export const version = '0.1.0'; + +// const abi = [ +// 'function PSPBalance(address _account) view returns (uint256 pspAmount_)' +// ]; + +const BalancerVaultAbi = [ + 'function getPoolTokens(bytes32 poolId) external view returns (address[] tokens, uint256[] balances, uint256 lastChangeBlock)' +]; +interface PoolTokensFromVault { + tokens: string[]; + balances: BigNumber[]; + lastChangeBlock: BigNumber; +} + +const BalancerHelpersAbi = [ + 'function queryExit(bytes32 poolId, address sender, address recipient, tuple(address[] assets, uint256[] minAmountsOut, bytes userData, bool toInternalBalance) request) returns (uint256 bptIn, uint256[] amountsOut)' +]; + +interface QueryExitResult { + bptIn: BigNumber; + amountsOut: BigNumber[]; +} + +type QueryExitInput = [ + poolId: string, + sender: string, + recipient: string, + exitRequest: ExitPoolRequest +]; + +interface StrategyOptions { + address: string; + symbol: string; + decimals: number; + sePSP2: { address: string; decimals: number }; + balancer: { + poolId: string; + BalancerHelpers: string; + Vault: string; + }; + multiplier: number; +} + +const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'; + +export async function strategy( + space: string, + network: string, + provider, + addresses: string[], + options: StrategyOptions, + snapshot: number +): Promise> { + const blockTag = typeof snapshot === 'number' ? snapshot : 'latest'; + + const erc20Options = { + ...options.sePSP2, + symbol: 'sePSP2' + }; + + const account2BPTBalance = await fetchERC20Balances( + space, + network, + provider, + addresses, + erc20Options, + snapshot + ); + + console.log('account2BPTBalance', account2BPTBalance); + + const balancerVault = new Contract( + options.balancer.Vault, + BalancerVaultAbi, + provider + ); + + const { tokens: poolTokens }: PoolTokensFromVault = + await balancerVault.getPoolTokens(options.balancer.poolId); + + const tokenLowercase = options.address.toLowerCase(); + const tokenIndex = poolTokens.findIndex( + (token) => token.toLowerCase() === tokenLowercase + ); + + if (tokenIndex === -1) { + throw new Error( + `Token ${options.address} doesn't belong to Balancer Pool ${options.balancer.poolId}` + ); + } + + const multi = new Multicaller(network, provider, BalancerHelpersAbi, { + blockTag + }); + + Object.entries(account2BPTBalance).forEach(([address, _bptBalance]) => { + try { + const bptBalance = parseUnits( + _bptBalance.toString(10), + options.sePSP2.decimals + ); + const exitPoolRequest = constructExitPoolRequest(poolTokens, bptBalance); + const params: QueryExitInput = [ + options.balancer.poolId, + ZERO_ADDRESS, + ZERO_ADDRESS, + exitPoolRequest + ]; + + return multi.call( + address, + options.balancer.BalancerHelpers, + 'queryExit', + params + ); + } catch (error) { + console.log(error); + } + }); + + const address2ExitResult: Record = + await multi.execute(); + + const address2PSPinSePSP2 = Object.fromEntries( + Object.entries(address2ExitResult).map(([address, exitResult]) => { + const pspBalance = exitResult.amountsOut[tokenIndex]; + + const checksummedAddress = getAddress(address); + + return [ + checksummedAddress, + parseFloat(formatUnits(pspBalance, options.decimals)) * + options.multiplier + ]; + }) + ); + + console.log('FINAL SCORE', address2PSPinSePSP2); + + return address2PSPinSePSP2; +} + +interface ExitPoolRequest { + assets: string[]; + minAmountsOut: BigNumberish[]; + userData: string; + toInternalBalance: boolean; +} + +// ExitKind enum for BalancerHerlpers.queryExit call +const EXACT_BPT_IN_FOR_TOKENS_OUT = 1; + +export function constructExitPoolRequest( + assets: string[], + bptAmountIn: BigNumberish +): ExitPoolRequest { + const abi = ['uint256', 'uint256']; + const data = [EXACT_BPT_IN_FOR_TOKENS_OUT, bptAmountIn]; + const userData = defaultAbiCoder.encode(abi, data); + + const minAmountsOut = assets.map(() => 0); + + return { + assets, + minAmountsOut, + userData, + toInternalBalance: false + }; +} From b06f501b668e6271b66a48cb81b8c7ea038aa77b Mon Sep 17 00:00:00 2001 From: Velenir Date: Thu, 26 Jan 2023 18:53:32 +0100 Subject: [PATCH 04/10] alt variant with fewer calls --- src/strategies/psp-in-sepsp2-balance/index.ts | 42 ++++++++++++++++++- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/src/strategies/psp-in-sepsp2-balance/index.ts b/src/strategies/psp-in-sepsp2-balance/index.ts index 3317d117c..20868d5d1 100644 --- a/src/strategies/psp-in-sepsp2-balance/index.ts +++ b/src/strategies/psp-in-sepsp2-balance/index.ts @@ -99,6 +99,44 @@ export async function strategy( ); } + const balancerHelpers = new Contract( + options.balancer.BalancerHelpers, + BalancerHelpersAbi, + provider + ); + + const exitPoolRequest = constructExitPoolRequest( + poolTokens, + parseUnits('1', options.sePSP2.decimals) + ); + + const queryExitResult: QueryExitResult = + await balancerHelpers.callStatic.queryExit( + options.balancer.poolId, + ZERO_ADDRESS, + ZERO_ADDRESS, + exitPoolRequest + ); + + console.log( + 'queryExitResult', + queryExitResult.amountsOut.map((am) => am.toString()) + ); + + const pspFor1BPT = parseFloat( + formatUnits(queryExitResult.amountsOut[tokenIndex], options.decimals) + ); + + const address2PSPinSePSP2_SIMPLE = Object.fromEntries( + Object.entries(account2BPTBalance).map(([address, bptBalance]) => { + const pspBalance = pspFor1BPT * bptBalance; + + const checksummedAddress = getAddress(address); + + return [checksummedAddress, pspBalance * options.multiplier]; + }) + ); + const multi = new Multicaller(network, provider, BalancerHelpersAbi, { blockTag }); @@ -145,9 +183,9 @@ export async function strategy( }) ); - console.log('FINAL SCORE', address2PSPinSePSP2); + console.log('FINAL SCORE', address2PSPinSePSP2, address2PSPinSePSP2_SIMPLE); - return address2PSPinSePSP2; + return address2PSPinSePSP2_SIMPLE; } interface ExitPoolRequest { From fee3b4c36df979506363e1f2e6abcc7156f3a451 Mon Sep 17 00:00:00 2001 From: Velenir Date: Thu, 26 Jan 2023 18:55:15 +0100 Subject: [PATCH 05/10] cleanup --- src/strategies/psp-in-sepsp2-balance/index.ts | 60 +------------------ 1 file changed, 3 insertions(+), 57 deletions(-) diff --git a/src/strategies/psp-in-sepsp2-balance/index.ts b/src/strategies/psp-in-sepsp2-balance/index.ts index 20868d5d1..458a7e18e 100644 --- a/src/strategies/psp-in-sepsp2-balance/index.ts +++ b/src/strategies/psp-in-sepsp2-balance/index.ts @@ -77,8 +77,6 @@ export async function strategy( snapshot ); - console.log('account2BPTBalance', account2BPTBalance); - const balancerVault = new Contract( options.balancer.Vault, BalancerVaultAbi, @@ -107,6 +105,7 @@ export async function strategy( const exitPoolRequest = constructExitPoolRequest( poolTokens, + // how much will get for 1 BPT parseUnits('1', options.sePSP2.decimals) ); @@ -118,16 +117,11 @@ export async function strategy( exitPoolRequest ); - console.log( - 'queryExitResult', - queryExitResult.amountsOut.map((am) => am.toString()) - ); - const pspFor1BPT = parseFloat( formatUnits(queryExitResult.amountsOut[tokenIndex], options.decimals) ); - const address2PSPinSePSP2_SIMPLE = Object.fromEntries( + const address2PSPinSePSP2 = Object.fromEntries( Object.entries(account2BPTBalance).map(([address, bptBalance]) => { const pspBalance = pspFor1BPT * bptBalance; @@ -137,55 +131,7 @@ export async function strategy( }) ); - const multi = new Multicaller(network, provider, BalancerHelpersAbi, { - blockTag - }); - - Object.entries(account2BPTBalance).forEach(([address, _bptBalance]) => { - try { - const bptBalance = parseUnits( - _bptBalance.toString(10), - options.sePSP2.decimals - ); - const exitPoolRequest = constructExitPoolRequest(poolTokens, bptBalance); - const params: QueryExitInput = [ - options.balancer.poolId, - ZERO_ADDRESS, - ZERO_ADDRESS, - exitPoolRequest - ]; - - return multi.call( - address, - options.balancer.BalancerHelpers, - 'queryExit', - params - ); - } catch (error) { - console.log(error); - } - }); - - const address2ExitResult: Record = - await multi.execute(); - - const address2PSPinSePSP2 = Object.fromEntries( - Object.entries(address2ExitResult).map(([address, exitResult]) => { - const pspBalance = exitResult.amountsOut[tokenIndex]; - - const checksummedAddress = getAddress(address); - - return [ - checksummedAddress, - parseFloat(formatUnits(pspBalance, options.decimals)) * - options.multiplier - ]; - }) - ); - - console.log('FINAL SCORE', address2PSPinSePSP2, address2PSPinSePSP2_SIMPLE); - - return address2PSPinSePSP2_SIMPLE; + return address2PSPinSePSP2; } interface ExitPoolRequest { From df44ebe8f8570c11f37eb48698e45d8bcb920bde Mon Sep 17 00:00:00 2001 From: Velenir Date: Thu, 26 Jan 2023 18:59:15 +0100 Subject: [PATCH 06/10] call at { blockTag } --- src/strategies/psp-in-sepsp2-balance/index.ts | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/strategies/psp-in-sepsp2-balance/index.ts b/src/strategies/psp-in-sepsp2-balance/index.ts index 458a7e18e..2b62330e2 100644 --- a/src/strategies/psp-in-sepsp2-balance/index.ts +++ b/src/strategies/psp-in-sepsp2-balance/index.ts @@ -31,13 +31,6 @@ interface QueryExitResult { amountsOut: BigNumber[]; } -type QueryExitInput = [ - poolId: string, - sender: string, - recipient: string, - exitRequest: ExitPoolRequest -]; - interface StrategyOptions { address: string; symbol: string; @@ -84,7 +77,7 @@ export async function strategy( ); const { tokens: poolTokens }: PoolTokensFromVault = - await balancerVault.getPoolTokens(options.balancer.poolId); + await balancerVault.getPoolTokens(options.balancer.poolId, { blockTag }); const tokenLowercase = options.address.toLowerCase(); const tokenIndex = poolTokens.findIndex( @@ -114,7 +107,8 @@ export async function strategy( options.balancer.poolId, ZERO_ADDRESS, ZERO_ADDRESS, - exitPoolRequest + exitPoolRequest, + { blockTag } ); const pspFor1BPT = parseFloat( From 70cda3f40758d1860806855015c0ff571cf048c6 Mon Sep 17 00:00:00 2001 From: Velenir Date: Thu, 26 Jan 2023 19:01:49 +0100 Subject: [PATCH 07/10] cleanup --- src/strategies/psp-in-sepsp2-balance/index.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/strategies/psp-in-sepsp2-balance/index.ts b/src/strategies/psp-in-sepsp2-balance/index.ts index 2b62330e2..8dfe8b890 100644 --- a/src/strategies/psp-in-sepsp2-balance/index.ts +++ b/src/strategies/psp-in-sepsp2-balance/index.ts @@ -3,16 +3,11 @@ import { formatUnits, parseUnits } from '@ethersproject/units'; import { Contract } from '@ethersproject/contracts'; import { defaultAbiCoder } from '@ethersproject/abi'; import { strategy as fetchERC20Balances } from '../erc20-balance-of'; -import { Multicaller } from '../../utils'; import { getAddress } from '@ethersproject/address'; export const author = 'paraswap'; export const version = '0.1.0'; -// const abi = [ -// 'function PSPBalance(address _account) view returns (uint256 pspAmount_)' -// ]; - const BalancerVaultAbi = [ 'function getPoolTokens(bytes32 poolId) external view returns (address[] tokens, uint256[] balances, uint256 lastChangeBlock)' ]; From d5dbac667c4a2874276ca02cafc9012319d14dea Mon Sep 17 00:00:00 2001 From: Velenir Date: Thu, 26 Jan 2023 19:13:47 +0100 Subject: [PATCH 08/10] update Readme --- src/strategies/psp-in-sepsp2-balance/README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/strategies/psp-in-sepsp2-balance/README.md b/src/strategies/psp-in-sepsp2-balance/README.md index 661047a89..68d1671ed 100644 --- a/src/strategies/psp-in-sepsp2-balance/README.md +++ b/src/strategies/psp-in-sepsp2-balance/README.md @@ -13,17 +13,17 @@ const sePSP_balance = BPT_balance = SPSP.PSPBalance(address) const [tokens] = await Vault.getPoolTokens(poolId) ``` -3. Construct an exit pool request the account would use if intending to unstake BPT balance +3. Construct an exit pool request that could be used to unstake 1 BPT balance ```js const exitPoolRequest = { assets: tokens, // Balancer Pools underlying tokens minAmountsOut: [0,0], // minimal amounts received - userData, // endoded [1, BPT_balance], // ExitKind.EXACT_BPT_IN_FOR_TOKENS_OUT = 1 + userData, // endoded [1, 1e18], // ExitKind.EXACT_BPT_IN_FOR_TOKENS_OUT = 1 toInternalBalance: false, // transfer tokens to recipient, as opposed to depositing to internal balance } ``` -4. Find how many tokens the account would receive by unstaking its BPT balance +4. Find how many tokens you would receive by unstaking 1 BPT balance ```js const [amountsOut] = await BalancerHelpers.callStatic.queryExit( poolId, @@ -33,16 +33,16 @@ const [amountsOut] = await BalancerHelpers.callStatic.queryExit( ) // sender & recipient don't matter as we only getting an estimate ``` -`amountsOut` is a representation of BPT balance in the Balancer Pool's underlying tokens. Ordered the same as `assets` +`amountsOut` is a representation of BPT balance in the Balancer Pool's underlying tokens. In the same order as `assets` -5. One of the `amountsOut` is PSP balance the account has locked in sePSP2. +5. One of the `amountsOut` is PSP portion of 1 BPT. ```js -const PSP_balance = amountsOut[index_from_assets] +const PSP_In_1_BPT = amountsOut[index_from_assets] ``` 6. Multiply PSP_balance by score multiplier. ```js -const Vote_power = PSP_balance * 2.5 +const Vote_power = PSP_In_1_BPT * BPT_balance * 2.5 ``` Here is an example of parameters: From 01c36f2b6801026953f6881fd6cefdf6f9cb6970 Mon Sep 17 00:00:00 2001 From: Velenir Date: Fri, 27 Jan 2023 12:46:00 +0100 Subject: [PATCH 09/10] add schema --- .../psp-in-sepsp2-balance/schema.json | 110 ++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 src/strategies/psp-in-sepsp2-balance/schema.json diff --git a/src/strategies/psp-in-sepsp2-balance/schema.json b/src/strategies/psp-in-sepsp2-balance/schema.json new file mode 100644 index 000000000..cbe115d84 --- /dev/null +++ b/src/strategies/psp-in-sepsp2-balance/schema.json @@ -0,0 +1,110 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$ref": "#/definitions/Strategy", + "definitions": { + "Strategy": { + "title": "Strategy", + "type": "object", + "properties": { + "symbol": { + "type": "string", + "title": "Symbol", + "examples": [ + "PSP" + ] + }, + "decimals": { + "type": "number", + "title": "Decimals", + "examples": [ + "18" + ] + }, + "address": { + "type": "string", + "title": "Address", + "pattern": "^0x[a-fA-F0-9]{40}$", + "minLength": 42, + "maxLength": 42, + "examples": [ + "0xcafe001067cdef266afb7eb5a286dcfd277f3de5" + ] + }, + "sePSP2": { + "type": "object", + "title": "sePSP2", + "properties": { + "address": { + "type": "string", + "title": "Address", + "pattern": "^0x[a-fA-F0-9]{40}$", + "minLength": 42, + "maxLength": 42, + "examples": [ + "0x593F39A4Ba26A9c8ed2128ac95D109E8e403C485" + ] + }, + "decimals": { + "type": "number", + "title": "Decimals", + "examples": [ + "18" + ] + } + } + }, + "balancer": { + "type": "object", + "title": "Balancer", + "properties": { + "poolId": { + "type": "string", + "title": "Balancer_PoolId", + "examples": [ + "0xcb0e14e96f2cefa8550ad8e4aea344f211e5061d00020000000000000000011a" + ], + "pattern": "^0x[a-fA-F0-9]{64}$", + "minLength": 66, + "maxLength": 66 + }, + "BalancerHelpers": { + "type": "string", + "title": "BalancerHelpers_address", + "pattern": "^0x[a-fA-F0-9]{40}$", + "minLength": 42, + "maxLength": 42, + "examples": [ + "0x5aDDCCa35b7A0D07C74063c48700C8590E87864E" + ] + }, + "Vault": { + "type": "string", + "title": "Vault_address", + "pattern": "^0x[a-fA-F0-9]{40}$", + "minLength": 42, + "maxLength": 42, + "examples": [ + "0xBA12222222228d8Ba445958a75a0704d566BF2C8" + ] + } + } + }, + "multiplier": { + "type": "number", + "title": "Multiplier", + "examples": [ + "2.5" + ] + } + }, + "required": [ + "decimals", + "address", + "sePSP2", + "balancer", + "multiplier" + ], + "additionalProperties": false + } + } +} \ No newline at end of file From bbc20eaf16d2e27eb05f5bf3121d06dc122ad553 Mon Sep 17 00:00:00 2001 From: Velenir Date: Fri, 27 Jan 2023 12:52:21 +0100 Subject: [PATCH 10/10] simplify params --- src/strategies/psp-in-sepsp2-balance/index.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/strategies/psp-in-sepsp2-balance/index.ts b/src/strategies/psp-in-sepsp2-balance/index.ts index 8dfe8b890..08dc87455 100644 --- a/src/strategies/psp-in-sepsp2-balance/index.ts +++ b/src/strategies/psp-in-sepsp2-balance/index.ts @@ -51,17 +51,12 @@ export async function strategy( ): Promise> { const blockTag = typeof snapshot === 'number' ? snapshot : 'latest'; - const erc20Options = { - ...options.sePSP2, - symbol: 'sePSP2' - }; - const account2BPTBalance = await fetchERC20Balances( space, network, provider, addresses, - erc20Options, + options.sePSP2, snapshot );