-
Notifications
You must be signed in to change notification settings - Fork 222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
client support for Fast USDC #10735
client support for Fast USDC #10735
Changes from all commits
9585105
7700425
fc940a3
a457695
ef689b4
943402f
2936c0d
6c2ebf8
948d7b7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -10,6 +10,7 @@ import type { | |||||
CurrentWalletRecord, | ||||||
UpdateRecord, | ||||||
} from '@agoric/smart-wallet/src/smartWallet.js'; | ||||||
import type { ContractRecord, PoolMetrics } from '@agoric/fast-usdc'; | ||||||
|
||||||
// For static string key types. String template matching has to be in the ternary below. | ||||||
type PublishedTypeMap = { | ||||||
|
@@ -34,4 +35,12 @@ export type TypedPublished<T extends string> = T extends keyof PublishedTypeMap | |||||
? OutcomeRecord | ||||||
: T extends `vaultFactory.managers.manager${number}.metrics` | ||||||
? VaultManagerMetrics | ||||||
: unknown; | ||||||
: T extends 'agoricNames.instance' | ||||||
? Array<[string, Instance]> | ||||||
: T extends 'agoricNames.brand' | ||||||
? Array<[string, Brand]> | ||||||
Comment on lines
+38
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A lot of the relevant code expects not just a
I suppose one can add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agreed this is low value because you'll often want the kind of brand. It's still true tho so I think it's worth having here. |
||||||
: T extends 'fastUsdc' | ||||||
? ContractRecord | ||||||
: T extends 'fastUsdc.poolMetrics' | ||||||
? PoolMetrics | ||||||
Comment on lines
+42
to
+45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It still feels strange for client-utils to depend on fast-usdc. Should it depend on dapp-offer-up and dapp-agoric-basics likewise? It seems like fast-usdc should extend the type from client-utils. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is weird but ok for now. We'll have to solve it for #10811 |
||||||
: unknown; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
"src", | ||
"tools" | ||
], | ||
"main": "src/main.js", | ||
"bin": { | ||
"fast-usdc": "./src/cli/bin.js" | ||
}, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to also add functions for accepting the operator invitation and submitting evidence? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
// @ts-check | ||
import { assertAllDefined } from '@agoric/internal'; | ||
|
||
/** | ||
* @import {USDCProposalShapes} from './pool-share-math.js'; | ||
*/ | ||
|
||
/** | ||
* @param {Pick< | ||
* import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's please stop using ref There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree eventually but can you accept that as being out of scope? The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I prefer the "platform is fixed" idea where fast-usdc is independent of inter-protocol. But I can live with this. |
||
* 'brand' | ||
* >} agoricNames | ||
* @param {object} opts | ||
* @param {string} opts.offerId | ||
* @param {bigint} opts.fastLPAmount | ||
* @param {bigint} opts.usdcAmount | ||
* @returns {import('@agoric/smart-wallet/src/offers.js').OfferSpec} | ||
*/ | ||
const makeDepositOffer = ({ brand }, { offerId, fastLPAmount, usdcAmount }) => { | ||
assertAllDefined({ offerId, fastLPAmount, usdcAmount }); | ||
|
||
return { | ||
id: offerId, | ||
invitationSpec: { | ||
source: 'agoricContract', | ||
instancePath: ['fastUsdc'], | ||
callPipe: [['makeDepositInvitation']], | ||
}, | ||
/** @type {USDCProposalShapes['deposit']} */ | ||
// @ts-expect-error https://github.com/Agoric/agoric-sdk/issues/10491 | ||
proposal: { | ||
give: { | ||
USDC: { | ||
brand: brand.USDC, | ||
value: usdcAmount, | ||
}, | ||
}, | ||
want: { | ||
PoolShare: { | ||
brand: brand.FastLP, | ||
value: fastLPAmount, | ||
}, | ||
}, | ||
}, | ||
}; | ||
}; | ||
|
||
/** | ||
* @param {Pick< | ||
* import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes, | ||
* 'brand' | ||
* >} agoricNames | ||
* @param {object} opts | ||
* @param {string} opts.offerId | ||
* @param {bigint} opts.fastLPAmount | ||
* @param {bigint} opts.usdcAmount | ||
* @returns {import('@agoric/smart-wallet/src/offers.js').OfferSpec} | ||
*/ | ||
const makeWithdrawOffer = ( | ||
{ brand }, | ||
{ offerId, fastLPAmount, usdcAmount }, | ||
) => ({ | ||
id: offerId, | ||
invitationSpec: { | ||
source: 'agoricContract', | ||
instancePath: ['fastUsdc'], | ||
callPipe: [['makeWithdrawInvitation']], | ||
}, | ||
proposal: { | ||
give: { | ||
PoolShare: { | ||
// @ts-expect-error https://github.com/Agoric/agoric-sdk/issues/10491 | ||
brand: brand.FastLP, | ||
value: fastLPAmount, | ||
}, | ||
}, | ||
want: { | ||
USDC: { | ||
// @ts-expect-error https://github.com/Agoric/agoric-sdk/issues/10491 | ||
brand: brand.USDC, | ||
value: usdcAmount, | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
/** | ||
* @satisfies {Record< | ||
* string, | ||
* Record<string, import('@agoric/smart-wallet/src/types.js').OfferMaker> | ||
* >} | ||
*/ | ||
export const Offers = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any particular reason to export this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't have it handy but there was a PR for refactoring our tests to use these and it let you merge multiple of these into an Also this provides a way to enforce that they all satisfy |
||
fastUsdc: { | ||
Deposit: makeDepositOffer, | ||
Withdraw: makeWithdrawOffer, | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -291,8 +291,8 @@ export const prepareAdvancerKit = ( | |
notifyFacet: M.remotable(), | ||
borrowerFacet: M.remotable(), | ||
poolAccount: M.remotable(), | ||
settlementAddress: ChainAddressShape, | ||
intermediateRecipient: M.opt(ChainAddressShape), | ||
settlementAddress: M.opt(ChainAddressShape), | ||
Comment on lines
+294
to
-295
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good catch! What prompted it, I wonder? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't remember but I'm guessing some type feedback |
||
}), | ||
}, | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './types.js'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,12 @@ export interface TransactionRecord extends CopyRecord { | |
status: TxStatus; | ||
} | ||
|
||
/** the record in vstorage at the path of the contract's node */ | ||
export interface ContractRecord extends CopyRecord { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the name... does it refer to "the record you'll get from vstorage if you query the contract's node"? docstring, please? |
||
poolAccount: ChainAddress['value']; | ||
settlementAccount: ChainAddress['value']; | ||
} | ||
|
||
export type LogFn = (...args: unknown[]) => void; | ||
|
||
export interface PendingTx extends CctpTxEvidence { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: there's a semicolon here but not for the lines above. I wonder if eslint/prettier should have a rule for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think ESlint has a linter for it. There's a Prettier plugin for JSDoc but it's quite buggy