-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
client support for Fast USDC (#10735)
closes: #10677 ## Description Everything in #10677 including some offer makers. There are more opportunities but this lays the groundwork for those to be added as valuable. ### Security Considerations none ### Scaling Considerations none ### Documentation Considerations none ### Testing Considerations nothing special ### Upgrade Considerations not yet released
- Loading branch information
Showing
17 changed files
with
233 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
* '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 = { | ||
fastUsdc: { | ||
Deposit: makeDepositOffer, | ||
Withdraw: makeWithdrawOffer, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './types.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.