@agoric/fast-usdc 0.1.1-other-dev-3eb1a1d.0 → 0.2.0-u18.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/README.md +43 -0
- package/package.json +19 -16
- package/src/cli/bridge-action.js +40 -0
- package/src/cli/cli.js +45 -152
- package/src/cli/config-commands.js +108 -0
- package/src/cli/config.js +15 -9
- package/src/cli/lp-commands.js +178 -0
- package/src/cli/operator-commands.js +145 -0
- package/src/cli/transfer.js +61 -11
- package/src/constants.js +25 -2
- package/src/exos/advancer.js +149 -103
- package/src/exos/liquidity-pool.js +52 -50
- package/src/exos/operator-kit.js +16 -10
- package/src/exos/settler.js +295 -58
- package/src/exos/status-manager.js +270 -57
- package/src/exos/transaction-feed.js +93 -35
- package/src/fast-usdc-policy.core.js +75 -0
- package/src/fast-usdc.contract.js +152 -63
- package/src/fast-usdc.flows.js +10 -0
- package/src/fast-usdc.start.js +44 -14
- package/src/type-guards.js +42 -20
- package/src/types.ts +58 -12
- package/src/util/agoric.js +1 -1
- package/src/util/bank.js +12 -0
- package/src/util/cctp.js +1 -1
- package/src/util/file.js +1 -1
- package/src/utils/deploy-config.js +166 -0
- package/tools/cli-tools.ts +9 -0
- package/tools/mock-io.ts +14 -0
- package/src/exos/README.md +0 -26
- package/src/utils/address.js +0 -71
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/** @file core-eval to publish update to Fast USDC feedPolicy */
|
|
2
|
+
|
|
3
|
+
import { E } from '@endo/far';
|
|
4
|
+
import { fromExternalConfig } from './utils/config-marshal.js';
|
|
5
|
+
import { FeedPolicyShape } from './type-guards.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @import {Passable} from '@endo/pass-style'
|
|
9
|
+
* @import {BootstrapManifest} from '@agoric/vats/src/core/lib-boot.js'
|
|
10
|
+
* @import {LegibleCapData} from './utils/config-marshal.js'
|
|
11
|
+
* @import {FeedPolicy} from './types.js'
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const contractName = 'fastUsdc';
|
|
15
|
+
const FEED_POLICY = 'feedPolicy';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* XXX copied from fast-usdc.start.js
|
|
19
|
+
*
|
|
20
|
+
* @param {ERef<StorageNode>} node
|
|
21
|
+
* @param {FeedPolicy} policy
|
|
22
|
+
*/
|
|
23
|
+
const publishFeedPolicy = async (node, policy) => {
|
|
24
|
+
const feedPolicy = E(node).makeChildNode(FEED_POLICY);
|
|
25
|
+
await E(feedPolicy).setValue(JSON.stringify(policy));
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @param {BootstrapPowers &
|
|
30
|
+
* { consume: { chainStorage: Promise<StorageNode> }}
|
|
31
|
+
* } powers
|
|
32
|
+
* @param {{ options: LegibleCapData<{feedPolicy: FeedPolicy & Passable}> }} config
|
|
33
|
+
*/
|
|
34
|
+
export const updateFastUsdcPolicy = async (
|
|
35
|
+
{ consume: { agoricNames, chainStorage } },
|
|
36
|
+
config,
|
|
37
|
+
) => {
|
|
38
|
+
/** @type {Issuer<'nat'>} */
|
|
39
|
+
const USDCissuer = await E(agoricNames).lookup('issuer', 'USDC');
|
|
40
|
+
const brands = harden({
|
|
41
|
+
USDC: await E(USDCissuer).getBrand(),
|
|
42
|
+
});
|
|
43
|
+
const { feedPolicy } = fromExternalConfig(
|
|
44
|
+
config.options,
|
|
45
|
+
brands,
|
|
46
|
+
harden({ feedPolicy: FeedPolicyShape }),
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
const storageNode = await E(chainStorage).makeChildNode(contractName);
|
|
50
|
+
|
|
51
|
+
await publishFeedPolicy(storageNode, feedPolicy);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @param {unknown} _utils
|
|
56
|
+
* @param {{
|
|
57
|
+
* options: LegibleCapData<{feedPolicy: FeedPolicy & Passable}>;
|
|
58
|
+
* }} param1
|
|
59
|
+
*/
|
|
60
|
+
export const getManifestForUpdateFastUsdcPolicy = (_utils, { options }) => {
|
|
61
|
+
return {
|
|
62
|
+
/** @type {BootstrapManifest} */
|
|
63
|
+
manifest: {
|
|
64
|
+
[updateFastUsdcPolicy.name]: {
|
|
65
|
+
consume: {
|
|
66
|
+
chainStorage: true,
|
|
67
|
+
|
|
68
|
+
// widely shared: name services
|
|
69
|
+
agoricNames: true,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
options,
|
|
74
|
+
};
|
|
75
|
+
};
|
|
@@ -1,41 +1,44 @@
|
|
|
1
1
|
import { AssetKind } from '@agoric/ertp';
|
|
2
|
-
import {
|
|
3
|
-
assertAllDefined,
|
|
4
|
-
deeplyFulfilledObject,
|
|
5
|
-
makeTracer,
|
|
6
|
-
} from '@agoric/internal';
|
|
2
|
+
import { makeTracer } from '@agoric/internal';
|
|
7
3
|
import { observeIteration, subscribeEach } from '@agoric/notifier';
|
|
8
4
|
import {
|
|
5
|
+
CosmosChainInfoShape,
|
|
6
|
+
DenomDetailShape,
|
|
7
|
+
DenomShape,
|
|
9
8
|
OrchestrationPowersShape,
|
|
9
|
+
registerChainsAndAssets,
|
|
10
10
|
withOrchestration,
|
|
11
11
|
} from '@agoric/orchestration';
|
|
12
|
+
import { makeZoeTools } from '@agoric/orchestration/src/utils/zoe-tools.js';
|
|
12
13
|
import { provideSingleton } from '@agoric/zoe/src/contractSupport/durability.js';
|
|
13
14
|
import { prepareRecorderKitMakers } from '@agoric/zoe/src/contractSupport/recorder.js';
|
|
14
|
-
import {
|
|
15
|
-
import { depositToSeat } from '@agoric/zoe/src/contractSupport/zoeHelpers.js';
|
|
15
|
+
import { Fail } from '@endo/errors';
|
|
16
16
|
import { E } from '@endo/far';
|
|
17
|
-
import { M
|
|
17
|
+
import { M } from '@endo/patterns';
|
|
18
18
|
import { prepareAdvancer } from './exos/advancer.js';
|
|
19
19
|
import { prepareLiquidityPoolKit } from './exos/liquidity-pool.js';
|
|
20
20
|
import { prepareSettler } from './exos/settler.js';
|
|
21
21
|
import { prepareStatusManager } from './exos/status-manager.js';
|
|
22
22
|
import { prepareTransactionFeedKit } from './exos/transaction-feed.js';
|
|
23
|
-
import { defineInertInvitation } from './utils/zoe.js';
|
|
24
|
-
import { FastUSDCTermsShape, FeeConfigShape } from './type-guards.js';
|
|
25
23
|
import * as flows from './fast-usdc.flows.js';
|
|
24
|
+
import { FastUSDCTermsShape, FeeConfigShape } from './type-guards.js';
|
|
25
|
+
import { defineInertInvitation } from './utils/zoe.js';
|
|
26
26
|
|
|
27
27
|
const trace = makeTracer('FastUsdc');
|
|
28
28
|
|
|
29
|
+
const TXNS_NODE = 'txns';
|
|
30
|
+
const FEE_NODE = 'feeConfig';
|
|
31
|
+
const ADDRESSES_BAGGAGE_KEY = 'addresses';
|
|
32
|
+
|
|
29
33
|
/**
|
|
30
|
-
* @import {Denom} from '@agoric/orchestration';
|
|
31
34
|
* @import {HostInterface} from '@agoric/async-flow';
|
|
32
|
-
* @import {OrchestrationAccount} from '@agoric/orchestration';
|
|
35
|
+
* @import {ChainAddress, CosmosChainInfo, Denom, DenomDetail, OrchestrationAccount} from '@agoric/orchestration';
|
|
33
36
|
* @import {OrchestrationPowers, OrchestrationTools} from '@agoric/orchestration/src/utils/start-helper.js';
|
|
34
|
-
* @import {
|
|
37
|
+
* @import {Remote} from '@agoric/internal';
|
|
38
|
+
* @import {Marshaller, StorageNode} from '@agoric/internal/src/lib-chainStorage.js'
|
|
35
39
|
* @import {Zone} from '@agoric/zone';
|
|
36
40
|
* @import {OperatorKit} from './exos/operator-kit.js';
|
|
37
|
-
* @import {CctpTxEvidence, FeeConfig} from './types.js';
|
|
38
|
-
* @import {RepayAmountKWR, RepayPaymentKWR} from './exos/liquidity-pool.js';
|
|
41
|
+
* @import {CctpTxEvidence, FeeConfig, RiskAssessment} from './types.js';
|
|
39
42
|
*/
|
|
40
43
|
|
|
41
44
|
/**
|
|
@@ -51,17 +54,45 @@ export const meta = {
|
|
|
51
54
|
privateArgsShape: {
|
|
52
55
|
// @ts-expect-error TypedPattern not recognized as record
|
|
53
56
|
...OrchestrationPowersShape,
|
|
57
|
+
assetInfo: M.arrayOf([DenomShape, DenomDetailShape]),
|
|
58
|
+
chainInfo: M.recordOf(M.string(), CosmosChainInfoShape),
|
|
54
59
|
feeConfig: FeeConfigShape,
|
|
55
60
|
marshaller: M.remotable(),
|
|
61
|
+
poolMetricsNode: M.remotable(),
|
|
56
62
|
},
|
|
57
63
|
};
|
|
58
64
|
harden(meta);
|
|
59
65
|
|
|
66
|
+
/**
|
|
67
|
+
* @param {Remote<StorageNode>} node
|
|
68
|
+
* @param {ERef<Marshaller>} marshaller
|
|
69
|
+
* @param {FeeConfig} feeConfig
|
|
70
|
+
*/
|
|
71
|
+
const publishFeeConfig = async (node, marshaller, feeConfig) => {
|
|
72
|
+
const feeNode = E(node).makeChildNode(FEE_NODE);
|
|
73
|
+
const value = await E(marshaller).toCapData(feeConfig);
|
|
74
|
+
return E(feeNode).setValue(JSON.stringify(value));
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @param {Remote<StorageNode>} contractNode
|
|
79
|
+
* @param {{
|
|
80
|
+
* poolAccount: ChainAddress['value'];
|
|
81
|
+
* settlementAccount: ChainAddress['value'];
|
|
82
|
+
* }} addresses
|
|
83
|
+
*/
|
|
84
|
+
const publishAddresses = (contractNode, addresses) => {
|
|
85
|
+
return E(contractNode).setValue(JSON.stringify(addresses));
|
|
86
|
+
};
|
|
87
|
+
|
|
60
88
|
/**
|
|
61
89
|
* @param {ZCF<FastUsdcTerms>} zcf
|
|
62
90
|
* @param {OrchestrationPowers & {
|
|
63
|
-
*
|
|
91
|
+
* assetInfo: [Denom, DenomDetail & { brandKey?: string}][];
|
|
92
|
+
* chainInfo: Record<string, CosmosChainInfo>;
|
|
64
93
|
* feeConfig: FeeConfig;
|
|
94
|
+
* marshaller: Marshaller;
|
|
95
|
+
* poolMetricsNode: Remote<StorageNode>;
|
|
65
96
|
* }} privateArgs
|
|
66
97
|
* @param {Zone} zone
|
|
67
98
|
* @param {OrchestrationTools} tools
|
|
@@ -71,14 +102,32 @@ export const contract = async (zcf, privateArgs, zone, tools) => {
|
|
|
71
102
|
const terms = zcf.getTerms();
|
|
72
103
|
assert('USDC' in terms.brands, 'no USDC brand');
|
|
73
104
|
assert('usdcDenom' in terms, 'no usdcDenom');
|
|
74
|
-
|
|
105
|
+
|
|
106
|
+
const { feeConfig, marshaller, storageNode } = privateArgs;
|
|
75
107
|
const { makeRecorderKit } = prepareRecorderKitMakers(
|
|
76
108
|
zone.mapStore('vstorage'),
|
|
77
109
|
marshaller,
|
|
78
110
|
);
|
|
79
|
-
|
|
80
|
-
const
|
|
81
|
-
|
|
111
|
+
|
|
112
|
+
const statusManager = prepareStatusManager(
|
|
113
|
+
zone,
|
|
114
|
+
E(storageNode).makeChildNode(TXNS_NODE),
|
|
115
|
+
{ marshaller },
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
const { USDC } = terms.brands;
|
|
119
|
+
const { withdrawToSeat } = tools.zoeTools;
|
|
120
|
+
const { baggage, chainHub, orchestrateAll, vowTools } = tools;
|
|
121
|
+
const makeSettler = prepareSettler(zone, {
|
|
122
|
+
statusManager,
|
|
123
|
+
USDC,
|
|
124
|
+
withdrawToSeat,
|
|
125
|
+
feeConfig,
|
|
126
|
+
vowTools: tools.vowTools,
|
|
127
|
+
zcf,
|
|
128
|
+
chainHub,
|
|
129
|
+
});
|
|
130
|
+
|
|
82
131
|
const { localTransfer } = makeZoeTools(zcf, vowTools);
|
|
83
132
|
const makeAdvancer = prepareAdvancer(zone, {
|
|
84
133
|
chainHub,
|
|
@@ -92,8 +141,9 @@ export const contract = async (zcf, privateArgs, zone, tools) => {
|
|
|
92
141
|
vowTools,
|
|
93
142
|
zcf,
|
|
94
143
|
});
|
|
144
|
+
|
|
95
145
|
const makeFeedKit = prepareTransactionFeedKit(zone, zcf);
|
|
96
|
-
|
|
146
|
+
|
|
97
147
|
const makeLiquidityPoolKit = prepareLiquidityPoolKit(
|
|
98
148
|
zone,
|
|
99
149
|
zcf,
|
|
@@ -106,42 +156,39 @@ export const contract = async (zcf, privateArgs, zone, tools) => {
|
|
|
106
156
|
'test of forcing evidence',
|
|
107
157
|
);
|
|
108
158
|
|
|
109
|
-
const { makeLocalAccount } = orchestrateAll(flows, {});
|
|
159
|
+
const { makeLocalAccount, makeNobleAccount } = orchestrateAll(flows, {});
|
|
110
160
|
|
|
111
161
|
const creatorFacet = zone.exo('Fast USDC Creator', undefined, {
|
|
112
162
|
/** @type {(operatorId: string) => Promise<Invitation<OperatorKit>>} */
|
|
113
163
|
async makeOperatorInvitation(operatorId) {
|
|
114
|
-
// eslint-disable-next-line no-use-before-define
|
|
115
164
|
return feedKit.creator.makeOperatorInvitation(operatorId);
|
|
116
165
|
},
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
166
|
+
async connectToNoble() {
|
|
167
|
+
return vowTools.when(nobleAccountV, nobleAccount => {
|
|
168
|
+
trace('nobleAccount', nobleAccount);
|
|
169
|
+
return vowTools.when(
|
|
170
|
+
E(nobleAccount).getAddress(),
|
|
171
|
+
intermediateRecipient => {
|
|
172
|
+
trace('intermediateRecipient', intermediateRecipient);
|
|
173
|
+
advancer.setIntermediateRecipient(intermediateRecipient);
|
|
174
|
+
settlerKit.creator.setIntermediateRecipient(intermediateRecipient);
|
|
175
|
+
return intermediateRecipient;
|
|
176
|
+
},
|
|
177
|
+
);
|
|
178
|
+
});
|
|
125
179
|
},
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
* @returns {Promise<AmountKeywordRecord>}
|
|
131
|
-
*/
|
|
132
|
-
async testRepay(amounts, payments) {
|
|
133
|
-
console.log('🚧🚧 UNTIL: repay is integrated (#10388) 🚧🚧', amounts);
|
|
134
|
-
const { zcfSeat: tmpAssetManagerSeat } = zcf.makeEmptySeatKit();
|
|
135
|
-
await depositToSeat(
|
|
136
|
-
zcf,
|
|
137
|
-
tmpAssetManagerSeat,
|
|
138
|
-
await deeplyFulfilledObject(
|
|
139
|
-
objectMap(payments, pmt => E(terms.issuers.USDC).getAmountOf(pmt)),
|
|
140
|
-
),
|
|
141
|
-
payments,
|
|
180
|
+
async publishAddresses() {
|
|
181
|
+
!baggage.has(ADDRESSES_BAGGAGE_KEY) || Fail`Addresses already published`;
|
|
182
|
+
const [poolAccountAddress] = await vowTools.when(
|
|
183
|
+
vowTools.all([E(poolAccount).getAddress()]),
|
|
142
184
|
);
|
|
143
|
-
|
|
144
|
-
|
|
185
|
+
const addresses = harden({
|
|
186
|
+
poolAccount: poolAccountAddress.value,
|
|
187
|
+
settlementAccount: settlementAddress.value,
|
|
188
|
+
});
|
|
189
|
+
baggage.init(ADDRESSES_BAGGAGE_KEY, addresses);
|
|
190
|
+
await publishAddresses(storageNode, addresses);
|
|
191
|
+
return addresses;
|
|
145
192
|
},
|
|
146
193
|
});
|
|
147
194
|
|
|
@@ -155,10 +202,10 @@ export const contract = async (zcf, privateArgs, zone, tools) => {
|
|
|
155
202
|
* capability is available in the smart-wallet bridge during UI testing.
|
|
156
203
|
*
|
|
157
204
|
* @param {CctpTxEvidence} evidence
|
|
205
|
+
* @param {RiskAssessment} [risk]
|
|
158
206
|
*/
|
|
159
|
-
makeTestPushInvitation(evidence) {
|
|
160
|
-
|
|
161
|
-
void advancer.handleTransactionEvent(evidence);
|
|
207
|
+
makeTestPushInvitation(evidence, risk = {}) {
|
|
208
|
+
void advancer.handleTransactionEvent({ evidence, risk });
|
|
162
209
|
return makeTestInvitation();
|
|
163
210
|
},
|
|
164
211
|
makeDepositInvitation() {
|
|
@@ -170,6 +217,13 @@ export const contract = async (zcf, privateArgs, zone, tools) => {
|
|
|
170
217
|
getPublicTopics() {
|
|
171
218
|
return poolKit.public.getPublicTopics();
|
|
172
219
|
},
|
|
220
|
+
getStaticInfo() {
|
|
221
|
+
baggage.has(ADDRESSES_BAGGAGE_KEY) ||
|
|
222
|
+
Fail`no addresses. creator must 'publishAddresses' first`;
|
|
223
|
+
return harden({
|
|
224
|
+
[ADDRESSES_BAGGAGE_KEY]: baggage.get(ADDRESSES_BAGGAGE_KEY),
|
|
225
|
+
});
|
|
226
|
+
},
|
|
173
227
|
});
|
|
174
228
|
|
|
175
229
|
// ^^^ Define all kinds above this line. Keep remote calls below. vvv
|
|
@@ -185,6 +239,8 @@ export const contract = async (zcf, privateArgs, zone, tools) => {
|
|
|
185
239
|
// So we use zone.exoClassKit above to define the liquidity pool kind
|
|
186
240
|
// and pass the shareMint into the maker / init function.
|
|
187
241
|
|
|
242
|
+
void publishFeeConfig(storageNode, marshaller, feeConfig);
|
|
243
|
+
|
|
188
244
|
const shareMint = await provideSingleton(
|
|
189
245
|
zone.mapStore('mint'),
|
|
190
246
|
'PoolShare',
|
|
@@ -195,37 +251,70 @@ export const contract = async (zcf, privateArgs, zone, tools) => {
|
|
|
195
251
|
);
|
|
196
252
|
|
|
197
253
|
const poolKit = zone.makeOnce('Liquidity Pool kit', () =>
|
|
198
|
-
makeLiquidityPoolKit(shareMint, privateArgs.
|
|
254
|
+
makeLiquidityPoolKit(shareMint, privateArgs.poolMetricsNode),
|
|
199
255
|
);
|
|
200
256
|
|
|
257
|
+
/** Chain, connection, and asset info can only be registered once */
|
|
258
|
+
const firstIncarnationKey = 'firstIncarnationKey';
|
|
259
|
+
if (!baggage.has(firstIncarnationKey)) {
|
|
260
|
+
baggage.init(firstIncarnationKey, true);
|
|
261
|
+
registerChainsAndAssets(
|
|
262
|
+
chainHub,
|
|
263
|
+
terms.brands,
|
|
264
|
+
privateArgs.chainInfo,
|
|
265
|
+
privateArgs.assetInfo,
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
const nobleAccountV = zone.makeOnce('NobleAccount', () => makeNobleAccount());
|
|
270
|
+
|
|
201
271
|
const feedKit = zone.makeOnce('Feed Kit', () => makeFeedKit());
|
|
202
272
|
|
|
203
|
-
const poolAccountV =
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
273
|
+
const poolAccountV = zone.makeOnce('PoolAccount', () => makeLocalAccount());
|
|
274
|
+
const settleAccountV = zone.makeOnce('SettleAccount', () =>
|
|
275
|
+
makeLocalAccount(),
|
|
276
|
+
);
|
|
277
|
+
// when() is OK here since this clearly resolves promptly.
|
|
278
|
+
/** @type {[HostInterface<OrchestrationAccount<{chainId: 'agoric-3';}>>, HostInterface<OrchestrationAccount<{chainId: 'agoric-3';}>>]} */
|
|
279
|
+
const [poolAccount, settlementAccount] = await vowTools.when(
|
|
280
|
+
vowTools.all([poolAccountV, settleAccountV]),
|
|
281
|
+
);
|
|
282
|
+
trace('settlementAccount', settlementAccount);
|
|
283
|
+
trace('poolAccount', poolAccount);
|
|
284
|
+
const settlementAddress = await E(settlementAccount).getAddress();
|
|
285
|
+
trace('settlementAddress', settlementAddress);
|
|
286
|
+
|
|
287
|
+
const [_agoric, _noble, agToNoble] = await vowTools.when(
|
|
288
|
+
chainHub.getChainsAndConnection('agoric', 'noble'),
|
|
289
|
+
);
|
|
290
|
+
const settlerKit = makeSettler({
|
|
291
|
+
repayer: poolKit.repayer,
|
|
292
|
+
sourceChannel: agToNoble.transferChannel.counterPartyChannelId,
|
|
293
|
+
remoteDenom: 'uusdc',
|
|
294
|
+
settlementAccount,
|
|
295
|
+
});
|
|
211
296
|
|
|
212
297
|
const advancer = zone.makeOnce('Advancer', () =>
|
|
213
298
|
makeAdvancer({
|
|
214
299
|
borrowerFacet: poolKit.borrower,
|
|
300
|
+
notifyFacet: settlerKit.notify,
|
|
215
301
|
poolAccount,
|
|
302
|
+
settlementAddress,
|
|
216
303
|
}),
|
|
217
304
|
);
|
|
218
305
|
// Connect evidence stream to advancer
|
|
219
306
|
void observeIteration(subscribeEach(feedKit.public.getEvidenceSubscriber()), {
|
|
220
|
-
updateState(
|
|
307
|
+
updateState(evidenceWithRisk) {
|
|
221
308
|
try {
|
|
222
|
-
void advancer.handleTransactionEvent(
|
|
309
|
+
void advancer.handleTransactionEvent(evidenceWithRisk);
|
|
223
310
|
} catch (err) {
|
|
224
311
|
trace('🚨 Error handling transaction event', err);
|
|
225
312
|
}
|
|
226
313
|
},
|
|
227
314
|
});
|
|
228
315
|
|
|
316
|
+
await settlerKit.creator.monitorMintingDeposits();
|
|
317
|
+
|
|
229
318
|
return harden({ creatorFacet, publicFacet });
|
|
230
319
|
};
|
|
231
320
|
harden(contract);
|
package/src/fast-usdc.flows.js
CHANGED
|
@@ -11,3 +11,13 @@ export const makeLocalAccount = async orch => {
|
|
|
11
11
|
return agoricChain.makeAccount();
|
|
12
12
|
};
|
|
13
13
|
harden(makeLocalAccount);
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @satisfies {OrchestrationFlow}
|
|
17
|
+
* @param {Orchestrator} orch
|
|
18
|
+
*/
|
|
19
|
+
export const makeNobleAccount = async orch => {
|
|
20
|
+
const nobleChain = await orch.getChain('noble');
|
|
21
|
+
return nobleChain.makeAccount();
|
|
22
|
+
};
|
|
23
|
+
harden(makeNobleAccount);
|
package/src/fast-usdc.start.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { deeplyFulfilledObject, makeTracer, objectMap } from '@agoric/internal';
|
|
2
|
+
import {
|
|
3
|
+
CosmosChainInfoShape,
|
|
4
|
+
DenomDetailShape,
|
|
5
|
+
DenomShape,
|
|
6
|
+
} from '@agoric/orchestration';
|
|
2
7
|
import { Fail } from '@endo/errors';
|
|
3
8
|
import { E } from '@endo/far';
|
|
4
9
|
import { makeMarshal } from '@endo/marshal';
|
|
@@ -17,30 +22,30 @@ import { fromExternalConfig } from './utils/config-marshal.js';
|
|
|
17
22
|
* @import {Board} from '@agoric/vats'
|
|
18
23
|
* @import {ManifestBundleRef} from '@agoric/deploy-script-support/src/externalTypes.js'
|
|
19
24
|
* @import {BootstrapManifest} from '@agoric/vats/src/core/lib-boot.js'
|
|
20
|
-
* @import {Passable} from '@endo/marshal';
|
|
21
25
|
* @import {LegibleCapData} from './utils/config-marshal.js'
|
|
22
|
-
* @import {FastUsdcSF
|
|
23
|
-
* @import {
|
|
26
|
+
* @import {FastUsdcSF} from './fast-usdc.contract.js'
|
|
27
|
+
* @import {FeedPolicy, FastUSDCConfig} from './types.js'
|
|
24
28
|
*/
|
|
25
29
|
|
|
30
|
+
const ShareAssetInfo = /** @type {const} */ harden({
|
|
31
|
+
issuerName: 'FastLP',
|
|
32
|
+
denom: 'ufastlp',
|
|
33
|
+
assetKind: 'nat',
|
|
34
|
+
decimalPlaces: 6,
|
|
35
|
+
});
|
|
36
|
+
|
|
26
37
|
const trace = makeTracer('FUSD-Start', true);
|
|
27
38
|
|
|
28
39
|
const contractName = 'fastUsdc';
|
|
29
40
|
|
|
30
|
-
/**
|
|
31
|
-
* @typedef {{
|
|
32
|
-
* terms: FastUsdcTerms;
|
|
33
|
-
* oracles: Record<string, string>;
|
|
34
|
-
* feeConfig: FeeConfig;
|
|
35
|
-
* feedPolicy: FeedPolicy & Passable;
|
|
36
|
-
* }} FastUSDCConfig
|
|
37
|
-
*/
|
|
38
41
|
/** @type {TypedPattern<FastUSDCConfig>} */
|
|
39
42
|
export const FastUSDCConfigShape = M.splitRecord({
|
|
40
43
|
terms: FastUSDCTermsShape,
|
|
41
44
|
oracles: M.recordOf(M.string(), M.string()),
|
|
42
45
|
feeConfig: FeeConfigShape,
|
|
43
46
|
feedPolicy: FeedPolicyShape,
|
|
47
|
+
chainInfo: M.recordOf(M.string(), CosmosChainInfoShape),
|
|
48
|
+
assetInfo: M.arrayOf([DenomShape, DenomDetailShape]),
|
|
44
49
|
});
|
|
45
50
|
|
|
46
51
|
/**
|
|
@@ -80,6 +85,7 @@ const publishDisplayInfo = async (brand, { board, chainStorage }) => {
|
|
|
80
85
|
};
|
|
81
86
|
|
|
82
87
|
const FEED_POLICY = 'feedPolicy';
|
|
88
|
+
const POOL_METRICS = 'poolMetrics';
|
|
83
89
|
|
|
84
90
|
/**
|
|
85
91
|
* @param {ERef<StorageNode>} node
|
|
@@ -117,6 +123,7 @@ export const startFastUSDC = async (
|
|
|
117
123
|
consume: {
|
|
118
124
|
agoricNames,
|
|
119
125
|
namesByAddress,
|
|
126
|
+
bankManager,
|
|
120
127
|
board,
|
|
121
128
|
chainStorage,
|
|
122
129
|
chainTimerService: timerService,
|
|
@@ -149,8 +156,8 @@ export const startFastUSDC = async (
|
|
|
149
156
|
USDC: await E(USDCissuer).getBrand(),
|
|
150
157
|
});
|
|
151
158
|
|
|
152
|
-
const { terms, oracles, feeConfig, feedPolicy } = fromExternalConfig(
|
|
153
|
-
config
|
|
159
|
+
const { terms, oracles, feeConfig, feedPolicy, ...net } = fromExternalConfig(
|
|
160
|
+
config.options,
|
|
154
161
|
brands,
|
|
155
162
|
FastUSDCConfigShape,
|
|
156
163
|
);
|
|
@@ -177,6 +184,7 @@ export const startFastUSDC = async (
|
|
|
177
184
|
chainStorage,
|
|
178
185
|
},
|
|
179
186
|
);
|
|
187
|
+
const poolMetricsNode = await E(storageNode).makeChildNode(POOL_METRICS);
|
|
180
188
|
|
|
181
189
|
const privateArgs = await deeplyFulfilledObject(
|
|
182
190
|
harden({
|
|
@@ -184,9 +192,12 @@ export const startFastUSDC = async (
|
|
|
184
192
|
feeConfig,
|
|
185
193
|
localchain,
|
|
186
194
|
orchestrationService: cosmosInterchainService,
|
|
195
|
+
poolMetricsNode,
|
|
187
196
|
storageNode,
|
|
188
197
|
timerService,
|
|
189
198
|
marshaller,
|
|
199
|
+
chainInfo: net.chainInfo,
|
|
200
|
+
assetInfo: net.assetInfo,
|
|
190
201
|
}),
|
|
191
202
|
);
|
|
192
203
|
|
|
@@ -203,13 +214,23 @@ export const startFastUSDC = async (
|
|
|
203
214
|
await publishFeedPolicy(storageNode, feedPolicy);
|
|
204
215
|
|
|
205
216
|
const {
|
|
206
|
-
issuers:
|
|
217
|
+
issuers: fastUsdcIssuers,
|
|
207
218
|
brands: { PoolShares: shareBrand },
|
|
208
219
|
} = await E(zoe).getTerms(instance);
|
|
220
|
+
/** @type {{ PoolShares: Issuer<'nat'> }} */
|
|
221
|
+
// @ts-expect-error see zcf.makeZCFMint(...) in fast-usdc.contract.js
|
|
222
|
+
const { PoolShares: shareIssuer } = fastUsdcIssuers;
|
|
209
223
|
produceShareIssuer.resolve(shareIssuer);
|
|
210
224
|
produceShareBrand.resolve(shareBrand);
|
|
211
225
|
await publishDisplayInfo(shareBrand, { board, chainStorage });
|
|
212
226
|
|
|
227
|
+
const { denom, issuerName } = ShareAssetInfo;
|
|
228
|
+
trace('addAsset', denom, shareBrand);
|
|
229
|
+
await E(bankManager).addAsset(denom, issuerName, issuerName, {
|
|
230
|
+
issuer: shareIssuer,
|
|
231
|
+
brand: shareBrand,
|
|
232
|
+
});
|
|
233
|
+
|
|
213
234
|
await Promise.all(
|
|
214
235
|
Object.entries(oracleDepositFacets).map(async ([name, depositFacet]) => {
|
|
215
236
|
const address = oracles[name];
|
|
@@ -223,6 +244,13 @@ export const startFastUSDC = async (
|
|
|
223
244
|
|
|
224
245
|
produceInstance.reset();
|
|
225
246
|
produceInstance.resolve(instance);
|
|
247
|
+
|
|
248
|
+
const addresses = await E(kit.creatorFacet).publishAddresses();
|
|
249
|
+
trace('contract orch account addresses', addresses);
|
|
250
|
+
if (!net.noNoble) {
|
|
251
|
+
const addr = await E(kit.creatorFacet).connectToNoble();
|
|
252
|
+
trace('noble intermediate recipient', addr);
|
|
253
|
+
}
|
|
226
254
|
trace('startFastUSDC done', instance);
|
|
227
255
|
};
|
|
228
256
|
harden(startFastUSDC);
|
|
@@ -248,6 +276,8 @@ export const getManifestForFastUSDC = (
|
|
|
248
276
|
fastUsdcKit: true,
|
|
249
277
|
},
|
|
250
278
|
consume: {
|
|
279
|
+
bankManager: true, // to add FastLP as vbank asset
|
|
280
|
+
|
|
251
281
|
chainStorage: true,
|
|
252
282
|
chainTimerService: true,
|
|
253
283
|
localchain: true,
|