@agoric/builders 0.1.1-dev-3cbd11f.0 → 0.1.1-dev-bdbd5df.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-3cbd11f.0+3cbd11f",
3
+ "version": "0.1.1-dev-bdbd5df.0+bdbd5df",
4
4
  "description": "Build scripts for proposals to an Agoric chain",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -23,14 +23,13 @@
23
23
  "author": "Agoric",
24
24
  "license": "Apache-2.0",
25
25
  "dependencies": {
26
- "@agoric/ertp": "0.16.3-dev-3cbd11f.0+3cbd11f",
27
- "@agoric/fast-usdc": "0.1.1-dev-3cbd11f.0+3cbd11f",
28
- "@agoric/internal": "0.3.3-dev-3cbd11f.0+3cbd11f",
29
- "@agoric/notifier": "0.6.3-dev-3cbd11f.0+3cbd11f",
30
- "@agoric/smart-wallet": "0.5.4-dev-3cbd11f.0+3cbd11f",
31
- "@agoric/vat-data": "0.5.3-dev-3cbd11f.0+3cbd11f",
32
- "@agoric/vats": "0.15.2-dev-3cbd11f.0+3cbd11f",
33
- "@agoric/zoe": "0.26.3-dev-3cbd11f.0+3cbd11f",
26
+ "@agoric/ertp": "0.16.3-dev-bdbd5df.0+bdbd5df",
27
+ "@agoric/internal": "0.3.3-dev-bdbd5df.0+bdbd5df",
28
+ "@agoric/notifier": "0.6.3-dev-bdbd5df.0+bdbd5df",
29
+ "@agoric/smart-wallet": "0.5.4-dev-bdbd5df.0+bdbd5df",
30
+ "@agoric/vat-data": "0.5.3-dev-bdbd5df.0+bdbd5df",
31
+ "@agoric/vats": "0.15.2-dev-bdbd5df.0+bdbd5df",
32
+ "@agoric/zoe": "0.26.3-dev-bdbd5df.0+bdbd5df",
34
33
  "@endo/bundle-source": "^3.5.1",
35
34
  "@endo/captp": "^4.4.4",
36
35
  "@endo/eventual-send": "^1.3.0",
@@ -43,14 +42,14 @@
43
42
  "import-meta-resolve": "^4.1.0"
44
43
  },
45
44
  "devDependencies": {
46
- "@agoric/deploy-script-support": "0.10.4-dev-3cbd11f.0+3cbd11f",
47
- "@agoric/governance": "0.10.4-dev-3cbd11f.0+3cbd11f",
48
- "@agoric/inter-protocol": "0.16.2-dev-3cbd11f.0+3cbd11f",
49
- "@agoric/orchestration": "0.1.1-dev-3cbd11f.0+3cbd11f",
50
- "@agoric/store": "0.9.3-dev-3cbd11f.0+3cbd11f",
51
- "@agoric/swing-store": "0.9.2-dev-3cbd11f.0+3cbd11f",
52
- "@agoric/swingset-liveslots": "0.10.3-dev-3cbd11f.0+3cbd11f",
53
- "@agoric/time": "0.3.3-dev-3cbd11f.0+3cbd11f",
45
+ "@agoric/deploy-script-support": "0.10.4-dev-bdbd5df.0+bdbd5df",
46
+ "@agoric/governance": "0.10.4-dev-bdbd5df.0+bdbd5df",
47
+ "@agoric/inter-protocol": "0.16.2-dev-bdbd5df.0+bdbd5df",
48
+ "@agoric/orchestration": "0.1.1-dev-bdbd5df.0+bdbd5df",
49
+ "@agoric/store": "0.9.3-dev-bdbd5df.0+bdbd5df",
50
+ "@agoric/swing-store": "0.9.2-dev-bdbd5df.0+bdbd5df",
51
+ "@agoric/swingset-liveslots": "0.10.3-dev-bdbd5df.0+bdbd5df",
52
+ "@agoric/time": "0.3.3-dev-bdbd5df.0+bdbd5df",
54
53
  "@endo/errors": "^1.2.9",
55
54
  "ava": "^5.3.0",
56
55
  "c8": "^10.1.2"
@@ -83,5 +82,5 @@
83
82
  "typeCoverage": {
84
83
  "atLeast": 91.55
85
84
  },
86
- "gitHead": "3cbd11f8f37ab21692bd18ecf148c3f85f8e7f9c"
85
+ "gitHead": "bdbd5df2e3fc45803658717b723a0f20e2c6379a"
87
86
  }
@@ -1,84 +0,0 @@
1
- // @ts-check
2
- import { makeHelpers } from '@agoric/deploy-script-support';
3
- import { getManifestForAddOperators } from '@agoric/fast-usdc/src/add-operators.core.js';
4
- import { toExternalConfig } from '@agoric/fast-usdc/src/utils/config-marshal.js';
5
- import { configurations } from '@agoric/fast-usdc/src/utils/deploy-config.js';
6
- import { Far } from '@endo/far';
7
- import { parseArgs } from 'node:util';
8
-
9
- /**
10
- * @import {CoreEvalBuilder, DeployScriptFunction} from '@agoric/deploy-script-support/src/externalTypes.js';
11
- * @import {ParseArgsConfig} from 'node:util';
12
- * @import {Brand} from '@agoric/ertp';
13
- * @import {FastUSDCConfig, FeedPolicy} from '@agoric/fast-usdc';
14
- * @import {FastUSDCOpts} from './start-fast-usdc.build.js';
15
- */
16
-
17
- const { keys } = Object;
18
-
19
- /** @type {ParseArgsConfig['options']} */
20
- const options = {
21
- net: { type: 'string' },
22
- oracle: { type: 'string', multiple: true },
23
- };
24
- const oraclesUsage = 'use --oracle name:address ...';
25
-
26
- const crossVatContext = /** @type {const} */ ({
27
- /** @type {Brand<'nat'>} */
28
- USDC: Far('USDC Brand'),
29
- });
30
-
31
- /** @type {CoreEvalBuilder} */
32
- export const defaultProposalBuilder = async (
33
- powers,
34
- /** @type {FastUSDCConfig} */ config,
35
- ) => {
36
- return harden({
37
- sourceSpec: '@agoric/fast-usdc/src/add-operators.core.js',
38
- /** @type {[string, Parameters<typeof getManifestForAddOperators>[1]]} */
39
- getManifestCall: [
40
- getManifestForAddOperators.name,
41
- {
42
- options: toExternalConfig(config, crossVatContext),
43
- },
44
- ],
45
- });
46
- };
47
-
48
- /** @type {DeployScriptFunction} */
49
- export default async (homeP, endowments) => {
50
- const { writeCoreEval } = await makeHelpers(homeP, endowments);
51
- const { scriptArgs } = endowments;
52
-
53
- /** @type {{ values: FastUSDCOpts }} */
54
- // @ts-expect-error ensured by options
55
- const {
56
- values: { oracle: oracleArgs, net },
57
- } = parseArgs({ args: scriptArgs, options });
58
-
59
- const parseOracleArgs = () => {
60
- if (net) {
61
- if (!(net in configurations)) {
62
- throw Error(`${net} not in ${keys(configurations)}`);
63
- }
64
- return configurations[net].oracles;
65
- }
66
- if (!oracleArgs) throw Error(oraclesUsage);
67
- return Object.fromEntries(
68
- oracleArgs.map(arg => {
69
- const result = arg.match(/(?<name>[^:]+):(?<address>.+)/);
70
- if (!(result && result.groups)) throw Error(oraclesUsage);
71
- const { name, address } = result.groups;
72
- return [name, address];
73
- }),
74
- );
75
- };
76
-
77
- const config = harden({
78
- oracles: parseOracleArgs(),
79
- });
80
-
81
- await writeCoreEval('add-operators', utils =>
82
- defaultProposalBuilder(utils, config),
83
- );
84
- };
@@ -1,47 +0,0 @@
1
- /**
2
- * Usage:
3
- * agoric run fast-usdc-fee-config.build.js
4
- *
5
- * see {@link @agoric/fast-usdc/src/update-fee-config.core.js}
6
- */
7
- import { makeHelpers } from '@agoric/deploy-script-support';
8
- import { getManifestForUpdateFeeConfig } from '@agoric/fast-usdc/src/update-fee-config.core.js';
9
-
10
- /**
11
- * @import {CoreEvalBuilder, DeployScriptFunction} from '@agoric/deploy-script-support/src/externalTypes.js';
12
- */
13
-
14
- /**
15
- * @param {Parameters<CoreEvalBuilder>[0]} powers
16
- * @param {{}} options
17
- * @satisfies {CoreEvalBuilder}
18
- */
19
- export const proposalBuilder = async (
20
- { publishRef, install },
21
- options = {},
22
- ) => {
23
- return harden({
24
- sourceSpec: '@agoric/fast-usdc/src/update-fee-config.core.js',
25
- /** @type {[string, Parameters<typeof getManifestForUpdateFeeConfig>[1]]} */
26
- getManifestCall: [
27
- getManifestForUpdateFeeConfig.name,
28
- {
29
- options,
30
- installKeys: {
31
- fastUsdc: publishRef(
32
- install('@agoric/fast-usdc/src/fast-usdc.contract.js'),
33
- ),
34
- },
35
- },
36
- ],
37
- });
38
- };
39
-
40
- /** @type {DeployScriptFunction} */
41
- export default async (homeP, endowments) => {
42
- const { writeCoreEval } = await makeHelpers(homeP, endowments);
43
-
44
- await writeCoreEval('eval-fast-usdc-fee-config', utils =>
45
- proposalBuilder(utils),
46
- );
47
- };
@@ -1,75 +0,0 @@
1
- import { makeHelpers } from '@agoric/deploy-script-support';
2
- import { AmountMath } from '@agoric/ertp';
3
- import { getManifestForDistributeFees } from '@agoric/fast-usdc/src/distribute-fees.core.js';
4
- import { toExternalConfig } from '@agoric/fast-usdc/src/utils/config-marshal.js';
5
- import {
6
- multiplyBy,
7
- parseRatio,
8
- } from '@agoric/zoe/src/contractSupport/ratio.js';
9
- import { Far } from '@endo/far';
10
- import { parseArgs } from 'node:util';
11
-
12
- /**
13
- * @import {CoreEvalBuilder, DeployScriptFunction} from '@agoric/deploy-script-support/src/externalTypes.js'
14
- * @import {FeeDistributionTerms} from '@agoric/fast-usdc/src/distribute-fees.core.js'
15
- */
16
-
17
- const usage =
18
- 'Use: [--fixedFees <number> | --feePortion <percent>] --destinationAddress <address> ...';
19
-
20
- const xVatCtx = /** @type {const} */ ({
21
- /** @type {Brand<'nat'>} */
22
- USDC: Far('USDC Brand'),
23
- });
24
- const { USDC } = xVatCtx;
25
- const USDC_DECIMALS = 6n;
26
- const unit = AmountMath.make(USDC, 10n ** USDC_DECIMALS);
27
-
28
- /**
29
- * @param {unknown} _utils
30
- * @param {FeeDistributionTerms} feeTerms
31
- * @satisfies {CoreEvalBuilder}
32
- */
33
- export const feeProposalBuilder = async (_utils, feeTerms) => {
34
- return harden({
35
- sourceSpec: '@agoric/fast-usdc/src/distribute-fees.core.js',
36
- /** @type {[string, Parameters<typeof getManifestForDistributeFees>[1]]} */
37
- getManifestCall: [
38
- getManifestForDistributeFees.name,
39
- { options: toExternalConfig(harden({ feeTerms }), xVatCtx) },
40
- ],
41
- });
42
- };
43
-
44
- /** @type {DeployScriptFunction} */
45
- export default async (homeP, endowments) => {
46
- const { writeCoreEval } = await makeHelpers(homeP, endowments);
47
- /** @type {{ values: Record<string, string | undefined> }} */
48
- const {
49
- values: { destinationAddress, ...opt },
50
- } = parseArgs({
51
- args: endowments.scriptArgs,
52
- options: {
53
- destinationAddress: { type: 'string' },
54
- fixedFees: { type: 'string' },
55
- feePortion: { type: 'string' },
56
- },
57
- });
58
- if (!destinationAddress) assert.fail(usage);
59
- if (opt.fixedFees && opt.feePortion) assert.fail(usage);
60
-
61
- /** @type {FeeDistributionTerms} */
62
- const feeTerms = {
63
- destinationAddress,
64
- ...((opt.fixedFees && {
65
- fixedFees: multiplyBy(unit, parseRatio(opt.fixedFees, USDC)),
66
- }) ||
67
- (opt.feePortion && {
68
- feePortion: parseRatio(opt.feePortion, USDC),
69
- }) ||
70
- assert.fail(usage)),
71
- };
72
- await writeCoreEval('eval-fast-usdc-fees', utils =>
73
- feeProposalBuilder(utils, feeTerms),
74
- );
75
- };
@@ -1,68 +0,0 @@
1
- /**
2
- * Usage:
3
- * agoric run fast-usdc-reconfigure.build.js [--agoricToNoble <IBCChannelInfo>]
4
- *
5
- * channel info defaults to mainnet configuration (see update-noble-ica.core.js)
6
- */
7
- import { makeHelpers } from '@agoric/deploy-script-support';
8
- import { getManifestForUpdateNobleICA } from '@agoric/fast-usdc/src/update-noble-ica.core.js';
9
- import { IBCConnectionInfoShape } from '@agoric/orchestration';
10
- import { mustMatch } from '@endo/patterns';
11
- import { parseArgs } from 'node:util';
12
-
13
- /**
14
- * @import {CoreEvalBuilder, DeployScriptFunction} from '@agoric/deploy-script-support/src/externalTypes.js'
15
- * @import {IBCConnectionInfo} from '@agoric/orchestration'
16
- * @import {Passable} from '@endo/marshal'
17
- */
18
-
19
- /**
20
- * @param {Parameters<CoreEvalBuilder>[0]} powers
21
- * @param {{ agoricToNoble?: IBCConnectionInfo } & Passable} options
22
- * @satisfies {CoreEvalBuilder}
23
- */
24
- export const proposalBuilder = async ({ publishRef, install }, options) => {
25
- return harden({
26
- sourceSpec: '@agoric/fast-usdc/src/update-noble-ica.core.js',
27
- /** @type {[string, Parameters<typeof getManifestForUpdateNobleICA>[1]]} */
28
- getManifestCall: [
29
- getManifestForUpdateNobleICA.name,
30
- {
31
- options,
32
- installKeys: {
33
- fastUsdc: publishRef(
34
- install('@agoric/fast-usdc/src/fast-usdc.contract.js'),
35
- ),
36
- },
37
- },
38
- ],
39
- });
40
- };
41
-
42
- /**
43
- * @param {string[]} [args]
44
- * @returns {{ agoricToNoble?: IBCConnectionInfo } & Passable}
45
- */
46
- const parseConnection = args => {
47
- /** @type {{ values: { agoricToNoble?: string } }} */
48
- const {
49
- values: { agoricToNoble: connJSON },
50
- } = parseArgs({
51
- args,
52
- options: { agoricToNoble: { type: 'string' } },
53
- });
54
- if (!connJSON) return {};
55
- /** @type {IBCConnectionInfo & Passable} */
56
- const conn = harden(JSON.parse(connJSON));
57
- mustMatch(conn, IBCConnectionInfoShape);
58
- return harden({ agoricToNoble: conn });
59
- };
60
-
61
- /** @type {DeployScriptFunction} */
62
- export default async (homeP, endowments) => {
63
- const { writeCoreEval } = await makeHelpers(homeP, endowments);
64
-
65
- await writeCoreEval('eval-fast-usdc-reconfigure', utils =>
66
- proposalBuilder(utils, parseConnection(endowments.scriptArgs)),
67
- );
68
- };
@@ -1,47 +0,0 @@
1
- /**
2
- * Usage:
3
- * agoric run fast-usdc-settler-ref.build.js
4
- *
5
- * (see update-settler-reference.core.js)
6
- */
7
- import { makeHelpers } from '@agoric/deploy-script-support';
8
- import { getManifestForUpdateSettlerReference } from '@agoric/fast-usdc/src/update-settler-reference.core.js';
9
-
10
- /**
11
- * @import {CoreEvalBuilder, DeployScriptFunction} from '@agoric/deploy-script-support/src/externalTypes.js';
12
- */
13
-
14
- /**
15
- * @param {Parameters<CoreEvalBuilder>[0]} powers
16
- * @param {{}} options
17
- * @satisfies {CoreEvalBuilder}
18
- */
19
- export const proposalBuilder = async (
20
- { publishRef, install },
21
- options = {},
22
- ) => {
23
- return harden({
24
- sourceSpec: '@agoric/fast-usdc/src/update-settler-reference.core.js',
25
- /** @type {[string, Parameters<typeof getManifestForUpdateSettlerReference>[1]]} */
26
- getManifestCall: [
27
- getManifestForUpdateSettlerReference.name,
28
- {
29
- options,
30
- installKeys: {
31
- fastUsdc: publishRef(
32
- install('@agoric/fast-usdc/src/fast-usdc.contract.js'),
33
- ),
34
- },
35
- },
36
- ],
37
- });
38
- };
39
-
40
- /** @type {DeployScriptFunction} */
41
- export default async (homeP, endowments) => {
42
- const { writeCoreEval } = await makeHelpers(homeP, endowments);
43
-
44
- await writeCoreEval('eval-fast-usdc-settler-ref', utils =>
45
- proposalBuilder(utils),
46
- );
47
- };
@@ -1,65 +0,0 @@
1
- import { parseArgs } from 'node:util';
2
- import { getManifestForUpdateFastUsdcPolicy } from '@agoric/fast-usdc/src/fast-usdc-policy.core.js';
3
- import { toExternalConfig } from '@agoric/fast-usdc/src/utils/config-marshal.js';
4
- import { FeedPolicyShape } from '@agoric/fast-usdc/src/type-guards.js';
5
- import { makeHelpers } from '@agoric/deploy-script-support';
6
-
7
- /**
8
- * @import {CoreEvalBuilder, DeployScriptFunction} from '@agoric/deploy-script-support/src/externalTypes.js'
9
- * @import {ParseArgsConfig} from 'node:util'
10
- * @import {FastUSDCConfig} from '@agoric/fast-usdc';
11
- */
12
-
13
- /** @type {ParseArgsConfig['options']} */
14
- const options = {
15
- feedPolicy: { type: 'string' },
16
- };
17
- const feedPolicyUsage = 'use --feedPolicy <policy> ...';
18
-
19
- /**
20
- * @typedef {{
21
- * feedPolicy?: string;
22
- * }} FastUSDCUpdateOpts
23
- */
24
-
25
- /**
26
- * @param {Parameters<CoreEvalBuilder>[0]} powers
27
- * @param {FastUSDCConfig} config
28
- * @satisfies {CoreEvalBuilder}
29
- */
30
- export const updateProposalBuilder = async (
31
- powers,
32
- /** @type {Pick<FastUSDCConfig, 'feedPolicy'>} */ config,
33
- ) => {
34
- return harden({
35
- sourceSpec: '@agoric/fast-usdc/src/fast-usdc-policy.core.js',
36
- /** @type {[string, Parameters<typeof getManifestForUpdateFastUsdcPolicy>[1]]} */
37
- getManifestCall: [
38
- getManifestForUpdateFastUsdcPolicy.name,
39
- {
40
- options: toExternalConfig(
41
- config,
42
- {},
43
- harden({ feedPolicy: FeedPolicyShape }),
44
- ),
45
- },
46
- ],
47
- });
48
- };
49
-
50
- /** @type {DeployScriptFunction} */
51
- export default async (homeP, endowments) => {
52
- const { writeCoreEval } = await makeHelpers(homeP, endowments);
53
- const {
54
- values: { feedPolicy },
55
- } = parseArgs({ args: endowments.scriptArgs, options });
56
-
57
- const parseFeedPolicy = () => {
58
- if (typeof feedPolicy !== 'string') throw Error(feedPolicyUsage);
59
- return JSON.parse(feedPolicy);
60
- };
61
- const config = harden({ feedPolicy: parseFeedPolicy() });
62
- await writeCoreEval('eval-fast-usdc-policy-update', utils =>
63
- updateProposalBuilder(utils, config),
64
- );
65
- };
@@ -1,208 +0,0 @@
1
- // @ts-check
2
- import { makeHelpers } from '@agoric/deploy-script-support';
3
- import { AmountMath } from '@agoric/ertp';
4
- import { getManifestForFastUSDC } from '@agoric/fast-usdc/src/start-fast-usdc.core.js';
5
- import { FastUSDCConfigShape } from '@agoric/fast-usdc/src/type-guards.js';
6
- import { toExternalConfig } from '@agoric/fast-usdc/src/utils/config-marshal.js';
7
- import { configurations } from '@agoric/fast-usdc/src/utils/deploy-config.js';
8
- import {
9
- multiplyBy,
10
- parseRatio,
11
- } from '@agoric/zoe/src/contractSupport/ratio.js';
12
- import { Far } from '@endo/far';
13
- import { parseArgs } from 'node:util';
14
-
15
- /**
16
- * @import {CoreEvalBuilder, DeployScriptFunction} from '@agoric/deploy-script-support/src/externalTypes.js'
17
- * @import {Brand} from '@agoric/ertp';
18
- * @import {ParseArgsConfig} from 'node:util'
19
- * @import {FastUSDCConfig, FeedPolicy} from '@agoric/fast-usdc';
20
- */
21
-
22
- const { keys } = Object;
23
-
24
- /** @type {ParseArgsConfig['options']} */
25
- const options = {
26
- flatFee: { type: 'string', default: '0.01' },
27
- variableRate: { type: 'string', default: '0.01' },
28
- contractRate: { type: 'string', default: '0.2' },
29
- net: { type: 'string' },
30
- oracle: { type: 'string', multiple: true },
31
- feedPolicy: { type: 'string' },
32
- usdcDenom: {
33
- type: 'string',
34
- default:
35
- 'ibc/FE98AAD68F02F03565E9FA39A5E627946699B2B07115889ED812D8BA639576A9',
36
- },
37
- chainInfo: { type: 'string' },
38
- assetInfo: { type: 'string' },
39
- noNoble: { type: 'boolean', default: false },
40
- };
41
- const oraclesUsage = 'use --oracle name:address ...';
42
-
43
- const feedPolicyUsage = 'use --feedPolicy <policy> ...';
44
-
45
- const chainInfoUsage = 'use --chainInfo {chainName:CosmosChainInfo, ...}';
46
- const assetInfoUsage =
47
- 'use --assetInfo { denom:DenomInfo & {brandKey?: string} ... }';
48
-
49
- /**
50
- * @typedef {{
51
- * flatFee: string;
52
- * variableRate: string;
53
- * contractRate: string;
54
- * net?: string;
55
- * oracle?: string[];
56
- * usdcDenom: string;
57
- * feedPolicy?: string;
58
- * chainInfo?: string;
59
- * assetInfo?: string;
60
- * noNoble: boolean;
61
- * }} FastUSDCOpts
62
- */
63
-
64
- const crossVatContext = /** @type {const} */ ({
65
- /** @type {Brand<'nat'>} */
66
- USDC: Far('USDC Brand'),
67
- });
68
- const { USDC } = crossVatContext;
69
- const USDC_DECIMALS = 6;
70
- const unit = AmountMath.make(USDC, 10n ** BigInt(USDC_DECIMALS));
71
-
72
- /**
73
- * @param {Parameters<CoreEvalBuilder>[0]} powers
74
- * @param {FastUSDCConfig} config
75
- * @satisfies {CoreEvalBuilder}
76
- */
77
- export const defaultProposalBuilder = async (
78
- { publishRef, install },
79
- config,
80
- ) => {
81
- return harden({
82
- sourceSpec: '@agoric/fast-usdc/src/start-fast-usdc.core.js',
83
- /** @type {[string, Parameters<typeof getManifestForFastUSDC>[1]]} */
84
- getManifestCall: [
85
- getManifestForFastUSDC.name,
86
- {
87
- options: toExternalConfig(config, crossVatContext, FastUSDCConfigShape),
88
- installKeys: {
89
- fastUsdc: publishRef(
90
- install('@agoric/fast-usdc/src/fast-usdc.contract.js'),
91
- ),
92
- },
93
- },
94
- ],
95
- });
96
- };
97
-
98
- /** @type {DeployScriptFunction} */
99
- export default async (homeP, endowments) => {
100
- const { writeCoreEval } = await makeHelpers(homeP, endowments);
101
- const { scriptArgs } = endowments;
102
-
103
- /** @type {{ values: FastUSDCOpts }} */
104
- // @ts-expect-error ensured by options
105
- const {
106
- values: {
107
- oracle: oracleArgs,
108
- net,
109
- usdcDenom,
110
- feedPolicy,
111
- chainInfo,
112
- assetInfo,
113
- noNoble,
114
- ...fees
115
- },
116
- } = parseArgs({ args: scriptArgs, options });
117
-
118
- /** @returns {FeedPolicy} */
119
- const parseFeedPolicy = () => {
120
- if (net) {
121
- if (!(net in configurations)) {
122
- throw Error(`${net} not in ${keys(configurations)}`);
123
- }
124
- return configurations[net].feedPolicy;
125
- }
126
- if (!feedPolicy) throw Error(feedPolicyUsage);
127
- const parsed = JSON.parse(feedPolicy);
128
- if (!parsed.chainPolicies) {
129
- return {
130
- ...configurations.MAINNET.feedPolicy,
131
- ...parsed,
132
- };
133
- } else {
134
- // consider having callers use `toExternalConfig` to pass in bigints and
135
- // use `fromExternalConfig` here to parse
136
- throw Error('TODO: support unmarshalling feedPolicy');
137
- }
138
- };
139
-
140
- const parseOracleArgs = () => {
141
- if (net) {
142
- if (!(net in configurations)) {
143
- throw Error(`${net} not in ${keys(configurations)}`);
144
- }
145
- return configurations[net].oracles;
146
- }
147
- if (!oracleArgs) throw Error(oraclesUsage);
148
- return Object.fromEntries(
149
- oracleArgs.map(arg => {
150
- const result = arg.match(/(?<name>[^:]+):(?<address>.+)/);
151
- if (!(result && result.groups)) throw Error(oraclesUsage);
152
- const { name, address } = result.groups;
153
- return [name, address];
154
- }),
155
- );
156
- };
157
-
158
- /** @param {string} numeral */
159
- const toAmount = numeral => multiplyBy(unit, parseRatio(numeral, USDC));
160
- /** @param {string} numeral */
161
- const toRatio = numeral => parseRatio(numeral, USDC);
162
- const parseFeeConfigArgs = () => {
163
- const { flatFee, variableRate, contractRate } = fees;
164
- return {
165
- flat: toAmount(flatFee),
166
- variableRate: toRatio(variableRate),
167
- contractRate: toRatio(contractRate),
168
- };
169
- };
170
-
171
- const parseChainInfo = () => {
172
- if (net) {
173
- if (!(net in configurations)) {
174
- throw Error(`${net} not in ${keys(configurations)}`);
175
- }
176
- return configurations[net].chainInfo;
177
- }
178
- if (!chainInfo) throw Error(chainInfoUsage);
179
- return JSON.parse(chainInfo);
180
- };
181
- const parseAssetInfo = () => {
182
- if (net) {
183
- if (!(net in configurations)) {
184
- throw Error(`${net} not in ${keys(configurations)}`);
185
- }
186
- return configurations[net].assetInfo;
187
- }
188
- if (!assetInfo) throw Error(assetInfoUsage);
189
- return JSON.parse(assetInfo);
190
- };
191
-
192
- /** @type {FastUSDCConfig} */
193
- const config = harden({
194
- oracles: parseOracleArgs(),
195
- terms: {
196
- usdcDenom,
197
- },
198
- feeConfig: parseFeeConfigArgs(),
199
- feedPolicy: parseFeedPolicy(),
200
- chainInfo: parseChainInfo(),
201
- assetInfo: parseAssetInfo(),
202
- noNoble,
203
- });
204
-
205
- await writeCoreEval('start-fast-usdc', utils =>
206
- defaultProposalBuilder(utils, config),
207
- );
208
- };