@agoric/inter-protocol 0.16.2-dev-40e0e4e.0 → 0.16.2-dev-ff9b882.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/inter-protocol",
3
- "version": "0.16.2-dev-40e0e4e.0+40e0e4e",
3
+ "version": "0.16.2-dev-ff9b882.0+ff9b882",
4
4
  "description": "Core cryptoeconomy contracts",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -31,15 +31,15 @@
31
31
  },
32
32
  "homepage": "https://github.com/Agoric/agoric-sdk#readme",
33
33
  "dependencies": {
34
- "@agoric/ertp": "0.16.3-dev-40e0e4e.0+40e0e4e",
35
- "@agoric/governance": "0.10.4-dev-40e0e4e.0+40e0e4e",
36
- "@agoric/internal": "0.3.3-dev-40e0e4e.0+40e0e4e",
37
- "@agoric/notifier": "0.6.3-dev-40e0e4e.0+40e0e4e",
38
- "@agoric/store": "0.9.3-dev-40e0e4e.0+40e0e4e",
39
- "@agoric/time": "0.3.3-dev-40e0e4e.0+40e0e4e",
40
- "@agoric/vat-data": "0.5.3-dev-40e0e4e.0+40e0e4e",
41
- "@agoric/vats": "0.15.2-dev-40e0e4e.0+40e0e4e",
42
- "@agoric/zoe": "0.26.3-dev-40e0e4e.0+40e0e4e",
34
+ "@agoric/ertp": "0.16.3-dev-ff9b882.0+ff9b882",
35
+ "@agoric/governance": "0.10.4-dev-ff9b882.0+ff9b882",
36
+ "@agoric/internal": "0.3.3-dev-ff9b882.0+ff9b882",
37
+ "@agoric/notifier": "0.6.3-dev-ff9b882.0+ff9b882",
38
+ "@agoric/store": "0.9.3-dev-ff9b882.0+ff9b882",
39
+ "@agoric/time": "0.3.3-dev-ff9b882.0+ff9b882",
40
+ "@agoric/vat-data": "0.5.3-dev-ff9b882.0+ff9b882",
41
+ "@agoric/vats": "0.15.2-dev-ff9b882.0+ff9b882",
42
+ "@agoric/zoe": "0.26.3-dev-ff9b882.0+ff9b882",
43
43
  "@endo/captp": "^4.4.2",
44
44
  "@endo/errors": "^1.2.7",
45
45
  "@endo/eventual-send": "^1.2.7",
@@ -50,10 +50,10 @@
50
50
  "jessie.js": "^0.3.4"
51
51
  },
52
52
  "devDependencies": {
53
- "@agoric/smart-wallet": "0.5.4-dev-40e0e4e.0+40e0e4e",
54
- "@agoric/swingset-liveslots": "0.10.3-dev-40e0e4e.0+40e0e4e",
55
- "@agoric/swingset-vat": "0.32.3-dev-40e0e4e.0+40e0e4e",
56
- "@agoric/zone": "0.2.3-dev-40e0e4e.0+40e0e4e",
53
+ "@agoric/smart-wallet": "0.5.4-dev-ff9b882.0+ff9b882",
54
+ "@agoric/swingset-liveslots": "0.10.3-dev-ff9b882.0+ff9b882",
55
+ "@agoric/swingset-vat": "0.32.3-dev-ff9b882.0+ff9b882",
56
+ "@agoric/zone": "0.2.3-dev-ff9b882.0+ff9b882",
57
57
  "@endo/bundle-source": "^3.4.2",
58
58
  "@endo/init": "^1.1.6",
59
59
  "@endo/promise-kit": "^1.1.7",
@@ -84,5 +84,5 @@
84
84
  "typeCoverage": {
85
85
  "atLeast": 95.71
86
86
  },
87
- "gitHead": "40e0e4e37503b611609d1752389477d8f14f1a8e"
87
+ "gitHead": "ff9b882dd93e3f8d3b7e9d305bbafda6bfb17fac"
88
88
  }
@@ -0,0 +1,48 @@
1
+ export function replaceFeeDistributor({ consume: { chainTimerService, bankManager, vaultFactoryKit, periodicFeeCollectors, reserveKit, zoe, contractKits: contractKitsP, }, produce: { feeDistributorKit, periodicFeeCollectors: periodicFeeCollectorsP, }, instance: { produce: { feeDistributor: feeDistributorP }, }, installation: { consume: { feeDistributor }, }, issuer: { consume: { [Stable.symbol]: centralIssuerP }, }, brand: { consume: { [Stable.symbol]: centralBrandP }, }, }: import("./econ-behaviors").EconomyBootstrapPowers, { options }: {
2
+ options: {
3
+ keywordShares: Record<string, bigint>;
4
+ collectionInterval: bigint;
5
+ };
6
+ }): Promise<void>;
7
+ export function getManifestForReplaceFeeDistributor(_: any, feeDistributorOptions: any): Promise<{
8
+ manifest: {
9
+ [x: string]: {
10
+ consume: {
11
+ chainTimerService: string;
12
+ bankManager: string;
13
+ vaultFactoryKit: string;
14
+ periodicFeeCollectors: string;
15
+ reserveKit: string;
16
+ zoe: string;
17
+ contractKits: string;
18
+ };
19
+ produce: {
20
+ feeDistributorKit: string;
21
+ periodicFeeCollectors: string;
22
+ };
23
+ instance: {
24
+ produce: {
25
+ feeDistributor: string;
26
+ };
27
+ };
28
+ installation: {
29
+ consume: {
30
+ feeDistributor: string;
31
+ };
32
+ };
33
+ issuer: {
34
+ consume: {
35
+ IST: string;
36
+ };
37
+ };
38
+ brand: {
39
+ consume: {
40
+ IST: string;
41
+ };
42
+ };
43
+ };
44
+ };
45
+ options: any;
46
+ }>;
47
+ import { Stable } from '@agoric/internal/src/tokens.js';
48
+ //# sourceMappingURL=replace-fee-distributor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replace-fee-distributor.d.ts","sourceRoot":"","sources":["replace-fee-distributor.js"],"names":[],"mappings":"AAkBO,geARI,OAAO,kBAAkB,EAAE,sBAAsB,eACjD;IACN,OAAO,EAAE;QACP,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACtC,kBAAkB,EAAE,MAAM,CAAC;KAC5B,CAAC;CACH,iBA4IH;AAIM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCL;uBAjMqB,gCAAgC"}
@@ -0,0 +1,195 @@
1
+ import { deeplyFulfilledObject, makeTracer } from '@agoric/internal';
2
+ import { Stable } from '@agoric/internal/src/tokens.js';
3
+ import { makeScalarBigMapStore } from '@agoric/vat-data';
4
+ import { getInterfaceOf, E } from '@endo/far';
5
+
6
+ const trace = makeTracer('ReplaceFeeDistributer', true);
7
+
8
+ /**
9
+ * Start the reward distributor.
10
+ *
11
+ * @param {import('./econ-behaviors').EconomyBootstrapPowers} powers
12
+ * @param {{
13
+ * options: {
14
+ * keywordShares: Record<string, bigint>;
15
+ * collectionInterval: bigint;
16
+ * };
17
+ * }} options
18
+ */
19
+ export const replaceFeeDistributor = async (
20
+ {
21
+ consume: {
22
+ chainTimerService,
23
+ bankManager,
24
+ vaultFactoryKit,
25
+ periodicFeeCollectors,
26
+ reserveKit,
27
+ zoe,
28
+ contractKits: contractKitsP,
29
+ },
30
+ produce: {
31
+ feeDistributorKit,
32
+ periodicFeeCollectors: periodicFeeCollectorsP,
33
+ },
34
+ instance: {
35
+ produce: { feeDistributor: feeDistributorP },
36
+ },
37
+ installation: {
38
+ consume: { feeDistributor },
39
+ },
40
+ issuer: {
41
+ consume: { [Stable.symbol]: centralIssuerP },
42
+ },
43
+ brand: {
44
+ consume: { [Stable.symbol]: centralBrandP },
45
+ },
46
+ },
47
+ { options },
48
+ ) => {
49
+ trace('replaceFeeDistributer', options);
50
+
51
+ const { keywordShares, collectionInterval } = options;
52
+
53
+ const feeDistributorTerms = await deeplyFulfilledObject(
54
+ harden({
55
+ timerService: chainTimerService,
56
+ collectionInterval,
57
+ keywordShares,
58
+ }),
59
+ );
60
+ trace('feeDistributorTerms', feeDistributorTerms);
61
+
62
+ const [centralIssuer, centralBrand, contractKits] = await Promise.all([
63
+ centralIssuerP,
64
+ centralBrandP,
65
+ contractKitsP,
66
+ ]);
67
+
68
+ const rewardDistributorDepositFacet = await E(bankManager)
69
+ .getRewardDistributorDepositFacet(Stable.denom, {
70
+ issuer: centralIssuer,
71
+ brand: centralBrand,
72
+ })
73
+ .catch(e => {
74
+ console.error('Cannot create fee collector deposit facet', e);
75
+ return undefined;
76
+ });
77
+
78
+ /**
79
+ * @type {StartedInstanceKit<
80
+ * typeof import('@agoric/inter-protocol/src/feeDistributor.js').start
81
+ * >}
82
+ */
83
+ const instanceKit = await E(zoe).startInstance(
84
+ feeDistributor,
85
+ { Fee: centralIssuer },
86
+ feeDistributorTerms,
87
+ undefined,
88
+ 'feeDistributor',
89
+ );
90
+ await E(instanceKit.creatorFacet).setDestinations({
91
+ ...(rewardDistributorDepositFacet && {
92
+ RewardDistributor: E(
93
+ instanceKit.creatorFacet,
94
+ ).makeDepositFacetDestination(rewardDistributorDepositFacet),
95
+ }),
96
+ Reserve: E(instanceKit.creatorFacet).makeOfferDestination(
97
+ zoe,
98
+ 'Collateral',
99
+ E.get(reserveKit).publicFacet,
100
+ 'makeAddCollateralInvitation',
101
+ ),
102
+ });
103
+
104
+ trace('Clearing the old instance from bootstrap powers...');
105
+ feeDistributorKit.reset();
106
+ feeDistributorP.reset();
107
+
108
+ trace('Now introduce the new instance');
109
+ feeDistributorKit.resolve(
110
+ harden({ ...instanceKit, label: 'feeDistributor' }),
111
+ );
112
+ feeDistributorP.resolve(instanceKit.instance);
113
+
114
+ const periodicCollectors = await periodicFeeCollectors;
115
+ trace(
116
+ `Stop periodicCollectors of the old instance. Number of collectors: ${periodicCollectors.getSize()}`,
117
+ );
118
+ for await (const [key, collector] of periodicCollectors.entries()) {
119
+ trace('Getting debugName', key);
120
+ // @ts-expect-error incomplete PeriodicFeeCollector type
121
+ const debugName = await E(collector).getDebugName();
122
+ trace(`Stopping ${debugName}...`);
123
+ await E(collector).stop();
124
+ }
125
+ periodicFeeCollectorsP.reset();
126
+
127
+ trace('Old collectors cleared. Start creating and setting new ones.');
128
+
129
+ const collectorKit = {
130
+ vaultFactory: E.get(vaultFactoryKit).creatorFacet,
131
+ };
132
+ const newCollectorStore = makeScalarBigMapStore('periodicCollectors', {
133
+ durable: true,
134
+ });
135
+ await Promise.all(
136
+ Object.entries(collectorKit).map(async ([debugName, collectorFacet]) => {
137
+ const collector = E(instanceKit.creatorFacet).makeContractFeeCollector(
138
+ zoe,
139
+ collectorFacet,
140
+ );
141
+ const periodicCollector = await E(
142
+ instanceKit.creatorFacet,
143
+ ).startPeriodicCollection(debugName, collector);
144
+ newCollectorStore.init(periodicCollectors.getSize(), periodicCollector);
145
+ }),
146
+ );
147
+
148
+ trace('Write newCollectorStore in periodicFeeCollectors');
149
+ periodicFeeCollectorsP.resolve(newCollectorStore);
150
+
151
+ trace('Write to contractKits');
152
+ const label = getInterfaceOf(instanceKit.instance);
153
+ const kit = harden({ ...instanceKit, label });
154
+ contractKits.init(kit.instance, kit);
155
+
156
+ trace('Done.');
157
+ };
158
+ harden(replaceFeeDistributor);
159
+
160
+ const t = 'replaceFeeDistributor';
161
+ export const getManifestForReplaceFeeDistributor = async (
162
+ _,
163
+ feeDistributorOptions,
164
+ ) => ({
165
+ manifest: {
166
+ [replaceFeeDistributor.name]: {
167
+ consume: {
168
+ chainTimerService: t,
169
+ bankManager: t,
170
+ vaultFactoryKit: t,
171
+ periodicFeeCollectors: t,
172
+ reserveKit: t,
173
+ zoe: t,
174
+ contractKits: t,
175
+ },
176
+ produce: {
177
+ feeDistributorKit: t,
178
+ periodicFeeCollectors: t,
179
+ },
180
+ instance: {
181
+ produce: { feeDistributor: t },
182
+ },
183
+ installation: {
184
+ consume: { feeDistributor: t },
185
+ },
186
+ issuer: {
187
+ consume: { [Stable.symbol]: t },
188
+ },
189
+ brand: {
190
+ consume: { [Stable.symbol]: t },
191
+ },
192
+ },
193
+ },
194
+ options: { ...feeDistributorOptions },
195
+ });