From 1d0a06b48ce3bd8c864d2d9282779964c98adbfa Mon Sep 17 00:00:00 2001 From: gidonkatten Date: Thu, 2 Jan 2025 15:56:53 +0000 Subject: [PATCH] subtract xalgo staking apr if borrow --- src/lend/utils.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lend/utils.ts b/src/lend/utils.ts index 51ad9b78..6c890dca 100644 --- a/src/lend/utils.ts +++ b/src/lend/utils.ts @@ -8,7 +8,7 @@ import { ONE_12_DP, ONE_16_DP, ONE_4_DP, - SECONDS_IN_YEAR + SECONDS_IN_YEAR, } from "../math-lib"; import { enc, fromIntToByteHex, getParsedValueFromState, parseUint64s, unixTime } from "../utils"; @@ -482,6 +482,13 @@ export function userLoanInfo( netRate -= borrowBalanceValue * interestRate; netYield -= borrowBalanceValue * interestYield; + // subtract xALGO staking apr if requested (must be mainnet) + if (assetId === MainnetPools.xALGO.assetId && xAlgoStakingRateBps) { + // multiply by 1e12 to standardise at 16 d.p. + netRate -= borrowBalanceValue * xAlgoStakingRateBps * ONE_12_DP; + netYield -= borrowBalanceValue * xAlgoStakingRateBps * ONE_12_DP; + } + borrows.push({ poolAppId, assetId,