From f56b5697c7b7177365a478f430fb11ff5f220aab Mon Sep 17 00:00:00 2001 From: Gerson2102 Date: Fri, 13 Dec 2024 23:10:58 -0600 Subject: [PATCH 1/5] Adding v1 of the new ETH filter for pools --- src/components/Filters.tsx | 31 +++++++++++++++++++++++++++++++ src/store/pools.ts | 5 +++-- src/store/protocols.ts | 10 ++++++---- src/store/strkfarm.atoms.ts | 10 ++++++---- 4 files changed, 46 insertions(+), 10 deletions(-) diff --git a/src/components/Filters.tsx b/src/components/Filters.tsx index 7851f969..ed454a01 100755 --- a/src/components/Filters.tsx +++ b/src/components/Filters.tsx @@ -313,6 +313,37 @@ export function CategoryFilters() { + {/* ETH pools */} + { + updateCategory(Category.ETH); + }} + bg={ + categoriesFilter.includes(Category.ETH.valueOf()) + ? 'purple' + : 'color1' + } + marginBottom={'10px'} + > + + + + + {Category.ETH.valueOf()} + + + {/* Low risk pools */} { export function getPoolInfoFromStrategy( strat: STRKFarmStrategyAPIResult, ): PoolInfo { - let category = Category.Others; + const category = [Category.Others]; if (strat.name.includes('STRK')) { - category = Category.STRK; + category.push(Category.STRK); } else if (strat.name.includes('USDC')) { - category = Category.Stable; + category.push(Category.Stable); } return { pool: { @@ -306,7 +306,9 @@ export const filteredPools = atom((get) => { // category filter if ( !categories.includes(ALL_FILTER) && - !categories.includes(pool.category.valueOf()) + !categories.some((category) => + pool.category.some((poolCategory) => poolCategory === category), + ) ) return false; diff --git a/src/store/strkfarm.atoms.ts b/src/store/strkfarm.atoms.ts index 6c2520d1..6baefc2c 100644 --- a/src/store/strkfarm.atoms.ts +++ b/src/store/strkfarm.atoms.ts @@ -53,13 +53,15 @@ export class STRKFarm extends IDapp { const rawPools: STRKFarmStrategyAPIResult[] = data.strategies; const pools: PoolInfo[] = []; return rawPools.map((rawPool) => { - let category = Category.Others; + const categories = [Category.Others]; const poolName = rawPool.name; const riskFactor = rawPool.riskFactor; if (poolName.includes('USDC') || poolName.includes('USDT')) { - category = Category.Stable; + categories.push(Category.Stable); } else if (poolName.includes('STRK')) { - category = Category.STRK; + categories.push(Category.STRK); + } else if (poolName.includes('ETH')) { + categories.push(Category.ETH); } const poolInfo: PoolInfo = { pool: { @@ -75,7 +77,7 @@ export class STRKFarm extends IDapp { apr: 0, tvl: rawPool.tvlUsd, aprSplits: [], - category, + category: categories, type: PoolType.Derivatives, lending: { collateralFactor: 0, From 739b6b3c57028fc0f7680c60e31fde0b589fbc88 Mon Sep 17 00:00:00 2001 From: Gerson2102 Date: Sat, 14 Dec 2024 11:17:26 -0600 Subject: [PATCH 2/5] Adding all the ETH filters in stores --- src/store/carmine.store.ts | 10 +++++----- src/store/ekobu.store.ts | 8 +++++--- src/store/haiko.store.ts | 8 +++++--- src/store/jedi.store.ts | 8 +++++--- src/store/myswap.store.ts | 8 +++++--- src/store/nostradegen.store.ts | 7 ++++++- src/store/nostradex.store.ts | 8 +++++--- src/store/protocols.ts | 2 ++ 8 files changed, 38 insertions(+), 21 deletions(-) diff --git a/src/store/carmine.store.ts b/src/store/carmine.store.ts index d24d1d0e..4ff5cdfe 100755 --- a/src/store/carmine.store.ts +++ b/src/store/carmine.store.ts @@ -48,14 +48,14 @@ export class Carmine extends Jediswap { const poolData = myData[config.name]; if (!poolData || !poolData.data) return; - let category: Category; + const category: Category[] = [Category.Others]; const riskFactor = 3; if (config.name.endsWith('(USDC)')) { - category = Category.Stable; + category.push(Category.Stable); } else if (config.name.endsWith('(STRK)')) { - category = Category.STRK; - } else { - category = Category.Others; + category.push(Category.STRK); + } else if (config.name.endsWith('(ETH)')) { + category.push(Category.ETH); } const logo1 = diff --git a/src/store/ekobu.store.ts b/src/store/ekobu.store.ts index aee40d33..b99af530 100755 --- a/src/store/ekobu.store.ts +++ b/src/store/ekobu.store.ts @@ -95,13 +95,15 @@ export class Ekubo extends IDapp { .filter(this.commonVaultFilter) .forEach((poolName) => { const arr = myData[poolName]; - let category = Category.Others; + const category: Category[] = [Category.Others]; let riskFactor = 3; if (poolName === 'USDC/USDT') { - category = Category.Stable; + category.push(Category.Stable); riskFactor = 0.5; } else if (poolName.includes('STRK')) { - category = Category.STRK; + category.push(Category.STRK); + } else if (poolName.includes('ETH')) { + category.push(Category.ETH); } const tokens: TokenName[] = poolName.split('/'); diff --git a/src/store/haiko.store.ts b/src/store/haiko.store.ts index 3d8ff9bd..f4f44bb2 100755 --- a/src/store/haiko.store.ts +++ b/src/store/haiko.store.ts @@ -62,13 +62,15 @@ export class Haiko extends IDapp { .filter(this.commonVaultFilter) .forEach((poolName) => { const arr = myData[poolName]; - let category = Category.Others; + const category: Category[] = [Category.Others]; let riskFactor = 3; if (poolName === 'USDC/USDT') { - category = Category.Stable; + category.push(Category.Stable); riskFactor = 0.5; } else if (poolName.includes('STRK')) { - category = Category.STRK; + category.push(Category.STRK); + } else if (poolName.includes('ETH')) { + category.push(Category.ETH); } const tokens: TokenName[] = poolName.split('/'); diff --git a/src/store/jedi.store.ts b/src/store/jedi.store.ts index 6ac516c7..cca43894 100755 --- a/src/store/jedi.store.ts +++ b/src/store/jedi.store.ts @@ -45,14 +45,16 @@ export class Jediswap extends IDapp { .filter(this.commonVaultFilter) .forEach((poolName) => { const arr = myData[poolName]; - let category = Category.Others; + const category: Category[] = [Category.Others]; let riskFactor = 3; if (poolName === 'USDC/USDT') { - category = Category.Stable; + category.push(Category.Stable); riskFactor = 0.5; } else if (poolName.includes('STRK')) { - category = Category.STRK; + category.push(Category.STRK); + } else if (poolName.includes('ETH')) { + category.push(Category.ETH); } const tokens: TokenName[] = poolName.split('/'); diff --git a/src/store/myswap.store.ts b/src/store/myswap.store.ts index 6f20c9e9..8cbeb737 100755 --- a/src/store/myswap.store.ts +++ b/src/store/myswap.store.ts @@ -77,13 +77,15 @@ export class MySwap extends IDapp { .filter(this.commonVaultFilter) .forEach((poolName) => { const arr = myData[poolName]; - let category = Category.Others; + const category: Category[] = [Category.Others]; let riskFactor = 3; if (poolName === 'USDC/USDT') { - category = Category.Stable; + category.push(Category.Stable); riskFactor = 0.5; } else if (poolName.includes('STRK')) { - category = Category.STRK; + category.push(Category.STRK); + } else if (poolName.includes('ETH')) { + category.push(Category.ETH); } const tokens: TokenName[] = poolName.split('/'); diff --git a/src/store/nostradegen.store.ts b/src/store/nostradegen.store.ts index 5a58325d..7c5d46e1 100755 --- a/src/store/nostradegen.store.ts +++ b/src/store/nostradegen.store.ts @@ -27,7 +27,12 @@ export class NostraDegen extends Jediswap { poolData.baseApr === '0' ? 0.0 : parseFloat(poolData.baseApr); const rewardApr = parseFloat(poolData.rewardApr); const isStrkPool = poolData.id.includes('STRK'); - const category = isStrkPool ? Category.STRK : Category.Others; + const category: Category[] = [Category.Others]; + if (isStrkPool) { + category.push(Category.STRK); + } else if (poolData.id.includes('ETH')) { + category.push(Category.ETH); + } const _poolName = poolData.id; const poolInfo: PoolInfo = { diff --git a/src/store/nostradex.store.ts b/src/store/nostradex.store.ts index aa17ed0b..3deedefc 100755 --- a/src/store/nostradex.store.ts +++ b/src/store/nostradex.store.ts @@ -33,13 +33,15 @@ export class NostraDex extends Jediswap { poolData.baseApr === '0' ? 0.0 : parseFloat(poolData.baseApr); const rewardApr = parseFloat(poolData.rewardApr); - let category = Category.Others; + const category: Category[] = [Category.Others]; let riskFactor = 3; if (poolData.id === 'USDC-USDT') { - category = Category.Stable; + category.push(Category.Stable); riskFactor = 0.5; } else if (poolData.id.includes('STRK')) { - category = Category.STRK; + category.push(Category.STRK); + } else if (poolData.id.includes('ETH')) { + category.push(Category.ETH); } const poolInfo: PoolInfo = { pool: { diff --git a/src/store/protocols.ts b/src/store/protocols.ts index 9f1b9fcd..7c2c8ca2 100644 --- a/src/store/protocols.ts +++ b/src/store/protocols.ts @@ -187,6 +187,8 @@ export function getPoolInfoFromStrategy( category.push(Category.STRK); } else if (strat.name.includes('USDC')) { category.push(Category.Stable); + } else if (strat.name.includes('ETH')) { + category.push(Category.ETH); } return { pool: { From f2d34b5c73cf4ad4201fbdb553a4b7a30d75845a Mon Sep 17 00:00:00 2001 From: Gerson2102 Date: Sat, 14 Dec 2024 11:35:11 -0600 Subject: [PATCH 3/5] Changing new way of adding protocol in docs file --- docs/add_new_protocol.md | 16 ++++++++++------ src/store/endur.store.ts | 2 +- src/store/hashstack.store.ts | 8 +++++--- src/store/lending.base.ts | 8 +++++--- src/store/nimboradex.store.ts | 4 ++-- 5 files changed, 23 insertions(+), 15 deletions(-) diff --git a/docs/add_new_protocol.md b/docs/add_new_protocol.md index 40cecd57..d1611ca5 100755 --- a/docs/add_new_protocol.md +++ b/docs/add_new_protocol.md @@ -57,11 +57,13 @@ export class MyProtocol extends IDapp { .filter(this.commonVaultFilter) .forEach((poolName) => { const arr = myData[poolName]; - let category = Category.Others; + let category: Category[] = [Category.Others]; if (poolName === 'USDC/USDT') { - category = Category.Stable; + category.push(Category.Stable); } else if (poolName.includes('STRK')) { - category = Category.STRK; + category.push(Category.STRK); + } else if (poolName.includes('ETH')) { + category.push(Category.ETH); } const tokens: TokenName[] = poolName.split('/'); @@ -223,11 +225,13 @@ export class MyProtocol extends IDapp { .filter(this.commonVaultFilter) .forEach((poolName) => { const arr = myData[poolName]; - let category = Category.Others; + let category: Category[] = [Category.Others]; if (poolName === 'USDC/USDT') { - category = Category.Stable; + category.push(Category.Stable); } else if (poolName.includes('STRK')) { - category = Category.STRK; + category.push(Category.STRK); + } else if (poolName.includes('ETH')) { + category.push(Category.ETH); } const tokens: TokenName[] = poolName.split('/'); diff --git a/src/store/endur.store.ts b/src/store/endur.store.ts index 1fc8e659..79db98ce 100644 --- a/src/store/endur.store.ts +++ b/src/store/endur.store.ts @@ -97,7 +97,7 @@ const EndurAtoms = { description: 'Includes fees & Defi spring rewards', }, ], - category: Category.STRK, + category: [Category.STRK], type: PoolType.Staking, additional: { riskFactor: 0.5, diff --git a/src/store/hashstack.store.ts b/src/store/hashstack.store.ts index 4d32a3da..1a562aab 100755 --- a/src/store/hashstack.store.ts +++ b/src/store/hashstack.store.ts @@ -29,11 +29,13 @@ export class Hashstack extends IDapp { const arr = myData[poolName]; if (arr.length === 0) return; - let category = Category.Others; + const category: Category[] = [Category.Others]; if (['USDC', 'USDT'].includes(poolName)) { - category = Category.Stable; + category.push(Category.Stable); } else if (poolName.includes('STRK')) { - category = Category.STRK; + category.push(Category.STRK); + } else if (poolName.includes('ETH')) { + category.push(Category.ETH); } const logo1 = CONSTANTS.LOGOS[poolName]; diff --git a/src/store/lending.base.ts b/src/store/lending.base.ts index 11179fcb..113571a1 100755 --- a/src/store/lending.base.ts +++ b/src/store/lending.base.ts @@ -56,11 +56,13 @@ export namespace LendingSpace { const arr = myData[poolName]; if (arr.length === 0) return; - let category = Category.Others; + const category: Category[] = [Category.Others]; if (['USDC', 'USDT'].includes(poolName)) { - category = Category.Stable; + category.push(Category.Stable); } else if (poolName.includes('STRK')) { - category = Category.STRK; + category.push(Category.STRK); + } else if (poolName.includes('ETH')) { + category.push(Category.ETH); } const logo1 = CONSTANTS.LOGOS[poolName]; diff --git a/src/store/nimboradex.store.ts b/src/store/nimboradex.store.ts index 28a72177..74b2bd56 100644 --- a/src/store/nimboradex.store.ts +++ b/src/store/nimboradex.store.ts @@ -59,11 +59,11 @@ export class NimboraDex extends IDapp { .filter(this.commonVaultFilter) .forEach((poolName) => { const poolData: NimboraDexDoc = data[poolName]; - let category = Category.Others; + const category: Category[] = [Category.Others]; const riskFactor = 0.75; if (poolName == 'USDC') { - category = Category.Stable; + category.push(Category.Stable); } const logo = From 002d70a79e75f5cada7c3546c0dbc9290eef8a54 Mon Sep 17 00:00:00 2001 From: EjembiEmmanuel Date: Thu, 19 Dec 2024 11:35:48 +0100 Subject: [PATCH 4/5] fix: fix eligible pools filter --- src/strategies/IStrategy.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/strategies/IStrategy.ts b/src/strategies/IStrategy.ts index 21e26398..f0a24dd6 100755 --- a/src/strategies/IStrategy.ts +++ b/src/strategies/IStrategy.ts @@ -222,7 +222,9 @@ export class IStrategy extends IStrategyProps { amount: string, prevActions: StrategyAction[], ) { - const eligiblePools = pools.filter((p) => p.category == Category.Stable); + const eligiblePools = pools.filter((p) => + p.category.includes(Category.Stable), + ); if (!eligiblePools) throw new Error(`${this.tag}: [F1] no eligible pools`); return eligiblePools; } From 358dcbc6a7100082d883c66fbf5549372243af87 Mon Sep 17 00:00:00 2001 From: Gerson2102 Date: Mon, 23 Dec 2024 11:09:31 -0600 Subject: [PATCH 5/5] Addressing PR comment related to defining the others category --- src/store/carmine.store.ts | 4 +++- src/store/ekobu.store.ts | 4 +++- src/store/haiko.store.ts | 4 +++- src/store/hashstack.store.ts | 4 +++- src/store/jedi.store.ts | 4 +++- src/store/lending.base.ts | 4 +++- src/store/myswap.store.ts | 4 +++- src/store/nimboradex.store.ts | 4 +++- src/store/nostradegen.store.ts | 4 +++- src/store/nostradex.store.ts | 4 +++- 10 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/store/carmine.store.ts b/src/store/carmine.store.ts index 4ff5cdfe..9389fad1 100755 --- a/src/store/carmine.store.ts +++ b/src/store/carmine.store.ts @@ -48,7 +48,7 @@ export class Carmine extends Jediswap { const poolData = myData[config.name]; if (!poolData || !poolData.data) return; - const category: Category[] = [Category.Others]; + const category: Category[] = []; const riskFactor = 3; if (config.name.endsWith('(USDC)')) { category.push(Category.Stable); @@ -56,6 +56,8 @@ export class Carmine extends Jediswap { category.push(Category.STRK); } else if (config.name.endsWith('(ETH)')) { category.push(Category.ETH); + } else { + category.push(Category.Others); } const logo1 = diff --git a/src/store/ekobu.store.ts b/src/store/ekobu.store.ts index b99af530..59822ad5 100755 --- a/src/store/ekobu.store.ts +++ b/src/store/ekobu.store.ts @@ -95,7 +95,7 @@ export class Ekubo extends IDapp { .filter(this.commonVaultFilter) .forEach((poolName) => { const arr = myData[poolName]; - const category: Category[] = [Category.Others]; + const category: Category[] = []; let riskFactor = 3; if (poolName === 'USDC/USDT') { category.push(Category.Stable); @@ -104,6 +104,8 @@ export class Ekubo extends IDapp { category.push(Category.STRK); } else if (poolName.includes('ETH')) { category.push(Category.ETH); + } else { + category.push(Category.Others); } const tokens: TokenName[] = poolName.split('/'); diff --git a/src/store/haiko.store.ts b/src/store/haiko.store.ts index f4f44bb2..53191497 100755 --- a/src/store/haiko.store.ts +++ b/src/store/haiko.store.ts @@ -62,7 +62,7 @@ export class Haiko extends IDapp { .filter(this.commonVaultFilter) .forEach((poolName) => { const arr = myData[poolName]; - const category: Category[] = [Category.Others]; + const category: Category[] = []; let riskFactor = 3; if (poolName === 'USDC/USDT') { category.push(Category.Stable); @@ -71,6 +71,8 @@ export class Haiko extends IDapp { category.push(Category.STRK); } else if (poolName.includes('ETH')) { category.push(Category.ETH); + } else { + category.push(Category.Others); } const tokens: TokenName[] = poolName.split('/'); diff --git a/src/store/hashstack.store.ts b/src/store/hashstack.store.ts index 1a562aab..feecf9bf 100755 --- a/src/store/hashstack.store.ts +++ b/src/store/hashstack.store.ts @@ -29,13 +29,15 @@ export class Hashstack extends IDapp { const arr = myData[poolName]; if (arr.length === 0) return; - const category: Category[] = [Category.Others]; + const category: Category[] = []; if (['USDC', 'USDT'].includes(poolName)) { category.push(Category.Stable); } else if (poolName.includes('STRK')) { category.push(Category.STRK); } else if (poolName.includes('ETH')) { category.push(Category.ETH); + } else { + category.push(Category.Others); } const logo1 = CONSTANTS.LOGOS[poolName]; diff --git a/src/store/jedi.store.ts b/src/store/jedi.store.ts index cca43894..7c1c49dc 100755 --- a/src/store/jedi.store.ts +++ b/src/store/jedi.store.ts @@ -45,7 +45,7 @@ export class Jediswap extends IDapp { .filter(this.commonVaultFilter) .forEach((poolName) => { const arr = myData[poolName]; - const category: Category[] = [Category.Others]; + const category: Category[] = []; let riskFactor = 3; if (poolName === 'USDC/USDT') { @@ -55,6 +55,8 @@ export class Jediswap extends IDapp { category.push(Category.STRK); } else if (poolName.includes('ETH')) { category.push(Category.ETH); + } else { + category.push(Category.Others); } const tokens: TokenName[] = poolName.split('/'); diff --git a/src/store/lending.base.ts b/src/store/lending.base.ts index 113571a1..b2cae266 100755 --- a/src/store/lending.base.ts +++ b/src/store/lending.base.ts @@ -56,13 +56,15 @@ export namespace LendingSpace { const arr = myData[poolName]; if (arr.length === 0) return; - const category: Category[] = [Category.Others]; + const category: Category[] = []; if (['USDC', 'USDT'].includes(poolName)) { category.push(Category.Stable); } else if (poolName.includes('STRK')) { category.push(Category.STRK); } else if (poolName.includes('ETH')) { category.push(Category.ETH); + } else { + category.push(Category.Others); } const logo1 = CONSTANTS.LOGOS[poolName]; diff --git a/src/store/myswap.store.ts b/src/store/myswap.store.ts index 8cbeb737..e8385731 100755 --- a/src/store/myswap.store.ts +++ b/src/store/myswap.store.ts @@ -77,7 +77,7 @@ export class MySwap extends IDapp { .filter(this.commonVaultFilter) .forEach((poolName) => { const arr = myData[poolName]; - const category: Category[] = [Category.Others]; + const category: Category[] = []; let riskFactor = 3; if (poolName === 'USDC/USDT') { category.push(Category.Stable); @@ -86,6 +86,8 @@ export class MySwap extends IDapp { category.push(Category.STRK); } else if (poolName.includes('ETH')) { category.push(Category.ETH); + } else { + category.push(Category.Others); } const tokens: TokenName[] = poolName.split('/'); diff --git a/src/store/nimboradex.store.ts b/src/store/nimboradex.store.ts index 74b2bd56..7787c7f5 100644 --- a/src/store/nimboradex.store.ts +++ b/src/store/nimboradex.store.ts @@ -59,11 +59,13 @@ export class NimboraDex extends IDapp { .filter(this.commonVaultFilter) .forEach((poolName) => { const poolData: NimboraDexDoc = data[poolName]; - const category: Category[] = [Category.Others]; + const category: Category[] = []; const riskFactor = 0.75; if (poolName == 'USDC') { category.push(Category.Stable); + } else { + category.push(Category.Others); } const logo = diff --git a/src/store/nostradegen.store.ts b/src/store/nostradegen.store.ts index 7c5d46e1..dce9d4b8 100755 --- a/src/store/nostradegen.store.ts +++ b/src/store/nostradegen.store.ts @@ -27,11 +27,13 @@ export class NostraDegen extends Jediswap { poolData.baseApr === '0' ? 0.0 : parseFloat(poolData.baseApr); const rewardApr = parseFloat(poolData.rewardApr); const isStrkPool = poolData.id.includes('STRK'); - const category: Category[] = [Category.Others]; + const category: Category[] = []; if (isStrkPool) { category.push(Category.STRK); } else if (poolData.id.includes('ETH')) { category.push(Category.ETH); + } else { + category.push(Category.Others); } const _poolName = poolData.id; diff --git a/src/store/nostradex.store.ts b/src/store/nostradex.store.ts index 3deedefc..246647d8 100755 --- a/src/store/nostradex.store.ts +++ b/src/store/nostradex.store.ts @@ -33,7 +33,7 @@ export class NostraDex extends Jediswap { poolData.baseApr === '0' ? 0.0 : parseFloat(poolData.baseApr); const rewardApr = parseFloat(poolData.rewardApr); - const category: Category[] = [Category.Others]; + const category: Category[] = []; let riskFactor = 3; if (poolData.id === 'USDC-USDT') { category.push(Category.Stable); @@ -42,6 +42,8 @@ export class NostraDex extends Jediswap { category.push(Category.STRK); } else if (poolData.id.includes('ETH')) { category.push(Category.ETH); + } else { + category.push(Category.Others); } const poolInfo: PoolInfo = { pool: {