agoric 0.21.2-other-dev-fbe72e7.0.fbe72e7 → 0.21.2-other-dev-d15096d.0.d15096d

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.
@@ -1,173 +0,0 @@
1
- // @ts-check
2
- /* eslint-env node */
3
- import {
4
- fetchEnvNetworkConfig,
5
- makeAgoricNames,
6
- makeVstorageKit,
7
- } from '@agoric/client-utils';
8
- import { Fail } from '@endo/errors';
9
- import { InvalidArgumentError } from 'commander';
10
- import { outputActionAndHint } from '../lib/wallet.js';
11
-
12
- /**
13
- * @import {ParamTypesMap, ParamTypesMapFromRecord} from '@agoric/governance/src/contractGovernance/typedParamManager.js'
14
- * @import {AuctionParamRecord} from '@agoric/inter-protocol/src/auction/params.js';
15
- * @import {ParamValueForType} from '@agoric/governance/src/types.js'
16
- */
17
-
18
- const networkConfig = await fetchEnvNetworkConfig({ env: process.env, fetch });
19
-
20
- /**
21
- * @template {ParamTypesMap} M
22
- * @typedef {{
23
- * [K in keyof M]: ParamValueForType<M[K]>
24
- * }} ParamValues
25
- */
26
-
27
- /** @typedef {ParamValues<ParamTypesMapFromRecord<AuctionParamRecord>>} AuctionParams */
28
-
29
- /**
30
- * @param {import('anylogger').Logger} _logger
31
- * @param {{
32
- * createCommand: typeof import('commander').createCommand,
33
- * fetch: typeof window.fetch,
34
- * stdout: Pick<import('stream').Writable, 'write'>,
35
- * stderr: Pick<import('stream').Writable, 'write'>,
36
- * now: () => number,
37
- * }} io
38
- */
39
- export const makeAuctionCommand = (
40
- _logger,
41
- { createCommand, stdout, stderr, fetch, now },
42
- ) => {
43
- const auctioneer = createCommand('auctioneer').description(
44
- 'Auctioneer commands',
45
- );
46
-
47
- auctioneer
48
- .command('proposeParamChange')
49
- .description('propose a change to start frequency')
50
- .option(
51
- '--start-frequency <seconds>',
52
- 'how often to start auctions',
53
- BigInt,
54
- )
55
- .option('--price-lock-period <seconds>', 'price lock period', BigInt)
56
- .option('--clock-step <seconds>', 'descending clock frequency', BigInt)
57
- .option(
58
- '--starting-rate <basis-points>',
59
- 'relative to oracle: 999 = 1bp discount',
60
- BigInt,
61
- )
62
- .option('--lowest-rate <basis-points>', 'lower limit for discount', BigInt)
63
- .option(
64
- '--discount-step <basis-points>',
65
- 'descending clock step size',
66
- BigInt,
67
- )
68
- .requiredOption(
69
- '--charterAcceptOfferId <string>',
70
- 'offer that had continuing invitation result',
71
- )
72
- .option('--offer-id <string>', 'Offer id', String, `propose-${Date.now()}`)
73
- .option(
74
- '--deadline <minutes>',
75
- 'minutes from now to close the vote',
76
- Number,
77
- 1,
78
- )
79
- .action(
80
- /**
81
- *
82
- * @param {{
83
- * charterAcceptOfferId: string,
84
- * startFrequency?: bigint,
85
- * clockStep?: bigint,
86
- * startingRate?: bigint,
87
- * lowestRate?: bigint,
88
- * discountStep?: bigint,
89
- * priceLockPeriod?: bigint,
90
- * offerId: string,
91
- * deadline: number,
92
- * }} opts
93
- */
94
- async opts => {
95
- const { readPublished, ...vsk } = makeVstorageKit(
96
- { fetch },
97
- networkConfig,
98
- );
99
- const agoricNames = await makeAgoricNames(vsk.fromBoard, vsk.vstorage);
100
-
101
- const { current } = await readPublished(`auction.governance`);
102
-
103
- const {
104
- AuctionStartDelay: {
105
- value: { timerBrand },
106
- },
107
- } = current;
108
- timerBrand || Fail`no timer brand?`;
109
-
110
- /**
111
- * typed param manager requires RelativeTimeRecord
112
- * but TimeMath.toRel prodocues a RelativeTime (which may be a bare bigint).
113
- *
114
- * @param {bigint} relValue
115
- * @returns {import('@agoric/time').RelativeTimeRecord}
116
- */
117
- const toRel = relValue => ({ timerBrand, relValue });
118
-
119
- /** @type {Partial<AuctionParams>} */
120
- const params = {
121
- ...(opts.startFrequency && {
122
- StartFrequency: toRel(opts.startFrequency),
123
- }),
124
- ...(opts.clockStep && { ClockStep: toRel(opts.clockStep) }),
125
- ...(opts.startingRate && { StartingRate: opts.startingRate }),
126
- ...(opts.lowestRate && { LowestRate: opts.lowestRate }),
127
- ...(opts.discountStep && { DiscountStep: opts.discountStep }),
128
- ...(opts.priceLockPeriod && {
129
- PriceLockPeriod: toRel(opts.priceLockPeriod),
130
- }),
131
- };
132
-
133
- if (Object.keys(params).length === 0) {
134
- // InvalidArgumentError is a class constructor, and so
135
- // must be invoked with `new`.
136
- throw new InvalidArgumentError(`no parameters given`);
137
- }
138
-
139
- const instance = agoricNames.instance.auctioneer;
140
- instance || Fail`missing auctioneer in names`;
141
-
142
- const t0 = now();
143
- const deadline = BigInt(Math.round(t0 / 1000) + 60 * opts.deadline);
144
-
145
- /** @type {import('@agoric/inter-protocol/src/econCommitteeCharter.js').ParamChangesOfferArgs} */
146
- const offerArgs = {
147
- deadline,
148
- params,
149
- instance,
150
- path: { paramPath: { key: 'governedParams' } },
151
- };
152
-
153
- /** @type {import('@agoric/smart-wallet/src/offers.js').OfferSpec} */
154
- const offer = {
155
- id: opts.offerId,
156
- invitationSpec: {
157
- source: 'continuing',
158
- previousOffer: opts.charterAcceptOfferId,
159
- invitationMakerName: 'VoteOnParamChange',
160
- },
161
- offerArgs,
162
- proposal: {},
163
- };
164
-
165
- outputActionAndHint(
166
- { method: 'executeOffer', offer },
167
- { stdout, stderr },
168
- );
169
- },
170
- );
171
-
172
- return auctioneer;
173
- };