@agoric/zoe 0.26.3-dev-ba2f0d9.0 → 0.26.3-dev-df3d0a7.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-contractFacet-js-meta.json +208 -208
- package/package.json +12 -12
- package/tools/priceAuthorityRegistry.js +0 -209
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/zoe",
|
|
3
|
-
"version": "0.26.3-dev-
|
|
3
|
+
"version": "0.26.3-dev-df3d0a7.0+df3d0a7",
|
|
4
4
|
"description": "Zoe: the Smart Contract Framework for Offer Enforcement",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/zoeService/zoe.js",
|
|
@@ -43,15 +43,15 @@
|
|
|
43
43
|
},
|
|
44
44
|
"homepage": "https://github.com/Agoric/agoric-sdk#readme",
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@agoric/assert": "0.6.1-dev-
|
|
47
|
-
"@agoric/ertp": "0.16.3-dev-
|
|
48
|
-
"@agoric/internal": "0.3.3-dev-
|
|
49
|
-
"@agoric/notifier": "0.6.3-dev-
|
|
50
|
-
"@agoric/store": "0.9.3-dev-
|
|
51
|
-
"@agoric/swingset-liveslots": "0.10.3-dev-
|
|
52
|
-
"@agoric/swingset-vat": "0.32.3-dev-
|
|
53
|
-
"@agoric/time": "0.3.3-dev-
|
|
54
|
-
"@agoric/vat-data": "0.5.3-dev-
|
|
46
|
+
"@agoric/assert": "0.6.1-dev-df3d0a7.0+df3d0a7",
|
|
47
|
+
"@agoric/ertp": "0.16.3-dev-df3d0a7.0+df3d0a7",
|
|
48
|
+
"@agoric/internal": "0.3.3-dev-df3d0a7.0+df3d0a7",
|
|
49
|
+
"@agoric/notifier": "0.6.3-dev-df3d0a7.0+df3d0a7",
|
|
50
|
+
"@agoric/store": "0.9.3-dev-df3d0a7.0+df3d0a7",
|
|
51
|
+
"@agoric/swingset-liveslots": "0.10.3-dev-df3d0a7.0+df3d0a7",
|
|
52
|
+
"@agoric/swingset-vat": "0.32.3-dev-df3d0a7.0+df3d0a7",
|
|
53
|
+
"@agoric/time": "0.3.3-dev-df3d0a7.0+df3d0a7",
|
|
54
|
+
"@agoric/vat-data": "0.5.3-dev-df3d0a7.0+df3d0a7",
|
|
55
55
|
"@endo/bundle-source": "^3.0.1",
|
|
56
56
|
"@endo/captp": "^4.0.1",
|
|
57
57
|
"@endo/eventual-send": "^1.0.1",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"yargs-parser": "^21.1.1"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@agoric/kmarshal": "0.1.1-dev-
|
|
67
|
+
"@agoric/kmarshal": "0.1.1-dev-df3d0a7.0+df3d0a7",
|
|
68
68
|
"@endo/init": "^1.0.1",
|
|
69
69
|
"ava": "^5.3.0",
|
|
70
70
|
"c8": "^7.13.0",
|
|
@@ -137,5 +137,5 @@
|
|
|
137
137
|
"typeCoverage": {
|
|
138
138
|
"atLeast": 84.82
|
|
139
139
|
},
|
|
140
|
-
"gitHead": "
|
|
140
|
+
"gitHead": "df3d0a78800845d0da9a3ebbe5841447c5bc61a6"
|
|
141
141
|
}
|
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
import { BrandShape } from '@agoric/ertp';
|
|
2
|
-
import {
|
|
3
|
-
M,
|
|
4
|
-
prepareExo,
|
|
5
|
-
makeScalarBigMapStore,
|
|
6
|
-
provideDurableMapStore,
|
|
7
|
-
} from '@agoric/vat-data';
|
|
8
|
-
import { provideLazy } from '@agoric/store';
|
|
9
|
-
import { E } from '@endo/eventual-send';
|
|
10
|
-
import { Far } from '@endo/marshal';
|
|
11
|
-
import { PriceAuthorityI } from '../src/contractSupport/priceAuthority.js';
|
|
12
|
-
|
|
13
|
-
const { Fail } = assert;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @typedef {object} Deleter
|
|
17
|
-
* @property {() => void} delete
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* @typedef {object} PriceAuthorityRegistryAdmin
|
|
22
|
-
* @property {(pa: ERef<PriceAuthority>,
|
|
23
|
-
* brandIn: Brand,
|
|
24
|
-
* brandOut: Brand,
|
|
25
|
-
* force?: boolean) => Promise<Deleter>} registerPriceAuthority
|
|
26
|
-
* Add a unique price authority for a given pair
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* @typedef {object} PriceAuthorityRegistry A price authority that is a facade
|
|
31
|
-
* for other backing price authorities registered for a given asset and price
|
|
32
|
-
* brand
|
|
33
|
-
* @property {PriceAuthority} priceAuthority
|
|
34
|
-
* @property {PriceAuthorityRegistryAdmin} adminFacet
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Make a singleton registry for priceAuthorities
|
|
39
|
-
*
|
|
40
|
-
* @param {import('@agoric/vat-data').Baggage} baggage
|
|
41
|
-
* @returns {PriceAuthorityRegistry}
|
|
42
|
-
*/
|
|
43
|
-
export const providePriceAuthorityRegistry = baggage => {
|
|
44
|
-
/**
|
|
45
|
-
* @typedef {object} PriceAuthorityRecord A record indicating a registered
|
|
46
|
-
* price authority. We put a box around the priceAuthority to ensure the
|
|
47
|
-
* deleter doesn't delete the wrong thing.
|
|
48
|
-
* @property {ERef<PriceAuthority>} priceAuthority the sub-authority for a
|
|
49
|
-
* given input and output brand pair
|
|
50
|
-
*/
|
|
51
|
-
|
|
52
|
-
/** @type {MapStore<Brand, MapStore<Brand, PriceAuthorityRecord>>} */
|
|
53
|
-
const assetToPriceStore = provideDurableMapStore(baggage, 'brandIn');
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Get the registered price authority for a given input and output pair.
|
|
57
|
-
*
|
|
58
|
-
* @param {Brand} brandIn
|
|
59
|
-
* @param {Brand} brandOut
|
|
60
|
-
* @returns {ERef<PriceAuthority>}
|
|
61
|
-
*/
|
|
62
|
-
const paFor = (brandIn, brandOut) => {
|
|
63
|
-
const priceStore = assetToPriceStore.get(brandIn);
|
|
64
|
-
return priceStore.get(brandOut).priceAuthority;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Create a quoteWhen* method for the given condition.
|
|
69
|
-
*
|
|
70
|
-
* @param {'LT' | 'LTE' | 'GTE' | 'GT'} relation
|
|
71
|
-
*/
|
|
72
|
-
const makeQuoteWhen =
|
|
73
|
-
relation =>
|
|
74
|
-
/**
|
|
75
|
-
* Return a quote when relation is true of the arguments.
|
|
76
|
-
*
|
|
77
|
-
* @param {Amount<'nat'>} amountIn monitor the amountOut corresponding to this amountIn
|
|
78
|
-
* @param {Amount<'nat'>} amountOutLimit the value to compare with the monitored amountOut
|
|
79
|
-
* @returns {Promise<PriceQuote>} resolve with a quote when `amountOut
|
|
80
|
-
* relation amountOutLimit` is true
|
|
81
|
-
*/
|
|
82
|
-
async (amountIn, amountOutLimit) => {
|
|
83
|
-
const pa = paFor(amountIn.brand, amountOutLimit.brand);
|
|
84
|
-
return E(pa)[`quoteWhen${relation}`](amountIn, amountOutLimit);
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Create a mutableQuoteWhen* method for the given condition.
|
|
89
|
-
*
|
|
90
|
-
* @param {'LT' | 'LTE' | 'GTE' | 'GT'} relation
|
|
91
|
-
*/
|
|
92
|
-
const makeMutableQuoteWhen =
|
|
93
|
-
relation =>
|
|
94
|
-
/**
|
|
95
|
-
* Return a mutable quote when relation is true of the arguments.
|
|
96
|
-
*
|
|
97
|
-
* @param {Amount} amountIn monitor the amountOut corresponding to this amountIn
|
|
98
|
-
* @param {Amount} amountOutLimit the value to compare with the monitored amountOut
|
|
99
|
-
* @returns {Promise<MutableQuote>} resolve with a quote when `amountOut
|
|
100
|
-
* relation amountOutLimit` is true
|
|
101
|
-
*/
|
|
102
|
-
async (amountIn, amountOutLimit) => {
|
|
103
|
-
const pa = paFor(amountIn.brand, amountOutLimit.brand);
|
|
104
|
-
return E(pa)[`mutableQuoteWhen${relation}`](amountIn, amountOutLimit);
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* This PriceAuthority is just a wrapper for multiple registered
|
|
109
|
-
* PriceAuthorities.
|
|
110
|
-
*
|
|
111
|
-
* @type {PriceAuthority}
|
|
112
|
-
*/
|
|
113
|
-
const priceAuthority = prepareExo(
|
|
114
|
-
baggage,
|
|
115
|
-
'composite price authority',
|
|
116
|
-
PriceAuthorityI,
|
|
117
|
-
{
|
|
118
|
-
getQuoteIssuer(brandIn, brandOut) {
|
|
119
|
-
return E(paFor(brandIn, brandOut)).getQuoteIssuer(brandIn, brandOut);
|
|
120
|
-
},
|
|
121
|
-
getTimerService(brandIn, brandOut) {
|
|
122
|
-
return E(paFor(brandIn, brandOut)).getTimerService(brandIn, brandOut);
|
|
123
|
-
},
|
|
124
|
-
quoteGiven(amountIn, brandOut) {
|
|
125
|
-
return E(paFor(amountIn.brand, brandOut)).quoteGiven(
|
|
126
|
-
amountIn,
|
|
127
|
-
brandOut,
|
|
128
|
-
);
|
|
129
|
-
},
|
|
130
|
-
quoteWanted(brandIn, amountOut) {
|
|
131
|
-
return E(paFor(brandIn, amountOut.brand)).quoteWanted(
|
|
132
|
-
brandIn,
|
|
133
|
-
amountOut,
|
|
134
|
-
);
|
|
135
|
-
},
|
|
136
|
-
makeQuoteNotifier(amountIn, brandOut) {
|
|
137
|
-
return E(paFor(amountIn.brand, brandOut)).makeQuoteNotifier(
|
|
138
|
-
amountIn,
|
|
139
|
-
brandOut,
|
|
140
|
-
);
|
|
141
|
-
},
|
|
142
|
-
quoteAtTime(deadline, amountIn, brandOut) {
|
|
143
|
-
return E(paFor(amountIn.brand, brandOut)).quoteAtTime(
|
|
144
|
-
deadline,
|
|
145
|
-
amountIn,
|
|
146
|
-
brandOut,
|
|
147
|
-
);
|
|
148
|
-
},
|
|
149
|
-
quoteWhenLT: makeQuoteWhen('LT'),
|
|
150
|
-
quoteWhenLTE: makeQuoteWhen('LTE'),
|
|
151
|
-
quoteWhenGTE: makeQuoteWhen('GTE'),
|
|
152
|
-
quoteWhenGT: makeQuoteWhen('GT'),
|
|
153
|
-
mutableQuoteWhenLT: makeMutableQuoteWhen('LT'),
|
|
154
|
-
mutableQuoteWhenLTE: makeMutableQuoteWhen('LTE'),
|
|
155
|
-
mutableQuoteWhenGTE: makeMutableQuoteWhen('GTE'),
|
|
156
|
-
mutableQuoteWhenGT: makeMutableQuoteWhen('GT'),
|
|
157
|
-
},
|
|
158
|
-
);
|
|
159
|
-
|
|
160
|
-
/** @type {PriceAuthorityRegistryAdmin} */
|
|
161
|
-
const adminFacet = prepareExo(
|
|
162
|
-
baggage,
|
|
163
|
-
'price authority admin facet',
|
|
164
|
-
M.interface('priceAuthorityRegistryAdmin', {
|
|
165
|
-
registerPriceAuthority: M.callWhen(
|
|
166
|
-
M.await(M.remotable('priceAuthority')),
|
|
167
|
-
BrandShape,
|
|
168
|
-
BrandShape,
|
|
169
|
-
)
|
|
170
|
-
.optional(M.boolean())
|
|
171
|
-
.returns(M.remotable('deleter')),
|
|
172
|
-
}),
|
|
173
|
-
{
|
|
174
|
-
registerPriceAuthority(pa, brandIn, brandOut, force = false) {
|
|
175
|
-
/** @type {MapStore<Brand, PriceAuthorityRecord>} */
|
|
176
|
-
const priceStore = provideLazy(assetToPriceStore, brandIn, () =>
|
|
177
|
-
makeScalarBigMapStore('brandOut', { durable: true }),
|
|
178
|
-
);
|
|
179
|
-
|
|
180
|
-
// Put a box around the authority so that we can be ensured the deleter
|
|
181
|
-
// won't delete the wrong thing.
|
|
182
|
-
const record = {
|
|
183
|
-
priceAuthority: pa,
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
// Set up the record.
|
|
187
|
-
if (force && priceStore.has(brandOut)) {
|
|
188
|
-
priceStore.set(brandOut, harden(record));
|
|
189
|
-
} else {
|
|
190
|
-
priceStore.init(brandOut, harden(record));
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
return Far('deleter', {
|
|
194
|
-
// @ts-expect-error XXX callWhen
|
|
195
|
-
delete() {
|
|
196
|
-
(priceStore.has(brandOut) && priceStore.get(brandOut) === record) ||
|
|
197
|
-
Fail`Price authority already dropped`;
|
|
198
|
-
priceStore.delete(brandOut);
|
|
199
|
-
},
|
|
200
|
-
});
|
|
201
|
-
},
|
|
202
|
-
},
|
|
203
|
-
);
|
|
204
|
-
|
|
205
|
-
return harden({
|
|
206
|
-
priceAuthority,
|
|
207
|
-
adminFacet,
|
|
208
|
-
});
|
|
209
|
-
};
|