Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anil/back comp #28

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/inter-protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"scripts": {
"build": "yarn build:bundles",
"build:bundles": "node ./scripts/build-bundles.js",
"build:upgrade-vaults-proposal": "agoric run scripts/liquidation-visibility-upgrade.js",
"test": "ava",
"test:c8": "c8 $C8_OPTIONS ava --config=ava-nesm.config.js",
"test:xs": "exit 0",
Expand Down
40 changes: 40 additions & 0 deletions packages/inter-protocol/scripts/liquidation-visibility-upgrade.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { makeHelpers } from '@agoric/deploy-script-support';
import { makeInstallCache } from '../src/proposals/utils.js';
import { getManifestVaultsUpgrade } from '../src/proposals/vaultsLiquidationVisibility.js';

/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').ProposalBuilder} */
export const vaultsUpgradeProposalBuilder = async ({
publishRef,
install: install0,
wrapInstall,
}) => {
const install = wrapInstall ? wrapInstall(install0) : install0;

return harden({
sourceSpec: '../src/proposals/vaultsLiquidationVisibility.js',
getManifestCall: [
getManifestVaultsUpgrade.name,
{
vaultFactoryRef: publishRef(
install(
'../src/vaultFactory/vaultFactory.js',
'../bundles/bundle-vaultFactory.js',
),
),
},
],
});
};

export default async (homeP, endowments) => {
const { writeCoreProposal } = await makeHelpers(homeP, endowments);

const tool = await makeInstallCache(homeP, {
loadBundle: spec => import(spec),
});

await writeCoreProposal('upgrade-vaults-liq-visibility', opts =>
// @ts-expect-error XXX makeInstallCache types
vaultsUpgradeProposalBuilder({ ...opts, wrapInstall: tool.wrapInstall }),
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { E } from '@endo/far';

export const upgradeVaultsLiquidationVisibility = async (
powers,
{ options: { vaultFactoryRef } },
) => {
const {
consume: { vaultFactoryKit: vaultFactoryKitP },
} = powers;

const { adminFacet, privateArgs } = await vaultFactoryKitP;
const result = await E(adminFacet).upgradeContract(
vaultFactoryRef.bundleID,
privateArgs,
);

console.log('Upgrade Resulted With: ', result);
};

/** @type { import("@agoric/vats/src/core/lib-boot").BootstrapManifest } */
const manifest = {
[upgradeVaultsLiquidationVisibility.name]: {
// include rationale for closely-held, high authority capabilities
consume: {
vaultFactoryKit: `to upgrade vaultFactory using its adminFacet`,
},
},
};
harden(manifest);

export const getManifestVaultsUpgrade = (_powers, { vaultFactoryRef }) => {
return harden({
manifest,
options: { vaultFactoryRef },
});
};
9 changes: 8 additions & 1 deletion 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/src/types').CancelToken} CancelToken */
/** @typedef {import('@agoric/time/src/types').RelativeTimeRecord} RelativeTimeRecord */

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

const makeCancelToken = makeCancelTokenMaker('liq');

/**
Expand Down Expand Up @@ -261,7 +268,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
30 changes: 28 additions & 2 deletions packages/inter-protocol/src/vaultFactory/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
* @typedef {import('../auction/auctioneer.js').AuctioneerPublicFacet} AuctioneerPublicFacet
* @typedef {import('./vaultFactory.js').VaultFactoryContract['publicFacet']} VaultFactoryPublicFacet
*
* @typedef {import('@agoric/time/src/types').Timestamp} Timestamp
* @typedef {import('@agoric/time/src/types').RelativeTime} RelativeTime
* @typedef {import('@agoric/time').Timestamp} Timestamp
*
* @typedef {import('@agoric/time/src/types.js').TimestampRecord} TimestampRecord
*
* @typedef {import('@agoric/time').RelativeTime} RelativeTime
*/

/**
Expand Down Expand Up @@ -132,3 +135,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 @@ -116,6 +116,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 @@ -592,6 +595,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
3 changes: 2 additions & 1 deletion packages/inter-protocol/src/vaultFactory/vaultDirector.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,8 @@ const prepareVaultDirector = (

makeLiquidationWaker() {
return makeWaker('liquidationWaker', _timestamp => {
allManagersDo(vm => vm.liquidateVaults(auctioneer));
// XXX floating promise
allManagersDo(vm => vm.liquidateVaults(auctioneer, _timestamp));
});
},
makeReschedulerWaker() {
Expand Down
Loading
Loading