@agoric/builders 0.1.1-dev-5fd303a.0 → 0.1.1-dev-7390224.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/builders",
3
- "version": "0.1.1-dev-5fd303a.0+5fd303a",
3
+ "version": "0.1.1-dev-7390224.0+7390224",
4
4
  "description": "Build scripts for proposals to an Agoric chain",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -23,32 +23,34 @@
23
23
  "author": "Agoric",
24
24
  "license": "Apache-2.0",
25
25
  "dependencies": {
26
- "@agoric/ertp": "0.16.3-dev-5fd303a.0+5fd303a",
27
- "@agoric/internal": "0.3.3-dev-5fd303a.0+5fd303a",
28
- "@agoric/notifier": "0.6.3-dev-5fd303a.0+5fd303a",
29
- "@agoric/smart-wallet": "0.5.4-dev-5fd303a.0+5fd303a",
30
- "@agoric/vat-data": "0.5.3-dev-5fd303a.0+5fd303a",
31
- "@agoric/vats": "0.15.2-dev-5fd303a.0+5fd303a",
32
- "@agoric/zoe": "0.26.3-dev-5fd303a.0+5fd303a",
26
+ "@agoric/ertp": "0.16.3-dev-7390224.0+7390224",
27
+ "@agoric/fast-usdc": "0.1.0",
28
+ "@agoric/internal": "0.3.3-dev-7390224.0+7390224",
29
+ "@agoric/notifier": "0.6.3-dev-7390224.0+7390224",
30
+ "@agoric/smart-wallet": "0.5.4-dev-7390224.0+7390224",
31
+ "@agoric/vat-data": "0.5.3-dev-7390224.0+7390224",
32
+ "@agoric/vats": "0.15.2-dev-7390224.0+7390224",
33
+ "@agoric/zoe": "0.26.3-dev-7390224.0+7390224",
33
34
  "@endo/bundle-source": "^3.4.2",
34
35
  "@endo/captp": "^4.4.2",
35
36
  "@endo/eventual-send": "^1.2.7",
36
37
  "@endo/far": "^1.1.8",
37
38
  "@endo/init": "^1.1.6",
38
39
  "@endo/marshal": "^1.6.1",
40
+ "@endo/patterns": "^1.4.6",
39
41
  "@endo/promise-kit": "^1.1.7",
40
42
  "@endo/stream": "^1.2.7",
41
43
  "import-meta-resolve": "^2.2.1"
42
44
  },
43
45
  "devDependencies": {
44
- "@agoric/deploy-script-support": "0.10.4-dev-5fd303a.0+5fd303a",
45
- "@agoric/governance": "0.10.4-dev-5fd303a.0+5fd303a",
46
- "@agoric/inter-protocol": "0.16.2-dev-5fd303a.0+5fd303a",
47
- "@agoric/orchestration": "0.1.1-dev-5fd303a.0+5fd303a",
48
- "@agoric/store": "0.9.3-dev-5fd303a.0+5fd303a",
49
- "@agoric/swing-store": "0.9.2-dev-5fd303a.0+5fd303a",
50
- "@agoric/swingset-liveslots": "0.10.3-dev-5fd303a.0+5fd303a",
51
- "@agoric/time": "0.3.3-dev-5fd303a.0+5fd303a",
46
+ "@agoric/deploy-script-support": "0.10.4-dev-7390224.0+7390224",
47
+ "@agoric/governance": "0.10.4-dev-7390224.0+7390224",
48
+ "@agoric/inter-protocol": "0.16.2-dev-7390224.0+7390224",
49
+ "@agoric/orchestration": "0.1.1-dev-7390224.0+7390224",
50
+ "@agoric/store": "0.9.3-dev-7390224.0+7390224",
51
+ "@agoric/swing-store": "0.9.2-dev-7390224.0+7390224",
52
+ "@agoric/swingset-liveslots": "0.10.3-dev-7390224.0+7390224",
53
+ "@agoric/time": "0.3.3-dev-7390224.0+7390224",
52
54
  "@endo/errors": "^1.2.7",
53
55
  "ava": "^5.3.0",
54
56
  "c8": "^9.1.0"
@@ -81,5 +83,5 @@
81
83
  "typeCoverage": {
82
84
  "atLeast": 89.69
83
85
  },
84
- "gitHead": "5fd303aa11d393f2f6ceefe0ad83ba8cf5178a44"
86
+ "gitHead": "739022455dbfb7e7d7d90e8ae7cef948cde3e97a"
85
87
  }
@@ -0,0 +1,126 @@
1
+ // @ts-check
2
+ import { makeHelpers } from '@agoric/deploy-script-support';
3
+ import { AmountMath } from '@agoric/ertp';
4
+ import {
5
+ FastUSDCConfigShape,
6
+ getManifestForFastUSDC,
7
+ } from '@agoric/fast-usdc/src/fast-usdc.start.js';
8
+ import { toExternalConfig } from '@agoric/fast-usdc/src/utils/config-marshal.js';
9
+ import {
10
+ multiplyBy,
11
+ parseRatio,
12
+ } from '@agoric/zoe/src/contractSupport/ratio.js';
13
+ import { Far } from '@endo/far';
14
+ import { parseArgs } from 'node:util';
15
+
16
+ /**
17
+ * @import {CoreEvalBuilder, DeployScriptFunction} from '@agoric/deploy-script-support/src/externalTypes.js'
18
+ * @import {ParseArgsConfig} from 'node:util'
19
+ * @import {FastUSDCConfig} from '@agoric/fast-usdc/src/fast-usdc.start.js'
20
+ */
21
+
22
+ /** @type {ParseArgsConfig['options']} */
23
+ const options = {
24
+ flatFee: { type: 'string', default: '0.01' },
25
+ variableRate: { type: 'string', default: '0.01' },
26
+ maxVariableFee: { type: 'string', default: '5' },
27
+ contractRate: { type: 'string', default: '0.2' },
28
+ oracle: { type: 'string', multiple: true },
29
+ usdcDenom: {
30
+ type: 'string',
31
+ default:
32
+ 'ibc/FE98AAD68F02F03565E9FA39A5E627946699B2B07115889ED812D8BA639576A9',
33
+ },
34
+ };
35
+ const oraclesRequiredUsage = 'use --oracle name:address ...';
36
+ /**
37
+ * @typedef {{
38
+ * flatFee: string;
39
+ * variableRate: string;
40
+ * maxVariableFee: string;
41
+ * contractRate: string;
42
+ * oracle?: string[];
43
+ * usdcDenom: string;
44
+ * }} FastUSDCOpts
45
+ */
46
+
47
+ const crossVatContext = /** @type {const} */ ({
48
+ /** @type {Brand<'nat'>} */
49
+ USDC: Far('USDC Brand'),
50
+ });
51
+ const { USDC } = crossVatContext;
52
+ const USDC_DECIMALS = 6;
53
+ const unit = AmountMath.make(USDC, 10n ** BigInt(USDC_DECIMALS));
54
+
55
+ /** @type {CoreEvalBuilder} */
56
+ export const defaultProposalBuilder = async (
57
+ { publishRef, install },
58
+ /** @type {FastUSDCConfig} */ config,
59
+ ) => {
60
+ return harden({
61
+ sourceSpec: '@agoric/fast-usdc/src/fast-usdc.start.js',
62
+ /** @type {[string, Parameters<typeof getManifestForFastUSDC>[1]]} */
63
+ getManifestCall: [
64
+ getManifestForFastUSDC.name,
65
+ {
66
+ options: toExternalConfig(config, crossVatContext, FastUSDCConfigShape),
67
+ installKeys: {
68
+ fastUsdc: publishRef(
69
+ install('@agoric/fast-usdc/src/fast-usdc.contract.js'),
70
+ ),
71
+ },
72
+ },
73
+ ],
74
+ });
75
+ };
76
+
77
+ /** @type {DeployScriptFunction} */
78
+ export default async (homeP, endowments) => {
79
+ const { writeCoreEval } = await makeHelpers(homeP, endowments);
80
+ const { scriptArgs } = endowments;
81
+
82
+ /** @type {{ values: FastUSDCOpts }} */
83
+ // @ts-expect-error ensured by options
84
+ const {
85
+ values: { oracle: oracleArgs, usdcDenom, ...fees },
86
+ } = parseArgs({ args: scriptArgs, options });
87
+
88
+ const parseOracleArgs = () => {
89
+ if (!oracleArgs) throw Error(oraclesRequiredUsage);
90
+ return Object.fromEntries(
91
+ oracleArgs.map(arg => {
92
+ const result = arg.match(/(?<name>[^:]+):(?<address>.+)/);
93
+ if (!(result && result.groups)) throw Error(oraclesRequiredUsage);
94
+ const { name, address } = result.groups;
95
+ return [name, address];
96
+ }),
97
+ );
98
+ };
99
+
100
+ /** @param {string} numeral */
101
+ const toAmount = numeral => multiplyBy(unit, parseRatio(numeral, USDC));
102
+ /** @param {string} numeral */
103
+ const toRatio = numeral => parseRatio(numeral, USDC);
104
+ const parseFeeConfigArgs = () => {
105
+ const { flatFee, variableRate, maxVariableFee, contractRate } = fees;
106
+ return {
107
+ flat: toAmount(flatFee),
108
+ variableRate: toRatio(variableRate),
109
+ maxVariable: toAmount(maxVariableFee),
110
+ contractRate: toRatio(contractRate),
111
+ };
112
+ };
113
+
114
+ /** @type {FastUSDCConfig} */
115
+ const config = harden({
116
+ oracles: parseOracleArgs(),
117
+ terms: {
118
+ usdcDenom,
119
+ },
120
+ feeConfig: parseFeeConfigArgs(),
121
+ });
122
+
123
+ await writeCoreEval('start-fast-usdc', utils =>
124
+ defaultProposalBuilder(utils, config),
125
+ );
126
+ };