Skip to content

Commit

Permalink
feat: add an accessor for the vaultDirector's parameters (#10707)
Browse files Browse the repository at this point in the history
closes: #10094

## Description

Add a direct way to retrieve the governed parameters from the vaultDirector

### Security Considerations

This was already accessible (and intended to be public) via vstorage. It just adds a direct way to request the values when you have the vaultFactory publicFacet.

### Scaling Considerations

No effect.

### Documentation Considerations
No change

### Testing Considerations

Added a Unit test.

### Upgrade Considerations
The purpose was to simplify retrieving the previous values for upgrade.
  • Loading branch information
mergify[bot] authored Dec 17, 2024
2 parents bfca51a + 32f1398 commit adb17dd
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/inter-protocol/src/vaultFactory/vaultDirector.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ const prepareVaultDirector = (
getGovernedParams: M.callWhen({ collateralBrand: BrandShape }).returns(
M.record(),
),
getDirectorGovernedParams: M.call().returns(M.promise()),
getInvitationAmount: M.call(M.string()).returns(AmountShape),
getPublicTopics: M.call().returns(TopicsRecordShape),
}),
Expand Down Expand Up @@ -492,14 +493,17 @@ const prepareVaultDirector = (
},
/**
* Note this works only for a collateral manager. For the director use,
* `getElectorateSubscription`
* `getDirectorGovernedParams`
*
* @param {{ collateralBrand: Brand }} selector
*/
getGovernedParams({ collateralBrand }) {
// TODO use named getters of TypedParamManager
return vaultParamManagers.get(collateralBrand).getParams();
},
getDirectorGovernedParams() {
return directorParamManager.getParams();
},
/** @param {string} name */
getInvitationAmount(name) {
return directorParamManager.getInvitationAmount(name);
Expand Down
35 changes: 35 additions & 0 deletions packages/inter-protocol/test/vaultFactory/vaultFactory.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2049,4 +2049,39 @@ test('governance publisher', async t => {
LiquidationPenalty: { type: 'ratio' },
MintFee: { type: 'ratio' },
});

const params = await E(vfPublic).getDirectorGovernedParams();
t.like(params, {
ChargingPeriod: { type: 'nat', value: 2n },
Electorate: { type: 'invitation' },
MinInitialDebt: { type: 'amount' },
RecordingPeriod: { type: 'nat' },
ReferencedUI: { value: 'abracadabra' },
ShortfallInvitation: { type: 'invitation' },
});
});

test('access to director params', async t => {
const { aeth } = t.context;

t.context.referencedUi = 'hocus pocus';
const services = await setupServices(
t,
[500n, 15n],
aeth.make(900n),
undefined,
undefined,
500n,
);
const { vfPublic } = services.vaultFactory;

const params = await E(vfPublic).getDirectorGovernedParams();
t.like(params, {
ChargingPeriod: { type: 'nat', value: 2n },
Electorate: { type: 'invitation' },
MinInitialDebt: { type: 'amount' },
RecordingPeriod: { type: 'nat' },
ReferencedUI: { value: 'hocus pocus' },
ShortfallInvitation: { type: 'invitation' },
});
});

0 comments on commit adb17dd

Please sign in to comment.