Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
fix: borrow liquidity has to be lower then supply liquidity (#777)
Browse files Browse the repository at this point in the history
  • Loading branch information
wpoulin authored Jun 28, 2022
1 parent 516ae1a commit 4ce52d5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 0 additions & 2 deletions src/apps/aurigami/aurora/aurigami.supply.token-fetcher.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Inject } from '@nestjs/common';

import { APP_TOOLKIT, IAppToolkit } from '~app-toolkit/app-toolkit.interface';
import { Register } from '~app-toolkit/decorators';
import { CompoundSupplyTokenHelper } from '~apps/compound';
import { PositionFetcher } from '~position/position-fetcher.interface';
Expand All @@ -17,7 +16,6 @@ const network = Network.AURORA_MAINNET;
@Register.TokenPositionFetcher({ appId, groupId, network, options: { includeInTvl: true } })
export class AuroraAurigamiSupplyTokenFetcher implements PositionFetcher<AppTokenPosition> {
constructor(
@Inject(APP_TOOLKIT) private readonly appToolkit: IAppToolkit,
@Inject(AurigamiContractFactory) private readonly aurigamiContractFactory: AurigamiContractFactory,
@Inject(CompoundSupplyTokenHelper) private readonly compoundSupplyTokenHelper: CompoundSupplyTokenHelper,
) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ export class CompoundBorrowContractPositionHelper {
const underlyingPrice = appToken.tokens[0].price;
// Liquidity is the total supply of "cash" multiplied by the price of an underlying token
const borrowedPositionliquidity = cashSupply * underlyingPrice;
const borrowLiquidity = underlyingLiquidity - borrowedPositionliquidity;

const borrowLiquidity =
borrowedPositionliquidity > underlyingLiquidity ? 0 : underlyingLiquidity - borrowedPositionliquidity;

const dataProps = {
...appToken.dataProps,
Expand Down

0 comments on commit 4ce52d5

Please sign in to comment.