-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(run-protocol): charge penalty for liquidation (#4996)
* refactor(run-protocol): broaden scope of collateral reserve to assets generally * types * LiquidationPenalty param on vault manager * charge liquidation penalty * test for liquidation math * review * Revert "refactor(run-protocol): broaden scope of collateral reserve to assets generally" This reverts commit 34a45e3.
- Loading branch information
Showing
15 changed files
with
175 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
packages/run-protocol/test/vaultFactory/test-liquidation.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// @ts-check | ||
// Must be first to set up globals | ||
import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js'; | ||
|
||
import { AmountMath } from '@agoric/ertp'; | ||
import { Far } from '@endo/marshal'; | ||
import { partitionProceeds } from '../../src/vaultFactory/liquidation.js'; | ||
|
||
export const mockBrand = Far('brand'); | ||
|
||
const amount = n => AmountMath.make(mockBrand, BigInt(n)); | ||
|
||
for (const [ | ||
proceeds, | ||
debt, | ||
penaltyPortion, | ||
debtPaid, | ||
penaltyProceeds, | ||
runToBurn, | ||
] of [ | ||
// no proceeds | ||
[0, 0, 0, 0, 0, 0], | ||
[0, 100, 10, 0, 0, 0], | ||
// proceeds gte debt | ||
[100, 100, 10, 100, 10, 90], | ||
[200, 100, 10, 100, 10, 90], | ||
// proceeds less than debt | ||
[100, 200, 10, 100, 10, 90], | ||
[100, 200, 200, 100, 100, 0], | ||
]) { | ||
test(`partitionProceeds: (${proceeds} for ${debt} with ${penaltyPortion} penalty) => ${{ | ||
debtPaid, | ||
penaltyProceeds, | ||
runToBurn, | ||
}}`, t => { | ||
const result = partitionProceeds( | ||
amount(proceeds), | ||
amount(debt), | ||
amount(penaltyPortion), | ||
); | ||
t.deepEqual(result, { | ||
debtPaid: amount(debtPaid), | ||
penaltyProceeds: amount(penaltyProceeds), | ||
runToBurn: amount(runToBurn), | ||
}); | ||
}); | ||
} |
Oops, something went wrong.