Skip to content

Commit

Permalink
🚸 apr: USDC.e for leverage APR preview strategie
Browse files Browse the repository at this point in the history
  • Loading branch information
franm91 committed Apr 22, 2024
1 parent 35ae4c9 commit 766fd1c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion e2e/utils/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
swapperABI,
} from '../../types/abi';

const ERC20TokenSymbols = ['WETH', 'USDC', 'OP', 'esEXA', 'EXA'] as const;
const ERC20TokenSymbols = ['WETH', 'USDC', 'USDC.e', 'OP', 'esEXA', 'EXA'] as const;
export type ERC20TokenSymbol = (typeof ERC20TokenSymbols)[number];
export type Coin = ERC20TokenSymbol | 'ETH';

Expand Down
8 changes: 4 additions & 4 deletions pages/strategies.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,23 @@ const Strategies: NextPage = () => {
return toPercentage(Number(lowestAPR) / 1e18);
}, [accountData]);

const { depositAPR: usdcDepositAPR } = useFloatingPoolAPR('USDC', undefined, 'deposit');
const { depositAPR: usdcDepositAPR } = useFloatingPoolAPR('USDC.e', undefined, 'deposit');

const { rates } = useRewards();

const maxYield = useMemo(() => {
const usdc = getMarketAccount('USDC');
const usdc = getMarketAccount('USDC.e');
if (!usdc || !usdcDepositAPR) return '0%';
const ratio = (WAD * WAD) / (WAD - (usdc.adjustFactor * usdc.adjustFactor) / WAD);

const marketAPR =
(parseEther(String(usdcDepositAPR)) * ratio) / WAD - (usdc.floatingBorrowRate * (ratio - WAD)) / WAD;

const collateralRewardsAPR =
rates['USDC']?.map((r) => (r.floatingDeposit * ratio) / WAD).reduce((acc, curr) => acc + curr, 0n) ?? 0n;
rates['USDC.e']?.map((r) => (r.floatingDeposit * ratio) / WAD).reduce((acc, curr) => acc + curr, 0n) ?? 0n;

const borrowRewardsAPR =
rates['USDC']?.map((r) => (r.borrow * (ratio - WAD)) / WAD).reduce((acc, curr) => acc + curr, 0n) ?? 0n;
rates['USDC.e']?.map((r) => (r.borrow * (ratio - WAD)) / WAD).reduce((acc, curr) => acc + curr, 0n) ?? 0n;

return toPercentage(Number(marketAPR + collateralRewardsAPR + borrowRewardsAPR) / 1e18);
}, [getMarketAccount, rates, usdcDepositAPR]);
Expand Down

0 comments on commit 766fd1c

Please sign in to comment.