Skip to content

Commit

Permalink
Merge pull request #9 from Jorge-Lopes/anil/develop
Browse files Browse the repository at this point in the history
Liquidation Visibility - Iteration One
  • Loading branch information
Jorge-Lopes authored Feb 8, 2024
2 parents 7d47297 + 728d695 commit c60c099
Show file tree
Hide file tree
Showing 11 changed files with 2,083 additions and 18 deletions.
14 changes: 8 additions & 6 deletions packages/inter-protocol/src/vaultFactory/liquidation.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ const trace = makeTracer('LIQ');
/** @typedef {import('@agoric/time').CancelToken} CancelToken */
/** @typedef {import('@agoric/time').RelativeTimeRecord} RelativeTimeRecord */

/**
* @typedef {MapStore<
* Vault,
* { collateralAmount: Amount<'nat'>; debtAmount: Amount<'nat'> }
* >} VaultData
*/

const makeCancelToken = makeCancelTokenMaker('liq');

/**
Expand Down Expand Up @@ -269,12 +276,7 @@ export const getLiquidatableVaults = (
const vaultsToLiquidate = prioritizedVaults.removeVaultsBelow(
collateralizationDetails,
);
/**
* @type {MapStore<
* Vault,
* { collateralAmount: Amount<'nat'>; debtAmount: Amount<'nat'> }
* >}
*/
/** @type {VaultData} */
const vaultData = makeScalarMapStore();

const { zcfSeat: liqSeat } = zcf.makeEmptySeatKit();
Expand Down
25 changes: 25 additions & 0 deletions packages/inter-protocol/src/vaultFactory/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
*
* @typedef {import('@agoric/time').Timestamp} Timestamp
*
* @typedef {import('@agoric/time').TimestampRecord} TimestampRecord
*
* @typedef {import('@agoric/time').RelativeTime} RelativeTime
*/

Expand Down Expand Up @@ -142,3 +144,26 @@
*/

/** @typedef {{ key: 'governedParams' | { collateralBrand: Brand } }} VaultFactoryParamPath */

/**
* @typedef {{
* plan: import('./proceeds.js').DistributionPlan;
* vaultsInPlan: Array;
* }} PostAuctionParams
*
* @typedef {{
* plan: import('./proceeds.js').DistributionPlan;
* totalCollateral: Amount<'nat'>;
* totalDebt: Amount<'nat'>;
* auctionSchedule: import('../auction/scheduler.js').FullSchedule;
* }} AuctionResultsParams
*/

/**
* @typedef {import('./liquidation.js').VaultData} VaultData
*
* @typedef {object} LiquidationVisibilityWriters
* @property {(vaultData: VaultData) => Promise<void>} writePreAuction
* @property {(postAuctionParams: PostAuctionParams) => Promise<void>} writePostAuction
* @property {(auctionResultParams: AuctionResultsParams) => Promise<void>} writeAuctionResults
*/
10 changes: 10 additions & 0 deletions packages/inter-protocol/src/vaultFactory/vault.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ export const VaultI = M.interface('Vault', {
getCurrentDebt: M.call().returns(AmountShape),
getNormalizedDebt: M.call().returns(AmountShape),
getVaultSeat: M.call().returns(SeatShape),
getVaultState: M.call().returns(
harden({ idInManager: M.string(), phase: M.string() }),
),
initVaultKit: M.call(SeatShape, StorageNodeShape).returns(M.promise()),
liquidated: M.call().returns(undefined),
liquidating: M.call().returns(undefined),
Expand Down Expand Up @@ -597,6 +600,13 @@ export const prepareVault = (baggage, makeRecorderKit, zcf) => {
return this.state.vaultSeat;
},

getVaultState() {
return {
idInManager: this.state.idInManager,
phase: this.state.phase,
};
},

/**
* @param {ZCFSeat} seat
* @param {StorageNode} storageNode
Expand Down
2 changes: 1 addition & 1 deletion packages/inter-protocol/src/vaultFactory/vaultDirector.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ const prepareVaultDirector = (
makeLiquidationWaker() {
return makeWaker('liquidationWaker', _timestamp => {
// XXX floating promise
allManagersDo(vm => vm.liquidateVaults(auctioneer));
allManagersDo(vm => vm.liquidateVaults(auctioneer, _timestamp));
});
},
makeReschedulerWaker() {
Expand Down
Loading

0 comments on commit c60c099

Please sign in to comment.