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

add performance fee for delta neutral strats #131

Merged
merged 1 commit into from
Sep 13, 2024
Merged
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
15 changes: 9 additions & 6 deletions src/app/strategy/[strategyId]/_components/Strategy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
TabPanels,
Tabs,
Text,
Tooltip,
VStack,
Wrap,
WrapItem,
Expand Down Expand Up @@ -66,7 +67,7 @@

useEffect(() => {
setBalQueryEnable(true);
}, []);

Check warning on line 70 in src/app/strategy/[strategyId]/_components/Strategy.tsx

View workflow job for this annotation

GitHub Actions / Performs linting, formatting on the application

React Hook useEffect has a missing dependency: 'setBalQueryEnable'. Either include it or remove the dependency array

// const balAtom = getBalanceAtom(strategy?.holdingTokens[0]);
const balData = useAtomValue(strategy?.balanceAtom || DUMMY_BAL_ATOM);
Expand Down Expand Up @@ -159,12 +160,14 @@
<StatLabel textAlign={{ base: 'left', md: 'right' }}>
APY
</StatLabel>
<StatNumber
color="cyan"
textAlign={{ base: 'left', md: 'right' }}
>
{(strategy.netYield * 100).toFixed(2)}%
</StatNumber>
<Tooltip label="Effective APY after removing fees. We charge a 10% performance fee on the rewards generated.">
<StatNumber
color="cyan"
textAlign={{ base: 'left', md: 'right' }}
>
{(strategy.netYield * 100).toFixed(2)}%
</StatNumber>
</Tooltip>
<StatHelpText textAlign={{ base: 'left', md: 'right' }}>
{strategy.leverage.toFixed(2)}x boosted
</StatHelpText>
Expand Down Expand Up @@ -391,7 +394,7 @@
</Text>

{/* If more than 1 filtered tx */}
{transactions.filter((tx) => tx.info.strategyId == strategy.id)

Check warning on line 397 in src/app/strategy/[strategyId]/_components/Strategy.tsx

View workflow job for this annotation

GitHub Actions / Performs linting, formatting on the application

Expected '===' and instead saw '=='
.length > 0 && (
<>
<Text
Expand All @@ -405,7 +408,7 @@
</Text>

{transactions
.filter((tx) => tx.info.strategyId == strategy.id)

Check warning on line 411 in src/app/strategy/[strategyId]/_components/Strategy.tsx

View workflow job for this annotation

GitHub Actions / Performs linting, formatting on the application

Expected '===' and instead saw '=='
.map((tx, index) => {
return (
<Box
Expand Down Expand Up @@ -442,8 +445,8 @@
)}

{/* If no filtered tx */}
{transactions.filter((tx) => tx.info.strategyId == strategy.id)

Check warning on line 448 in src/app/strategy/[strategyId]/_components/Strategy.tsx

View workflow job for this annotation

GitHub Actions / Performs linting, formatting on the application

Expected '===' and instead saw '=='
.length == 0 && (

Check warning on line 449 in src/app/strategy/[strategyId]/_components/Strategy.tsx

View workflow job for this annotation

GitHub Actions / Performs linting, formatting on the application

Expected '===' and instead saw '=='
<Text fontSize={'14px'} textAlign={'center'} color="light_grey">
No transactions recorded since this feature was added. We use
your {"browser's"} storage to save your transaction history.
Expand Down
9 changes: 0 additions & 9 deletions src/components/Deposit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -329,15 +329,6 @@ export default function Deposit(props: DepositProps) {
/>
</Center>

<Text
textAlign="center"
color="disabled_bg"
fontSize="12px"
marginTop="20px"
>
No additional fees by STRKFarm
</Text>

<Box width="100%" marginTop={'15px'}>
<Flex justifyContent="space-between">
<Text fontSize={'12px'} color="color2" fontWeight={'bold'}>
Expand Down
1 change: 1 addition & 0 deletions src/strategies/IStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }[];
Expand Down
14 changes: 13 additions & 1 deletion src/strategies/delta_neutral_mm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
},
Expand Down
Loading