diff --git a/packages/huma-shared/src/solana/utils/poolUtils.ts b/packages/huma-shared/src/solana/utils/poolUtils.ts index 873c2135..25cf2ae8 100644 --- a/packages/huma-shared/src/solana/utils/poolUtils.ts +++ b/packages/huma-shared/src/solana/utils/poolUtils.ts @@ -14,11 +14,7 @@ export const getSolanaPoolApy = ( defaultMaxSeniorJuniorRatio: number, fixedSeniorYieldInBps: number, tranchesRiskAdjustmentInBps: number, -): { - blendedApy: number - seniorTrancheApy: number - juniorTrancheApy: number -} => +) => getPoolApyV2( protocolFeeInBps, yieldInBps, diff --git a/packages/huma-shared/src/utils/apy.ts b/packages/huma-shared/src/utils/apy.ts index ff0550b8..aaab75a1 100644 --- a/packages/huma-shared/src/utils/apy.ts +++ b/packages/huma-shared/src/utils/apy.ts @@ -38,7 +38,7 @@ const getFlcTotalAssetsAfterRisk = ( return flcTotalAssetsAfterRisk } -export const getPoolApyV2 = ( +const getPoolApyV2Base = ( protocolFeeInBps: number, yieldInBps: number, rewardRateInBpsForPoolOwner: number, @@ -153,3 +153,57 @@ export const getPoolApyV2 = ( juniorTrancheApy, } } + +export const getPoolApyV2 = ( + protocolFeeInBps: number, + yieldInBps: number, + rewardRateInBpsForPoolOwner: number, + rewardRateInBpsForEA: number, + liquidityCap: string, + seniorDeployedAssets: string, + juniorDeployedAssets: string, + maxSeniorJuniorRatio: number, + fixedSeniorYieldInBps: number, + tranchesRiskAdjustmentInBps: number, + BP_FACTOR: number, + FirstLossCoverIndexes: string[] = [], + flcConfigs: FclConfig[] = [], +): PoolApy & { maxJuniorTrancheApy: number } => { + const realApyResult = getPoolApyV2Base( + protocolFeeInBps, + yieldInBps, + rewardRateInBpsForPoolOwner, + rewardRateInBpsForEA, + liquidityCap, + seniorDeployedAssets, + juniorDeployedAssets, + maxSeniorJuniorRatio, + fixedSeniorYieldInBps, + tranchesRiskAdjustmentInBps, + BP_FACTOR, + FirstLossCoverIndexes, + flcConfigs, + ) + + const liquidityCapBN = BigNumber.from(liquidityCap) + const juniorAssetsBN = liquidityCapBN.div(maxSeniorJuniorRatio + 1) + const seniorAssetsBN = liquidityCapBN.sub(juniorAssetsBN) + const maxJuniorApyResult = getPoolApyV2Base( + protocolFeeInBps, + yieldInBps, + rewardRateInBpsForPoolOwner, + rewardRateInBpsForEA, + liquidityCap, + seniorAssetsBN.toString(), + juniorAssetsBN.toString(), + maxSeniorJuniorRatio, + fixedSeniorYieldInBps, + tranchesRiskAdjustmentInBps, + BP_FACTOR, + ) + + return { + ...realApyResult, + maxJuniorTrancheApy: maxJuniorApyResult.juniorTrancheApy, + } +} diff --git a/packages/huma-web-shared/src/solana/types/solanaPoolState.ts b/packages/huma-web-shared/src/solana/types/solanaPoolState.ts index 3805dd9f..eb5cfdf4 100644 --- a/packages/huma-web-shared/src/solana/types/solanaPoolState.ts +++ b/packages/huma-web-shared/src/solana/types/solanaPoolState.ts @@ -20,6 +20,7 @@ export type SolanaPoolState = { rangeApy?: string seniorTrancheApy?: number juniorTrancheApy?: number + maxJuniorTrancheApy?: number amountDefaulted?: number amountOriginated?: number amountRepaid?: number