@agoric/inter-protocol 0.16.2-dev-b05c226.0 → 0.16.2-dev-6bce049.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-auctioneer-js-meta.json +118 -118
- package/bundles/bundle-auctioneer.js +1 -1
- package/bundles/bundle-econCommitteeCharter-js-meta.json +83 -83
- package/bundles/bundle-econCommitteeCharter.js +1 -1
- package/bundles/bundle-feeDistributor-js-meta.json +57 -57
- package/bundles/bundle-feeDistributor.js +1 -1
- package/bundles/bundle-fluxAggregatorKit-js-meta.json +111 -111
- package/bundles/bundle-fluxAggregatorKit.js +1 -1
- package/bundles/bundle-psm-js-meta.json +109 -109
- package/bundles/bundle-psm.js +1 -1
- package/bundles/bundle-reserve-js-meta.json +108 -108
- package/bundles/bundle-reserve.js +1 -1
- package/bundles/bundle-scaledPriceAuthority-js-meta.json +78 -78
- package/bundles/bundle-vaultFactory-js-meta.json +135 -135
- package/bundles/bundle-vaultFactory.js +1 -1
- package/package.json +16 -18
- package/src/clientSupport.js +70 -71
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/inter-protocol",
|
|
3
|
-
"version": "0.16.2-dev-
|
|
3
|
+
"version": "0.16.2-dev-6bce049.0+6bce049",
|
|
4
4
|
"description": "Core cryptoeconomy contracts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -30,29 +30,28 @@
|
|
|
30
30
|
},
|
|
31
31
|
"homepage": "https://github.com/Agoric/agoric-sdk#readme",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@agoric/assert": "0.6.1-dev-
|
|
34
|
-
"@agoric/ertp": "0.16.3-dev-
|
|
35
|
-
"@agoric/governance": "0.10.4-dev-
|
|
36
|
-
"@agoric/internal": "0.3.3-dev-
|
|
37
|
-
"@agoric/notifier": "0.6.3-dev-
|
|
38
|
-
"@agoric/store": "0.9.3-dev-
|
|
39
|
-
"@agoric/time": "0.3.3-dev-
|
|
40
|
-
"@agoric/vat-data": "0.5.3-dev-
|
|
41
|
-
"@agoric/vats": "0.15.2-dev-
|
|
42
|
-
"@agoric/zoe": "0.26.3-dev-
|
|
33
|
+
"@agoric/assert": "0.6.1-dev-6bce049.0+6bce049",
|
|
34
|
+
"@agoric/ertp": "0.16.3-dev-6bce049.0+6bce049",
|
|
35
|
+
"@agoric/governance": "0.10.4-dev-6bce049.0+6bce049",
|
|
36
|
+
"@agoric/internal": "0.3.3-dev-6bce049.0+6bce049",
|
|
37
|
+
"@agoric/notifier": "0.6.3-dev-6bce049.0+6bce049",
|
|
38
|
+
"@agoric/store": "0.9.3-dev-6bce049.0+6bce049",
|
|
39
|
+
"@agoric/time": "0.3.3-dev-6bce049.0+6bce049",
|
|
40
|
+
"@agoric/vat-data": "0.5.3-dev-6bce049.0+6bce049",
|
|
41
|
+
"@agoric/vats": "0.15.2-dev-6bce049.0+6bce049",
|
|
42
|
+
"@agoric/zoe": "0.26.3-dev-6bce049.0+6bce049",
|
|
43
43
|
"@endo/captp": "^3.1.1",
|
|
44
44
|
"@endo/eventual-send": "^0.17.2",
|
|
45
45
|
"@endo/far": "^0.2.18",
|
|
46
46
|
"@endo/marshal": "^0.8.5",
|
|
47
47
|
"@endo/nat": "^4.1.27",
|
|
48
|
-
"agoric": "0.21.2-dev-b05c226.0+b05c226",
|
|
49
48
|
"jessie.js": "^0.3.2"
|
|
50
49
|
},
|
|
51
50
|
"devDependencies": {
|
|
52
|
-
"@agoric/deploy-script-support": "0.10.4-dev-
|
|
53
|
-
"@agoric/smart-wallet": "0.5.4-dev-
|
|
54
|
-
"@agoric/swingset-liveslots": "0.10.3-dev-
|
|
55
|
-
"@agoric/swingset-vat": "0.32.3-dev-
|
|
51
|
+
"@agoric/deploy-script-support": "0.10.4-dev-6bce049.0+6bce049",
|
|
52
|
+
"@agoric/smart-wallet": "0.5.4-dev-6bce049.0+6bce049",
|
|
53
|
+
"@agoric/swingset-liveslots": "0.10.3-dev-6bce049.0+6bce049",
|
|
54
|
+
"@agoric/swingset-vat": "0.32.3-dev-6bce049.0+6bce049",
|
|
56
55
|
"@endo/bundle-source": "^2.5.1",
|
|
57
56
|
"@endo/init": "^0.5.56",
|
|
58
57
|
"@endo/promise-kit": "^0.2.56",
|
|
@@ -73,12 +72,11 @@
|
|
|
73
72
|
"files": [
|
|
74
73
|
"test/**/test-*.js"
|
|
75
74
|
],
|
|
76
|
-
"concurrency": 2,
|
|
77
75
|
"workerThreads": false,
|
|
78
76
|
"timeout": "10m"
|
|
79
77
|
},
|
|
80
78
|
"publishConfig": {
|
|
81
79
|
"access": "public"
|
|
82
80
|
},
|
|
83
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "6bce049552bcc46666a9f2eb4afac8a017b5f3d4"
|
|
84
82
|
}
|
package/src/clientSupport.js
CHANGED
|
@@ -9,29 +9,31 @@ import { parseRatio } from '@agoric/zoe/src/contractSupport/ratio.js';
|
|
|
9
9
|
const COSMOS_UNIT = 1_000_000n;
|
|
10
10
|
const scaleDecimals = num => BigInt(num * Number(COSMOS_UNIT));
|
|
11
11
|
|
|
12
|
+
// TODO use '@satisfies" in TS 5.1 to make sure these each conform to OfferMaker interface
|
|
13
|
+
|
|
12
14
|
// NB: not really a Proposal because the brands are not remotes
|
|
13
15
|
// Instead they're copyRecord like "{"boardId":"board0257","iface":"Alleged: IST brand"}" to pass through the boardId
|
|
14
16
|
// mustMatch(harden(proposal), ProposalShape);
|
|
15
17
|
/**
|
|
16
18
|
* Give/want
|
|
17
19
|
*
|
|
18
|
-
* @param {
|
|
20
|
+
* @param {Pick<import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes, 'brand'>} agoricNames
|
|
19
21
|
* @param {{ giveMinted?: number, wantMinted?: number } | { collateralBrandKey: string, giveCollateral?: number, wantCollateral?: number }} opts
|
|
20
22
|
* @returns {Proposal}
|
|
21
23
|
*/
|
|
22
|
-
const makeVaultProposal = (
|
|
24
|
+
const makeVaultProposal = ({ brand }, opts) => {
|
|
23
25
|
const proposal = { give: {}, want: {} };
|
|
24
26
|
|
|
25
27
|
if ('giveCollateral' in opts && opts.giveCollateral) {
|
|
26
28
|
const { collateralBrandKey } = opts;
|
|
27
29
|
proposal.give.Collateral = {
|
|
28
|
-
brand:
|
|
30
|
+
brand: brand[collateralBrandKey],
|
|
29
31
|
value: scaleDecimals(opts.giveCollateral),
|
|
30
32
|
};
|
|
31
33
|
}
|
|
32
34
|
if ('giveMinted' in opts && opts.giveMinted) {
|
|
33
35
|
proposal.give.Minted = {
|
|
34
|
-
brand:
|
|
36
|
+
brand: brand.IST,
|
|
35
37
|
value: scaleDecimals(opts.giveMinted),
|
|
36
38
|
};
|
|
37
39
|
}
|
|
@@ -39,13 +41,13 @@ const makeVaultProposal = (brands, opts) => {
|
|
|
39
41
|
if ('wantCollateral' in opts && opts.wantCollateral) {
|
|
40
42
|
const { collateralBrandKey } = opts;
|
|
41
43
|
proposal.want.Collateral = {
|
|
42
|
-
brand:
|
|
44
|
+
brand: brand[collateralBrandKey],
|
|
43
45
|
value: scaleDecimals(opts.wantCollateral),
|
|
44
46
|
};
|
|
45
47
|
}
|
|
46
48
|
if ('wantMinted' in opts && opts.wantMinted) {
|
|
47
49
|
proposal.want.Minted = {
|
|
48
|
-
brand:
|
|
50
|
+
brand: brand.IST,
|
|
49
51
|
value: scaleDecimals(opts.wantMinted),
|
|
50
52
|
};
|
|
51
53
|
}
|
|
@@ -54,18 +56,18 @@ const makeVaultProposal = (brands, opts) => {
|
|
|
54
56
|
};
|
|
55
57
|
|
|
56
58
|
/**
|
|
57
|
-
* @param {
|
|
59
|
+
* @param {Pick<import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes, 'brand'>} agoricNames
|
|
58
60
|
* @param {{ offerId: string, wantMinted: number, giveCollateral: number, collateralBrandKey: string }} opts
|
|
59
61
|
* @returns {import('@agoric/smart-wallet/src/offers.js').OfferSpec}
|
|
60
62
|
*/
|
|
61
|
-
const makeOpenOffer = (
|
|
62
|
-
const proposal = makeVaultProposal(
|
|
63
|
+
const makeOpenOffer = ({ brand }, opts) => {
|
|
64
|
+
const proposal = makeVaultProposal({ brand }, opts);
|
|
63
65
|
|
|
64
66
|
// NB: not really a Proposal because the brands are not remotes
|
|
65
67
|
// Instead they're copyRecord like "{"boardId":"board0257","iface":"Alleged: IST brand"}" to pass through the boardId
|
|
66
68
|
// mustMatch(harden(proposal), ProposalShape);
|
|
67
69
|
|
|
68
|
-
const collateralBrand =
|
|
70
|
+
const collateralBrand = brand[opts.collateralBrandKey];
|
|
69
71
|
|
|
70
72
|
return {
|
|
71
73
|
id: opts.offerId,
|
|
@@ -82,16 +84,16 @@ const makeOpenOffer = (brands, opts) => {
|
|
|
82
84
|
};
|
|
83
85
|
|
|
84
86
|
/**
|
|
85
|
-
* @param {
|
|
87
|
+
* @param {Pick<import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes, 'brand'>} agoricNames
|
|
86
88
|
* @param {{ offerId: string, collateralBrandKey?: string, giveCollateral?: number, wantCollateral?: number, giveMinted?: number, wantMinted?: number }} opts
|
|
87
89
|
* @param {string} previousOffer
|
|
88
90
|
* @returns {import('@agoric/smart-wallet/src/offers.js').OfferSpec}
|
|
89
91
|
*/
|
|
90
|
-
const makeAdjustOffer = (
|
|
92
|
+
const makeAdjustOffer = ({ brand }, opts, previousOffer) => {
|
|
91
93
|
// NB: not really a Proposal because the brands are not remotes
|
|
92
94
|
// Instead they're copyRecord like "{"boardId":"board0257","iface":"Alleged: IST brand"}" to pass through the boardId
|
|
93
95
|
// mustMatch(harden(proposal), ProposalShape);
|
|
94
|
-
const proposal = makeVaultProposal(
|
|
96
|
+
const proposal = makeVaultProposal({ brand }, opts);
|
|
95
97
|
|
|
96
98
|
return {
|
|
97
99
|
id: opts.offerId,
|
|
@@ -105,13 +107,13 @@ const makeAdjustOffer = (brands, opts, previousOffer) => {
|
|
|
105
107
|
};
|
|
106
108
|
|
|
107
109
|
/**
|
|
108
|
-
* @param {
|
|
110
|
+
* @param {Pick<import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes, 'brand'>} agoricNames
|
|
109
111
|
* @param {{ offerId: string, collateralBrandKey?: string, giveMinted: number }} opts
|
|
110
112
|
* @param {string} previousOffer
|
|
111
113
|
* @returns {import('@agoric/smart-wallet/src/offers.js').OfferSpec}
|
|
112
114
|
*/
|
|
113
|
-
const makeCloseOffer = (
|
|
114
|
-
const proposal = makeVaultProposal(
|
|
115
|
+
const makeCloseOffer = ({ brand }, opts, previousOffer) => {
|
|
116
|
+
const proposal = makeVaultProposal({ brand }, opts);
|
|
115
117
|
|
|
116
118
|
return {
|
|
117
119
|
id: opts.offerId,
|
|
@@ -171,19 +173,19 @@ const makePsmProposal = (brands, opts, fee = 0, anchor = 'AUSD') => {
|
|
|
171
173
|
};
|
|
172
174
|
|
|
173
175
|
/**
|
|
176
|
+
* @param {Pick<import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes, 'brand'>} agoricNames
|
|
174
177
|
* @param {Instance} instance
|
|
175
|
-
* @param {Record<string, Brand>} brands
|
|
176
178
|
* @param {{ offerId: string, feePct?: number, pair: [string, string] } &
|
|
177
179
|
* ({ wantMinted: number } | { giveMinted: number })} opts
|
|
178
180
|
* @returns {import('@agoric/smart-wallet/src/offers.js').OfferSpec}
|
|
179
181
|
*/
|
|
180
|
-
const makePsmSwapOffer = (
|
|
182
|
+
const makePsmSwapOffer = ({ brand }, instance, opts) => {
|
|
181
183
|
const method =
|
|
182
184
|
'wantMinted' in opts
|
|
183
185
|
? 'makeWantMintedInvitation'
|
|
184
186
|
: 'makeGiveMintedInvitation'; // ref psm.js
|
|
185
187
|
const proposal = makePsmProposal(
|
|
186
|
-
|
|
188
|
+
brand,
|
|
187
189
|
opts,
|
|
188
190
|
opts.feePct ? opts.feePct / 100 : undefined,
|
|
189
191
|
opts.pair[1],
|
|
@@ -205,13 +207,53 @@ const makePsmSwapOffer = (instance, brands, opts) => {
|
|
|
205
207
|
};
|
|
206
208
|
|
|
207
209
|
/**
|
|
208
|
-
* @param {
|
|
210
|
+
* @param {{
|
|
211
|
+
* brand: Record<string, Brand>,
|
|
212
|
+
* vbankAsset: Record<string, { brand: Brand, displayInfo: DisplayInfo }>,
|
|
213
|
+
* }} agoricNames
|
|
214
|
+
* @param {(msg: string) => Error} makeError error constructor
|
|
215
|
+
* @returns {(a: string) => Amount<'nat'>}
|
|
216
|
+
*/
|
|
217
|
+
export const makeParseAmount =
|
|
218
|
+
(agoricNames, makeError = msg => RangeError(msg)) =>
|
|
219
|
+
opt => {
|
|
220
|
+
assert.typeof(opt, 'string', 'parseAmount expected string');
|
|
221
|
+
const m = opt.match(/^(?<value>[\d_]+(\.[\d_]+)?)(?<brand>[A-Z]\w*?)$/);
|
|
222
|
+
if (!m || !m.groups) {
|
|
223
|
+
throw makeError(`invalid amount: ${opt}`);
|
|
224
|
+
}
|
|
225
|
+
const anyBrand = agoricNames.brand[m.groups.brand];
|
|
226
|
+
if (!anyBrand) {
|
|
227
|
+
throw makeError(`unknown brand: ${m.groups.brand}`);
|
|
228
|
+
}
|
|
229
|
+
const assetDesc = Object.values(agoricNames.vbankAsset).find(
|
|
230
|
+
d => d.brand === anyBrand,
|
|
231
|
+
);
|
|
232
|
+
if (!assetDesc) {
|
|
233
|
+
throw makeError(`unknown brand: ${m.groups.brand}`);
|
|
234
|
+
}
|
|
235
|
+
const { displayInfo } = assetDesc;
|
|
236
|
+
if (!displayInfo.decimalPlaces || displayInfo.assetKind !== 'nat') {
|
|
237
|
+
throw makeError(`bad brand: ${displayInfo}`);
|
|
238
|
+
}
|
|
239
|
+
const value = BigInt(
|
|
240
|
+
Number(m.groups.value.replace(/_/g, '')) *
|
|
241
|
+
10 ** displayInfo.decimalPlaces,
|
|
242
|
+
);
|
|
243
|
+
/** @type {Brand<'nat'>} */
|
|
244
|
+
// @ts-expect-error dynamic cast
|
|
245
|
+
const natBrand = anyBrand;
|
|
246
|
+
const amt = { value, brand: natBrand };
|
|
247
|
+
return amt;
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* @param {Pick<import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes, 'brand' | 'vbankAsset'>} agoricNames
|
|
209
252
|
* @param {{
|
|
210
253
|
* offerId: string,
|
|
211
254
|
* give: string,
|
|
212
255
|
* maxBuy: string,
|
|
213
256
|
* wantMinimum?: string,
|
|
214
|
-
* parseAmount: (x: string) => Amount<'nat'>,
|
|
215
257
|
* } & ({
|
|
216
258
|
* price: number,
|
|
217
259
|
* } | {
|
|
@@ -219,14 +261,13 @@ const makePsmSwapOffer = (instance, brands, opts) => {
|
|
|
219
261
|
* })} opts
|
|
220
262
|
* @returns {import('@agoric/smart-wallet/src/offers.js').OfferSpec}
|
|
221
263
|
*/
|
|
222
|
-
const makeBidOffer = (
|
|
223
|
-
assert.typeof(opts.parseAmount, 'function');
|
|
264
|
+
const makeBidOffer = (agoricNames, opts) => {
|
|
224
265
|
assertAllDefined({
|
|
225
266
|
offerId: opts.offerId,
|
|
226
267
|
give: opts.give,
|
|
227
268
|
maxBuy: opts.maxBuy,
|
|
228
269
|
});
|
|
229
|
-
const
|
|
270
|
+
const parseAmount = makeParseAmount(agoricNames);
|
|
230
271
|
const proposal = {
|
|
231
272
|
give: { Bid: parseAmount(opts.give) },
|
|
232
273
|
...(opts.wantMinimum
|
|
@@ -276,7 +317,7 @@ const makeBidOffer = (_brands, opts) => {
|
|
|
276
317
|
};
|
|
277
318
|
|
|
278
319
|
/**
|
|
279
|
-
* @param {
|
|
320
|
+
* @param {Pick<import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes, 'brand'>} agoricNames
|
|
280
321
|
* @param {{
|
|
281
322
|
* offerId: string,
|
|
282
323
|
* give: number,
|
|
@@ -284,11 +325,11 @@ const makeBidOffer = (_brands, opts) => {
|
|
|
284
325
|
* }} opts
|
|
285
326
|
* @returns {import('@agoric/smart-wallet/src/offers.js').OfferSpec}
|
|
286
327
|
*/
|
|
287
|
-
const makeAddCollateralOffer = (
|
|
328
|
+
const makeAddCollateralOffer = ({ brand }, opts) => {
|
|
288
329
|
/** @type {AmountKeywordRecord} */
|
|
289
330
|
const give = {
|
|
290
331
|
Collateral: AmountMath.make(
|
|
291
|
-
|
|
332
|
+
brand[opts.collateralBrandKey],
|
|
292
333
|
scaleDecimals(opts.give),
|
|
293
334
|
),
|
|
294
335
|
};
|
|
@@ -308,7 +349,7 @@ const makeAddCollateralOffer = (brands, opts) => {
|
|
|
308
349
|
|
|
309
350
|
/**
|
|
310
351
|
*
|
|
311
|
-
* @param {
|
|
352
|
+
* @param {unknown} _agoricNames
|
|
312
353
|
* @param {{
|
|
313
354
|
* offerId: string,
|
|
314
355
|
* roundId?: bigint,
|
|
@@ -317,7 +358,7 @@ const makeAddCollateralOffer = (brands, opts) => {
|
|
|
317
358
|
* @param {string} previousOffer
|
|
318
359
|
* @returns {import('@agoric/smart-wallet/src/offers.js').OfferSpec}
|
|
319
360
|
*/
|
|
320
|
-
const makePushPriceOffer = (
|
|
361
|
+
const makePushPriceOffer = (_agoricNames, opts, previousOffer) => {
|
|
321
362
|
return {
|
|
322
363
|
id: opts.offerId,
|
|
323
364
|
invitationSpec: {
|
|
@@ -332,48 +373,6 @@ const makePushPriceOffer = (_brands, opts, previousOffer) => {
|
|
|
332
373
|
};
|
|
333
374
|
};
|
|
334
375
|
|
|
335
|
-
// TODO DRY with CLI wallet.js
|
|
336
|
-
/**
|
|
337
|
-
* @param {{
|
|
338
|
-
* brand: Record<string, Brand>,
|
|
339
|
-
* vbankAsset: Record<string, { brand: Brand, displayInfo: DisplayInfo }>,
|
|
340
|
-
* }} agoricNames
|
|
341
|
-
* @param {(msg: string) => Error} makeError error constructor
|
|
342
|
-
* @returns {(a: string) => Amount<'nat'>}
|
|
343
|
-
*/
|
|
344
|
-
export const makeParseAmount =
|
|
345
|
-
(agoricNames, makeError = msg => RangeError(msg)) =>
|
|
346
|
-
opt => {
|
|
347
|
-
assert.typeof(opt, 'string', 'parseAmount expected string');
|
|
348
|
-
const m = opt.match(/^(?<value>[\d_]+(\.[\d_]+)?)(?<brand>[A-Z]\w*?)$/);
|
|
349
|
-
if (!m || !m.groups) {
|
|
350
|
-
throw makeError(`invalid amount: ${opt}`);
|
|
351
|
-
}
|
|
352
|
-
const anyBrand = agoricNames.brand[m.groups.brand];
|
|
353
|
-
if (!anyBrand) {
|
|
354
|
-
throw makeError(`unknown brand: ${m.groups.brand}`);
|
|
355
|
-
}
|
|
356
|
-
const assetDesc = Object.values(agoricNames.vbankAsset).find(
|
|
357
|
-
d => d.brand === anyBrand,
|
|
358
|
-
);
|
|
359
|
-
if (!assetDesc) {
|
|
360
|
-
throw makeError(`unknown brand: ${m.groups.brand}`);
|
|
361
|
-
}
|
|
362
|
-
const { displayInfo } = assetDesc;
|
|
363
|
-
if (!displayInfo.decimalPlaces || displayInfo.assetKind !== 'nat') {
|
|
364
|
-
throw makeError(`bad brand: ${displayInfo}`);
|
|
365
|
-
}
|
|
366
|
-
const value = BigInt(
|
|
367
|
-
Number(m.groups.value.replace(/_/g, '')) *
|
|
368
|
-
10 ** displayInfo.decimalPlaces,
|
|
369
|
-
);
|
|
370
|
-
/** @type {Brand<'nat'>} */
|
|
371
|
-
// @ts-expect-error dynamic cast
|
|
372
|
-
const natBrand = anyBrand;
|
|
373
|
-
const amt = { value, brand: natBrand };
|
|
374
|
-
return amt;
|
|
375
|
-
};
|
|
376
|
-
|
|
377
376
|
export const Offers = {
|
|
378
377
|
auction: {
|
|
379
378
|
Bid: makeBidOffer,
|