Merge pull request #14 from mars-protocol/hofix/farm-apr

fix: fixed the farm borrowing apr
This commit is contained in:
Linkie Link 2023-02-27 17:04:08 +01:00 committed by GitHub
commit 193bb0f2d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 32 deletions

View File

@ -91,7 +91,9 @@ export const useAvailableVaultsColumns = () => {
const borrowAsset = redBankAssets.find(
(asset) => asset.denom === row.original.denoms.secondary,
)
const maxBorrowRate = Number(borrowAsset?.borrowRate ?? 0) * row.original.ltv.max
const maxBorrowRate =
Number(borrowAsset?.borrowRate ?? 0) * (ltvToLeverage(row.original.ltv.max) - 1)
const minAPY = new BigNumber(row.original.apy).toNumber()
const maxAPY = new BigNumber(minAPY).times(maxLeverage).toNumber() - maxBorrowRate

View File

@ -209,7 +209,8 @@ export const BreakdownTable = (props: Props) => {
const currentLeverage = props.newPosition.currentLeverage
const trueBorrowRate =
(Number(secondaryRedBankAsset?.borrowRate ?? 0) / 2) * (Number(currentLeverage) - 1)
Number(secondaryRedBankAsset?.borrowRate ?? 0) * (Number(currentLeverage) - 1)
const apy = (props.vault.apy || 0) * currentLeverage - trueBorrowRate
const apyData = {

View File

@ -1,24 +1,18 @@
@import 'src/styles/master';
.primary,
.secondary {
position: absolute;
top: 50%;
transform: translateY(-50%);
}
.primary {
position: absolute;
margin-top: space(-1);
left: 20%;
z-index: 1;
}
.secondary {
position: absolute;
margin-top: space(1);
right: 20%;
top: 20%;
}
@media only screen and (min-width: $bpMediumLow) {
.primary {
top: 20%;
}
.secondary {
top: unset;
bottom: 20%;
}
}

View File

@ -154,6 +154,7 @@ export const vaultsSlice = (set: NamedSet<Store>, get: GetState<Store>): VaultsS
const networkConfig = get().networkConfig
if (!networkConfig) return null
try {
const response = await fetch(networkConfig!.apolloAprUrl)
if (response.ok) {
@ -176,6 +177,9 @@ export const vaultsSlice = (set: NamedSet<Store>, get: GetState<Store>): VaultsS
}
return null
} catch {
return null
}
},
getCaps: async (options?: Options) => {
const caps = get().caps
@ -360,7 +364,7 @@ export const vaultsSlice = (set: NamedSet<Store>, get: GetState<Store>): VaultsS
const borrowRate =
redBankAssets.find((asset) => asset.denom === curr.denoms.secondary)?.borrowRate || 0
const trueBorrowRate = (borrowRate / 2) * (leverage - 1)
const trueBorrowRate = (leverage - 1) * borrowRate
const getPositionStatus = (unlockTime?: number) => {
if (!unlockTime) return 'active'