@agoric/fast-usdc 0.1.1-dev-fb6a3e0.0 → 0.1.1-dev-46061c3.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/fast-usdc",
3
- "version": "0.1.1-dev-fb6a3e0.0+fb6a3e0",
3
+ "version": "0.1.1-dev-46061c3.0+46061c3",
4
4
  "description": "CLI and library for Fast USDC product",
5
5
  "type": "module",
6
6
  "files": [
@@ -23,9 +23,9 @@
23
23
  "lint:eslint": "eslint ."
24
24
  },
25
25
  "devDependencies": {
26
- "@agoric/swingset-liveslots": "0.10.3-dev-fb6a3e0.0+fb6a3e0",
27
- "@agoric/vats": "0.15.2-dev-fb6a3e0.0+fb6a3e0",
28
- "@agoric/zone": "0.2.3-dev-fb6a3e0.0+fb6a3e0",
26
+ "@agoric/swingset-liveslots": "0.10.3-dev-46061c3.0+46061c3",
27
+ "@agoric/vats": "0.15.2-dev-46061c3.0+46061c3",
28
+ "@agoric/zone": "0.2.3-dev-46061c3.0+46061c3",
29
29
  "@fast-check/ava": "^2.0.1",
30
30
  "ava": "^5.3.0",
31
31
  "c8": "^10.1.2",
@@ -33,16 +33,16 @@
33
33
  "ts-blank-space": "^0.4.4"
34
34
  },
35
35
  "dependencies": {
36
- "@agoric/client-utils": "0.1.1-dev-fb6a3e0.0+fb6a3e0",
37
- "@agoric/cosmic-proto": "0.4.1-dev-fb6a3e0.0+fb6a3e0",
38
- "@agoric/ertp": "0.16.3-dev-fb6a3e0.0+fb6a3e0",
39
- "@agoric/internal": "0.3.3-dev-fb6a3e0.0+fb6a3e0",
40
- "@agoric/notifier": "0.6.3-dev-fb6a3e0.0+fb6a3e0",
41
- "@agoric/orchestration": "0.1.1-dev-fb6a3e0.0+fb6a3e0",
42
- "@agoric/store": "0.9.3-dev-fb6a3e0.0+fb6a3e0",
43
- "@agoric/vat-data": "0.5.3-dev-fb6a3e0.0+fb6a3e0",
44
- "@agoric/vow": "0.1.1-dev-fb6a3e0.0+fb6a3e0",
45
- "@agoric/zoe": "0.26.3-dev-fb6a3e0.0+fb6a3e0",
36
+ "@agoric/client-utils": "0.1.1-dev-46061c3.0+46061c3",
37
+ "@agoric/cosmic-proto": "0.4.1-dev-46061c3.0+46061c3",
38
+ "@agoric/ertp": "0.16.3-dev-46061c3.0+46061c3",
39
+ "@agoric/internal": "0.3.3-dev-46061c3.0+46061c3",
40
+ "@agoric/notifier": "0.6.3-dev-46061c3.0+46061c3",
41
+ "@agoric/orchestration": "0.1.1-dev-46061c3.0+46061c3",
42
+ "@agoric/store": "0.9.3-dev-46061c3.0+46061c3",
43
+ "@agoric/vat-data": "0.5.3-dev-46061c3.0+46061c3",
44
+ "@agoric/vow": "0.1.1-dev-46061c3.0+46061c3",
45
+ "@agoric/zoe": "0.26.3-dev-46061c3.0+46061c3",
46
46
  "@cosmjs/proto-signing": "^0.32.4",
47
47
  "@cosmjs/stargate": "^0.32.4",
48
48
  "@endo/base64": "^1.0.9",
@@ -82,5 +82,5 @@
82
82
  "publishConfig": {
83
83
  "access": "public"
84
84
  },
85
- "gitHead": "fb6a3e0102deabc5e57eb0511e2208bc3b415d27"
85
+ "gitHead": "46061c3ad3267fb9642309a5c8287dc01ef9c5dc"
86
86
  }
@@ -32,12 +32,12 @@ import { makeFeeTools } from '../utils/fees.js';
32
32
  * @typedef {{
33
33
  * chainHub: ChainHub;
34
34
  * feeConfig: FeeConfig;
35
- * localTransfer: ZoeTools['localTransfer'];
36
35
  * log?: LogFn;
37
36
  * statusManager: StatusManager;
38
37
  * usdc: { brand: Brand<'nat'>; denom: Denom; };
39
38
  * vowTools: VowTools;
40
39
  * zcf: ZCF;
40
+ * zoeTools: ZoeTools;
41
41
  * }} AdvancerKitPowers
42
42
  */
43
43
 
@@ -69,6 +69,16 @@ const AdvancerKitI = harden({
69
69
  ),
70
70
  onRejected: M.call(M.error(), AdvancerVowCtxShape).returns(M.undefined()),
71
71
  }),
72
+ withdrawHandler: M.interface('WithdrawHandlerI', {
73
+ onFulfilled: M.call(M.undefined(), {
74
+ advanceAmount: AnyNatAmountShape,
75
+ tmpReturnSeat: M.remotable(),
76
+ }).returns(M.undefined()),
77
+ onRejected: M.call(M.error(), {
78
+ advanceAmount: AnyNatAmountShape,
79
+ tmpReturnSeat: M.remotable(),
80
+ }).returns(M.undefined()),
81
+ }),
72
82
  });
73
83
 
74
84
  /**
@@ -98,12 +108,12 @@ export const prepareAdvancerKit = (
98
108
  {
99
109
  chainHub,
100
110
  feeConfig,
101
- localTransfer,
102
111
  log = makeTracer('Advancer', true),
103
112
  statusManager,
104
113
  usdc,
105
114
  vowTools: { watch, when },
106
115
  zcf,
116
+ zoeTools: { localTransfer, withdrawToSeat },
107
117
  },
108
118
  ) => {
109
119
  assertAllDefined({
@@ -289,10 +299,55 @@ export const prepareAdvancerKit = (
289
299
  * @param {AdvancerVowCtx} ctx
290
300
  */
291
301
  onRejected(error, ctx) {
292
- const { notifier } = this.state;
302
+ const { notifier, poolAccount } = this.state;
293
303
  log('Advance failed', error);
294
- const { advanceAmount: _, ...restCtx } = ctx;
304
+ const { advanceAmount, ...restCtx } = ctx;
295
305
  notifier.notifyAdvancingResult(restCtx, false);
306
+ const { zcfSeat: tmpReturnSeat } = zcf.makeEmptySeatKit();
307
+ const withdrawV = withdrawToSeat(
308
+ // @ts-expect-error LocalAccountMethods vs OrchestrationAccount
309
+ poolAccount,
310
+ tmpReturnSeat,
311
+ harden({ USDC: advanceAmount }),
312
+ );
313
+ void watch(withdrawV, this.facets.withdrawHandler, {
314
+ advanceAmount,
315
+ tmpReturnSeat,
316
+ });
317
+ },
318
+ },
319
+ withdrawHandler: {
320
+ /**
321
+ *
322
+ * @param {undefined} result
323
+ * @param {{ advanceAmount: Amount<'nat'>; tmpReturnSeat: ZCFSeat; }} ctx
324
+ */
325
+ onFulfilled(result, { advanceAmount, tmpReturnSeat }) {
326
+ const { borrower } = this.state;
327
+ try {
328
+ borrower.returnToPool(tmpReturnSeat, advanceAmount);
329
+ } catch (e) {
330
+ // If we reach here, the unused advance funds will remain in `tmpReturnSeat`
331
+ // and must be retrieved from recovery sets.
332
+ log(
333
+ `🚨 return ${q(advanceAmount)} to pool failed. funds remain on "tmpReturnSeat"`,
334
+ e,
335
+ );
336
+ }
337
+ tmpReturnSeat.exit();
338
+ },
339
+ /**
340
+ * @param {Error} error
341
+ * @param {{ advanceAmount: Amount<'nat'>; tmpReturnSeat: ZCFSeat; }} ctx
342
+ */
343
+ onRejected(error, { advanceAmount, tmpReturnSeat }) {
344
+ log(
345
+ `🚨 withdraw ${q(advanceAmount)} from "poolAccount" to return to pool failed`,
346
+ error,
347
+ );
348
+ // If we reach here, the unused advance funds will remain in the `poolAccount`.
349
+ // A contract update will be required to return them to the LiquidityPool.
350
+ tmpReturnSeat.exit();
296
351
  },
297
352
  },
298
353
  },
@@ -362,7 +362,9 @@ export const prepareSettler = (
362
362
  * @param {EvmHash} txHash
363
363
  */
364
364
  onRejected(reason, txHash) {
365
- log('⚠️ forward transfer rejected!', reason, txHash);
365
+ // funds remain in `settlementAccount` and must be recovered via a
366
+ // contract upgrade
367
+ log('🚨 forward transfer rejected!', reason, txHash);
366
368
  // update status manager, flagging a terminal state that needs to be
367
369
  // manual intervention or a code update to remediate
368
370
  statusManager.forwarded(txHash, false);
@@ -125,11 +125,10 @@ export const contract = async (zcf, privateArgs, zone, tools) => {
125
125
  chainHub,
126
126
  });
127
127
 
128
- const { localTransfer } = makeZoeTools(zcf, vowTools);
128
+ const zoeTools = makeZoeTools(zcf, vowTools);
129
129
  const makeAdvancer = prepareAdvancer(zone, {
130
130
  chainHub,
131
131
  feeConfig,
132
- localTransfer,
133
132
  usdc: harden({
134
133
  brand: terms.brands.USDC,
135
134
  denom: terms.usdcDenom,
@@ -137,6 +136,7 @@ export const contract = async (zcf, privateArgs, zone, tools) => {
137
136
  statusManager,
138
137
  vowTools,
139
138
  zcf,
139
+ zoeTools,
140
140
  });
141
141
 
142
142
  const makeFeedKit = prepareTransactionFeedKit(zone, zcf);