Skip to content

Commit

Permalink
add xSTRK dnmm [wip]
Browse files Browse the repository at this point in the history
  • Loading branch information
akiraonstarknet committed Jan 5, 2025
1 parent a3661e2 commit e4057b0
Show file tree
Hide file tree
Showing 12 changed files with 405 additions and 141 deletions.
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"editor.tabSize": 2,
"editor.insertSpaces": true
}
6 changes: 3 additions & 3 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
const nextConfig = {
// output: 'export',
compiler: {
removeConsole: {
exclude: ['error'],
},
// removeConsole: {
// exclude: ['error'],
// },
},
async rewrites() {
return [
Expand Down
23 changes: 18 additions & 5 deletions src/app/api/strategies/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,38 @@ import { MY_STORE } from '@/store';
import MyNumber from '@/utils/MyNumber';
import { IStrategy, NFTInfo, TokenInfo } from '@/strategies/IStrategy';
import { STRKFarmStrategyAPIResult } from '@/store/strkfarm.atoms';
import VesuAtoms, { vesu } from '@/store/vesu.store';
import EndurAtoms, { endur } from '@/store/endur.store';

export const revalidate = 3600; // 1 hr

const allPoolsAtom = atom<PoolInfo[]>((get) => {
const pools: PoolInfo[] = [];
const poolAtoms = [ZkLendAtoms, NostraLendingAtoms];
const poolAtoms = [ZkLendAtoms, NostraLendingAtoms, VesuAtoms, EndurAtoms];
return poolAtoms.reduce((_pools, p) => _pools.concat(get(p.pools)), pools);
});

async function getPools(store: any, retry = 0) {
const allPools: PoolInfo[] | undefined = store.get(allPoolsAtom);

const minProtocolsRequired = [zkLend.name, nostraLending.name];
console.log('allPools', allPools?.length);
const minProtocolsRequired = [
zkLend.name,
nostraLending.name,
vesu.name,
endur.name,
];
const hasRequiredPools = minProtocolsRequired.every((p) => {
if (!allPools) return false;
return allPools.some(
(pool) => pool.protocol.name === p && pool.type == PoolType.Lending,
);
return allPools.some((pool) => {
console.log('pool.protocol.name', pool.protocol.name);
return (
pool.protocol.name === p &&
(pool.type == PoolType.Lending || pool.type == PoolType.Staking)
);
});
});
console.log('hasRequiredPools', hasRequiredPools);
const MAX_RETRIES = 120;
if (retry >= MAX_RETRIES) {
throw new Error('Failed to fetch pools');
Expand Down
18 changes: 15 additions & 3 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const LOGOS = {
STRK: '/zklend/icons/tokens/strk.svg?w=20',
DAI: '/zklend/icons/tokens/dai.svg?w=20',
kSTRK: '/zklend/icons/tokens/kstrk.svg?w=20',
xSTRK: 'https://endur.fi/logo.svg',
};

export type TokenName =
Expand All @@ -20,7 +21,8 @@ export type TokenName =
| 'STRK'
| 'WBTC'
| 'DAI'
| 'kSTRK';
| 'kSTRK'
| 'xSTRK';

const CONSTANTS = {
DEX_INCENTIVE_URL:
Expand Down Expand Up @@ -80,6 +82,8 @@ const CONSTANTS = {
'0x9d23d9b1fa0db8c9d75a1df924c3820e594fc4ab1475695889286f3f6df250',
DeltaNeutralMMETHUSDCXL:
'0x9140757f8fb5748379be582be39d6daf704cc3a0408882c0d57981a885eed9',
DeltaNeutralxSTRKSTRKXL:
'0x7b07bf17944cbc5f8d8a3f8c75c3ddd3f3634b45d1290b88fc3b82760dd6b06',
},
MOBILE_MSG: 'Desktop/Tablet only',
};
Expand Down Expand Up @@ -117,7 +121,7 @@ export const TOKENS: TokenInfo[] = [
name: 'xSTRK',
decimals: 18,
displayDecimals: 2,
logo: CONSTANTS.LOGOS.STRK,
logo: CONSTANTS.LOGOS.xSTRK,
minAmount: MyNumber.fromEther('10', 18),
maxAmount: MyNumber.fromEther('10000', 18),
stepAmount: MyNumber.fromEther('10', 18),
Expand Down Expand Up @@ -216,7 +220,7 @@ export const TOKENS: TokenInfo[] = [
name: 'frmxSTRK',
decimals: 18,
displayDecimals: 2,
logo: CONSTANTS.LOGOS.STRK,
logo: CONSTANTS.LOGOS.xSTRK,
minAmount: MyNumber.fromEther('0.01', 18),
maxAmount: MyNumber.fromEther('10000', 18),
stepAmount: MyNumber.fromEther('0.01', 18),
Expand Down Expand Up @@ -270,6 +274,14 @@ export const NFTS: NFTInfo[] = [
mainTokenName: 'ETH',
},
},
{
name: '',
address: CONSTANTS.CONTRACTS.DeltaNeutralxSTRKSTRKXL,
logo: CONSTANTS.LOGOS.xSTRK,
config: {
mainTokenName: 'xSTRK',
},
},
];

function getNetwork(): constants.StarknetChainId {
Expand Down
1 change: 1 addition & 0 deletions src/store/IDapp.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export class IDapp<BaseAPYT> {
'USDT',
'ETH',
'STRK',
'xSTRK',
];
console.log('filter', poolName, supportedPools.includes(poolName));
// return !poolName.includes('DAI') && !poolName.includes('WSTETH') && !poolName.includes('BTC');
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 @@ -23,7 +23,7 @@ interface PoolData {
};
}

interface IndexedPoolData {
export interface IndexedPoolData {
[key: string]: PoolData[];
}

Expand Down
8 changes: 8 additions & 0 deletions src/store/nostralending.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { AtomWithQueryResult } from 'jotai-tanstack-query';
import { LendingSpace } from './lending.base';
import { IDapp } from './IDapp.store';
import { customAtomWithFetch } from '@/utils/customAtomWithFetch';
import { getTokenInfoFromName } from '@/utils';

interface MyBaseAprDoc {
_id: string;
Expand Down Expand Up @@ -61,6 +62,13 @@ const PoolAddresses: { [token: string]: NostraPoolFactor } = {
borrowFactor: 0.95,
collateralFactor: 0.8,
},
xSTRK: {
asset: getTokenInfoFromName('xSTRK').address || '',
dToken:
'0x0424638c9060d08b4820aabbb28347fc7234e2b7aadab58ad0f101e2412ea42d',
borrowFactor: 0.8,
collateralFactor: 0.6,
},
};

export class NostraLending extends IDapp<LendingSpace.MyBaseAprDoc[]> {
Expand Down
Loading

0 comments on commit e4057b0

Please sign in to comment.