@agoric/fast-usdc 0.1.1-dev-3b478fb.0 → 0.1.1-dev-8f9f075.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 +14 -14
- package/src/cli/lp-commands.js +28 -21
- package/src/cli/operator-commands.js +10 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/fast-usdc",
|
|
3
|
-
"version": "0.1.1-dev-
|
|
3
|
+
"version": "0.1.1-dev-8f9f075.0+8f9f075",
|
|
4
4
|
"description": "CLI and library for Fast USDC product",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"lint:eslint": "eslint ."
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@agoric/swingset-liveslots": "0.10.3-dev-
|
|
26
|
-
"@agoric/vats": "0.15.2-dev-
|
|
27
|
-
"@agoric/zone": "0.2.3-dev-
|
|
25
|
+
"@agoric/swingset-liveslots": "0.10.3-dev-8f9f075.0+8f9f075",
|
|
26
|
+
"@agoric/vats": "0.15.2-dev-8f9f075.0+8f9f075",
|
|
27
|
+
"@agoric/zone": "0.2.3-dev-8f9f075.0+8f9f075",
|
|
28
28
|
"@fast-check/ava": "^2.0.1",
|
|
29
29
|
"ava": "^5.3.0",
|
|
30
30
|
"c8": "^10.1.2",
|
|
@@ -32,15 +32,15 @@
|
|
|
32
32
|
"ts-blank-space": "^0.4.4"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@agoric/client-utils": "0.1.1-dev-
|
|
36
|
-
"@agoric/ertp": "0.16.3-dev-
|
|
37
|
-
"@agoric/internal": "0.3.3-dev-
|
|
38
|
-
"@agoric/notifier": "0.6.3-dev-
|
|
39
|
-
"@agoric/orchestration": "0.1.1-dev-
|
|
40
|
-
"@agoric/store": "0.9.3-dev-
|
|
41
|
-
"@agoric/vat-data": "0.5.3-dev-
|
|
42
|
-
"@agoric/vow": "0.1.1-dev-
|
|
43
|
-
"@agoric/zoe": "0.26.3-dev-
|
|
35
|
+
"@agoric/client-utils": "0.1.1-dev-8f9f075.0+8f9f075",
|
|
36
|
+
"@agoric/ertp": "0.16.3-dev-8f9f075.0+8f9f075",
|
|
37
|
+
"@agoric/internal": "0.3.3-dev-8f9f075.0+8f9f075",
|
|
38
|
+
"@agoric/notifier": "0.6.3-dev-8f9f075.0+8f9f075",
|
|
39
|
+
"@agoric/orchestration": "0.1.1-dev-8f9f075.0+8f9f075",
|
|
40
|
+
"@agoric/store": "0.9.3-dev-8f9f075.0+8f9f075",
|
|
41
|
+
"@agoric/vat-data": "0.5.3-dev-8f9f075.0+8f9f075",
|
|
42
|
+
"@agoric/vow": "0.1.1-dev-8f9f075.0+8f9f075",
|
|
43
|
+
"@agoric/zoe": "0.26.3-dev-8f9f075.0+8f9f075",
|
|
44
44
|
"@cosmjs/proto-signing": "^0.32.4",
|
|
45
45
|
"@cosmjs/stargate": "^0.32.4",
|
|
46
46
|
"@endo/base64": "^1.0.9",
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"publishConfig": {
|
|
81
81
|
"access": "public"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "8f9f07501c1e5f25103d0a015f2f2817275391f2"
|
|
84
84
|
}
|
package/src/cli/lp-commands.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-env node */
|
|
1
2
|
/**
|
|
2
3
|
* @import {Command} from 'commander';
|
|
3
4
|
* @import {OfferSpec} from '@agoric/smart-wallet/src/offers.js';
|
|
@@ -5,17 +6,22 @@
|
|
|
5
6
|
* @import {USDCProposalShapes} from '../pool-share-math.js';
|
|
6
7
|
*/
|
|
7
8
|
|
|
8
|
-
import {
|
|
9
|
-
|
|
9
|
+
import {
|
|
10
|
+
fetchEnvNetworkConfig,
|
|
11
|
+
makeSmartWalletKit,
|
|
12
|
+
} from '@agoric/client-utils';
|
|
13
|
+
import { AmountMath } from '@agoric/ertp';
|
|
10
14
|
import {
|
|
11
15
|
assertParsableNumber,
|
|
12
16
|
ceilDivideBy,
|
|
13
17
|
multiplyBy,
|
|
14
18
|
parseRatio,
|
|
15
19
|
} from '@agoric/zoe/src/contractSupport/ratio.js';
|
|
16
|
-
import {
|
|
20
|
+
import { InvalidArgumentError } from 'commander';
|
|
17
21
|
import { outputActionAndHint } from './bridge-action.js';
|
|
18
22
|
|
|
23
|
+
export const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
|
|
24
|
+
|
|
19
25
|
/** @param {string} arg */
|
|
20
26
|
const parseDecimal = arg => {
|
|
21
27
|
try {
|
|
@@ -41,7 +47,7 @@ const parseUSDCAmount = (amountString, usdc) => {
|
|
|
41
47
|
* @param {Command} program
|
|
42
48
|
* @param {{
|
|
43
49
|
* fetch?: Window['fetch'];
|
|
44
|
-
*
|
|
50
|
+
* smartWalletKit?: import('@agoric/client-utils').SmartWalletKit;
|
|
45
51
|
* stdout: typeof process.stdout;
|
|
46
52
|
* stderr: typeof process.stderr;
|
|
47
53
|
* env: typeof process.env;
|
|
@@ -50,18 +56,18 @@ const parseUSDCAmount = (amountString, usdc) => {
|
|
|
50
56
|
*/
|
|
51
57
|
export const addLPCommands = (
|
|
52
58
|
program,
|
|
53
|
-
{ fetch,
|
|
59
|
+
{ fetch, smartWalletKit, stderr, stdout, env, now },
|
|
54
60
|
) => {
|
|
55
|
-
const
|
|
56
|
-
if (
|
|
57
|
-
return
|
|
61
|
+
const loadSwk = async () => {
|
|
62
|
+
if (smartWalletKit) {
|
|
63
|
+
return smartWalletKit;
|
|
58
64
|
}
|
|
59
65
|
assert(fetch);
|
|
60
66
|
const networkConfig = await fetchEnvNetworkConfig({ env, fetch });
|
|
61
|
-
return
|
|
67
|
+
return makeSmartWalletKit({ delay, fetch }, networkConfig);
|
|
62
68
|
};
|
|
63
|
-
/** @type {undefined | ReturnType<typeof
|
|
64
|
-
let
|
|
69
|
+
/** @type {undefined | ReturnType<typeof loadSwk>} */
|
|
70
|
+
let swkP;
|
|
65
71
|
|
|
66
72
|
program
|
|
67
73
|
.command('deposit')
|
|
@@ -73,11 +79,11 @@ export const addLPCommands = (
|
|
|
73
79
|
.requiredOption('--amount <number>', 'USDC amount', parseDecimal)
|
|
74
80
|
.option('--offerId <string>', 'Offer id', String, `lpDeposit-${now()}`)
|
|
75
81
|
.action(async opts => {
|
|
76
|
-
|
|
77
|
-
const
|
|
82
|
+
swkP ||= loadSwk();
|
|
83
|
+
const swk = await swkP;
|
|
78
84
|
/** @type {Brand<'nat'>} */
|
|
79
85
|
// @ts-expect-error it doesnt recognize usdc as a Brand type
|
|
80
|
-
const usdc =
|
|
86
|
+
const usdc = swk.agoricNames.brand.USDC;
|
|
81
87
|
assert(usdc, 'USDC brand not in agoricNames');
|
|
82
88
|
|
|
83
89
|
const usdcAmount = parseUSDCAmount(opts.amount, usdc);
|
|
@@ -106,7 +112,7 @@ export const addLPCommands = (
|
|
|
106
112
|
offer,
|
|
107
113
|
};
|
|
108
114
|
|
|
109
|
-
outputActionAndHint(bridgeAction, { stderr, stdout },
|
|
115
|
+
outputActionAndHint(bridgeAction, { stderr, stdout }, swk.marshaller);
|
|
110
116
|
});
|
|
111
117
|
|
|
112
118
|
program
|
|
@@ -119,24 +125,25 @@ export const addLPCommands = (
|
|
|
119
125
|
.requiredOption('--amount <number>', 'USDC amount', parseDecimal)
|
|
120
126
|
.option('--offerId <string>', 'Offer id', String, `lpWithdraw-${now()}`)
|
|
121
127
|
.action(async opts => {
|
|
122
|
-
|
|
123
|
-
|
|
128
|
+
swkP ||= loadSwk();
|
|
129
|
+
swkP ||= loadSwk();
|
|
130
|
+
const swk = await swkP;
|
|
124
131
|
|
|
125
132
|
/** @type {Brand<'nat'>} */
|
|
126
133
|
// @ts-expect-error it doesnt recognize FastLP as a Brand type
|
|
127
|
-
const poolShare =
|
|
134
|
+
const poolShare = swk.agoricNames.brand.FastLP;
|
|
128
135
|
assert(poolShare, 'FastLP brand not in agoricNames');
|
|
129
136
|
|
|
130
137
|
/** @type {Brand<'nat'>} */
|
|
131
138
|
// @ts-expect-error it doesnt recognize usdc as a Brand type
|
|
132
|
-
const usdc =
|
|
139
|
+
const usdc = swk.agoricNames.brand.USDC;
|
|
133
140
|
assert(usdc, 'USDC brand not in agoricNames');
|
|
134
141
|
|
|
135
142
|
const usdcAmount = parseUSDCAmount(opts.amount, usdc);
|
|
136
143
|
|
|
137
144
|
/** @type {import('../types.js').PoolMetrics} */
|
|
138
145
|
// @ts-expect-error it treats this as "unknown"
|
|
139
|
-
const metrics = await
|
|
146
|
+
const metrics = await swk.readPublished('fastUsdc.poolMetrics');
|
|
140
147
|
const fastLPAmount = ceilDivideBy(usdcAmount, metrics.shareWorth);
|
|
141
148
|
|
|
142
149
|
/** @type {USDCProposalShapes['withdraw']} */
|
|
@@ -163,7 +170,7 @@ export const addLPCommands = (
|
|
|
163
170
|
outputActionAndHint(
|
|
164
171
|
{ method: 'executeOffer', offer },
|
|
165
172
|
{ stderr, stdout },
|
|
166
|
-
|
|
173
|
+
swk.marshaller,
|
|
167
174
|
);
|
|
168
175
|
});
|
|
169
176
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-env node */
|
|
1
2
|
/**
|
|
2
3
|
* @import {Command} from 'commander';
|
|
3
4
|
* @import {OfferSpec} from '@agoric/smart-wallet/src/offers.js';
|
|
@@ -5,7 +6,10 @@
|
|
|
5
6
|
* @import {OperatorKit} from '../exos/operator-kit.js';
|
|
6
7
|
*/
|
|
7
8
|
|
|
8
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
fetchEnvNetworkConfig,
|
|
11
|
+
makeSmartWalletKit,
|
|
12
|
+
} from '@agoric/client-utils';
|
|
9
13
|
import { mustMatch } from '@agoric/internal';
|
|
10
14
|
import { Nat } from '@endo/nat';
|
|
11
15
|
import { InvalidArgumentError } from 'commander';
|
|
@@ -13,6 +17,8 @@ import { INVITATION_MAKERS_DESC } from '../exos/transaction-feed.js';
|
|
|
13
17
|
import { CctpTxEvidenceShape } from '../type-guards.js';
|
|
14
18
|
import { outputActionAndHint } from './bridge-action.js';
|
|
15
19
|
|
|
20
|
+
export const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
|
|
21
|
+
|
|
16
22
|
/** @param {string} arg */
|
|
17
23
|
const parseNat = arg => {
|
|
18
24
|
const n = Nat(BigInt(arg));
|
|
@@ -53,8 +59,9 @@ export const addOperatorCommands = (
|
|
|
53
59
|
.option('--offerId <string>', 'Offer id', String, `operatorAccept-${now()}`)
|
|
54
60
|
.action(async opts => {
|
|
55
61
|
const networkConfig = await fetchEnvNetworkConfig({ env, fetch });
|
|
56
|
-
|
|
57
|
-
const
|
|
62
|
+
|
|
63
|
+
const swk = await makeSmartWalletKit({ delay, fetch }, networkConfig);
|
|
64
|
+
const instance = swk.agoricNames.instance.fastUsdc;
|
|
58
65
|
assert(instance, 'fastUsdc instance not in agoricNames');
|
|
59
66
|
|
|
60
67
|
/** @type {OfferSpec} */
|