@agoric/inter-protocol 0.13.2-dev-55d06de.0 → 0.13.2-dev-097dca8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/bundle-amm-meta.js +128 -128
- package/bundles/bundle-amm.js +1 -1
- package/bundles/bundle-econCommitteeCharter-meta.js +74 -74
- package/bundles/bundle-econCommitteeCharter.js +1 -1
- package/bundles/bundle-feeDistributor-meta.js +54 -54
- package/bundles/bundle-feeDistributor.js +1 -1
- package/bundles/bundle-interchainPool-meta.js +104 -104
- package/bundles/bundle-interchainPool.js +1 -1
- package/bundles/bundle-liquidateIncrementally-meta.js +68 -68
- package/bundles/bundle-liquidateIncrementally.js +1 -1
- package/bundles/bundle-liquidateMinimum-meta.js +68 -68
- package/bundles/bundle-liquidateMinimum.js +1 -1
- package/bundles/bundle-priceAggregatorChainlink-meta.js +73 -73
- package/bundles/bundle-priceAggregatorChainlink.js +1 -1
- package/bundles/bundle-psm-meta.js +107 -107
- package/bundles/bundle-psm.js +1 -1
- package/bundles/bundle-reserve-meta.js +105 -105
- package/bundles/bundle-reserve.js +1 -1
- package/bundles/bundle-scaledPriceAuthority-meta.js +80 -80
- package/bundles/bundle-scaledPriceAuthority.js +1 -1
- package/bundles/bundle-stakeFactory-meta.js +114 -114
- package/bundles/bundle-stakeFactory.js +1 -1
- package/bundles/bundle-vaultFactory-meta.js +132 -132
- package/bundles/bundle-vaultFactory.js +1 -1
- package/package.json +14 -14
- package/src/contractSupport.js +7 -0
- package/src/vaultFactory/vault.js +48 -83
- package/src/vaultFactory/vaultDirector.js +427 -528
- package/src/vaultFactory/vaultFactory.js +7 -3
- package/src/vaultFactory/vaultHolder.js +3 -3
- package/src/vaultFactory/vaultKit.js +9 -5
- package/src/vaultFactory/vaultManager.js +132 -256
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/inter-protocol",
|
|
3
|
-
"version": "0.13.2-dev-
|
|
3
|
+
"version": "0.13.2-dev-097dca8.0+097dca8",
|
|
4
4
|
"description": "Core cryptoeconomy contracts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -29,17 +29,17 @@
|
|
|
29
29
|
},
|
|
30
30
|
"homepage": "https://github.com/Agoric/agoric-sdk#readme",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@agoric/assert": "0.5.2-dev-
|
|
33
|
-
"@agoric/ertp": "0.15.4-dev-
|
|
34
|
-
"@agoric/governance": "0.9.2-dev-
|
|
35
|
-
"@agoric/internal": "0.2.2-dev-
|
|
32
|
+
"@agoric/assert": "0.5.2-dev-097dca8.0+097dca8",
|
|
33
|
+
"@agoric/ertp": "0.15.4-dev-097dca8.0+097dca8",
|
|
34
|
+
"@agoric/governance": "0.9.2-dev-097dca8.0+097dca8",
|
|
35
|
+
"@agoric/internal": "0.2.2-dev-097dca8.0+097dca8",
|
|
36
36
|
"@agoric/nat": "^4.1.0",
|
|
37
|
-
"@agoric/notifier": "0.5.2-dev-
|
|
38
|
-
"@agoric/store": "0.8.4-dev-
|
|
39
|
-
"@agoric/swingset-vat": "0.30.3-dev-
|
|
40
|
-
"@agoric/vat-data": "0.4.4-dev-
|
|
41
|
-
"@agoric/vats": "0.13.1-dev-
|
|
42
|
-
"@agoric/zoe": "0.25.4-dev-
|
|
37
|
+
"@agoric/notifier": "0.5.2-dev-097dca8.0+097dca8",
|
|
38
|
+
"@agoric/store": "0.8.4-dev-097dca8.0+097dca8",
|
|
39
|
+
"@agoric/swingset-vat": "0.30.3-dev-097dca8.0+097dca8",
|
|
40
|
+
"@agoric/vat-data": "0.4.4-dev-097dca8.0+097dca8",
|
|
41
|
+
"@agoric/vats": "0.13.1-dev-097dca8.0+097dca8",
|
|
42
|
+
"@agoric/zoe": "0.25.4-dev-097dca8.0+097dca8",
|
|
43
43
|
"@endo/bundle-source": "^2.4.2",
|
|
44
44
|
"@endo/captp": "^2.0.18",
|
|
45
45
|
"@endo/eventual-send": "^0.16.8",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"@endo/promise-kit": "^0.2.52"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@agoric/deploy-script-support": "0.9.5-dev-
|
|
53
|
-
"@agoric/smart-wallet": "0.4.3-dev-
|
|
52
|
+
"@agoric/deploy-script-support": "0.9.5-dev-097dca8.0+097dca8",
|
|
53
|
+
"@agoric/smart-wallet": "0.4.3-dev-097dca8.0+097dca8",
|
|
54
54
|
"@endo/init": "^0.5.52",
|
|
55
55
|
"@fast-check/ava": "^1.1.3",
|
|
56
56
|
"ava": "^5.1.0",
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
"publishConfig": {
|
|
78
78
|
"access": "public"
|
|
79
79
|
},
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "097dca859e4a6f128876df1a778d9a63bd305ce1"
|
|
81
81
|
}
|
package/src/contractSupport.js
CHANGED
|
@@ -174,6 +174,13 @@ export const makeEphemeraProvider = init => {
|
|
|
174
174
|
};
|
|
175
175
|
harden(makeEphemeraProvider);
|
|
176
176
|
|
|
177
|
+
/**
|
|
178
|
+
*
|
|
179
|
+
* @param {ZCF} zcf
|
|
180
|
+
* @param {import('@agoric/ertp').Baggage} baggage
|
|
181
|
+
* @param {string} name
|
|
182
|
+
* @returns {ZCFSeat}
|
|
183
|
+
*/
|
|
177
184
|
export const provideEmptySeat = (zcf, baggage, name) => {
|
|
178
185
|
return provide(baggage, name, () => zcf.makeEmptySeatKit().zcfSeat);
|
|
179
186
|
};
|
|
@@ -14,7 +14,6 @@ import {
|
|
|
14
14
|
addSubtract,
|
|
15
15
|
allEmpty,
|
|
16
16
|
assertOnlyKeys,
|
|
17
|
-
makeEphemeraProvider,
|
|
18
17
|
stageDelta,
|
|
19
18
|
} from '../contractSupport.js';
|
|
20
19
|
import { calculateCurrentDebt, reverseInterest } from '../interest-math.js';
|
|
@@ -102,6 +101,7 @@ const validTransitions = {
|
|
|
102
101
|
* @typedef {Readonly<{
|
|
103
102
|
* idInManager: VaultId,
|
|
104
103
|
* manager: VaultManager,
|
|
104
|
+
* storageNode: StorageNode,
|
|
105
105
|
* vaultSeat: ZCFSeat,
|
|
106
106
|
* }>} ImmutableState
|
|
107
107
|
*/
|
|
@@ -113,59 +113,10 @@ const validTransitions = {
|
|
|
113
113
|
* interestSnapshot: Ratio,
|
|
114
114
|
* phase: VaultPhase,
|
|
115
115
|
* debtSnapshot: Amount<'nat'>,
|
|
116
|
+
* outerUpdater: Publisher<VaultNotification> | null,
|
|
116
117
|
* }} MutableState
|
|
117
118
|
*/
|
|
118
119
|
|
|
119
|
-
/**
|
|
120
|
-
* Ephemera are the elements of state that cannot (or need not) be durable.
|
|
121
|
-
* When there's a single instance it can be held in a closure, but there are
|
|
122
|
-
* many vault manaager objects. So we hold their ephemera keyed by the durable
|
|
123
|
-
* vault manager object reference.
|
|
124
|
-
*
|
|
125
|
-
* @type {(key: VaultId) => {
|
|
126
|
-
* storageNode: ERef<StorageNode>,
|
|
127
|
-
* marshaller: ERef<Marshaller>,
|
|
128
|
-
* outerUpdater: Publisher<VaultNotification> | null,
|
|
129
|
-
* zcf: ZCF,
|
|
130
|
-
* }} */
|
|
131
|
-
// @ts-expect-error not yet defined
|
|
132
|
-
const provideEphemera = makeEphemeraProvider(() => ({}));
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* @param {ZCF} zcf
|
|
136
|
-
* @param {VaultManager} manager
|
|
137
|
-
* @param {VaultId} idInManager
|
|
138
|
-
* @param {ERef<StorageNode>} storageNode
|
|
139
|
-
* @param {ERef<Marshaller>} marshaller
|
|
140
|
-
* @returns {ImmutableState & MutableState}
|
|
141
|
-
*/
|
|
142
|
-
const initState = (zcf, manager, idInManager, storageNode, marshaller) => {
|
|
143
|
-
trace('vault initState');
|
|
144
|
-
|
|
145
|
-
const ephemera = provideEphemera(idInManager);
|
|
146
|
-
ephemera.storageNode = storageNode;
|
|
147
|
-
ephemera.marshaller = marshaller;
|
|
148
|
-
ephemera.zcf = zcf;
|
|
149
|
-
|
|
150
|
-
return harden({
|
|
151
|
-
idInManager,
|
|
152
|
-
manager,
|
|
153
|
-
outerUpdater: null,
|
|
154
|
-
phase: Phase.ACTIVE,
|
|
155
|
-
|
|
156
|
-
// vaultSeat will hold the collateral until the loan is retired. The
|
|
157
|
-
// payout from it will be handed to the user: if the vault dies early
|
|
158
|
-
// (because the vaultFactory vat died), they'll get all their
|
|
159
|
-
// collateral back. If that happens, the issuer for the Minted will be dead,
|
|
160
|
-
// so their loan will be worthless.
|
|
161
|
-
vaultSeat: zcf.makeEmptySeatKit().zcfSeat,
|
|
162
|
-
|
|
163
|
-
// Two values from the same moment
|
|
164
|
-
interestSnapshot: manager.getCompoundedInterest(),
|
|
165
|
-
debtSnapshot: AmountMath.makeEmpty(manager.getDebtBrand()),
|
|
166
|
-
});
|
|
167
|
-
};
|
|
168
|
-
|
|
169
120
|
/**
|
|
170
121
|
* Check whether we can proceed with an `adjustBalances`.
|
|
171
122
|
*
|
|
@@ -205,9 +156,7 @@ export const VaultI = M.interface('Vault', {
|
|
|
205
156
|
getCurrentDebt: M.call().returns(AmountShape),
|
|
206
157
|
getNormalizedDebt: M.call().returns(AmountShape),
|
|
207
158
|
getVaultSeat: M.call().returns(SeatShape),
|
|
208
|
-
initVaultKit: M.call(SeatShape, M.
|
|
209
|
-
M.promise(),
|
|
210
|
-
),
|
|
159
|
+
initVaultKit: M.call(SeatShape, StorageNodeShape).returns(M.promise()),
|
|
211
160
|
liquidated: M.call().returns(undefined),
|
|
212
161
|
liquidating: M.call().returns(undefined),
|
|
213
162
|
makeAdjustBalancesInvitation: M.call().returns(M.promise()),
|
|
@@ -215,11 +164,14 @@ export const VaultI = M.interface('Vault', {
|
|
|
215
164
|
makeTransferInvitation: M.call().returns(M.promise()),
|
|
216
165
|
});
|
|
217
166
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
167
|
+
/**
|
|
168
|
+
* @param {import('@agoric/ertp').Baggage} baggage
|
|
169
|
+
* @param {ERef<Marshaller>} marshaller
|
|
170
|
+
* @param {ZCF} zcf
|
|
171
|
+
*/
|
|
172
|
+
export const prepareVault = (baggage, marshaller, zcf) => {
|
|
173
|
+
const makeVaultKit = prepareVaultKit(baggage, marshaller);
|
|
221
174
|
|
|
222
|
-
// TODO find a way to not have to indent a level deeper than defineDurableExoClassKit does
|
|
223
175
|
const maker = prepareExoClassKit(
|
|
224
176
|
baggage,
|
|
225
177
|
'Vault',
|
|
@@ -227,7 +179,33 @@ export const prepareVault = baggage => {
|
|
|
227
179
|
helper: UnguardedHelperI,
|
|
228
180
|
self: VaultI,
|
|
229
181
|
},
|
|
230
|
-
|
|
182
|
+
/**
|
|
183
|
+
* @param {VaultManager} manager
|
|
184
|
+
* @param {VaultId} idInManager
|
|
185
|
+
* @param {StorageNode} storageNode
|
|
186
|
+
* @returns {ImmutableState & MutableState}
|
|
187
|
+
*/
|
|
188
|
+
(manager, idInManager, storageNode) => {
|
|
189
|
+
return harden({
|
|
190
|
+
idInManager,
|
|
191
|
+
manager,
|
|
192
|
+
outerUpdater: null,
|
|
193
|
+
phase: Phase.ACTIVE,
|
|
194
|
+
|
|
195
|
+
storageNode,
|
|
196
|
+
|
|
197
|
+
// vaultSeat will hold the collateral until the loan is retired. The
|
|
198
|
+
// payout from it will be handed to the user: if the vault dies early
|
|
199
|
+
// (because the vaultFactory vat died), they'll get all their
|
|
200
|
+
// collateral back. If that happens, the issuer for the Minted will be dead,
|
|
201
|
+
// so their loan will be worthless.
|
|
202
|
+
vaultSeat: zcf.makeEmptySeatKit().zcfSeat,
|
|
203
|
+
|
|
204
|
+
// Two values from the same moment
|
|
205
|
+
interestSnapshot: manager.getCompoundedInterest(),
|
|
206
|
+
debtSnapshot: AmountMath.makeEmpty(manager.getDebtBrand()),
|
|
207
|
+
});
|
|
208
|
+
},
|
|
231
209
|
{
|
|
232
210
|
helper: {
|
|
233
211
|
// #region Computed constants
|
|
@@ -370,8 +348,7 @@ export const prepareVault = baggage => {
|
|
|
370
348
|
*/
|
|
371
349
|
updateUiState() {
|
|
372
350
|
const { state, facets } = this;
|
|
373
|
-
const
|
|
374
|
-
const { outerUpdater } = ephemera;
|
|
351
|
+
const { outerUpdater } = state;
|
|
375
352
|
if (!outerUpdater) {
|
|
376
353
|
// It's not an error to change to liquidating during transfer
|
|
377
354
|
return;
|
|
@@ -388,7 +365,7 @@ export const prepareVault = baggage => {
|
|
|
388
365
|
break;
|
|
389
366
|
case Phase.CLOSED:
|
|
390
367
|
outerUpdater.finish(uiState);
|
|
391
|
-
|
|
368
|
+
state.outerUpdater = null;
|
|
392
369
|
break;
|
|
393
370
|
default:
|
|
394
371
|
throw Error(`unreachable vault phase: ${phase}`);
|
|
@@ -404,7 +381,6 @@ export const prepareVault = baggage => {
|
|
|
404
381
|
const { self, helper } = facets;
|
|
405
382
|
helper.assertCloseable();
|
|
406
383
|
const { phase, vaultSeat } = state;
|
|
407
|
-
const { zcf } = provideEphemera(state.idInManager);
|
|
408
384
|
|
|
409
385
|
// Held as keys for cleanup in the manager
|
|
410
386
|
const oldDebtNormalized = self.getNormalizedDebt();
|
|
@@ -502,8 +478,7 @@ export const prepareVault = baggage => {
|
|
|
502
478
|
const { state, facets } = this;
|
|
503
479
|
|
|
504
480
|
const { self, helper } = facets;
|
|
505
|
-
const
|
|
506
|
-
const { outerUpdater: updaterPre } = ephemera;
|
|
481
|
+
const { outerUpdater: updaterPre } = state;
|
|
507
482
|
const { vaultSeat } = state;
|
|
508
483
|
const proposal = clientSeat.getProposal();
|
|
509
484
|
assertOnlyKeys(proposal, ['Collateral', 'Minted']);
|
|
@@ -521,7 +496,7 @@ export const prepareVault = baggage => {
|
|
|
521
496
|
);
|
|
522
497
|
// max debt supported by current Collateral as modified by proposal
|
|
523
498
|
const maxDebtPre = await state.manager.maxDebtFor(newCollateralPre);
|
|
524
|
-
updaterPre ===
|
|
499
|
+
updaterPre === state.outerUpdater ||
|
|
525
500
|
Fail`Transfer during vault adjustment`;
|
|
526
501
|
helper.assertActive();
|
|
527
502
|
|
|
@@ -611,16 +586,13 @@ export const prepareVault = baggage => {
|
|
|
611
586
|
helper.assertCloseable();
|
|
612
587
|
seat.exit();
|
|
613
588
|
|
|
614
|
-
const ephemera = provideEphemera(state.idInManager);
|
|
615
|
-
|
|
616
589
|
// eslint-disable-next-line no-use-before-define
|
|
617
590
|
const vaultKit = makeVaultKit(
|
|
618
591
|
self,
|
|
619
|
-
|
|
620
|
-
ephemera.marshaller,
|
|
592
|
+
state.storageNode,
|
|
621
593
|
state.manager.getAssetSubscriber(),
|
|
622
594
|
);
|
|
623
|
-
|
|
595
|
+
state.outerUpdater = vaultKit.vaultUpdater;
|
|
624
596
|
helper.updateUiState();
|
|
625
597
|
|
|
626
598
|
return vaultKit;
|
|
@@ -638,8 +610,6 @@ export const prepareVault = baggage => {
|
|
|
638
610
|
async initVaultKit(seat, storageNode) {
|
|
639
611
|
const { state, facets } = this;
|
|
640
612
|
|
|
641
|
-
const ephemera = provideEphemera(state.idInManager);
|
|
642
|
-
|
|
643
613
|
const { self, helper } = facets;
|
|
644
614
|
|
|
645
615
|
const normalizedDebtPre = self.getNormalizedDebt();
|
|
@@ -694,10 +664,9 @@ export const prepareVault = baggage => {
|
|
|
694
664
|
const vaultKit = makeVaultKit(
|
|
695
665
|
self,
|
|
696
666
|
storageNode,
|
|
697
|
-
ephemera.marshaller,
|
|
698
667
|
state.manager.getAssetSubscriber(),
|
|
699
668
|
);
|
|
700
|
-
|
|
669
|
+
state.outerUpdater = vaultKit.vaultUpdater;
|
|
701
670
|
helper.updateUiState();
|
|
702
671
|
return vaultKit;
|
|
703
672
|
},
|
|
@@ -731,10 +700,9 @@ export const prepareVault = baggage => {
|
|
|
731
700
|
},
|
|
732
701
|
|
|
733
702
|
makeAdjustBalancesInvitation() {
|
|
734
|
-
const {
|
|
703
|
+
const { facets } = this;
|
|
735
704
|
const { helper } = facets;
|
|
736
705
|
helper.assertActive();
|
|
737
|
-
const { zcf } = provideEphemera(state.idInManager);
|
|
738
706
|
return zcf.makeInvitation(
|
|
739
707
|
seat => helper.adjustBalancesHook(seat),
|
|
740
708
|
'AdjustBalances',
|
|
@@ -742,10 +710,9 @@ export const prepareVault = baggage => {
|
|
|
742
710
|
},
|
|
743
711
|
|
|
744
712
|
makeCloseInvitation() {
|
|
745
|
-
const {
|
|
713
|
+
const { facets } = this;
|
|
746
714
|
const { helper } = facets;
|
|
747
715
|
helper.assertCloseable();
|
|
748
|
-
const { zcf } = provideEphemera(state.idInManager);
|
|
749
716
|
return zcf.makeInvitation(
|
|
750
717
|
seat => helper.closeHook(seat),
|
|
751
718
|
'CloseVault',
|
|
@@ -757,8 +724,7 @@ export const prepareVault = baggage => {
|
|
|
757
724
|
*/
|
|
758
725
|
makeTransferInvitation() {
|
|
759
726
|
const { state, facets } = this;
|
|
760
|
-
const
|
|
761
|
-
const { outerUpdater } = ephemera;
|
|
727
|
+
const { outerUpdater } = state;
|
|
762
728
|
const { self, helper } = facets;
|
|
763
729
|
// Bring the debt snapshot current for the final report before transfer
|
|
764
730
|
helper.updateDebtSnapshot(self.getCurrentDebt());
|
|
@@ -769,14 +735,13 @@ export const prepareVault = baggage => {
|
|
|
769
735
|
} = state;
|
|
770
736
|
if (outerUpdater) {
|
|
771
737
|
outerUpdater.finish(helper.getStateSnapshot(Phase.TRANSFER));
|
|
772
|
-
|
|
738
|
+
state.outerUpdater = null;
|
|
773
739
|
}
|
|
774
740
|
const transferState = {
|
|
775
741
|
debtSnapshot: { debt, interest },
|
|
776
742
|
locked: self.getCollateralAmount(),
|
|
777
743
|
vaultState: phase,
|
|
778
744
|
};
|
|
779
|
-
const { zcf } = provideEphemera(state.idInManager);
|
|
780
745
|
return zcf.makeInvitation(
|
|
781
746
|
seat => helper.makeTransferInvitationHook(seat),
|
|
782
747
|
'TransferVault',
|