Skip to content

Commit

Permalink
fix: allow liq margin plus fees for new loans (#2813)
Browse files Browse the repository at this point in the history
Co-authored-by: Dean Tribble <tribble@agoric.com>
  • Loading branch information
dtribble and dtribble authored Apr 6, 2021
1 parent e15cee8 commit 5284548
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/treasury/src/vault.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export function makeVaultKit(
runBrand,
);

return divideBy(getAmountOut(quoteAmount), manager.getInitialMargin());
return divideBy(getAmountOut(quoteAmount), manager.getLiquidationMargin());
}

async function assertSufficientCollateral(collateralAmount, wantedRun) {
Expand Down Expand Up @@ -379,7 +379,6 @@ export function makeVaultKit(
} = seat.getProposal();

const collateralPayoutP = E(userSeat).getPayouts();
await assertSufficientCollateral(collateralAmount, wantedRun);

// todo trigger process() check right away, in case the price dropped while we ran

Expand All @@ -389,6 +388,8 @@ export function makeVaultKit(
}

runDebt = amountMath.add(wantedRun, fee);
await assertSufficientCollateral(collateralAmount, runDebt);

runMint.mintGains({ RUN: runDebt }, vaultSeat);
const priorCollateral = getCollateralAllocated(vaultSeat);

Expand Down

0 comments on commit 5284548

Please sign in to comment.