@agoric/fast-usdc 0.2.0-upgrade-19-dev-0754752.0 → 0.2.0-upgrade-18a-dev-4ee0508.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 +25 -26
- package/src/cli/cli.js +1 -1
- package/src/cli/config-commands.js +1 -1
- package/src/cli/config.js +1 -1
- package/src/cli/lp-commands.js +39 -21
- package/src/cli/operator-commands.js +0 -1
- package/src/cli/transfer.js +5 -5
- package/src/exos/advancer.js +41 -109
- package/src/exos/liquidity-pool.js +34 -81
- package/src/exos/operator-kit.js +2 -0
- package/src/exos/settler.js +95 -154
- package/src/exos/status-manager.js +59 -97
- package/src/exos/transaction-feed.js +9 -30
- package/src/fast-usdc-policy.core.js +12 -2
- package/src/fast-usdc.contract.js +31 -23
- package/src/{start-fast-usdc.core.js → fast-usdc.start.js} +81 -13
- package/src/pool-share-math.js +9 -55
- package/src/type-guards.js +8 -37
- package/src/types.ts +5 -34
- package/src/utils/deploy-config.js +75 -36
- package/src/utils/fees.js +4 -3
- package/src/add-operators.core.js +0 -63
- package/src/clientSupport.js +0 -98
- package/src/distribute-fees.core.js +0 -93
- package/src/main.js +0 -1
- package/src/utils/chain-policies.js +0 -140
- package/src/utils/core-eval.js +0 -73
- /package/src/{cli/util → util}/agoric.js +0 -0
- /package/src/{cli/util → util}/bank.js +0 -0
- /package/src/{cli/util → util}/cctp.js +0 -0
- /package/src/{cli/util → util}/file.js +0 -0
- /package/src/{cli/util → util}/noble.js +0 -0
|
@@ -53,12 +53,6 @@ const pendingTxKeyOf = evidence => {
|
|
|
53
53
|
* }} StatusManagerPowers
|
|
54
54
|
*/
|
|
55
55
|
|
|
56
|
-
export const stateShape = harden({
|
|
57
|
-
pendingSettleTxs: M.remotable(),
|
|
58
|
-
seenTxs: M.remotable(),
|
|
59
|
-
storedCompletedTxs: M.remotable(),
|
|
60
|
-
});
|
|
61
|
-
|
|
62
56
|
/**
|
|
63
57
|
* The `StatusManager` keeps track of Pending and Seen Transactions
|
|
64
58
|
* via {@link PendingTxStatus} states, aiding in coordination between the `Advancer`
|
|
@@ -75,15 +69,14 @@ export const prepareStatusManager = (
|
|
|
75
69
|
txnsNode,
|
|
76
70
|
{
|
|
77
71
|
marshaller,
|
|
78
|
-
|
|
79
|
-
log = makeTracer('StatusManager', true),
|
|
72
|
+
log = makeTracer('Advancer', true),
|
|
80
73
|
} = /** @type {StatusManagerPowers} */ ({}),
|
|
81
74
|
) => {
|
|
82
75
|
/**
|
|
83
76
|
* Keyed by a tuple of the Noble Forwarding Account and amount.
|
|
84
77
|
* @type {MapStore<PendingTxKey, PendingTx[]>}
|
|
85
78
|
*/
|
|
86
|
-
const
|
|
79
|
+
const pendingTxs = zone.mapStore('PendingTxs', {
|
|
87
80
|
keyShape: M.string(),
|
|
88
81
|
valueShape: M.arrayOf(PendingTxShape),
|
|
89
82
|
});
|
|
@@ -91,18 +84,13 @@ export const prepareStatusManager = (
|
|
|
91
84
|
/**
|
|
92
85
|
* Transactions seen *ever* by the contract.
|
|
93
86
|
*
|
|
94
|
-
* Note that like all durable stores, this
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
* chains use the same Unix epoch and won't drift more than minutes apart,
|
|
99
|
-
* which is more than enough precision for pruning old transaction.
|
|
100
|
-
*
|
|
101
|
-
* @type {MapStore<EvmHash, NatValue>}
|
|
87
|
+
* Note that like all durable stores, this SetStore is stored in IAVL. It
|
|
88
|
+
* grows without bound (though the amount of growth per incoming message to
|
|
89
|
+
* the contract is bounded). At some point in the future we may want to prune.
|
|
90
|
+
* @type {SetStore<EvmHash>}
|
|
102
91
|
*/
|
|
103
|
-
const seenTxs = zone.
|
|
92
|
+
const seenTxs = zone.setStore('SeenTxs', {
|
|
104
93
|
keyShape: M.string(),
|
|
105
|
-
valueShape: M.nat(),
|
|
106
94
|
});
|
|
107
95
|
|
|
108
96
|
/**
|
|
@@ -165,10 +153,10 @@ export const prepareStatusManager = (
|
|
|
165
153
|
if (seenTxs.has(txHash)) {
|
|
166
154
|
throw makeError(`Transaction already seen: ${q(txHash)}`);
|
|
167
155
|
}
|
|
168
|
-
seenTxs.
|
|
156
|
+
seenTxs.add(txHash);
|
|
169
157
|
|
|
170
158
|
appendToStoredArray(
|
|
171
|
-
|
|
159
|
+
pendingTxs,
|
|
172
160
|
pendingTxKeyOf(evidence),
|
|
173
161
|
harden({ ...evidence, status }),
|
|
174
162
|
);
|
|
@@ -189,8 +177,8 @@ export const prepareStatusManager = (
|
|
|
189
177
|
*/
|
|
190
178
|
function setPendingTxStatus({ nfa, amount }, status) {
|
|
191
179
|
const key = makePendingTxKey(nfa, amount);
|
|
192
|
-
|
|
193
|
-
const pending =
|
|
180
|
+
pendingTxs.has(key) || Fail`no advancing tx with ${{ nfa, amount }}`;
|
|
181
|
+
const pending = pendingTxs.get(key);
|
|
194
182
|
const ix = pending.findIndex(tx => tx.status === PendingTxStatus.Advancing);
|
|
195
183
|
ix >= 0 || Fail`no advancing tx with ${{ nfa, amount }}`;
|
|
196
184
|
const [prefix, tx, suffix] = [
|
|
@@ -199,7 +187,7 @@ export const prepareStatusManager = (
|
|
|
199
187
|
pending.slice(ix + 1),
|
|
200
188
|
];
|
|
201
189
|
const txpost = { ...tx, status };
|
|
202
|
-
|
|
190
|
+
pendingTxs.set(key, harden([...prefix, txpost, ...suffix]));
|
|
203
191
|
void publishTxnRecord(tx.txHash, harden({ status }));
|
|
204
192
|
}
|
|
205
193
|
|
|
@@ -207,19 +195,24 @@ export const prepareStatusManager = (
|
|
|
207
195
|
'Fast USDC Status Manager',
|
|
208
196
|
M.interface('StatusManagerI', {
|
|
209
197
|
// TODO: naming scheme for transition events
|
|
210
|
-
advance: M.call(CctpTxEvidenceShape).returns(),
|
|
198
|
+
advance: M.call(CctpTxEvidenceShape).returns(M.undefined()),
|
|
211
199
|
advanceOutcome: M.call(M.string(), M.nat(), M.boolean()).returns(),
|
|
212
|
-
skipAdvance: M.call(CctpTxEvidenceShape, M.arrayOf(M.string())).returns(
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
observe: M.call(CctpTxEvidenceShape).returns(),
|
|
200
|
+
skipAdvance: M.call(CctpTxEvidenceShape, M.arrayOf(M.string())).returns(
|
|
201
|
+
M.undefined(),
|
|
202
|
+
),
|
|
203
|
+
observe: M.call(CctpTxEvidenceShape).returns(M.undefined()),
|
|
216
204
|
hasBeenObserved: M.call(CctpTxEvidenceShape).returns(M.boolean()),
|
|
217
205
|
deleteCompletedTxs: M.call().returns(M.undefined()),
|
|
218
206
|
dequeueStatus: M.call(M.string(), M.bigint()).returns(
|
|
219
207
|
M.or(
|
|
220
208
|
{
|
|
221
209
|
txHash: EvmHashShape,
|
|
222
|
-
status: M.or(
|
|
210
|
+
status: M.or(
|
|
211
|
+
PendingTxStatus.Advanced,
|
|
212
|
+
PendingTxStatus.AdvanceSkipped,
|
|
213
|
+
PendingTxStatus.AdvanceFailed,
|
|
214
|
+
PendingTxStatus.Observed,
|
|
215
|
+
),
|
|
223
216
|
},
|
|
224
217
|
M.undefined(),
|
|
225
218
|
),
|
|
@@ -227,7 +220,9 @@ export const prepareStatusManager = (
|
|
|
227
220
|
disbursed: M.call(EvmHashShape, AmountKeywordRecordShape).returns(
|
|
228
221
|
M.undefined(),
|
|
229
222
|
),
|
|
230
|
-
forwarded: M.call(EvmHashShape, M.
|
|
223
|
+
forwarded: M.call(M.opt(EvmHashShape), M.string(), M.nat()).returns(
|
|
224
|
+
M.undefined(),
|
|
225
|
+
),
|
|
231
226
|
lookupPending: M.call(M.string(), M.bigint()).returns(
|
|
232
227
|
M.arrayOf(PendingTxShape),
|
|
233
228
|
),
|
|
@@ -263,7 +258,7 @@ export const prepareStatusManager = (
|
|
|
263
258
|
},
|
|
264
259
|
|
|
265
260
|
/**
|
|
266
|
-
* Record result of
|
|
261
|
+
* Record result of ADVANCING
|
|
267
262
|
*
|
|
268
263
|
* @param {NobleAddress} nfa Noble Forwarding Account
|
|
269
264
|
* @param {import('@agoric/ertp').NatValue} amount
|
|
@@ -277,43 +272,6 @@ export const prepareStatusManager = (
|
|
|
277
272
|
);
|
|
278
273
|
},
|
|
279
274
|
|
|
280
|
-
/**
|
|
281
|
-
* If minted while advancing, publish a status update for the advance
|
|
282
|
-
* to vstorage.
|
|
283
|
-
*
|
|
284
|
-
* Does not add or amend `pendingSettleTxs` as this has
|
|
285
|
-
* already settled.
|
|
286
|
-
*
|
|
287
|
-
* @param {EvmHash} txHash
|
|
288
|
-
* @param {boolean} success whether the Transfer succeeded
|
|
289
|
-
*/
|
|
290
|
-
advanceOutcomeForMintedEarly(txHash, success) {
|
|
291
|
-
void publishTxnRecord(
|
|
292
|
-
txHash,
|
|
293
|
-
harden({
|
|
294
|
-
status: success
|
|
295
|
-
? PendingTxStatus.Advanced
|
|
296
|
-
: PendingTxStatus.AdvanceFailed,
|
|
297
|
-
}),
|
|
298
|
-
);
|
|
299
|
-
},
|
|
300
|
-
|
|
301
|
-
/**
|
|
302
|
-
* If minted before observed and the evidence is eventually
|
|
303
|
-
* reported, publish the evidence without adding to `pendingSettleTxs`
|
|
304
|
-
*
|
|
305
|
-
* @param {CctpTxEvidence} evidence
|
|
306
|
-
*/
|
|
307
|
-
advanceOutcomeForUnknownMint(evidence) {
|
|
308
|
-
const { txHash } = evidence;
|
|
309
|
-
// unexpected path, since `hasBeenObserved` will be called before this
|
|
310
|
-
if (seenTxs.has(txHash)) {
|
|
311
|
-
throw makeError(`Transaction already seen: ${q(txHash)}`);
|
|
312
|
-
}
|
|
313
|
-
seenTxs.init(txHash, evidence.blockTimestamp);
|
|
314
|
-
publishEvidence(txHash, evidence);
|
|
315
|
-
},
|
|
316
|
-
|
|
317
275
|
/**
|
|
318
276
|
* Add a new transaction with OBSERVED status
|
|
319
277
|
* @param {CctpTxEvidence} evidence
|
|
@@ -345,32 +303,34 @@ export const prepareStatusManager = (
|
|
|
345
303
|
},
|
|
346
304
|
|
|
347
305
|
/**
|
|
348
|
-
* Remove and return
|
|
349
|
-
* forwarding account and amount. Since multiple pending transactions may exist with
|
|
350
|
-
* identical (account, amount) pairs, we process them in FIFO order.
|
|
306
|
+
* Remove and return an `ADVANCED` or `OBSERVED` tx waiting to be `SETTLED`.
|
|
351
307
|
*
|
|
352
308
|
* @param {NobleAddress} nfa
|
|
353
309
|
* @param {bigint} amount
|
|
354
|
-
* @returns {Pick<PendingTx, 'status' | 'txHash'> | undefined} undefined if
|
|
355
|
-
*
|
|
310
|
+
* @returns {Pick<PendingTx, 'status' | 'txHash'> | undefined} undefined if nothing
|
|
311
|
+
* with this address and amount has been marked pending.
|
|
356
312
|
*/
|
|
357
313
|
dequeueStatus(nfa, amount) {
|
|
358
314
|
const key = makePendingTxKey(nfa, amount);
|
|
359
|
-
if (!
|
|
360
|
-
const pending =
|
|
315
|
+
if (!pendingTxs.has(key)) return undefined;
|
|
316
|
+
const pending = pendingTxs.get(key);
|
|
361
317
|
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
const [{ status, txHash }, ...remaining] = pending;
|
|
318
|
+
const dequeueIdx = pending.findIndex(
|
|
319
|
+
x => x.status !== PendingTxStatus.Advancing,
|
|
320
|
+
);
|
|
321
|
+
if (dequeueIdx < 0) return undefined;
|
|
367
322
|
|
|
368
|
-
if (
|
|
369
|
-
|
|
323
|
+
if (pending.length > 1) {
|
|
324
|
+
const pendingCopy = [...pending];
|
|
325
|
+
pendingCopy.splice(dequeueIdx, 1);
|
|
326
|
+
pendingTxs.set(key, harden(pendingCopy));
|
|
370
327
|
} else {
|
|
371
|
-
|
|
328
|
+
pendingTxs.delete(key);
|
|
372
329
|
}
|
|
373
330
|
|
|
331
|
+
const { status, txHash } = pending[dequeueIdx];
|
|
332
|
+
// TODO: store txHash -> evidence for txs pending settlement?
|
|
333
|
+
// If necessary for vstorage writes in `forwarded` and `settled`
|
|
374
334
|
return harden({ status, txHash });
|
|
375
335
|
},
|
|
376
336
|
|
|
@@ -388,18 +348,21 @@ export const prepareStatusManager = (
|
|
|
388
348
|
},
|
|
389
349
|
|
|
390
350
|
/**
|
|
391
|
-
* Mark a transaction as `FORWARDED`
|
|
351
|
+
* Mark a transaction as `FORWARDED`
|
|
392
352
|
*
|
|
393
|
-
* @param {EvmHash} txHash
|
|
394
|
-
* @param {
|
|
353
|
+
* @param {EvmHash | undefined} txHash - undefined in case mint before observed
|
|
354
|
+
* @param {NobleAddress} nfa
|
|
355
|
+
* @param {bigint} amount
|
|
395
356
|
*/
|
|
396
|
-
forwarded(txHash,
|
|
397
|
-
|
|
398
|
-
txHash,
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
357
|
+
forwarded(txHash, nfa, amount) {
|
|
358
|
+
if (txHash) {
|
|
359
|
+
void publishTxnRecord(txHash, harden({ status: TxStatus.Forwarded }));
|
|
360
|
+
} else {
|
|
361
|
+
// TODO store (early) `Minted` transactions to check against incoming evidence
|
|
362
|
+
log(
|
|
363
|
+
`⚠️ Forwarded minted amount ${amount} from account ${nfa} before it was observed.`,
|
|
364
|
+
);
|
|
365
|
+
}
|
|
403
366
|
},
|
|
404
367
|
|
|
405
368
|
/**
|
|
@@ -413,13 +376,12 @@ export const prepareStatusManager = (
|
|
|
413
376
|
*/
|
|
414
377
|
lookupPending(nfa, amount) {
|
|
415
378
|
const key = makePendingTxKey(nfa, amount);
|
|
416
|
-
if (!
|
|
379
|
+
if (!pendingTxs.has(key)) {
|
|
417
380
|
return harden([]);
|
|
418
381
|
}
|
|
419
|
-
return
|
|
382
|
+
return pendingTxs.get(key);
|
|
420
383
|
},
|
|
421
384
|
},
|
|
422
|
-
{ stateShape },
|
|
423
385
|
);
|
|
424
386
|
};
|
|
425
387
|
harden(prepareStatusManager);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { makeTracer } from '@agoric/internal';
|
|
2
2
|
import { prepareDurablePublishKit } from '@agoric/notifier';
|
|
3
3
|
import { keyEQ, M } from '@endo/patterns';
|
|
4
|
-
import { Fail
|
|
4
|
+
import { Fail } from '@endo/errors';
|
|
5
5
|
import { CctpTxEvidenceShape, RiskAssessmentShape } from '../type-guards.js';
|
|
6
6
|
import { defineInertInvitation } from '../utils/zoe.js';
|
|
7
7
|
import { prepareOperatorKit } from './operator-kit.js';
|
|
@@ -15,10 +15,6 @@ import { prepareOperatorKit } from './operator-kit.js';
|
|
|
15
15
|
|
|
16
16
|
const trace = makeTracer('TxFeed', true);
|
|
17
17
|
|
|
18
|
-
/**
|
|
19
|
-
* @typedef {Pick<OperatorKit, 'invitationMakers' | 'operator'>} OperatorOfferResult
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
18
|
/** Name in the invitation purse (keyed also by this contract instance) */
|
|
23
19
|
export const INVITATION_MAKERS_DESC = 'oracle operator invitation';
|
|
24
20
|
|
|
@@ -31,10 +27,8 @@ const TransactionFeedKitI = harden({
|
|
|
31
27
|
).returns(),
|
|
32
28
|
}),
|
|
33
29
|
creator: M.interface('Transaction Feed Creator', {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
operator: M.remotable(),
|
|
37
|
-
}),
|
|
30
|
+
// TODO narrow the return shape to OperatorKit
|
|
31
|
+
initOperator: M.call(M.string()).returns(M.record()),
|
|
38
32
|
makeOperatorInvitation: M.call(M.string()).returns(M.promise()),
|
|
39
33
|
removeOperator: M.call(M.string()).returns(),
|
|
40
34
|
}),
|
|
@@ -59,12 +53,6 @@ const allRisksIdentified = (riskStores, txHash) => {
|
|
|
59
53
|
return [...setOfRisks.values()].sort();
|
|
60
54
|
};
|
|
61
55
|
|
|
62
|
-
export const stateShape = {
|
|
63
|
-
operators: M.remotable(),
|
|
64
|
-
pending: M.remotable(),
|
|
65
|
-
risks: M.remotable(),
|
|
66
|
-
};
|
|
67
|
-
|
|
68
56
|
/**
|
|
69
57
|
* @param {Zone} zone
|
|
70
58
|
* @param {ZCF} zcf
|
|
@@ -104,14 +92,14 @@ export const prepareTransactionFeedKit = (zone, zcf) => {
|
|
|
104
92
|
* CCTP transactions.
|
|
105
93
|
*
|
|
106
94
|
* @param {string} operatorId unique per contract instance
|
|
107
|
-
* @returns {Promise<Invitation<
|
|
95
|
+
* @returns {Promise<Invitation<OperatorKit>>}
|
|
108
96
|
*/
|
|
109
97
|
makeOperatorInvitation(operatorId) {
|
|
110
98
|
const { creator } = this.facets;
|
|
111
99
|
trace('makeOperatorInvitation', operatorId);
|
|
112
100
|
|
|
113
101
|
return zcf.makeInvitation(
|
|
114
|
-
/** @type {OfferHandler<
|
|
102
|
+
/** @type {OfferHandler<OperatorKit>} */
|
|
115
103
|
seat => {
|
|
116
104
|
seat.exit();
|
|
117
105
|
return creator.initOperator(operatorId);
|
|
@@ -119,10 +107,7 @@ export const prepareTransactionFeedKit = (zone, zcf) => {
|
|
|
119
107
|
INVITATION_MAKERS_DESC,
|
|
120
108
|
);
|
|
121
109
|
},
|
|
122
|
-
/**
|
|
123
|
-
* @param {string} operatorId
|
|
124
|
-
* @returns {OperatorOfferResult}
|
|
125
|
-
*/
|
|
110
|
+
/** @param {string} operatorId */
|
|
126
111
|
initOperator(operatorId) {
|
|
127
112
|
const { operators, pending, risks } = this.state;
|
|
128
113
|
trace('initOperator', operatorId);
|
|
@@ -138,16 +123,11 @@ export const prepareTransactionFeedKit = (zone, zcf) => {
|
|
|
138
123
|
);
|
|
139
124
|
risks.init(operatorId, zone.detached().mapStore('risk assessments'));
|
|
140
125
|
|
|
141
|
-
|
|
142
|
-
const { invitationMakers, operator } = operatorKit;
|
|
143
|
-
return {
|
|
144
|
-
invitationMakers,
|
|
145
|
-
operator,
|
|
146
|
-
};
|
|
126
|
+
return operatorKit;
|
|
147
127
|
},
|
|
148
128
|
|
|
149
129
|
/** @param {string} operatorId */
|
|
150
|
-
removeOperator(operatorId) {
|
|
130
|
+
async removeOperator(operatorId) {
|
|
151
131
|
const { operators } = this.state;
|
|
152
132
|
trace('removeOperator', operatorId);
|
|
153
133
|
const operatorKit = operators.get(operatorId);
|
|
@@ -221,7 +201,7 @@ export const prepareTransactionFeedKit = (zone, zcf) => {
|
|
|
221
201
|
'!=',
|
|
222
202
|
next,
|
|
223
203
|
);
|
|
224
|
-
Fail`conflicting evidence for ${
|
|
204
|
+
Fail`conflicting evidence for ${txHash}`;
|
|
225
205
|
}
|
|
226
206
|
}
|
|
227
207
|
lastEvidence = next;
|
|
@@ -251,7 +231,6 @@ export const prepareTransactionFeedKit = (zone, zcf) => {
|
|
|
251
231
|
getEvidenceSubscriber: () => subscriber,
|
|
252
232
|
},
|
|
253
233
|
},
|
|
254
|
-
{ stateShape },
|
|
255
234
|
);
|
|
256
235
|
};
|
|
257
236
|
harden(prepareTransactionFeedKit);
|
|
@@ -3,10 +3,8 @@
|
|
|
3
3
|
import { E } from '@endo/far';
|
|
4
4
|
import { fromExternalConfig } from './utils/config-marshal.js';
|
|
5
5
|
import { FeedPolicyShape } from './type-guards.js';
|
|
6
|
-
import { publishFeedPolicy } from './utils/core-eval.js';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
|
-
* @import {Issuer} from '@agoric/ertp';
|
|
10
8
|
* @import {Passable} from '@endo/pass-style'
|
|
11
9
|
* @import {BootstrapManifest} from '@agoric/vats/src/core/lib-boot.js'
|
|
12
10
|
* @import {LegibleCapData} from './utils/config-marshal.js'
|
|
@@ -14,6 +12,18 @@ import { publishFeedPolicy } from './utils/core-eval.js';
|
|
|
14
12
|
*/
|
|
15
13
|
|
|
16
14
|
const contractName = 'fastUsdc';
|
|
15
|
+
const FEED_POLICY = 'feedPolicy';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* XXX copied from fast-usdc.start.js
|
|
19
|
+
*
|
|
20
|
+
* @param {ERef<StorageNode>} node
|
|
21
|
+
* @param {FeedPolicy} policy
|
|
22
|
+
*/
|
|
23
|
+
const publishFeedPolicy = async (node, policy) => {
|
|
24
|
+
const feedPolicy = E(node).makeChildNode(FEED_POLICY);
|
|
25
|
+
await E(feedPolicy).setValue(JSON.stringify(policy));
|
|
26
|
+
};
|
|
17
27
|
|
|
18
28
|
/**
|
|
19
29
|
* @param {BootstrapPowers &
|
|
@@ -22,6 +22,7 @@ import { prepareStatusManager } from './exos/status-manager.js';
|
|
|
22
22
|
import { prepareTransactionFeedKit } from './exos/transaction-feed.js';
|
|
23
23
|
import * as flows from './fast-usdc.flows.js';
|
|
24
24
|
import { FastUSDCTermsShape, FeeConfigShape } from './type-guards.js';
|
|
25
|
+
import { defineInertInvitation } from './utils/zoe.js';
|
|
25
26
|
|
|
26
27
|
const trace = makeTracer('FastUsdc');
|
|
27
28
|
|
|
@@ -36,9 +37,8 @@ const ADDRESSES_BAGGAGE_KEY = 'addresses';
|
|
|
36
37
|
* @import {Remote} from '@agoric/internal';
|
|
37
38
|
* @import {Marshaller, StorageNode} from '@agoric/internal/src/lib-chainStorage.js'
|
|
38
39
|
* @import {Zone} from '@agoric/zone';
|
|
39
|
-
* @import {OperatorOfferResult} from './exos/transaction-feed.js';
|
|
40
40
|
* @import {OperatorKit} from './exos/operator-kit.js';
|
|
41
|
-
* @import {CctpTxEvidence,
|
|
41
|
+
* @import {CctpTxEvidence, FeeConfig, RiskAssessment} from './types.js';
|
|
42
42
|
*/
|
|
43
43
|
|
|
44
44
|
/**
|
|
@@ -76,7 +76,10 @@ const publishFeeConfig = async (node, marshaller, feeConfig) => {
|
|
|
76
76
|
|
|
77
77
|
/**
|
|
78
78
|
* @param {Remote<StorageNode>} contractNode
|
|
79
|
-
* @param {
|
|
79
|
+
* @param {{
|
|
80
|
+
* poolAccount: ChainAddress['value'];
|
|
81
|
+
* settlementAccount: ChainAddress['value'];
|
|
82
|
+
* }} addresses
|
|
80
83
|
*/
|
|
81
84
|
const publishAddresses = (contractNode, addresses) => {
|
|
82
85
|
return E(contractNode).setValue(JSON.stringify(addresses));
|
|
@@ -90,7 +93,6 @@ const publishAddresses = (contractNode, addresses) => {
|
|
|
90
93
|
* feeConfig: FeeConfig;
|
|
91
94
|
* marshaller: Marshaller;
|
|
92
95
|
* poolMetricsNode: Remote<StorageNode>;
|
|
93
|
-
* storageNode: Remote<StorageNode>;
|
|
94
96
|
* }} privateArgs
|
|
95
97
|
* @param {Zone} zone
|
|
96
98
|
* @param {OrchestrationTools} tools
|
|
@@ -126,10 +128,11 @@ export const contract = async (zcf, privateArgs, zone, tools) => {
|
|
|
126
128
|
chainHub,
|
|
127
129
|
});
|
|
128
130
|
|
|
129
|
-
const
|
|
131
|
+
const { localTransfer } = makeZoeTools(zcf, vowTools);
|
|
130
132
|
const makeAdvancer = prepareAdvancer(zone, {
|
|
131
133
|
chainHub,
|
|
132
134
|
feeConfig,
|
|
135
|
+
localTransfer,
|
|
133
136
|
usdc: harden({
|
|
134
137
|
brand: terms.brands.USDC,
|
|
135
138
|
denom: terms.usdcDenom,
|
|
@@ -137,7 +140,6 @@ export const contract = async (zcf, privateArgs, zone, tools) => {
|
|
|
137
140
|
statusManager,
|
|
138
141
|
vowTools,
|
|
139
142
|
zcf,
|
|
140
|
-
zoeTools,
|
|
141
143
|
});
|
|
142
144
|
|
|
143
145
|
const makeFeedKit = prepareTransactionFeedKit(zone, zcf);
|
|
@@ -149,24 +151,18 @@ export const contract = async (zcf, privateArgs, zone, tools) => {
|
|
|
149
151
|
{ makeRecorderKit },
|
|
150
152
|
);
|
|
151
153
|
|
|
154
|
+
const makeTestInvitation = defineInertInvitation(
|
|
155
|
+
zcf,
|
|
156
|
+
'test of forcing evidence',
|
|
157
|
+
);
|
|
158
|
+
|
|
152
159
|
const { makeLocalAccount, makeNobleAccount } = orchestrateAll(flows, {});
|
|
153
160
|
|
|
154
161
|
const creatorFacet = zone.exo('Fast USDC Creator', undefined, {
|
|
155
|
-
/** @type {(operatorId: string) => Promise<Invitation<
|
|
162
|
+
/** @type {(operatorId: string) => Promise<Invitation<OperatorKit>>} */
|
|
156
163
|
async makeOperatorInvitation(operatorId) {
|
|
157
164
|
return feedKit.creator.makeOperatorInvitation(operatorId);
|
|
158
165
|
},
|
|
159
|
-
/** @type {(operatorId: string) => void} */
|
|
160
|
-
removeOperator(operatorId) {
|
|
161
|
-
return feedKit.creator.removeOperator(operatorId);
|
|
162
|
-
},
|
|
163
|
-
async getContractFeeBalance() {
|
|
164
|
-
return poolKit.feeRecipient.getContractFeeBalance();
|
|
165
|
-
},
|
|
166
|
-
/** @type {() => Promise<Invitation<unknown>>} */
|
|
167
|
-
async makeWithdrawFeesInvitation() {
|
|
168
|
-
return poolKit.feeRecipient.makeWithdrawFeesInvitation();
|
|
169
|
-
},
|
|
170
166
|
async connectToNoble() {
|
|
171
167
|
return vowTools.when(nobleAccountV, nobleAccount => {
|
|
172
168
|
trace('nobleAccount', nobleAccount);
|
|
@@ -194,12 +190,24 @@ export const contract = async (zcf, privateArgs, zone, tools) => {
|
|
|
194
190
|
await publishAddresses(storageNode, addresses);
|
|
195
191
|
return addresses;
|
|
196
192
|
},
|
|
197
|
-
deleteCompletedTxs() {
|
|
198
|
-
return statusManager.deleteCompletedTxs();
|
|
199
|
-
},
|
|
200
193
|
});
|
|
201
194
|
|
|
202
195
|
const publicFacet = zone.exo('Fast USDC Public', undefined, {
|
|
196
|
+
// XXX to be removed before production
|
|
197
|
+
/**
|
|
198
|
+
* NB: Any caller with access to this invitation maker has the ability to
|
|
199
|
+
* force handling of evidence.
|
|
200
|
+
*
|
|
201
|
+
* Provide an API call in the form of an invitation maker, so that the
|
|
202
|
+
* capability is available in the smart-wallet bridge during UI testing.
|
|
203
|
+
*
|
|
204
|
+
* @param {CctpTxEvidence} evidence
|
|
205
|
+
* @param {RiskAssessment} [risk]
|
|
206
|
+
*/
|
|
207
|
+
makeTestPushInvitation(evidence, risk = {}) {
|
|
208
|
+
void advancer.handleTransactionEvent({ evidence, risk });
|
|
209
|
+
return makeTestInvitation();
|
|
210
|
+
},
|
|
203
211
|
makeDepositInvitation() {
|
|
204
212
|
return poolKit.public.makeDepositInvitation();
|
|
205
213
|
},
|
|
@@ -288,8 +296,8 @@ export const contract = async (zcf, privateArgs, zone, tools) => {
|
|
|
288
296
|
|
|
289
297
|
const advancer = zone.makeOnce('Advancer', () =>
|
|
290
298
|
makeAdvancer({
|
|
291
|
-
|
|
292
|
-
|
|
299
|
+
borrowerFacet: poolKit.borrower,
|
|
300
|
+
notifyFacet: settlerKit.notify,
|
|
293
301
|
poolAccount,
|
|
294
302
|
settlementAddress,
|
|
295
303
|
}),
|