At vaults liquidation, how could the flow 2a result in transfers of mintedRemaining to the vaults? #8833
-
Question:Accordingly to the description of flow 2a, the remaining debt is recorded in the reserve as a shortfall and vaults receive nothing back. However, there is a condition where, if mintedRemaining is not empty, the remaining IST not burned will be sent back to the vaults. Note: I couldn't find any test covering this scenario, if it exists I would appreciate it if you could point me to it. ContextFlow 2: Auction does not raise enough to cover IST debt Flow 2a: all collateral sold and debt is not covered
When the If minted is /**
* @param {Amount<'nat'>} debt
* @param {Amount<'nat'>} minted
* @returns {{ overage: Amount<'nat'>; shortfall: Amount<'nat'> }}
*/
export const liquidationResults = (debt, minted) => {
if (AmountMath.isEmpty(minted)) {
return { overage: minted, shortfall: debt };
}
const [overage, shortfall] = AmountMath.isGTE(debt, minted)
? [AmountMath.makeEmptyFromAmount(debt), AmountMath.subtract(debt, minted)]
: [AmountMath.subtract(minted, debt), AmountMath.makeEmptyFromAmount(debt)];
return { overage, shortfall };
};
harden(liquidationResults); In Flow 2a we assume that minted is less than debt, which means that accounting object should have an empty amount as overage and some IST amount as shortfall. try {
if (AmountMath.isEmpty(accounting.shortfall)) {
// Flow #1: no shortfall
runFlow1();
} else if (AmountMath.isEmpty(collateralProceeds)) {
// Flow 2a: all collateral was sold but debt was not covered
runFlow2a();
} else {
// Flow #2b: There's unsold collateral; some vaults may be reinstated.
runFlow2b();
}
} catch (err) {
console.error('🚨 Failure running distribution flow:', err);
// continue to return `plan` in the state that was reached
} As mentioned before, we know that minted is lower than debt, so when the const penaltyInMinted = ceilMultiplyBy(totalDebt, penaltyRate);
const recoveredDebt = AmountMath.min(
AmountMath.add(totalDebt, penaltyInMinted),
mintedProceeds,
);
plan.debtToBurn = recoveredDebt;
const distributable = subtractToEmpty(mintedProceeds, recoveredDebt);
let mintedRemaining = distributable; So, assuming that mintedRemaining will be empty, the following condition will not pass and there will be no transfer of if (!AmountMath.isEmpty(mintedRemaining)) {
const mintedToReturn = AmountMath.min(mintedRemaining, vaultShare);
mintedRemaining = AmountMath.subtract(mintedRemaining, mintedToReturn);
plan.transfersToVault.push([vaultIndex, { Minted: mintedToReturn }]);
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I believe your analysis is correct. I think the extraneous check is there because it helped with a bug which has since been fixed. I looked for a short while, but didn't identify the particular bug. It doesn't seem worth tracking down further. If you'll be making changes to that file anyway, feel free to drop that clause. |
Beta Was this translation helpful? Give feedback.
I believe your analysis is correct. I think the extraneous check is there because it helped with a bug which has since been fixed. I looked for a short while, but didn't identify the particular bug. It doesn't seem worth tracking down further.
If you'll be making changes to that file anyway, feel free to drop that clause.