From 96ad41cdd7949ad2f02f3b440d9a0766eecab6c0 Mon Sep 17 00:00:00 2001 From: 0xPatrick Date: Thu, 21 Nov 2024 21:42:46 -0500 Subject: [PATCH] fix: fusdc contract integration - Advancer now relies on a Settler facet --- packages/fast-usdc/src/exos/liquidity-pool.js | 2 +- packages/fast-usdc/src/fast-usdc.contract.js | 45 ++++++++---------- .../snapshots/fast-usdc.contract.test.ts.md | 4 +- .../snapshots/fast-usdc.contract.test.ts.snap | Bin 2040 -> 2028 bytes 4 files changed, 22 insertions(+), 29 deletions(-) diff --git a/packages/fast-usdc/src/exos/liquidity-pool.js b/packages/fast-usdc/src/exos/liquidity-pool.js index b9eed94448b..d8b2991a4df 100644 --- a/packages/fast-usdc/src/exos/liquidity-pool.js +++ b/packages/fast-usdc/src/exos/liquidity-pool.js @@ -1,4 +1,4 @@ -import { AmountMath, AmountShape } from '@agoric/ertp'; +import { AmountMath } from '@agoric/ertp'; import { makeRecorderTopic, TopicsRecordShape, diff --git a/packages/fast-usdc/src/fast-usdc.contract.js b/packages/fast-usdc/src/fast-usdc.contract.js index 616d2b55680..735fbc28141 100644 --- a/packages/fast-usdc/src/fast-usdc.contract.js +++ b/packages/fast-usdc/src/fast-usdc.contract.js @@ -214,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, }), ); @@ -240,28 +249,12 @@ export const contract = async (zcf, privateArgs, zone, tools) => { }, }); - console.log('\n\n\nDEBUG making settlementAccount'); - - const settleAccountV = zone.makeOnce('settleAccount', () => - makeLocalAccount(), - ); - // when() is OK here since this clearly resolves promptly. - /** @type {Parameters[0]['settlementAccount']} */ - const settlementAccount = await tools.vowTools.when(settleAccountV); - console.log('DEBUG settlementAccount', settlementAccount.getAddress()); - const { creator: settlerCreator } = makeSettler({ - repayer: poolKit.repayer, - sourceChannel: 'channel-1234', // TODO: fix this as soon as testing needs it', - remoteDenom: 'uusdc', - settlementAccount, - }); - - console.log('DEBUG made settler', settlerCreator); + console.log('DEBUG made settler', settlerKit); // FIXME triggers a race in packet-tools, but it can't be called earlier and the only way to do it later is to have the // await settler.monitorMintingDeposits(); - await settlerCreator.monitorMintingDeposits(); + await settlerKit.creator.monitorMintingDeposits(); return harden({ creatorFacet, publicFacet }); }; diff --git a/packages/fast-usdc/test/snapshots/fast-usdc.contract.test.ts.md b/packages/fast-usdc/test/snapshots/fast-usdc.contract.test.ts.md index 9bf2c42a7f4..e508daf0f99 100644 --- a/packages/fast-usdc/test/snapshots/fast-usdc.contract.test.ts.md +++ b/packages/fast-usdc/test/snapshots/fast-usdc.contract.test.ts.md @@ -82,8 +82,9 @@ Generated by [AVA](https://avajs.dev). 'Liquidity Pool_kindHandle': 'Alleged: kind', 'Operator Kit_kindHandle': 'Alleged: kind', PendingTxs: {}, - 'Pool Local Orch Account': 'Vow', + PoolAccount: 'Vow', SeenTxs: [], + SettleAccount: 'Vow', mint: { PoolShare: 'Alleged: zcfMint', }, @@ -94,7 +95,6 @@ Generated by [AVA](https://avajs.dev). }, }, pending: {}, - settleAccount: 'Vow', vstorage: { 'Durable Publish Kit_kindHandle': 'Alleged: kind', Recorder_kindHandle: 'Alleged: kind', diff --git a/packages/fast-usdc/test/snapshots/fast-usdc.contract.test.ts.snap b/packages/fast-usdc/test/snapshots/fast-usdc.contract.test.ts.snap index 2e31c836d9b53624ec82433bbbaf021f4fcf9ac1..5428f409065f1cc146eb00cb8b3eb4e35d236f29 100644 GIT binary patch literal 2028 zcmVvcwNkkfn+)z#oeU00000000BUSzU-ER~7zl|Nl()O#jSJ_sq`rW;eSUji9TDdCFvVhS}^+ zcCxcSh>F~#1``qpf)7FTLGeWl z5my9J5VxzkYHr=?X{W~r=ViLv*QubNtp6mAGzNbpLo(|CE(5p&;0*wO1n_SF3k3K$0V*U_BB?9Q&oNC9 z5`3JQnE@$)q(P=pA+aingCt92`9ja8O_MdYdQH=Cb{m%r@!7Uv=^ND2P3FT2E2ha> zOn;;?kSQFMt4!mz&g>&7775uTfG^HcXW!D+P2P7!&r70=wo46bqt|pLe-25wC2Xn* zS7OBuBn573yUYAjhUCAT1iqF8ewqaSl?2YDfJalnr&GWeQ^2z+;MXZ&IjvBo zRjQhn28=ZDavJz+8aST;ZfAg>-TzOrz-AWsMizJ{3w$&OJdp!f4)}Twcs&Os^T4S* zu#pF79(XzrJf8=CoCkiB2mY22z&8uPO9h4E zL6su?Mge&HKD=B6nnmD+BJlenur#fxejsv6r<4;`ThTj)wc?+ZNe}3PqV5=0%VdIE zK43o34kHzw>SM;hN`qUITClX1vrQ)Gpw6gC?aL=Mw6-m%V3YV+B!o+rRlS86~K^qmz;Uk!|ylNK}jlNTg=i8t95P9QHb*cYgROk_blN*i{BXbn9CAH zdYdsTs$cL>UvJOf?r62%q>T7o3^~m zD5F^Xp;hj5xYM{IlQ)JAG&Z<-wC+5_`OsyqQS%VWV~h!lE}vWB*QrMJi93t=15+li zfJ;|dhYL2@^7m8dFLGG5&}}uEeCqFs$8@zwf63n)!=^W#v%)0Ad7l!E^ zEl8%c-*sDdOlkizB=&R}xKma}khn6vc+%vGZPR^{@IOsYPX{tzGd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