diff --git a/packages/fast-usdc/src/fast-usdc.contract.js b/packages/fast-usdc/src/fast-usdc.contract.js index 0d838534184..952d26480d1 100644 --- a/packages/fast-usdc/src/fast-usdc.contract.js +++ b/packages/fast-usdc/src/fast-usdc.contract.js @@ -71,14 +71,28 @@ export const contract = async (zcf, privateArgs, zone, tools) => { const terms = zcf.getTerms(); assert('USDC' in terms.brands, 'no USDC brand'); assert('usdcDenom' in terms, 'no usdcDenom'); + const { feeConfig, marshaller } = privateArgs; const { makeRecorderKit } = prepareRecorderKitMakers( zone.mapStore('vstorage'), marshaller, ); + const statusManager = prepareStatusManager(zone); - const makeSettler = prepareSettler(zone, { statusManager }); + + const { USDC } = terms.brands; + const { withdrawToSeat } = tools.zoeTools; const { chainHub, orchestrateAll, vowTools } = tools; + const makeSettler = prepareSettler(zone, { + statusManager, + USDC, + withdrawToSeat, + feeConfig, + vowTools: tools.vowTools, + zcf, + chainHub, + }); + const { localTransfer } = makeZoeTools(zcf, vowTools); const makeAdvancer = prepareAdvancer(zone, { chainHub, @@ -92,8 +106,10 @@ export const contract = async (zcf, privateArgs, zone, tools) => { vowTools, zcf, }); + const makeFeedKit = prepareTransactionFeedKit(zone, zcf); assertAllDefined({ makeFeedKit, makeAdvancer, makeSettler, statusManager }); + const makeLiquidityPoolKit = prepareLiquidityPoolKit( zone, zcf, @@ -111,7 +127,6 @@ export const contract = async (zcf, privateArgs, zone, tools) => { const creatorFacet = zone.exo('Fast USDC Creator', undefined, { /** @type {(operatorId: string) => Promise>} */ async makeOperatorInvitation(operatorId) { - // eslint-disable-next-line no-use-before-define return feedKit.creator.makeOperatorInvitation(operatorId); }, /** @@ -157,7 +172,6 @@ export const contract = async (zcf, privateArgs, zone, tools) => { * @param {CctpTxEvidence} evidence */ makeTestPushInvitation(evidence) { - // eslint-disable-next-line no-use-before-define void advancer.handleTransactionEvent(evidence); return makeTestInvitation(); }, @@ -200,18 +214,27 @@ export const contract = async (zcf, privateArgs, zone, tools) => { const feedKit = zone.makeOnce('Feed Kit', () => makeFeedKit()); - const poolAccountV = - // cast to HostInterface - /** @type { Vow>>} */ ( - /** @type {unknown}*/ ( - zone.makeOnce('Pool Local Orch Account', () => makeLocalAccount()) - ) - ); - const poolAccount = await vowTools.when(poolAccountV); + const poolAccountV = zone.makeOnce('PoolAccount', () => makeLocalAccount()); + const settleAccountV = zone.makeOnce('SettleAccount', () => + makeLocalAccount(), + ); + // when() is OK here since this clearly resolves promptly. + /** @type {HostInterface>[]} */ + const [poolAccount, settlementAccount] = await vowTools.when( + vowTools.all([poolAccountV, settleAccountV]), + ); + + const settlerKit = makeSettler({ + repayer: poolKit.repayer, + sourceChannel: 'channel-1234', // TODO: fix this as soon as testing needs it', + remoteDenom: 'uusdc', + settlementAccount, + }); const advancer = zone.makeOnce('Advancer', () => makeAdvancer({ borrowerFacet: poolKit.borrower, + notifyFacet: settlerKit.notify, poolAccount, }), ); @@ -226,6 +249,8 @@ export const contract = async (zcf, privateArgs, zone, tools) => { }, }); + await settlerKit.creator.monitorMintingDeposits(); + return harden({ creatorFacet, publicFacet }); }; harden(contract);