@agoric/fast-usdc 0.1.1-dev-fbae24c.0 → 0.1.1-dev-bdf5c17.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/src/type-guards.js +8 -11
- package/src/types.ts +6 -3
- package/src/utils/deploy-config.js +6 -4
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-bdf5c17.0+bdf5c17",
|
|
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-bdf5c17.0+bdf5c17",
|
|
26
|
+
"@agoric/vats": "0.15.2-dev-bdf5c17.0+bdf5c17",
|
|
27
|
+
"@agoric/zone": "0.2.3-dev-bdf5c17.0+bdf5c17",
|
|
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-bdf5c17.0+bdf5c17",
|
|
36
|
+
"@agoric/ertp": "0.16.3-dev-bdf5c17.0+bdf5c17",
|
|
37
|
+
"@agoric/internal": "0.3.3-dev-bdf5c17.0+bdf5c17",
|
|
38
|
+
"@agoric/notifier": "0.6.3-dev-bdf5c17.0+bdf5c17",
|
|
39
|
+
"@agoric/orchestration": "0.1.1-dev-bdf5c17.0+bdf5c17",
|
|
40
|
+
"@agoric/store": "0.9.3-dev-bdf5c17.0+bdf5c17",
|
|
41
|
+
"@agoric/vat-data": "0.5.3-dev-bdf5c17.0+bdf5c17",
|
|
42
|
+
"@agoric/vow": "0.1.1-dev-bdf5c17.0+bdf5c17",
|
|
43
|
+
"@agoric/zoe": "0.26.3-dev-bdf5c17.0+bdf5c17",
|
|
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": "bdf5c1715492b9e65b205db0b8128e38876c853f"
|
|
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} */
|
package/src/type-guards.js
CHANGED
|
@@ -94,16 +94,13 @@ export const PoolMetricsShape = {
|
|
|
94
94
|
harden(PoolMetricsShape);
|
|
95
95
|
|
|
96
96
|
/** @type {TypedPattern<ChainPolicy>} */
|
|
97
|
-
export const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
{ chainType: M.number() },
|
|
105
|
-
);
|
|
106
|
-
harden(ChainPoliciesShape);
|
|
97
|
+
export const ChainPolicyShape = {
|
|
98
|
+
attenuatedCttpBridgeAddress: EvmHashShape,
|
|
99
|
+
cctpTokenMessengerAddress: EvmHashShape,
|
|
100
|
+
confirmations: M.number(),
|
|
101
|
+
chainId: M.number(),
|
|
102
|
+
};
|
|
103
|
+
harden(ChainPolicyShape);
|
|
107
104
|
|
|
108
105
|
/**
|
|
109
106
|
* @type {TypedPattern<FeedPolicy>}
|
|
@@ -115,7 +112,7 @@ export const FeedPolicyShape = M.splitRecord(
|
|
|
115
112
|
{
|
|
116
113
|
nobleDomainId: M.number(),
|
|
117
114
|
nobleAgoricChannelId: M.string(),
|
|
118
|
-
chainPolicies: M.recordOf(M.string(),
|
|
115
|
+
chainPolicies: M.recordOf(M.string(), ChainPolicyShape),
|
|
119
116
|
},
|
|
120
117
|
{ eventFilter: M.string() },
|
|
121
118
|
);
|
package/src/types.ts
CHANGED
|
@@ -58,11 +58,14 @@ export interface PoolMetrics extends PoolStats {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
export interface ChainPolicy {
|
|
61
|
-
|
|
61
|
+
/** `msg.sender` of DepositAndBurn to TokenMessenger must be an attenuated wrapper contract that does not contain `replaceDepositForBurn` */
|
|
62
|
+
attenuatedCttpBridgeAddress: EvmHash;
|
|
63
|
+
/** @see {@link https://developers.circle.com/stablecoins/evm-smart-contracts} */
|
|
62
64
|
cctpTokenMessengerAddress: EvmHash;
|
|
63
|
-
|
|
65
|
+
/** e.g., `1` for ETH mainnet 42161 for Arbitrum One. @see {@link https://chainlist.org/} */
|
|
64
66
|
chainId: EvmChainID;
|
|
65
|
-
|
|
67
|
+
/** the number of block confirmations to observe before reporting */
|
|
68
|
+
confirmations: number;
|
|
66
69
|
}
|
|
67
70
|
|
|
68
71
|
export interface FeedPolicy {
|
|
@@ -64,11 +64,12 @@ export const configurations = {
|
|
|
64
64
|
nobleDomainId: 4,
|
|
65
65
|
chainPolicies: {
|
|
66
66
|
Arbitrum: {
|
|
67
|
+
attenuatedCttpBridgeAddress:
|
|
68
|
+
'0xe298b93ffB5eA1FB628e0C0D55A43aeaC268e347',
|
|
67
69
|
cctpTokenMessengerAddress:
|
|
68
70
|
'0x19330d10D9Cc8751218eaf51E8885D058642E08A',
|
|
69
71
|
chainId: 42161,
|
|
70
72
|
confirmations: 2,
|
|
71
|
-
nobleContractAddress: '0x19330d10D9Cc8751218eaf51E8885D058642E08A',
|
|
72
73
|
},
|
|
73
74
|
},
|
|
74
75
|
},
|
|
@@ -92,11 +93,12 @@ export const configurations = {
|
|
|
92
93
|
nobleDomainId: 4,
|
|
93
94
|
chainPolicies: {
|
|
94
95
|
Arbitrum: {
|
|
96
|
+
attenuatedCttpBridgeAddress:
|
|
97
|
+
'0xe298b93ffB5eA1FB628e0C0D55A43aeaC268e347',
|
|
95
98
|
cctpTokenMessengerAddress:
|
|
96
99
|
'0x19330d10D9Cc8751218eaf51E8885D058642E08A',
|
|
97
100
|
chainId: 42161,
|
|
98
101
|
confirmations: 2,
|
|
99
|
-
nobleContractAddress: '0x19330d10D9Cc8751218eaf51E8885D058642E08A',
|
|
100
102
|
},
|
|
101
103
|
},
|
|
102
104
|
},
|
|
@@ -118,10 +120,10 @@ export const configurations = {
|
|
|
118
120
|
nobleDomainId: 4,
|
|
119
121
|
chainPolicies: {
|
|
120
122
|
Arbitrum: {
|
|
123
|
+
attenuatedCttpBridgeAddress: '0xTODO',
|
|
121
124
|
cctpTokenMessengerAddress: '0xTODO',
|
|
122
125
|
chainId: 421614,
|
|
123
126
|
confirmations: 2,
|
|
124
|
-
nobleContractAddress: '0xTODO',
|
|
125
127
|
},
|
|
126
128
|
},
|
|
127
129
|
},
|
|
@@ -140,10 +142,10 @@ export const configurations = {
|
|
|
140
142
|
nobleDomainId: 4,
|
|
141
143
|
chainPolicies: {
|
|
142
144
|
Arbitrum: {
|
|
145
|
+
attenuatedCttpBridgeAddress: '0xTODO',
|
|
143
146
|
cctpTokenMessengerAddress: '0xTODO',
|
|
144
147
|
chainId: 421614,
|
|
145
148
|
confirmations: 2,
|
|
146
|
-
nobleContractAddress: '0xTODO',
|
|
147
149
|
},
|
|
148
150
|
},
|
|
149
151
|
},
|