@agoric/fast-usdc 0.1.1-dev-3cbd11f.0 → 0.1.1-dev-4b5dff2.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 +9 -16
- package/src/cli/operator-commands.js +1 -4
- package/src/operator-kit-interface.js +29 -0
- package/src/pool-share-math.js +1 -1
- package/src/type-guards.js +2 -2
- package/src/types.ts +5 -3
- package/src/utils/fees.js +16 -1
- package/tools/mock-evidence.ts +141 -0
- package/src/add-operators.core.js +0 -63
- package/src/distribute-fees.core.js +0 -93
- package/src/exos/advancer.js +0 -375
- package/src/exos/liquidity-pool.js +0 -404
- package/src/exos/operator-kit.js +0 -124
- package/src/exos/settler.js +0 -405
- package/src/exos/status-manager.js +0 -422
- package/src/exos/transaction-feed.js +0 -275
- package/src/fast-usdc-policy.core.js +0 -65
- package/src/fast-usdc.contract.js +0 -338
- package/src/fast-usdc.flows.js +0 -23
- package/src/start-fast-usdc.core.js +0 -253
- package/src/update-fee-config.core.js +0 -99
- package/src/update-noble-ica.core.js +0 -164
- package/src/update-settler-reference.core.js +0 -67
- package/src/utils/chain-policies.js +0 -151
- package/src/utils/config-marshal.js +0 -130
- package/src/utils/core-eval.js +0 -73
- package/src/utils/deploy-config.js +0 -123
- package/src/utils/store.js +0 -117
- package/src/utils/zoe.js +0 -28
|
@@ -1,65 +0,0 @@
|
|
|
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
|
-
import { publishFeedPolicy } from './utils/core-eval.js';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @import {Issuer} from '@agoric/ertp';
|
|
10
|
-
* @import {Passable} from '@endo/pass-style'
|
|
11
|
-
* @import {BootstrapManifest} from '@agoric/vats/src/core/lib-boot.js'
|
|
12
|
-
* @import {LegibleCapData} from './utils/config-marshal.js'
|
|
13
|
-
* @import {FeedPolicy} from './types.js'
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
const contractName = 'fastUsdc';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @param {BootstrapPowers &
|
|
20
|
-
* { consume: { chainStorage: Promise<StorageNode> }}
|
|
21
|
-
* } powers
|
|
22
|
-
* @param {{ options: LegibleCapData<{feedPolicy: FeedPolicy & Passable}> }} config
|
|
23
|
-
*/
|
|
24
|
-
export const updateFastUsdcPolicy = async (
|
|
25
|
-
{ consume: { agoricNames, chainStorage } },
|
|
26
|
-
config,
|
|
27
|
-
) => {
|
|
28
|
-
/** @type {Issuer<'nat'>} */
|
|
29
|
-
const USDCissuer = await E(agoricNames).lookup('issuer', 'USDC');
|
|
30
|
-
const brands = harden({
|
|
31
|
-
USDC: await E(USDCissuer).getBrand(),
|
|
32
|
-
});
|
|
33
|
-
const { feedPolicy } = fromExternalConfig(
|
|
34
|
-
config.options,
|
|
35
|
-
brands,
|
|
36
|
-
harden({ feedPolicy: FeedPolicyShape }),
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
const storageNode = await E(chainStorage).makeChildNode(contractName);
|
|
40
|
-
|
|
41
|
-
await publishFeedPolicy(storageNode, feedPolicy);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* @param {unknown} _utils
|
|
46
|
-
* @param {{
|
|
47
|
-
* options: LegibleCapData<{feedPolicy: FeedPolicy & Passable}>;
|
|
48
|
-
* }} param1
|
|
49
|
-
*/
|
|
50
|
-
export const getManifestForUpdateFastUsdcPolicy = (_utils, { options }) => {
|
|
51
|
-
return {
|
|
52
|
-
/** @type {BootstrapManifest} */
|
|
53
|
-
manifest: {
|
|
54
|
-
[updateFastUsdcPolicy.name]: {
|
|
55
|
-
consume: {
|
|
56
|
-
chainStorage: true,
|
|
57
|
-
|
|
58
|
-
// widely shared: name services
|
|
59
|
-
agoricNames: true,
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
options,
|
|
64
|
-
};
|
|
65
|
-
};
|
|
@@ -1,338 +0,0 @@
|
|
|
1
|
-
import { AssetKind } from '@agoric/ertp';
|
|
2
|
-
import { makeTracer } from '@agoric/internal';
|
|
3
|
-
import { observeIteration, subscribeEach } from '@agoric/notifier';
|
|
4
|
-
import {
|
|
5
|
-
CosmosChainInfoShape,
|
|
6
|
-
DenomDetailShape,
|
|
7
|
-
DenomShape,
|
|
8
|
-
OrchestrationPowersShape,
|
|
9
|
-
registerChainsAndAssets,
|
|
10
|
-
withOrchestration,
|
|
11
|
-
} from '@agoric/orchestration';
|
|
12
|
-
import { makeZoeTools } from '@agoric/orchestration/src/utils/zoe-tools.js';
|
|
13
|
-
import { provideSingleton } from '@agoric/zoe/src/contractSupport/durability.js';
|
|
14
|
-
import { prepareRecorderKitMakers } from '@agoric/zoe/src/contractSupport/recorder.js';
|
|
15
|
-
import { Fail } from '@endo/errors';
|
|
16
|
-
import { E } from '@endo/far';
|
|
17
|
-
import { M } from '@endo/patterns';
|
|
18
|
-
import { prepareAdvancer } from './exos/advancer.js';
|
|
19
|
-
import { prepareLiquidityPoolKit } from './exos/liquidity-pool.js';
|
|
20
|
-
import { prepareSettler } from './exos/settler.js';
|
|
21
|
-
import { prepareStatusManager } from './exos/status-manager.js';
|
|
22
|
-
import { prepareTransactionFeedKit } from './exos/transaction-feed.js';
|
|
23
|
-
import * as flows from './fast-usdc.flows.js';
|
|
24
|
-
import { FastUSDCTermsShape, FeeConfigShape } from './type-guards.js';
|
|
25
|
-
|
|
26
|
-
const trace = makeTracer('FastUsdc');
|
|
27
|
-
|
|
28
|
-
const TXNS_NODE = 'txns';
|
|
29
|
-
const FEE_NODE = 'feeConfig';
|
|
30
|
-
const ADDRESSES_BAGGAGE_KEY = 'addresses';
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* @import {HostInterface} from '@agoric/async-flow';
|
|
34
|
-
* @import {CosmosChainInfo, Denom, DenomDetail, OrchestrationAccount, IBCConnectionInfo} from '@agoric/orchestration';
|
|
35
|
-
* @import {OrchestrationPowers, OrchestrationTools} from '@agoric/orchestration/src/utils/start-helper.js';
|
|
36
|
-
* @import {Remote} from '@agoric/internal';
|
|
37
|
-
* @import {Marshaller, StorageNode} from '@agoric/internal/src/lib-chainStorage.js'
|
|
38
|
-
* @import {Zone} from '@agoric/zone';
|
|
39
|
-
* @import {OperatorOfferResult} from './exos/transaction-feed.js';
|
|
40
|
-
* @import {ContractRecord, FeeConfig} from './types.js';
|
|
41
|
-
*/
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* @typedef {{
|
|
45
|
-
* usdcDenom: Denom;
|
|
46
|
-
* }} FastUsdcTerms
|
|
47
|
-
*/
|
|
48
|
-
|
|
49
|
-
/** @type {ContractMeta<typeof start>} */
|
|
50
|
-
export const meta = {
|
|
51
|
-
// @ts-expect-error TypedPattern not recognized as record
|
|
52
|
-
customTermsShape: FastUSDCTermsShape,
|
|
53
|
-
privateArgsShape: {
|
|
54
|
-
// @ts-expect-error TypedPattern not recognized as record
|
|
55
|
-
...OrchestrationPowersShape,
|
|
56
|
-
assetInfo: M.arrayOf([DenomShape, DenomDetailShape]),
|
|
57
|
-
chainInfo: M.recordOf(M.string(), CosmosChainInfoShape),
|
|
58
|
-
feeConfig: FeeConfigShape,
|
|
59
|
-
marshaller: M.remotable(),
|
|
60
|
-
poolMetricsNode: M.remotable(),
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
harden(meta);
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* @param {Remote<StorageNode>} node
|
|
67
|
-
* @param {ERef<Marshaller>} marshaller
|
|
68
|
-
* @param {FeeConfig} feeConfig
|
|
69
|
-
*/
|
|
70
|
-
const publishFeeConfig = (node, marshaller, feeConfig) => {
|
|
71
|
-
const feeNode = E(node).makeChildNode(FEE_NODE);
|
|
72
|
-
void E.when(E(marshaller).toCapData(feeConfig), value =>
|
|
73
|
-
E(feeNode).setValue(JSON.stringify(value)),
|
|
74
|
-
);
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* @param {Remote<StorageNode>} contractNode
|
|
79
|
-
* @param {ContractRecord} addresses
|
|
80
|
-
*/
|
|
81
|
-
const publishAddresses = (contractNode, addresses) => {
|
|
82
|
-
return E(contractNode).setValue(JSON.stringify(addresses));
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* @param {ZCF<FastUsdcTerms>} zcf
|
|
87
|
-
* @param {OrchestrationPowers & {
|
|
88
|
-
* assetInfo: [Denom, DenomDetail & { brandKey?: string}][];
|
|
89
|
-
* chainInfo: Record<string, CosmosChainInfo>;
|
|
90
|
-
* feeConfig: FeeConfig;
|
|
91
|
-
* marshaller: Marshaller;
|
|
92
|
-
* poolMetricsNode: Remote<StorageNode>;
|
|
93
|
-
* storageNode: Remote<StorageNode>;
|
|
94
|
-
* }} privateArgs
|
|
95
|
-
* @param {Zone} zone
|
|
96
|
-
* @param {OrchestrationTools} tools
|
|
97
|
-
*/
|
|
98
|
-
export const contract = async (zcf, privateArgs, zone, tools) => {
|
|
99
|
-
assert(tools, 'no tools');
|
|
100
|
-
const terms = zcf.getTerms();
|
|
101
|
-
assert('USDC' in terms.brands, 'no USDC brand');
|
|
102
|
-
assert('usdcDenom' in terms, 'no usdcDenom');
|
|
103
|
-
|
|
104
|
-
const { feeConfig, marshaller, storageNode } = privateArgs;
|
|
105
|
-
const { makeRecorderKit } = prepareRecorderKitMakers(
|
|
106
|
-
zone.mapStore('vstorage'),
|
|
107
|
-
marshaller,
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
const statusManager = prepareStatusManager(
|
|
111
|
-
zone,
|
|
112
|
-
E(storageNode).makeChildNode(TXNS_NODE),
|
|
113
|
-
{ marshaller },
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
const { USDC } = terms.brands;
|
|
117
|
-
const { withdrawToSeat } = tools.zoeTools;
|
|
118
|
-
const { baggage, chainHub, orchestrateAll, vowTools } = tools;
|
|
119
|
-
const makeSettler = prepareSettler(zone, {
|
|
120
|
-
statusManager,
|
|
121
|
-
USDC,
|
|
122
|
-
withdrawToSeat,
|
|
123
|
-
feeConfig,
|
|
124
|
-
vowTools: tools.vowTools,
|
|
125
|
-
zcf,
|
|
126
|
-
chainHub,
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
const zoeTools = makeZoeTools(zcf, vowTools);
|
|
130
|
-
const makeAdvancer = prepareAdvancer(zone, {
|
|
131
|
-
chainHub,
|
|
132
|
-
feeConfig,
|
|
133
|
-
usdc: harden({
|
|
134
|
-
brand: terms.brands.USDC,
|
|
135
|
-
denom: terms.usdcDenom,
|
|
136
|
-
}),
|
|
137
|
-
statusManager,
|
|
138
|
-
vowTools,
|
|
139
|
-
zcf,
|
|
140
|
-
zoeTools,
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
const makeFeedKit = prepareTransactionFeedKit(zone, zcf);
|
|
144
|
-
|
|
145
|
-
const makeLiquidityPoolKit = prepareLiquidityPoolKit(
|
|
146
|
-
zone,
|
|
147
|
-
zcf,
|
|
148
|
-
terms.brands.USDC,
|
|
149
|
-
{ makeRecorderKit },
|
|
150
|
-
);
|
|
151
|
-
|
|
152
|
-
const { makeLocalAccount, makeNobleAccount } = orchestrateAll(flows, {});
|
|
153
|
-
|
|
154
|
-
const creatorFacet = zone.exo('Fast USDC Creator', undefined, {
|
|
155
|
-
/** @type {(operatorId: string) => Promise<Invitation<OperatorOfferResult>>} */
|
|
156
|
-
async makeOperatorInvitation(operatorId) {
|
|
157
|
-
return feedKit.creator.makeOperatorInvitation(operatorId);
|
|
158
|
-
},
|
|
159
|
-
/** @type {(operatorId: string) => void} */
|
|
160
|
-
removeOperator(operatorId) {
|
|
161
|
-
return feedKit.creator.removeOperator(operatorId);
|
|
162
|
-
},
|
|
163
|
-
async getContractFeeBalance() {
|
|
164
|
-
return poolKit.feeRecipient.getContractFeeBalance();
|
|
165
|
-
},
|
|
166
|
-
/** @type {() => Promise<Invitation<unknown>>} */
|
|
167
|
-
async makeWithdrawFeesInvitation() {
|
|
168
|
-
return poolKit.feeRecipient.makeWithdrawFeesInvitation();
|
|
169
|
-
},
|
|
170
|
-
/**
|
|
171
|
-
* @param {string} [agoricChainId]
|
|
172
|
-
* @param {string} [nobleChainId]
|
|
173
|
-
* @param {IBCConnectionInfo} [agoricToNoble]
|
|
174
|
-
*/
|
|
175
|
-
async connectToNoble(agoricChainId, nobleChainId, agoricToNoble) {
|
|
176
|
-
const shouldUpdate = agoricChainId && nobleChainId && agoricToNoble;
|
|
177
|
-
if (shouldUpdate) {
|
|
178
|
-
trace('connectToNoble', agoricChainId, nobleChainId, agoricToNoble);
|
|
179
|
-
chainHub.updateConnection(agoricChainId, nobleChainId, agoricToNoble);
|
|
180
|
-
}
|
|
181
|
-
const nobleICALabel = `NobleICA-${(shouldUpdate ? agoricToNoble : agToNoble).counterparty.connection_id}`;
|
|
182
|
-
trace('NobleICA', nobleICALabel);
|
|
183
|
-
// v1 has `NobleAccount` which we don't expect to ever settle.
|
|
184
|
-
// v2 has `NobleICA-connection-38` which will be settled/cached when v3 starts
|
|
185
|
-
const nobleAccountV = zone.makeOnce(nobleICALabel, () =>
|
|
186
|
-
makeNobleAccount(),
|
|
187
|
-
);
|
|
188
|
-
|
|
189
|
-
return vowTools.when(nobleAccountV, nobleAccount => {
|
|
190
|
-
trace('nobleAccount', nobleAccount);
|
|
191
|
-
return vowTools.when(
|
|
192
|
-
E(nobleAccount).getAddress(),
|
|
193
|
-
intermediateRecipient => {
|
|
194
|
-
trace('intermediateRecipient', intermediateRecipient);
|
|
195
|
-
advancer.setIntermediateRecipient(intermediateRecipient);
|
|
196
|
-
settlerKit.creator.setIntermediateRecipient(intermediateRecipient);
|
|
197
|
-
return intermediateRecipient;
|
|
198
|
-
},
|
|
199
|
-
);
|
|
200
|
-
});
|
|
201
|
-
},
|
|
202
|
-
async publishAddresses() {
|
|
203
|
-
!baggage.has(ADDRESSES_BAGGAGE_KEY) || Fail`Addresses already published`;
|
|
204
|
-
const [poolAccountAddress] = await vowTools.when(
|
|
205
|
-
vowTools.all([E(poolAccount).getAddress()]),
|
|
206
|
-
);
|
|
207
|
-
const addresses = harden({
|
|
208
|
-
poolAccount: poolAccountAddress.value,
|
|
209
|
-
settlementAccount: settlementAddress.value,
|
|
210
|
-
});
|
|
211
|
-
baggage.init(ADDRESSES_BAGGAGE_KEY, addresses);
|
|
212
|
-
await publishAddresses(storageNode, addresses);
|
|
213
|
-
return addresses;
|
|
214
|
-
},
|
|
215
|
-
deleteCompletedTxs() {
|
|
216
|
-
return statusManager.deleteCompletedTxs();
|
|
217
|
-
},
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
const publicFacet = zone.exo('Fast USDC Public', undefined, {
|
|
221
|
-
makeDepositInvitation() {
|
|
222
|
-
return poolKit.public.makeDepositInvitation();
|
|
223
|
-
},
|
|
224
|
-
makeWithdrawInvitation() {
|
|
225
|
-
return poolKit.public.makeWithdrawInvitation();
|
|
226
|
-
},
|
|
227
|
-
getPublicTopics() {
|
|
228
|
-
return poolKit.public.getPublicTopics();
|
|
229
|
-
},
|
|
230
|
-
getStaticInfo() {
|
|
231
|
-
baggage.has(ADDRESSES_BAGGAGE_KEY) ||
|
|
232
|
-
Fail`no addresses. creator must 'publishAddresses' first`;
|
|
233
|
-
/** @type {ContractRecord} */
|
|
234
|
-
const addresses = baggage.get(ADDRESSES_BAGGAGE_KEY);
|
|
235
|
-
return harden({
|
|
236
|
-
[ADDRESSES_BAGGAGE_KEY]: addresses,
|
|
237
|
-
});
|
|
238
|
-
},
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
// ^^^ Define all kinds above this line. Keep remote calls below. vvv
|
|
242
|
-
|
|
243
|
-
// NOTE: Using a ZCFMint is helpful for the usual reasons (
|
|
244
|
-
// synchronous mint/burn, keeping assets out of contract vats, ...).
|
|
245
|
-
// And there's just one pool, which suggests building it with zone.exo().
|
|
246
|
-
//
|
|
247
|
-
// But zone.exo() defines a kind and
|
|
248
|
-
// all kinds have to be defined before any remote calls,
|
|
249
|
-
// such as the one to the zoe vat as part of making a ZCFMint.
|
|
250
|
-
//
|
|
251
|
-
// So we use zone.exoClassKit above to define the liquidity pool kind
|
|
252
|
-
// and pass the shareMint into the maker / init function.
|
|
253
|
-
|
|
254
|
-
publishFeeConfig(storageNode, marshaller, feeConfig);
|
|
255
|
-
|
|
256
|
-
const shareMint = await provideSingleton(
|
|
257
|
-
zone.mapStore('mint'),
|
|
258
|
-
'PoolShare',
|
|
259
|
-
() =>
|
|
260
|
-
zcf.makeZCFMint('PoolShares', AssetKind.NAT, {
|
|
261
|
-
decimalPlaces: 6,
|
|
262
|
-
}),
|
|
263
|
-
);
|
|
264
|
-
|
|
265
|
-
const poolKit = zone.makeOnce('Liquidity Pool kit', () =>
|
|
266
|
-
makeLiquidityPoolKit(shareMint, privateArgs.poolMetricsNode),
|
|
267
|
-
);
|
|
268
|
-
|
|
269
|
-
/** Chain, connection, and asset info can only be registered once */
|
|
270
|
-
const firstIncarnationKey = 'firstIncarnationKey';
|
|
271
|
-
if (!baggage.has(firstIncarnationKey)) {
|
|
272
|
-
baggage.init(firstIncarnationKey, true);
|
|
273
|
-
registerChainsAndAssets(
|
|
274
|
-
chainHub,
|
|
275
|
-
terms.brands,
|
|
276
|
-
privateArgs.chainInfo,
|
|
277
|
-
privateArgs.assetInfo,
|
|
278
|
-
);
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
const feedKit = zone.makeOnce('Feed Kit', () => makeFeedKit());
|
|
282
|
-
|
|
283
|
-
const poolAccountV = zone.makeOnce('PoolAccount', () => makeLocalAccount());
|
|
284
|
-
const settleAccountV = zone.makeOnce('SettleAccount', () =>
|
|
285
|
-
makeLocalAccount(),
|
|
286
|
-
);
|
|
287
|
-
// when() is OK here since this clearly resolves promptly.
|
|
288
|
-
/** @type {[HostInterface<OrchestrationAccount<{chainId: 'agoric-3';}>>, HostInterface<OrchestrationAccount<{chainId: 'agoric-3';}>>]} */
|
|
289
|
-
const [poolAccount, settlementAccount] = await vowTools.when(
|
|
290
|
-
vowTools.all([poolAccountV, settleAccountV]),
|
|
291
|
-
);
|
|
292
|
-
trace('settlementAccount', settlementAccount);
|
|
293
|
-
trace('poolAccount', poolAccount);
|
|
294
|
-
const settlementAddress = await E(settlementAccount).getAddress();
|
|
295
|
-
trace('settlementAddress', settlementAddress);
|
|
296
|
-
|
|
297
|
-
const [_agoric, _noble, agToNoble] = await vowTools.when(
|
|
298
|
-
chainHub.getChainsAndConnection('agoric', 'noble'),
|
|
299
|
-
);
|
|
300
|
-
const settlerKit = zone.makeOnce('settlerKit', () =>
|
|
301
|
-
makeSettler({
|
|
302
|
-
repayer: poolKit.repayer,
|
|
303
|
-
sourceChannel: agToNoble.transferChannel.counterPartyChannelId,
|
|
304
|
-
remoteDenom: 'uusdc',
|
|
305
|
-
settlementAccount,
|
|
306
|
-
}),
|
|
307
|
-
);
|
|
308
|
-
|
|
309
|
-
// we create a new Advancer on every upgrade. It does not contain precious state, but on each
|
|
310
|
-
// upgrade we must remember to call `advancer.setIntermediateRecipient()`
|
|
311
|
-
// XXX delete `Advancer` that still may remain in zone after `update-settler-reference.core.js`
|
|
312
|
-
const advancer = makeAdvancer({
|
|
313
|
-
borrower: poolKit.borrower,
|
|
314
|
-
notifier: settlerKit.notifier,
|
|
315
|
-
poolAccount,
|
|
316
|
-
settlementAddress,
|
|
317
|
-
});
|
|
318
|
-
|
|
319
|
-
// Connect evidence stream to advancer
|
|
320
|
-
void observeIteration(subscribeEach(feedKit.public.getEvidenceSubscriber()), {
|
|
321
|
-
updateState(evidenceWithRisk) {
|
|
322
|
-
try {
|
|
323
|
-
void advancer.handleTransactionEvent(evidenceWithRisk);
|
|
324
|
-
} catch (err) {
|
|
325
|
-
trace('🚨 Error handling transaction event', err);
|
|
326
|
-
}
|
|
327
|
-
},
|
|
328
|
-
});
|
|
329
|
-
|
|
330
|
-
await settlerKit.creator.monitorMintingDeposits();
|
|
331
|
-
|
|
332
|
-
return harden({ creatorFacet, publicFacet });
|
|
333
|
-
};
|
|
334
|
-
harden(contract);
|
|
335
|
-
|
|
336
|
-
export const start = withOrchestration(contract);
|
|
337
|
-
harden(start);
|
|
338
|
-
/** @typedef {typeof start} FastUsdcSF */
|
package/src/fast-usdc.flows.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @import {Orchestrator, OrchestrationFlow} from '@agoric/orchestration';
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @satisfies {OrchestrationFlow}
|
|
7
|
-
* @param {Orchestrator} orch
|
|
8
|
-
*/
|
|
9
|
-
export const makeLocalAccount = async orch => {
|
|
10
|
-
const agoricChain = await orch.getChain('agoric');
|
|
11
|
-
return agoricChain.makeAccount();
|
|
12
|
-
};
|
|
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);
|
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
import { deeplyFulfilledObject, makeTracer } from '@agoric/internal';
|
|
2
|
-
import { E } from '@endo/far';
|
|
3
|
-
import { FastUSDCConfigShape } from './type-guards.js';
|
|
4
|
-
import { fromExternalConfig } from './utils/config-marshal.js';
|
|
5
|
-
import {
|
|
6
|
-
inviteOracles,
|
|
7
|
-
publishDisplayInfo,
|
|
8
|
-
publishFeedPolicy,
|
|
9
|
-
} from './utils/core-eval.js';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @import {Brand, Issuer} from '@agoric/ertp';
|
|
13
|
-
* @import {Instance, StartParams} from '@agoric/zoe/src/zoeService/utils.js'
|
|
14
|
-
* @import {Board} from '@agoric/vats'
|
|
15
|
-
* @import {ManifestBundleRef} from '@agoric/deploy-script-support/src/externalTypes.js'
|
|
16
|
-
* @import {BootstrapManifest} from '@agoric/vats/src/core/lib-boot.js'
|
|
17
|
-
* @import {LegibleCapData} from './utils/config-marshal.js'
|
|
18
|
-
* @import {FastUsdcSF} from './fast-usdc.contract.js'
|
|
19
|
-
* @import {FastUSDCConfig} from './types.js'
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
const ShareAssetInfo = /** @type {const} */ harden({
|
|
23
|
-
issuerName: 'FastLP',
|
|
24
|
-
denom: 'ufastlp',
|
|
25
|
-
assetKind: 'nat',
|
|
26
|
-
decimalPlaces: 6,
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
const trace = makeTracer('FUSD-Start', true);
|
|
30
|
-
|
|
31
|
-
const contractName = 'fastUsdc';
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* XXX Shouldn't the bridge or board vat handle this?
|
|
35
|
-
*
|
|
36
|
-
* @param {string} path
|
|
37
|
-
* @param {{
|
|
38
|
-
* chainStorage: ERef<StorageNode>;
|
|
39
|
-
* board: ERef<Board>;
|
|
40
|
-
* }} io
|
|
41
|
-
*/
|
|
42
|
-
const makePublishingStorageKit = async (path, { chainStorage, board }) => {
|
|
43
|
-
const storageNode = await E(chainStorage).makeChildNode(path);
|
|
44
|
-
|
|
45
|
-
const marshaller = await E(board).getPublishingMarshaller();
|
|
46
|
-
return { storageNode, marshaller };
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const POOL_METRICS = 'poolMetrics';
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* @typedef { PromiseSpaceOf<{
|
|
53
|
-
* fastUsdcKit: FastUSDCKit
|
|
54
|
-
* }> & {
|
|
55
|
-
* installation: PromiseSpaceOf<{ fastUsdc: Installation<FastUsdcSF> }>;
|
|
56
|
-
* instance: PromiseSpaceOf<{ fastUsdc: Instance<FastUsdcSF> }>;
|
|
57
|
-
* issuer: PromiseSpaceOf<{ FastLP: Issuer }>;
|
|
58
|
-
* brand: PromiseSpaceOf<{ FastLP: Brand }>;
|
|
59
|
-
* }} FastUSDCCorePowers
|
|
60
|
-
*
|
|
61
|
-
* @typedef {StartedInstanceKitWithLabel & {
|
|
62
|
-
* publicFacet: StartedInstanceKit<FastUsdcSF>['publicFacet'];
|
|
63
|
-
* creatorFacet: StartedInstanceKit<FastUsdcSF>['creatorFacet'];
|
|
64
|
-
* privateArgs: StartParams<FastUsdcSF>['privateArgs'];
|
|
65
|
-
* }} FastUSDCKit
|
|
66
|
-
*/
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* @throws if oracle smart wallets are not yet provisioned
|
|
70
|
-
*
|
|
71
|
-
* @param {BootstrapPowers & FastUSDCCorePowers } powers
|
|
72
|
-
* @param {{ options: LegibleCapData<FastUSDCConfig> }} config
|
|
73
|
-
*/
|
|
74
|
-
export const startFastUSDC = async (
|
|
75
|
-
{
|
|
76
|
-
produce: { fastUsdcKit },
|
|
77
|
-
consume: {
|
|
78
|
-
agoricNames,
|
|
79
|
-
namesByAddress,
|
|
80
|
-
bankManager,
|
|
81
|
-
board,
|
|
82
|
-
chainStorage,
|
|
83
|
-
chainTimerService: timerService,
|
|
84
|
-
localchain,
|
|
85
|
-
cosmosInterchainService,
|
|
86
|
-
startUpgradable,
|
|
87
|
-
zoe,
|
|
88
|
-
},
|
|
89
|
-
issuer: {
|
|
90
|
-
produce: { FastLP: produceShareIssuer },
|
|
91
|
-
},
|
|
92
|
-
brand: {
|
|
93
|
-
produce: { FastLP: produceShareBrand },
|
|
94
|
-
},
|
|
95
|
-
installation: {
|
|
96
|
-
consume: { fastUsdc },
|
|
97
|
-
},
|
|
98
|
-
instance: {
|
|
99
|
-
produce: { fastUsdc: produceInstance },
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
config,
|
|
103
|
-
) => {
|
|
104
|
-
trace('startFastUSDC');
|
|
105
|
-
|
|
106
|
-
await null;
|
|
107
|
-
/** @type {Issuer<'nat'>} */
|
|
108
|
-
const USDCissuer = await E(agoricNames).lookup('issuer', 'USDC');
|
|
109
|
-
const brands = harden({
|
|
110
|
-
USDC: await E(USDCissuer).getBrand(),
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
const { terms, oracles, feeConfig, feedPolicy, ...net } = fromExternalConfig(
|
|
114
|
-
config.options,
|
|
115
|
-
brands,
|
|
116
|
-
FastUSDCConfigShape,
|
|
117
|
-
);
|
|
118
|
-
trace('using terms', terms);
|
|
119
|
-
trace('using fee config', feeConfig);
|
|
120
|
-
|
|
121
|
-
const { storageNode, marshaller } = await makePublishingStorageKit(
|
|
122
|
-
contractName,
|
|
123
|
-
{
|
|
124
|
-
board,
|
|
125
|
-
// @ts-expect-error Promise<null> case is vestigial
|
|
126
|
-
chainStorage,
|
|
127
|
-
},
|
|
128
|
-
);
|
|
129
|
-
const poolMetricsNode = await E(storageNode).makeChildNode(POOL_METRICS);
|
|
130
|
-
|
|
131
|
-
const privateArgs = await deeplyFulfilledObject(
|
|
132
|
-
harden({
|
|
133
|
-
agoricNames,
|
|
134
|
-
feeConfig,
|
|
135
|
-
localchain,
|
|
136
|
-
orchestrationService: cosmosInterchainService,
|
|
137
|
-
poolMetricsNode,
|
|
138
|
-
storageNode,
|
|
139
|
-
timerService,
|
|
140
|
-
marshaller,
|
|
141
|
-
chainInfo: net.chainInfo,
|
|
142
|
-
assetInfo: net.assetInfo,
|
|
143
|
-
}),
|
|
144
|
-
);
|
|
145
|
-
|
|
146
|
-
const kit = await E(startUpgradable)({
|
|
147
|
-
label: contractName,
|
|
148
|
-
installation: fastUsdc,
|
|
149
|
-
issuerKeywordRecord: harden({ USDC: USDCissuer }),
|
|
150
|
-
terms,
|
|
151
|
-
privateArgs,
|
|
152
|
-
});
|
|
153
|
-
fastUsdcKit.resolve(harden({ ...kit, privateArgs }));
|
|
154
|
-
const { instance, creatorFacet } = kit;
|
|
155
|
-
|
|
156
|
-
await publishFeedPolicy(storageNode, feedPolicy);
|
|
157
|
-
|
|
158
|
-
const {
|
|
159
|
-
issuers: fastUsdcIssuers,
|
|
160
|
-
brands: { PoolShares: shareBrand },
|
|
161
|
-
} = await E(zoe).getTerms(instance);
|
|
162
|
-
/** @type {{ PoolShares: Issuer<'nat'> }} */
|
|
163
|
-
// @ts-expect-error see zcf.makeZCFMint(...) in fast-usdc.contract.js
|
|
164
|
-
const { PoolShares: shareIssuer } = fastUsdcIssuers;
|
|
165
|
-
produceShareIssuer.resolve(shareIssuer);
|
|
166
|
-
produceShareBrand.resolve(shareBrand);
|
|
167
|
-
await publishDisplayInfo(shareBrand, { board, chainStorage });
|
|
168
|
-
|
|
169
|
-
const { denom, issuerName } = ShareAssetInfo;
|
|
170
|
-
trace('addAsset', denom, shareBrand);
|
|
171
|
-
await E(bankManager).addAsset(denom, issuerName, issuerName, {
|
|
172
|
-
issuer: shareIssuer,
|
|
173
|
-
brand: shareBrand,
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
await inviteOracles({ creatorFacet, namesByAddress }, oracles);
|
|
177
|
-
|
|
178
|
-
produceInstance.reset();
|
|
179
|
-
produceInstance.resolve(instance);
|
|
180
|
-
|
|
181
|
-
const addresses = await E(kit.creatorFacet).publishAddresses();
|
|
182
|
-
trace('contract orch account addresses', addresses);
|
|
183
|
-
if (!net.noNoble) {
|
|
184
|
-
const { agoric, noble } = privateArgs.chainInfo;
|
|
185
|
-
const agoricToNoble = agoric.connections[noble.chainId];
|
|
186
|
-
const addr = await E(kit.creatorFacet).connectToNoble(
|
|
187
|
-
agoric.chainId,
|
|
188
|
-
noble.chainId,
|
|
189
|
-
agoricToNoble,
|
|
190
|
-
);
|
|
191
|
-
trace('noble intermediate recipient', addr);
|
|
192
|
-
}
|
|
193
|
-
trace('startFastUSDC done', instance);
|
|
194
|
-
};
|
|
195
|
-
harden(startFastUSDC);
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* @param {{
|
|
199
|
-
* restoreRef: (b: ERef<ManifestBundleRef>) => Promise<Installation>;
|
|
200
|
-
* }} utils
|
|
201
|
-
* @param {{
|
|
202
|
-
* installKeys: { fastUsdc: ERef<ManifestBundleRef> };
|
|
203
|
-
* options: LegibleCapData<FastUSDCConfig>;
|
|
204
|
-
* }} param1
|
|
205
|
-
*/
|
|
206
|
-
export const getManifestForFastUSDC = (
|
|
207
|
-
{ restoreRef },
|
|
208
|
-
{ installKeys, options },
|
|
209
|
-
) => {
|
|
210
|
-
return {
|
|
211
|
-
/** @type {BootstrapManifest} */
|
|
212
|
-
manifest: {
|
|
213
|
-
[startFastUSDC.name]: {
|
|
214
|
-
produce: {
|
|
215
|
-
fastUsdcKit: true,
|
|
216
|
-
},
|
|
217
|
-
consume: {
|
|
218
|
-
bankManager: true, // to add FastLP as vbank asset
|
|
219
|
-
|
|
220
|
-
chainStorage: true,
|
|
221
|
-
chainTimerService: true,
|
|
222
|
-
localchain: true,
|
|
223
|
-
cosmosInterchainService: true,
|
|
224
|
-
|
|
225
|
-
// limited distribution durin MN2: contract installation
|
|
226
|
-
startUpgradable: true,
|
|
227
|
-
zoe: true, // only getTerms() is needed. XXX should be split?
|
|
228
|
-
|
|
229
|
-
// widely shared: name services
|
|
230
|
-
agoricNames: true,
|
|
231
|
-
namesByAddress: true,
|
|
232
|
-
board: true,
|
|
233
|
-
},
|
|
234
|
-
issuer: {
|
|
235
|
-
produce: { FastLP: true },
|
|
236
|
-
},
|
|
237
|
-
brand: {
|
|
238
|
-
produce: { FastLP: true },
|
|
239
|
-
},
|
|
240
|
-
instance: {
|
|
241
|
-
produce: { fastUsdc: true },
|
|
242
|
-
},
|
|
243
|
-
installation: {
|
|
244
|
-
consume: { fastUsdc: true },
|
|
245
|
-
},
|
|
246
|
-
},
|
|
247
|
-
},
|
|
248
|
-
installations: {
|
|
249
|
-
fastUsdc: restoreRef(installKeys.fastUsdc),
|
|
250
|
-
},
|
|
251
|
-
options,
|
|
252
|
-
};
|
|
253
|
-
};
|