From 3b3f7dbda9bf8ab1d0d267195e63ca11d5a3dc7a Mon Sep 17 00:00:00 2001 From: akiraonstarknet Date: Fri, 13 Sep 2024 13:06:36 +0530 Subject: [PATCH] add performance fee for delta neutral strats --- .../[strategyId]/_components/Strategy.tsx | 15 +++++++++------ src/components/Deposit.tsx | 9 --------- src/strategies/IStrategy.ts | 1 + src/strategies/delta_neutral_mm.ts | 14 +++++++++++++- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/app/strategy/[strategyId]/_components/Strategy.tsx b/src/app/strategy/[strategyId]/_components/Strategy.tsx index 439c76a..44558fb 100755 --- a/src/app/strategy/[strategyId]/_components/Strategy.tsx +++ b/src/app/strategy/[strategyId]/_components/Strategy.tsx @@ -23,6 +23,7 @@ import { TabPanels, Tabs, Text, + Tooltip, VStack, Wrap, WrapItem, @@ -159,12 +160,14 @@ const Strategy = ({ params }: StrategyParams) => { APY - - {(strategy.netYield * 100).toFixed(2)}% - + + + {(strategy.netYield * 100).toFixed(2)}% + + {strategy.leverage.toFixed(2)}x boosted diff --git a/src/components/Deposit.tsx b/src/components/Deposit.tsx index 1a290ff..8f42c13 100755 --- a/src/components/Deposit.tsx +++ b/src/components/Deposit.tsx @@ -329,15 +329,6 @@ export default function Deposit(props: DepositProps) { /> - - No additional fees by STRKFarm - - diff --git a/src/strategies/IStrategy.ts b/src/strategies/IStrategy.ts index 67265f2..2b65fc8 100755 --- a/src/strategies/IStrategy.ts +++ b/src/strategies/IStrategy.ts @@ -92,6 +92,7 @@ export class IStrategyProps { actions: StrategyAction[] = []; netYield: number = 0; leverage: number = 0; + fee_factor = 0; // in absolute terms, not % status = StrategyStatus.UNINTIALISED; readonly rewardTokens: { logo: string }[]; diff --git a/src/strategies/delta_neutral_mm.ts b/src/strategies/delta_neutral_mm.ts index c4e9e80..4ccaae0 100755 --- a/src/strategies/delta_neutral_mm.ts +++ b/src/strategies/delta_neutral_mm.ts @@ -31,6 +31,7 @@ export class DeltaNeutralMM extends IStrategy { readonly strategyAddress: string; // Factor of Amount to be deposited/borrowed at each step relative to the previous step readonly stepAmountFactors: number[]; + fee_factor = 0.1; // 10% fee constructor( token: TokenInfo, @@ -149,10 +150,21 @@ export class DeltaNeutralMM extends IStrategy { const _amount = ( Number(amount) * this.stepAmountFactors[actions.length] ).toFixed(2); + const pool = { ...eligiblePools[0] }; + const isDeposit = actions.length == 0 || actions.length == 2; + const effectiveAPR = pool.aprSplits.reduce((a, b) => { + if (b.apr == 'Err') return a; + if (!isDeposit) return a + Number(b.apr); + if (b.title.includes('STRK rewards')) { + return a + Number(b.apr) * (1 - this.fee_factor); + } + return a + Number(b.apr); + }, 0); + pool.apr = isDeposit ? effectiveAPR : pool.borrow.apr; return [ ...actions, { - pool: eligiblePools[0], + pool, amount: _amount, isDeposit: actions.length == 0 || actions.length == 2, },