@agoric/fast-usdc 0.1.1-dev-09ccd43.0 → 0.1.1-dev-6fb05ae.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-09ccd43.0+09ccd43",
3
+ "version": "0.1.1-dev-6fb05ae.0+6fb05ae",
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-09ccd43.0+09ccd43",
27
- "@agoric/vats": "0.15.2-dev-09ccd43.0+09ccd43",
28
- "@agoric/zone": "0.2.3-dev-09ccd43.0+09ccd43",
26
+ "@agoric/swingset-liveslots": "0.10.3-dev-6fb05ae.0+6fb05ae",
27
+ "@agoric/vats": "0.15.2-dev-6fb05ae.0+6fb05ae",
28
+ "@agoric/zone": "0.2.3-dev-6fb05ae.0+6fb05ae",
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-09ccd43.0+09ccd43",
37
- "@agoric/cosmic-proto": "0.4.1-dev-09ccd43.0+09ccd43",
38
- "@agoric/ertp": "0.16.3-dev-09ccd43.0+09ccd43",
39
- "@agoric/internal": "0.3.3-dev-09ccd43.0+09ccd43",
40
- "@agoric/notifier": "0.6.3-dev-09ccd43.0+09ccd43",
41
- "@agoric/orchestration": "0.1.1-dev-09ccd43.0+09ccd43",
42
- "@agoric/store": "0.9.3-dev-09ccd43.0+09ccd43",
43
- "@agoric/vat-data": "0.5.3-dev-09ccd43.0+09ccd43",
44
- "@agoric/vow": "0.1.1-dev-09ccd43.0+09ccd43",
45
- "@agoric/zoe": "0.26.3-dev-09ccd43.0+09ccd43",
36
+ "@agoric/client-utils": "0.1.1-dev-6fb05ae.0+6fb05ae",
37
+ "@agoric/cosmic-proto": "0.4.1-dev-6fb05ae.0+6fb05ae",
38
+ "@agoric/ertp": "0.16.3-dev-6fb05ae.0+6fb05ae",
39
+ "@agoric/internal": "0.3.3-dev-6fb05ae.0+6fb05ae",
40
+ "@agoric/notifier": "0.6.3-dev-6fb05ae.0+6fb05ae",
41
+ "@agoric/orchestration": "0.1.1-dev-6fb05ae.0+6fb05ae",
42
+ "@agoric/store": "0.9.3-dev-6fb05ae.0+6fb05ae",
43
+ "@agoric/vat-data": "0.5.3-dev-6fb05ae.0+6fb05ae",
44
+ "@agoric/vow": "0.1.1-dev-6fb05ae.0+6fb05ae",
45
+ "@agoric/zoe": "0.26.3-dev-6fb05ae.0+6fb05ae",
46
46
  "@cosmjs/proto-signing": "^0.33.0",
47
47
  "@cosmjs/stargate": "^0.33.0",
48
48
  "@endo/base64": "^1.0.9",
@@ -82,5 +82,5 @@
82
82
  "publishConfig": {
83
83
  "access": "public"
84
84
  },
85
- "gitHead": "09ccd43baa1008caf35c52d900ffc934f8b8419e"
85
+ "gitHead": "6fb05aed0a0a3b44df4c0374f896fe6d4ff6d7ad"
86
86
  }
@@ -0,0 +1,99 @@
1
+ /** @file core-eval to update feeConfig. feeConfig is supplied via privateArgs and requires a contract upgrade to change */
2
+
3
+ import { makeTracer } from '@agoric/internal';
4
+ import { E } from '@endo/far';
5
+
6
+ const trace = makeTracer('FUSD-UpdateFees', true);
7
+
8
+ // avoid importing all of @agoric/ertp
9
+ /** @type {typeof import('@agoric/ertp').AmountMath.make} */
10
+ // @ts-expect-error AssetKind conditionals aren't captured
11
+ const make = (brand, value) => harden({ brand, value });
12
+
13
+ /**
14
+ * @typedef {object} UpdateOpts
15
+ * @property {{bundleID: BundleID}} [fastUsdcCode]
16
+ */
17
+
18
+ /**
19
+ * @import {CopyRecord} from '@endo/pass-style';
20
+ * @import {Brand} from '@agoric/ertp';
21
+ * @import {ManifestBundleRef} from '@agoric/deploy-script-support/src/externalTypes.js';
22
+ * @import {BundleID} from '@agoric/swingset-vat';
23
+ * @import {BootstrapManifest} from '@agoric/vats/src/core/lib-boot.js';
24
+ * @import {FastUSDCCorePowers} from './start-fast-usdc.core.js';
25
+ * @import {FeeConfig} from './types.js';
26
+ */
27
+
28
+ /**
29
+ * Update feeConfig.flat to 0n (no flat fee)
30
+ *
31
+ * @param {FeeConfig} feeConfigPre
32
+ * @param {Brand<'nat'>} usdcBrand
33
+ * @param {Amount<'nat'>} flat
34
+ * @returns {FeeConfig}
35
+ */
36
+ const updateFlatFee = (feeConfigPre, usdcBrand, flat = make(usdcBrand, 0n)) =>
37
+ harden({ ...feeConfigPre, flat });
38
+
39
+ const { keys } = Object;
40
+
41
+ /**
42
+ * @param {BootstrapPowers & FastUSDCCorePowers} powers
43
+ * @param {object} [config]
44
+ * @param {UpdateOpts} [config.options]
45
+ */
46
+ export const updateFeeConfig = async (
47
+ { consume: { fastUsdcKit }, produce },
48
+ { options = {} } = {},
49
+ ) => {
50
+ trace('options', options);
51
+ const { fastUsdcCode = assert.fail('missing bundleID') } = options;
52
+ const kitPre = await fastUsdcKit;
53
+ trace('fastUsdcKit.privateArgs keys:', keys(kitPre.privateArgs));
54
+ const { adminFacet, creatorFacet } = kitPre;
55
+
56
+ const { brand: usdcBrand } = kitPre.privateArgs.feeConfig.flat;
57
+ const kitPost = harden({
58
+ ...kitPre,
59
+ privateArgs: {
60
+ ...kitPre.privateArgs,
61
+ feeConfig: updateFlatFee(kitPre.privateArgs.feeConfig, usdcBrand),
62
+ },
63
+ });
64
+ trace('updated fee config', kitPost.privateArgs.feeConfig);
65
+ const upgraded = await E(adminFacet).upgradeContract(
66
+ fastUsdcCode.bundleID,
67
+ kitPost.privateArgs,
68
+ );
69
+ trace('fastUsdc upgraded', upgraded);
70
+ produce.fastUsdcKit.reset();
71
+ produce.fastUsdcKit.resolve(kitPost);
72
+
73
+ // ensure Advancer has intermediateRecipient
74
+ await E(creatorFacet).connectToNoble();
75
+ trace('setIntermediateRecipient done');
76
+ };
77
+
78
+ /**
79
+ * @param {unknown} _utils
80
+ * @param {{
81
+ * installKeys: { fastUsdc: ERef<ManifestBundleRef> };
82
+ * options: Omit<UpdateOpts, 'fastUsdcCode'> & CopyRecord;
83
+ * }} opts
84
+ */
85
+ export const getManifestForUpdateFeeConfig = (
86
+ _utils,
87
+ { installKeys, options },
88
+ ) => {
89
+ return {
90
+ /** @type {BootstrapManifest} */
91
+ manifest: {
92
+ [updateFeeConfig.name]: {
93
+ consume: { fastUsdcKit: true },
94
+ produce: { fastUsdcKit: true },
95
+ },
96
+ },
97
+ options: { ...options, fastUsdcCode: installKeys.fastUsdc },
98
+ };
99
+ };