Skip to content
Merged

Sync #181

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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@prisma/client": "5.18.0",
"@starknet-react/chains": "^5.0.1",
"@starknet-react/core": "^5.0.1",
"@strkfarm/sdk": "1.1.28",
"@strkfarm/sdk": "1.1.39",
"@tanstack/query-core": "5.28.0",
"@types/mixpanel-browser": "2.49.0",
"@types/mustache": "4.2.5",
Expand Down
10 changes: 5 additions & 5 deletions src/app/api/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,27 +54,27 @@ export const getRewardsInfo = async (
{
token: 'ETH',
maxAPY: 100, // in %
maxRewardsPerDay: 0.538755 / 30, // tokem amount / days
maxRewardsPerDay: 0, // tokem amount / days
},
{
token: 'WBTC',
maxAPY: 100, // in %
maxRewardsPerDay: 0.02191182 / 30, // tokem amount / days
maxRewardsPerDay: 0, // tokem amount / days
},
{
token: 'USDC',
maxAPY: 100, // in %
maxRewardsPerDay: 2306 / 30, // tokem amount / days
maxRewardsPerDay: 0, // tokem amount / days
},
{
token: 'USDT',
maxAPY: 75, // in %
maxRewardsPerDay: 1349 / 30, // tokem amount / days
maxRewardsPerDay: 0, // tokem amount / days
},
{
token: 'STRK',
maxAPY: 75, // in %
maxRewardsPerDay: 10500 / 30, // tokem amount / days
maxRewardsPerDay: 0, // tokem amount / days
},
];
const allowedStrats = UniversalStrategies.map((u) => {
Expand Down
16 changes: 13 additions & 3 deletions src/app/api/strategies/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,19 @@ export async function GET(req: Request) {
// sort based on risk factor, live status and apy
// const aRisk = a.riskFactor;
// const bRisk = b.riskFactor;
const aLive = a.status.number < 5 ? 0 : a.status.number;
const bLive = b.status.number < 5 ? 0 : b.status.number;
if (aLive !== bLive) return aLive - bLive;

// Priority: status < 5 (priority 0), then status 5 (priority 1), then others (priority 2)
// console.log('statusNumber', a.status, b.status, a.name, b.name);
const getPriority = (statusNumber: number) => {
if (statusNumber < 5) return 0;
if (statusNumber === 5) return 1;
return 2;
};

const aPriority = getPriority(a.status.number);
const bPriority = getPriority(b.status.number);

// if (aPriority !== bPriority) return aPriority - bPriority;
Copy link

Copilot AI Oct 9, 2025

Choose a reason for hiding this comment

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

Dead code should be removed. The priority comparison logic is calculated but never used.

Suggested change
// if (aPriority !== bPriority) return aPriority - bPriority;
if (aPriority !== bPriority) return aPriority - bPriority;

Copilot uses AI. Check for mistakes.
// if (aRisk !== bRisk) return aRisk - bRisk;
return b.apy - a.apy;
});
Expand Down
44 changes: 20 additions & 24 deletions src/store/protocols.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import trovesLogo from '@public/logo.png';
import { atom } from 'jotai';
import CarmineAtoms, { carmine } from './carmine.store';
import EkuboAtoms, { ekubo } from './ekobu.store';
import EndurAtoms, { endur } from './endur.store';
import NostraDegenAtoms, { nostraDegen } from './nostradegen.store';
import NostraDexAtoms, { nostraDex } from './nostradex.store';
import NostraLendingAtoms, { nostraLending } from './nostralending.store';
import { Category, isPoolRetired, PoolInfo, PoolType } from './pools';
import { getLiveStatusEnum } from '@/utils/strategyStatus';
import TrovesAtoms, { troves, TrovesStrategyAPIResult } from './troves.atoms';
Expand Down Expand Up @@ -38,21 +34,21 @@ export const getProtocols = () => [
// class: tenkswap,
// atoms: TenkSwapAtoms,
// },
{
name: nostraDex.name,
class: nostraDex,
atoms: NostraDexAtoms,
},
{
name: nostraDegen.name,
class: nostraDegen,
atoms: NostraDegenAtoms,
},
{
name: carmine.name,
class: carmine,
atoms: CarmineAtoms,
},
// {
// name: nostraDex.name,
// class: nostraDex,
// atoms: NostraDexAtoms,
// },
// {
// name: nostraDegen.name,
// class: nostraDegen,
// atoms: NostraDegenAtoms,
// },
// {
// name: carmine.name,
// class: carmine,
// atoms: CarmineAtoms,
// },
// {
// name: starkDefi.name,
// class: starkDefi,
Expand All @@ -63,11 +59,11 @@ export const getProtocols = () => [
// class: sithswap,
// atoms: SithswapAtoms,
// },
{
name: nostraLending.name,
class: nostraLending,
atoms: NostraLendingAtoms,
},
// {
// name: nostraLending.name,
// class: nostraLending,
// atoms: NostraLendingAtoms,
// },
{
name: vesu.name,
class: vesu,
Expand Down
22 changes: 15 additions & 7 deletions src/store/strategies.atoms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,14 @@ export function getStrategies() {
);
});

const lstMaxTVLs = {
xWBTC: 18,
xLBTC: 5,
xtBTC: 5,
xsBTC: 5,
xSTRK: 200000,
};

const hyperLSTStrategies = HyperLSTStrategies.map((hyper) => {
const lstToken = hyper.depositTokens[0].symbol;
const baseToken = lstToken.replace('x', '');
Expand All @@ -394,7 +402,7 @@ export function getStrategies() {
hyper,
StrategyLiveStatus.HOT,
{
maxTVL: 0,
maxTVL: lstMaxTVLs[lstToken as keyof typeof lstMaxTVLs],
isPaused: false,
alerts: [
{
Expand Down Expand Up @@ -439,12 +447,12 @@ export function getStrategies() {

// undo
const strategies: IStrategy<any>[] = [
autoStrkStrategy,
autoUSDCStrategy,
deltaNeutralMMUSDCETH,
deltaNeutralMMETHUSDC,
deltaNeutralMMSTRKETH,
deltaNeutralMMETHUSDCReverse,
// autoStrkStrategy,
// autoUSDCStrategy,
// deltaNeutralMMUSDCETH,
// deltaNeutralMMETHUSDC,
// deltaNeutralMMSTRKETH,
// deltaNeutralMMETHUSDCReverse,
deltaNeutralxSTRKSTRK,
...vesuRebalanceStrats,
...ekuboCLStrats,
Expand Down
24 changes: 24 additions & 0 deletions src/strategies/hyper-lst.strat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ import {
DepositActionInputs,
IStrategySettings,
StrategyLiveStatus,
StrategyStatus,
TokenInfo,
} from './IStrategy';
import { buildStrategyActionHook, DummyStrategyActionHook } from '@/utils';
import { PoolInfo } from '@/store/pools';

export class HyperLSTStrategy extends UniversalStrategyClass<
typeof UniversalLstMultiplierStrategy
Expand Down Expand Up @@ -104,4 +106,26 @@ export class HyperLSTStrategy extends UniversalStrategyClass<
// buildStrategyActionHook([...swapCalls.calls, ...calls], [lstUnderlying]),
];
};

async solve(pools: PoolInfo[], amount: string) {
const yieldInfo = await this.universalStrategy.netAPY();
// todo to deduct fee
const LSTYield = yieldInfo.splits.find((split) => split.id == 'lst_apy');
Copy link

Copilot AI Oct 9, 2025

Choose a reason for hiding this comment

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

Use strict equality (===) instead of loose equality (==) for comparison.

Suggested change
const LSTYield = yieldInfo.splits.find((split) => split.id == 'lst_apy');
const LSTYield = yieldInfo.splits.find((split) => split.id === 'lst_apy');

Copilot uses AI. Check for mistakes.
if (!LSTYield) {
throw new Error('LST yield not found');
}
console.log(
`${this.metadata.name}::LST APY: ${LSTYield.apy}, net APY: ${yieldInfo.net}, fee factor: ${this.fee_factor}`,
);
Comment on lines +117 to +119
Copy link

Copilot AI Oct 9, 2025

Choose a reason for hiding this comment

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

Console.log statements should be removed from production code or replaced with proper logging.

Copilot uses AI. Check for mistakes.
this.netYield =
LSTYield.apy + (yieldInfo.net - LSTYield.apy) * (1 - this.fee_factor);
console.log('netYield2', this.netYield, Number(amount));
Copy link

Copilot AI Oct 9, 2025

Choose a reason for hiding this comment

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

Console.log statements should be removed from production code or replaced with proper logging.

Copilot uses AI. Check for mistakes.
this.leverage = 1;

this.investmentFlows = [];

this.postSolve();

this.status = StrategyStatus.SOLVED;
}
}
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2557,18 +2557,18 @@
viem "^2.21.1"
zod "^3.22.4"

"@strkfarm/sdk@1.1.28":
version "1.1.28"
resolved "https://registry.yarnpkg.com/@strkfarm/sdk/-/sdk-1.1.28.tgz#c74504cc1e8d2a31474518a41871128935842d7e"
integrity sha512-fGxVR8pnzdtOT9+NxTKI9+cCRUa6zSXBrxQU9KepsVzY7ZdtKikcyfA0c8RlRz3q8VpFDFey1fgTH/rhnrGtgQ==
"@strkfarm/sdk@1.1.39":
version "1.1.39"
resolved "https://registry.yarnpkg.com/@strkfarm/sdk/-/sdk-1.1.39.tgz#4a17855011b09272eb4d203bd4ae6f0678a2de43"
integrity sha512-GNwO8SeCSjNwj38TvGpZBYAGmwLQmUYIjEOgaLhEYxg0oahI6cHo95Y60NCq9ItAabrAZTLcH8/W6Xa2hHQxYg==
dependencies:
"@apollo/client" "3.11.8"
"@avnu/avnu-sdk" "3.0.2"
"@ericnordelo/strk-merkle-tree" "^1.0.0"
"@noble/curves" "^1.0.0"
"@noble/hashes" "^2.0.0"
"@scure/starknet" "^2.0.0"
"@strkfarm/sdk" "link:../../Library/Caches/Yarn/v6/npm-@strkfarm-sdk-1.1.28-c74504cc1e8d2a31474518a41871128935842d7e-integrity/node_modules/@strkfarm/sdk"
"@strkfarm/sdk" "link:../../Library/Caches/Yarn/v6/npm-@strkfarm-sdk-1.1.39-4a17855011b09272eb4d203bd4ae6f0678a2de43-integrity/node_modules/@strkfarm/sdk"
bignumber.js "4.0.4"
browser-assert "^1.2.1"
chalk "^4.1.2"
Expand Down
Loading