Skip to content

Commit

Permalink
reduce debug/trace output
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Feb 14, 2022
1 parent b85cc96 commit 5af883b
Showing 1 changed file with 3 additions and 28 deletions.
31 changes: 3 additions & 28 deletions packages/run-protocol/src/vaultFactory/vault.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,8 @@ export const makeVaultKit = (
* @param {Amount} oldDebt - prior principal and all accrued interest
* @param {Amount} oldCollateral - actual collateral
* @param {Amount} newDebt - actual principal and all accrued interest
* @param {Amount} newCollateral - actual collateral
*/
const refreshLoanTracking = (
oldDebt,
oldCollateral,
newDebt,
newCollateral,
) => {
trace(idInManager, 'refreshLoanTracking', {
oldDebt,
oldCollateral,
newDebt,
newCollateral,
});
const refreshLoanTracking = (oldDebt, oldCollateral, newDebt) => {
updateDebtSnapshot(newDebt);
// update vault manager which tracks total debt
manager.applyDebtDelta(oldDebt, newDebt);
Expand Down Expand Up @@ -253,8 +241,6 @@ export const makeVaultKit = (
vaultState,
});

trace('updateUiState', uiState);

switch (vaultState) {
case VaultState.ACTIVE:
case VaultState.LIQUIDATING:
Expand Down Expand Up @@ -283,15 +269,13 @@ export const makeVaultKit = (
* @param {Amount} newDebt
*/
const liquidated = newDebt => {
trace(idInManager, 'liquidated', newDebt);
updateDebtSnapshot(newDebt);

vaultState = VaultState.CLOSED;
updateUiState();
};

const liquidating = () => {
trace(idInManager, 'liquidating');
vaultState = VaultState.LIQUIDATING;
updateUiState();
};
Expand Down Expand Up @@ -489,7 +473,6 @@ export const makeVaultKit = (
* @param {ZCFSeat} clientSeat
*/
const adjustBalancesHook = async clientSeat => {
trace('adjustBalancesHook start');
assertVaultIsOpen();
const proposal = clientSeat.getProposal();
const oldDebt = getDebtAmount();
Expand Down Expand Up @@ -559,10 +542,8 @@ export const makeVaultKit = (
transferRun(clientSeat);
manager.reallocateReward(fee, vaultSeat, clientSeat);

trace('adjustBalancesHook', { oldCollateral, newDebt });

// parent needs to know about the change in debt
refreshLoanTracking(oldDebt, oldCollateral, newDebt, getCollateralAmount());
refreshLoanTracking(oldDebt, oldCollateral, newDebt);

runMint.burnLosses(harden({ RUN: runAfter.vault }), vaultSeat);

Expand All @@ -587,7 +568,6 @@ export const makeVaultKit = (
);
const oldDebt = getDebtAmount();
const oldCollateral = getCollateralAmount();
trace('openLoan start: collateral', { oldDebt, oldCollateral });

// get the payout to provide access to the collateral if the
// contract abandons
Expand All @@ -604,7 +584,6 @@ export const makeVaultKit = (
Error('loan requested is too small; cannot accrue interest'),
);
}
trace(idInManager, 'openLoan', { wantedRun, fee }, getCollateralAmount());

const runDebt = AmountMath.add(wantedRun, fee);
await assertSufficientCollateral(collateralAmount, runDebt);
Expand All @@ -617,11 +596,7 @@ export const makeVaultKit = (
);
manager.reallocateReward(fee, vaultSeat, seat);

trace(
'openLoan about to refreshLoanTracking: collateral',
getCollateralAmount(),
);
refreshLoanTracking(oldDebt, oldCollateral, runDebt, collateralAmount);
refreshLoanTracking(oldDebt, oldCollateral, runDebt);

updateUiState();

Expand Down

0 comments on commit 5af883b

Please sign in to comment.