Skip to content

Commit

Permalink
chore(fast-usdc): update contract for exo APIs
Browse files Browse the repository at this point in the history
settler, advancer
  • Loading branch information
dckc committed Nov 23, 2024
1 parent 47d1373 commit 4c37d5d
Showing 1 changed file with 36 additions and 11 deletions.
47 changes: 36 additions & 11 deletions packages/fast-usdc/src/fast-usdc.contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -111,7 +127,6 @@ export const contract = async (zcf, privateArgs, zone, tools) => {
const creatorFacet = zone.exo('Fast USDC Creator', undefined, {
/** @type {(operatorId: string) => Promise<Invitation<OperatorKit>>} */
async makeOperatorInvitation(operatorId) {
// eslint-disable-next-line no-use-before-define
return feedKit.creator.makeOperatorInvitation(operatorId);
},
/**
Expand Down Expand Up @@ -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();
},
Expand Down Expand Up @@ -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<HostInterface<OrchestrationAccount<{chainId: 'agoric';}>>>} */ (
/** @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<OrchestrationAccount<{chainId: 'agoric';}>>[]} */
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,
}),
);
Expand All @@ -226,6 +249,8 @@ export const contract = async (zcf, privateArgs, zone, tools) => {
},
});

await settlerKit.creator.monitorMintingDeposits();

return harden({ creatorFacet, publicFacet });
};
harden(contract);
Expand Down

0 comments on commit 4c37d5d

Please sign in to comment.