Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding v1 of the new ETH filter for pools #196

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions docs/add_new_protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@ export class MyProtocol extends IDapp<BaseAPYT> {
.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('/');
Expand Down Expand Up @@ -223,11 +225,13 @@ export class MyProtocol extends IDapp<BaseAPYT> {
.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('/');
Expand Down
31 changes: 31 additions & 0 deletions src/components/Filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,37 @@ export function CategoryFilters() {
</TagLabel>
</Tag>

{/* ETH pools */}
<Tag
size="lg"
borderRadius="full"
mr={'10px'}
padding={'6px 10px'}
as={'button'}
onClick={() => {
updateCategory(Category.ETH);
}}
bg={
categoriesFilter.includes(Category.ETH.valueOf())
? 'purple'
: 'color1'
}
marginBottom={'10px'}
>
<AvatarGroup size={'xs'} spacing={'-15px'} mr={'5px'}>
<Avatar
src={getTokenInfoFromName('ETH').logo}
name="ETH"
key={'ETH'}
/>
</AvatarGroup>
<TagLabel
{...getTextProps(categoriesFilter.includes(Category.ETH.valueOf()))}
>
{Category.ETH.valueOf()}
</TagLabel>
</Tag>

{/* Low risk pools */}
<Tag
size="lg"
Expand Down
10 changes: 6 additions & 4 deletions src/store/carmine.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,16 @@
const poolData = myData[config.name];
if (!poolData || !poolData.data) return;

let category: Category;
const category: Category[] = [];
const riskFactor = 3;
if (config.name.endsWith('(USDC)')) {
category = Category.Stable;
category.push(Category.Stable);
} else if (config.name.endsWith('(STRK)')) {
category = Category.STRK;
category.push(Category.STRK);
} else if (config.name.endsWith('(ETH)')) {
category.push(Category.ETH);
} else {
category = Category.Others;
category.push(Category.Others);
}

const logo1 =
Expand Down Expand Up @@ -133,9 +135,9 @@
{ name: 'wBTC/USDC Call Pool (wBTC)', endpoint: 'btc-usdc-call' },
];

export const CarmineAtom = atomWithQuery((get) => ({

Check notice on line 138 in src/store/carmine.store.ts

View check run for this annotation

codefactor.io / CodeFactor

src/store/carmine.store.ts#L138

'get' is defined but never used. Allowed unused args must match /^_/u. (unused-imports/no-unused-vars)
queryKey: ['isCarmine'],
queryFn: async ({ queryKey }) => {

Check notice on line 140 in src/store/carmine.store.ts

View check run for this annotation

codefactor.io / CodeFactor

src/store/carmine.store.ts#L140

'queryKey' is defined but never used. Allowed unused args must match /^_/u. (unused-imports/no-unused-vars)
const fetchPool = async (
endpoint: string,
): Promise<{ data: CarminePoolData }> => {
Expand Down
10 changes: 7 additions & 3 deletions src/store/ekobu.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,17 @@ export class Ekubo extends IDapp<EkuboBaseAprDoc> {
.filter(this.commonVaultFilter)
.forEach((poolName) => {
const arr = myData[poolName];
let category = Category.Others;
const category: Category[] = [];
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);
} else {
category.push(Category.Others);
}

const tokens: TokenName[] = <TokenName[]>poolName.split('/');
Expand Down
2 changes: 1 addition & 1 deletion src/store/endur.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 7 additions & 3 deletions src/store/haiko.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,17 @@
.filter(this.commonVaultFilter)
.forEach((poolName) => {
const arr = myData[poolName];
let category = Category.Others;
const category: Category[] = [];
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);
} else {
category.push(Category.Others);
}

const tokens: TokenName[] = <TokenName[]>poolName.split('/');
Expand Down Expand Up @@ -188,9 +192,9 @@

export const haiko = new Haiko();
const HaikoAtoms: ProtocolAtoms = {
baseAPRs: atomWithQuery((get) => ({

Check notice on line 195 in src/store/haiko.store.ts

View check run for this annotation

codefactor.io / CodeFactor

src/store/haiko.store.ts#L195

'get' is defined but never used. Allowed unused args must match /^_/u. (unused-imports/no-unused-vars)
queryKey: ['haiko_base_aprs'],
queryFn: async ({ queryKey }): Promise<Pool[]> => {

Check notice on line 197 in src/store/haiko.store.ts

View check run for this annotation

codefactor.io / CodeFactor

src/store/haiko.store.ts#L197

'queryKey' is defined but never used. Allowed unused args must match /^_/u. (unused-imports/no-unused-vars)
const response = await fetchWithRetry(
`${CONSTANTS.HAIKO.BASE_APR_API}`,
{
Expand Down
10 changes: 7 additions & 3 deletions src/store/hashstack.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@ export class Hashstack extends IDapp<LendingSpace.MyBaseAprDoc[]> {
const arr = myData[poolName];
if (arr.length === 0) return;

let category = Category.Others;
const category: Category[] = [];
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);
} else {
category.push(Category.Others);
}

const logo1 = CONSTANTS.LOGOS[<TokenName>poolName];
Expand Down
10 changes: 7 additions & 3 deletions src/store/jedi.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,18 @@
.filter(this.commonVaultFilter)
.forEach((poolName) => {
const arr = myData[poolName];
let category = Category.Others;
const category: Category[] = [];

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);
} else {
category.push(Category.Others);
}

const tokens: TokenName[] = <TokenName[]>poolName.split('/');
Expand Down Expand Up @@ -167,9 +171,9 @@

export const jedi = new Jediswap();
const JediAtoms: ProtocolAtoms = {
baseAPRs: atomWithQuery((get) => ({

Check notice on line 174 in src/store/jedi.store.ts

View check run for this annotation

codefactor.io / CodeFactor

src/store/jedi.store.ts#L174

'get' is defined but never used. Allowed unused args must match /^_/u. (unused-imports/no-unused-vars)
queryKey: ['jedi_base_aprs'],
queryFn: async ({ queryKey }) => {

Check notice on line 176 in src/store/jedi.store.ts

View check run for this annotation

codefactor.io / CodeFactor

src/store/jedi.store.ts#L176

'queryKey' is defined but never used. Allowed unused args must match /^_/u. (unused-imports/no-unused-vars)
console.log('jedi base');
const nowSeconds = Math.round(new Date().getTime() / 1000) - 300; // giving enough time to have data
const NowMinus1DSeconds = nowSeconds - 86400;
Expand Down
10 changes: 7 additions & 3 deletions src/store/lending.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,15 @@ export namespace LendingSpace {
const arr = myData[poolName];
if (arr.length === 0) return;

let category = Category.Others;
const category: Category[] = [];
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);
} else {
category.push(Category.Others);
}

const logo1 = CONSTANTS.LOGOS[<TokenName>poolName];
Expand Down
10 changes: 7 additions & 3 deletions src/store/myswap.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,17 @@
.filter(this.commonVaultFilter)
.forEach((poolName) => {
const arr = myData[poolName];
let category = Category.Others;
const category: Category[] = [];
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);
} else {
category.push(Category.Others);
}

const tokens: TokenName[] = <TokenName[]>poolName.split('/');
Expand Down Expand Up @@ -242,9 +246,9 @@

export const mySwap = new MySwap();
const MySwapAtoms: ProtocolAtoms = {
baseAPRs: atomWithQuery((get) => ({

Check notice on line 249 in src/store/myswap.store.ts

View check run for this annotation

codefactor.io / CodeFactor

src/store/myswap.store.ts#L249

'get' is defined but never used. Allowed unused args must match /^_/u. (unused-imports/no-unused-vars)
queryKey: ['mySwap_base_aprs'],
queryFn: async ({ queryKey }) => {

Check notice on line 251 in src/store/myswap.store.ts

View check run for this annotation

codefactor.io / CodeFactor

src/store/myswap.store.ts#L251

'queryKey' is defined but never used. Allowed unused args must match /^_/u. (unused-imports/no-unused-vars)
const pools = await fetch_pools();
const pool_keys = getPoolKeys(pools, POOL_NAMES);
const apr_data = fetchAprData(POOL_NAMES, pool_keys);
Expand Down
6 changes: 4 additions & 2 deletions src/store/nimboradex.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,13 @@ export class NimboraDex extends IDapp<NimboraDexDoc> {
.filter(this.commonVaultFilter)
.forEach((poolName) => {
const poolData: NimboraDexDoc = data[poolName];
let category = Category.Others;
const category: Category[] = [];
const riskFactor = 0.75;

if (poolName == 'USDC') {
category = Category.Stable;
category.push(Category.Stable);
} else {
category.push(Category.Others);
}

const logo =
Expand Down
9 changes: 8 additions & 1 deletion src/store/nostradegen.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
const pools: PoolInfo[] = [];
Object.entries(myData)
.filter(([_, poolData]: any) => poolData.isDegen)
.forEach(([poolName, poolData]: any) => {

Check notice on line 22 in src/store/nostradegen.store.ts

View check run for this annotation

codefactor.io / CodeFactor

src/store/nostradegen.store.ts#L22

'poolName' is defined but never used. Allowed unused args must match /^_/u. (unused-imports/no-unused-vars)
const tokens: TokenName[] = [poolData.tokenA, poolData.tokenB];
const logo1 = CONSTANTS.LOGOS[tokens[0]];
const logo2 = CONSTANTS.LOGOS[tokens[1]];
Expand All @@ -27,7 +27,14 @@
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[] = [];
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;
const poolInfo: PoolInfo = {
Expand Down
10 changes: 7 additions & 3 deletions src/store/nostradex.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,17 @@ 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[] = [];
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);
} else {
category.push(Category.Others);
}
const poolInfo: PoolInfo = {
pool: {
Expand Down
5 changes: 3 additions & 2 deletions src/store/pools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import fetchWithRetry from '@/utils/fetchWithRetry';
export enum Category {
Stable = 'Stable Pools',
STRK = 'STRK Pools',
ETH = 'ETH Pools',
Others = 'Others',
}

Expand Down Expand Up @@ -50,7 +51,7 @@ export interface PoolInfo extends PoolMetadata {
tvl: number;
apr: number; // not in %
aprSplits: APRSplit[];
category: Category;
category: Category[];
type: PoolType;
isLoading?: boolean;
additional: {
Expand All @@ -77,7 +78,7 @@ export function getDefaultPoolInfo(): PoolInfo {
apr: 0,
tvl: 0,
aprSplits: [],
category: Category.Others,
category: [Category.Others],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to validate this. @EjembiEmmanuel

type: PoolType.Derivatives,
additional: {
riskFactor: 0,
Expand Down
12 changes: 8 additions & 4 deletions src/store/protocols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,13 @@ export const allPoolsAtomUnSorted = atom((get) => {
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);
} else if (strat.name.includes('ETH')) {
category.push(Category.ETH);
}
return {
pool: {
Expand Down Expand Up @@ -306,7 +308,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;

Expand Down
10 changes: 6 additions & 4 deletions src/store/strkfarm.atoms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,15 @@ export class STRKFarm extends IDapp<STRKFarmStrategyAPIResult> {
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: {
Expand All @@ -75,7 +77,7 @@ export class STRKFarm extends IDapp<STRKFarmStrategyAPIResult> {
apr: 0,
tvl: rawPool.tvlUsd,
aprSplits: [],
category,
category: categories,
type: PoolType.Derivatives,
lending: {
collateralFactor: 0,
Expand Down
4 changes: 3 additions & 1 deletion src/strategies/IStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down