Skip to content

Commit

Permalink
feat(vault): number of vaults per manager in EconState
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed May 5, 2022
1 parent 17e0cc5 commit 8761fe1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ export const makePrioritizedVaults = (reschedulePriceCheck = () => {}) => {
addVault,
entries: vaults.entries,
entriesPrioritizedGTE,
getSize: vaults.getSize,
highestRatio: firstDebtRatio,
refreshVaultPriority,
removeVault,
Expand Down
14 changes: 8 additions & 6 deletions packages/run-protocol/src/vaultFactory/vaultManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ const trace = makeTracer('VM', false);
* compoundedInterest: Ratio,
* interestRate: Ratio,
* latestInterestUpdate: bigint,
* liquidatorInstance?: Instance,
* }} AssetState
*
* @typedef {{
* numVaults: number,
* totalCollateral: Amount<'nat'>,
* totalDebt: Amount<'nat'>,
* liquidatorInstance?: Instance,
* }} EconState
*
* @typedef {{
Expand Down Expand Up @@ -240,12 +240,13 @@ const helperBehavior = {
updateTime,
);
Object.assign(state, stateUpdates);
facets.helper.notify();
facets.helper.assetNotify();
trace('chargeAllVaults complete');
facets.helper.reschedulePriceCheck();
},

notify: ({ state }) => {
/** @param {MethodContext} context */
assetNotify: ({ state }) => {
const interestRate = state.factoryPowers
.getGovernedParams()
.getInterestRate();
Expand All @@ -254,7 +255,7 @@ const helperBehavior = {
compoundedInterest: state.compoundedInterest,
interestRate,
latestInterestUpdate: state.latestInterestUpdate,
totalDebt: state.totalDebt,
// XXX move to EconState and type as present with null
liquidatorInstance: state.liquidatorInstance,
});
state.assetUpdater.updateState(payload);
Expand Down Expand Up @@ -521,7 +522,7 @@ const selfBehavior = {
* @param {MethodContext} context
* @param {ZCFSeat} seat
*/
makeVaultKit: async ({ state, facets: { manager } }, seat) => {
makeVaultKit: async ({ state, facets: { helper, manager } }, seat) => {
const { prioritizedVaults, zcf } = state;
assertProposalShape(seat, {
give: { Collateral: null },
Expand All @@ -545,6 +546,7 @@ const selfBehavior = {
vaultKit.vault.getCollateralAmount(),
);
seat.exit();
helper.econNotify();
return vaultKit;
} catch (err) {
// remove it from prioritizedVaults
Expand Down Expand Up @@ -594,7 +596,7 @@ const selfBehavior = {
});
state.liquidatorInstance = instance;
state.liquidator = creatorFacet;
facets.helper.notify();
facets.helper.assetNotify();
},

/** @param {MethodContext} context */
Expand Down

0 comments on commit 8761fe1

Please sign in to comment.