Skip to content

Commit

Permalink
# This is a combination of 22 commits.
Browse files Browse the repository at this point in the history
# This is the 1st commit message:

create dedicated files for test assertions and tools

# This is the commit message #2:

Add new test file for liquidation visibility

# This is the commit message #3:

auctioneer snapshot

# This is the commit message #4:

Update visibility tests and helper functions

# This is the commit message #5:

add tools and assertions to match subscriber with vstorage data

# This is the commit message #6:

update test visibility of vault liquidation

# This is the commit message #7:

fix(liquidationVisibility): fix linting errors

# This is the commit message #8:

fix(liquidationVisibility): type error

# This is the commit message #9:

chore(liquidationVisibility): #4 testing tools setup

# This is the commit message #10:

chore(liquidationVisibility): #4 improve testing tools

# This is the commit message #11:

chore(liquidationVisibility): #4 improve testing tools

# This is the commit message #12:

fix(liquidationVisibility): linting fixes

# This is the commit message #13:

chore(liquidationVisibility): fix test names

# This is the commit message #14:

fix(liquidationVisibility): lint fix

# This is the commit message #15:

chore(liquidationVisibility): #4 implement `assertNodeInStorage`

# This is the commit message #16:

fix(liquidationVisibility): #4 lint fix

# This is the commit message #17:

chore(liquidationVisibility): #4 test skeleton is ready

# This is the commit message #18:

chore(liquidationVisibility): #4 add marshaller for comparing data from the vstorage

# This is the commit message #19:

chore(liquidationVisibility): sample test for `preAuction` and `postAuction` data fields

# This is the commit message #20:

chore(liquidationVisibility): make sure `assertStorageData` works

# This is the commit message #21:

chore(liquidationVisibility): #4 add test for case 2b, uncomment assertions for running the tests

# This is the commit message #22:

feat(liquidationVisibility): create liquidation storageNodes and recorderKits

BREAKING CHANGE: Introduced the `_timestamp` as an argument for the vaultManager liquidateVaults method.

feat(liquidationVisibility): write preAuctionState and auctionResultState to Vstorage

BREAKING CHANGE: a getVaultId method was included in the Vault interface, which returns the vault `idInManager`

fix(liquidationVisibility): fix type definitions errors and concurrently await multiple promises

feat(liquidationVisibility): write postAuctionState to Vstorage

BREAKING CHANGE: the getVaultId method of vaults interface was updated to getVaultState, which will return the vault phase as well

chore(liquidationVisibility): update helper methods, type definitions and names

fix(liquidationVisibility): lint fix

fix(liquidationVisibility): update sequence to write auction state to Vstorage and its structure

The helper methods built for this purpose became unnecessary and were removed.

fix(liquidationVisibility): update postAuctionState structure and change to writeFinal recorder method

fix(liquidationVisibility): remove temporary changes made to tests

fix(liquidationVisibility): #4 test for scenario 2b passed, test api updated, #7 is fixed

chore(liquidationVisibility): #4 test for scenario 2a passed

chore(liquidationVisibility): #4 update scenario 1

Squashed commit of the following:

commit 728d695
Author: anilhelvaci <anilhelvaci96@gmail.com>
Date:   Wed Jan 31 14:28:14 2024 +0300

    chore(liquidationVisibility): uncomment post auction assertion in `liq-result-scenario-1`

commit dd3fbdb
Author: anilhelvaci <anilhelvaci96@gmail.com>
Date:   Wed Jan 31 14:25:22 2024 +0300

    fix(liquidationVisibility): lint fix

commit 6920d1a
Author: anilhelvaci <anilhelvaci96@gmail.com>
Date:   Wed Jan 31 14:22:28 2024 +0300

    fix(liquidationVisibility): explain Promise.allSettled

commit 732e1d7
Author: anilhelvaci <anilhelvaci96@gmail.com>
Date:   Wed Jan 31 11:37:45 2024 +0300

    feat(liquidationVisibility): handle errors that might arise from other vats

commit 683f56d
Author: anilhelvaci <anilhelvaci96@gmail.com>
Date:   Tue Jan 30 14:31:13 2024 +0300

    feat(liquidationVisibility): add LiquidationVisibilityWriters to improve readability, fetch schedule during the auction itself

commit 4c45f2a
Author: anilhelvaci <anilhelvaci96@gmail.com>
Date:   Tue Jan 30 10:30:02 2024 +0300

    fix(liquidationVisibility): add pattern matcher to `getVaultState`

chore(liquidationVisibility): #4 add auctioneer wrapper and update setupBasics

chore(liquidationVisibility): #4 add mock makeChainStorageNode

chore(liquidationVisibility): #4 add tests for no vaults and rejected schedule

fix(liquidationVisibility): #4 add setBlockMakeChildNode method and update file name

fix(liquidationVisibility): #4 update import path

chore(liquidationVisibility): #4 add liq-rejected-timestampStorageNode test

fix(liquidationVisibility): #4 fix bug with at makeChildNode

fix(liquidationVisibility): #4 update test names and comments

fix(liquidationVisibility): #4 lint fix

chore(internal): create key-value pairs for Promise.allSettled values

fix(internal): make allValuesSettled a mapper for resolved promises and silently handles rejected ones

fix(internal): fix doc

fix(liquidationVisibility): make sure promises are assigned in key-value fashion, lint fixes.

chore(liquidationVisibility): extend liq-rejected-timestampStorageNode and clean outdated comments

fix(liquidationVisibility): revert update made to package.json

chore(liquidationVisibility): update snapshot generated by unit tests

fix(liquidationVisibility): lint fix

chore(liquidationVisibility) #4 test multiple vaultManagers

fix(liquidationVisibility): #4 lint fix

fix(liquidationVisibility): add pattern matcher to `getVaultState`

feat(liquidationVisibility): add LiquidationVisibilityWriters to improve readability, fetch schedule during the auction itself

chore(liquidationVisibility): init work for bootstrap tests

chore(liquidationVisibility): created test-liquidation-visibility.ts and started building a test suite

chore(liquidationVisibility): upgrade tests are implemented.

Refs: #15

fix(liquidationVisibility): vaults are now displayed in the correct order at `vaults.preAuction`

Refs: #13

fix(liquidationVisibility): vault phases are now displayed correctly at `vaults.postAuction`

Refs: #14

chore(liquidationVisibility): add storage snapshot

Refs: #15

fix(liquidationVisibility): don't reverse `vaultData` for preAuction storage node

Refs: #13
  • Loading branch information
Jorge-Lopes authored and anilhelvaci committed Jun 21, 2024
1 parent 01a1123 commit d3c4976
Show file tree
Hide file tree
Showing 18 changed files with 5,468 additions and 23 deletions.

Large diffs are not rendered by default.

Binary file not shown.
442 changes: 442 additions & 0 deletions packages/boot/test/bootstrapTests/test-liquidation-visibility.ts

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion packages/boot/tools/liquidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ export const makeLiquidationTestKit = async ({
collateralBrandKey: string,
buyerWalletAddress: string,
setup: LiquidationSetup,
base = 0, // number of bids made before
) => {
const buyer =
await walletFactoryDriver.provideSmartWallet(buyerWalletAddress);
Expand All @@ -275,7 +276,11 @@ export const makeLiquidationTestKit = async ({
const maxBuy = `10000${collateralBrandKey}`;

for (let i = 0; i < setup.bids.length; i += 1) {
<<<<<<< HEAD
const offerId = `${collateralBrandKey}-bid${i + 1}`;
=======
const offerId = `${collateralBrandKey}-bid${i + 1 + base}`;
>>>>>>> 69a90400e (# This is a combination of 22 commits.)
// bids are long-lasting offers so we can't wait here for completion
await buyer.sendOfferMaker(Offers.auction.Bid, {
offerId,
Expand All @@ -300,11 +305,12 @@ export const makeLiquidationTestKit = async ({
priceFeedDrivers,
setupVaults,
placeBids,
setupStartingState,
};
};

export const makeLiquidationTestContext = async t => {
const swingsetTestKit = await makeSwingsetTestKit(t.log);
const swingsetTestKit = await makeSwingsetTestKit(t.log, 'bundles/vaults');
console.time('DefaultTestContext');

const { runUtils, storage } = swingsetTestKit;
Expand Down
21 changes: 15 additions & 6 deletions packages/inter-protocol/src/vaultFactory/liquidation.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ const trace = makeTracer('LIQ');
/** @import {RelativeTimeRecord} from '@agoric/time' */
/** @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js'; */

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

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

const makeCancelToken = makeCancelTokenMaker('liq');

/**
Expand Down Expand Up @@ -270,12 +284,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
24 changes: 24 additions & 0 deletions packages/inter-protocol/src/vaultFactory/types-ambient.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* @import {AssetReservePublicFacet} from '../reserve/assetReserve.js'
* @import {AuctioneerPublicFacet} from '../auction/auctioneer.js'
* @import {Timestamp} from '@agoric/time'
* @import {TimestampRecord} from '@agoric/time'
* @import {RelativeTime} from '@agoric/time'
*/

Expand Down Expand Up @@ -132,3 +133,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 @@ -132,6 +132,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 @@ -604,6 +607,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 @@ -434,7 +434,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 d3c4976

Please sign in to comment.