-
Notifications
You must be signed in to change notification settings - Fork 212
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
feat(AMM)!: remove the AMM and cleanup bootstrap etc. dependencies #7074
Conversation
I wonder... if we ever want this back, can we somehow get the git history back with it such that |
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.
Amazing. The package feels lighter already 😉
Some questions before approval.
Also there's more non-code to delete,
- docs/threat_models/smart_contracts/amm/
- node AMM in vaultFactory.puml
- "take some action (i.e. add a new collateral type to the AMM)"
- AMM in governance-params.md and inter-protocol-preview.md
- AMM in zoe-catalog-of-storage.md
test.skip('collect fees from loan and AMM'
- test-demoAMM.js
And I guess a subsequent PR will clear liquidateIncrementally.js and liquidateMinimum.js?
@@ -139,8 +134,9 @@ async function run() { | |||
const zoeInstallVaultFactory = await doCounted('zoeInstallVaultFactory'); | |||
console.log(`zoe install (vaultFactory): ${zoeInstallVaultFactory}`); | |||
|
|||
const zoeInstallAMM = await doCounted('zoeInstallBundle', [autoswapBundle]); | |||
console.log(`zoe install (AMM): ${zoeInstallAMM}`); | |||
// XXX Does this need to be replace by something else in order to be useful? |
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 so. Who uses this tool… maybe @warner ?
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.
Don't worry about it.
The misc-tools directory has a README-analysis-tools.md
disclaimer:
They were built as-needed to investigate various performance issues, and vary drastically in quality and usability.
I think the PSM is a likely replacement, but I think it's fair to leave it in XXX state until somebody comes along and wants to use it again.
@@ -1,4 +1,4 @@ | |||
import { atomicTransfer } from '@agoric/zoe/src/contractSupport'; | |||
import { atomicTransfer } from '@agoric/zoe/src/contractSupport/index.js'; |
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.
TIL that ESM doesn't support the implicit index.js
so we should have this everywhere. 👍
@@ -41,7 +41,7 @@ export const customTermsShape = harden({ | |||
*/ | |||
|
|||
/** | |||
* wrapper to take the vaultFactory or AMM's creatorFacet, and make a call that | |||
* wrapper to take the vaultFactory's creatorFacet, and make a call that |
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.
* wrapper to take the vaultFactory's creatorFacet, and make a call that | |
* wrapper to take a creatorFacet (e.g. vaultFactory) and make a call that |
@@ -462,33 +462,24 @@ export const poolRates = (issuerName, record, kits, central) => { | |||
* consume: { mints } | |||
* }} powers | |||
*/ | |||
// XXX Is this dead? I can't find references to it. It seems to do more than |
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.
in master it's only used in SIM_CHAIN_MANIFEST
. @michaelfig is it still needed for that? Does green CI imply "no"?
Either way this isn't XXX tech debt that should go into master. I'd make this comment DONOTMERGE and make sure it's resolved before approval.
* { | ||
* governedApis: ['addLiquidityToAmmPool'], | ||
* governedApis: ['burnFeesToReduceShortfall'], |
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 missed including that.
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.
See #7072
@@ -48,7 +48,7 @@ const trace = makeTracer('LiqI', false); | |||
|
|||
/** | |||
* @typedef {{ | |||
* amm: XYKAMMPublicFacet, | |||
* amm: any, |
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.
consider a TODO
comment linking the the issue or PR that will remove AMM entirely
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.
Is it important to use any
here? Can we use unknown instead?
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.
it's going away. I felt free to be sloppy. I've updated.
@@ -207,11 +200,6 @@ export const prepareVaultManagerKit = ( | |||
); | |||
|
|||
const poolIncrementSeat = provideEmptySeat(zcf, baggage, 'pool increment'); | |||
const retainedCollateralSeat = provideEmptySeat( |
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.
will the new liquidation system need something like 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.
Yes, it re-appears in #7074. This was a quick way to make lint happy.
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.
consider a lint suppression since it's temporary. that would retain the blame history
@@ -779,20 +609,6 @@ export const prepareVaultManagerKit = ( | |||
return factoryPowers.getGovernedParams(); | |||
}, | |||
|
|||
/** | |||
* In extreme situations, system health may require liquidating all vaults. |
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.
is this no longer a requirement?
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.
The comment notwithstanding, this wasn't hooked up to an API, and I don't know how it ought to be connected to governance. If there's a future requirement for it, we can add something similar in the context of the new liquidation approach.
That's in #7047, which should arguably be stacked on top of this, and maybe be combined before merging this. |
afd8d53
to
0b697b7
Compare
|
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.
re fundAMM
I'm not sure it can completely go. IOU more info when I find it.
@@ -1,26 +1,18 @@ | |||
import { E, Far } from '@endo/far'; |
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 suppose we should delete this whole contract.
Its only purpose is to support permissionless creation of AMM pools.
// TODO(cth) DONOTMERGE Is this dead? I can't find references to it. It seems to | ||
// do more than fund the AMM, and I don't know if it's needed somewhere. |
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.
The reference was in SIM_CHAIN_MANIFEST
above
https://github.com/Agoric/agoric-sdk/pull/7074/files#diff-892e7aad2dc384ce64eb722139fb97bf82a639fa2137ee6867141d8696348476L178
As you note, it does seem to do more than fund the AMM. It's at most a feature of the local development REPL environment. packages/solo/test/test-home.js
should exercise it. I hope to chat with @michaelfig to jog my memory about exactly what it's supposed to do.
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.
It creates (demo) price authorities. We have other mechanisms for that now:
- real oracle providers
- a default price
// AMM requires Reserve in order to add pools, but we can't provide it at startInstance | ||
// time because Reserve requires AMM itself in order to be started. | ||
// Now that we have the reserve, provide it to the AMM. | ||
trace('Resolving the reserve public facet on the AMM'); | ||
await E(ammKit.creatorFacet).resolveReserveFacet(publicFacet); |
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.
good riddance!
@@ -56,18 +48,11 @@ const nonalphanumeric = /[^A-Za-z0-9]/g; | |||
|
|||
/** | |||
* Asset Reserve holds onto assets for the Inter Protocol, and can | |||
* dispense it for various purposes under governance control. It currently | |||
* supports governance decisions to add liquidity to an AMM pool. | |||
* dispense it for various purposes under governance control. |
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.
It can't really dispense until it's upgraded, right? Is that implicit in "under governance control"?
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.
Yeah. that's what I was thinking.
* @param {Installation<unknown>} oldInstall | ||
* @param {unknown} oldTerms | ||
*/ | ||
const watchGovernance = (vaultManager, oldInstall, oldTerms) => { |
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 guess you know where to look if you want this back when we add liquidation via auction?
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.
The vaultManagers were responsible for starting the liquidation contract, but the Auction runs independently of the Vaults. There won't be a need to bring this back.
@@ -485,150 +462,6 @@ export const prepareVaultManagerKit = ( | |||
updateQuote(outstandingQuote, highestDebtRatio, liquidationMargin); | |||
trace('update quote', collateralBrand, highestDebtRatio); | |||
}, | |||
|
|||
async processLiquidations() { |
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.
It seems odd to take this out.
sure, we can put it back, but the git history will get obscured. hm.
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.
liquidations will be invoked in a very different way. Connecting the new code to the previous didn't seem helpful, and I couldn't identify a subset of this code that I could retain and keep lint happy
farZoeKit, | ||
); | ||
const { produce } = | ||
const setupReserveBootstrap = async (t, timer, farZoeKit) => { |
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.
This is the sort of test bootstrap setup that we could perhaps do away with using the swingset bootstrap testing approach @turadg presented today.
@@ -60,7 +60,6 @@ test('storage keys', async t => { | |||
'numActiveVaults', | |||
'numLiquidatingVaults', | |||
'numLiquidationsCompleted', | |||
'retainedCollateral', |
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 see why this goes away. (most likely I skimmed something too fast)
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.
It's an output of liquidation, which is temporarily missing.
runLiquidity, | ||
) => { | ||
/** @param {import('ava').ExecutionContext<Context>} t */ | ||
const setupElectorateAndReserve = async t => { |
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.
more setup that could be replaced by swingset bootstrap testing
@@ -1727,7 +1615,9 @@ test('overdeposit', async t => { | |||
// Both loans will initially be over collateralized 100%. Alice will withdraw | |||
// enough of the overage that she'll get caught when prices drop. Bob will be | |||
// charged interest (twice), which will trigger liquidation. | |||
test('mutable liquidity triggers and interest', async t => { | |||
|
|||
// TODO (7047) reinstate when vaults can use auction |
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.
ah. good. so we're keeping track of the tests.
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.
yeah, though they migrate to a different file in #7047
testing consideration: deployment-test, loadgenWe're seeing deployment-test failures. This is unsurprising, since the deployment-test / loadgen depends on an AMM. While looking into how to remove the dependency on an AMM, I'm reminded that the loadgen also uses |
I'm trying to confirm that this PR is consistent with smart wallet usage; I hit a
|
testing consideration: smoke test for open / adjust / close vault worksThe bootstrap here does work in the context of a running chain. The
(in the run above, |
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.
fundAMM
and its test can go.
I suggest removing interchainPool.js
The most visible consequence is to vault liquidation. Some pieces are left hanging, and will be repaired by #7047.
Remove a few more things, mostly doc comments.
remove interchainPool and other bootstrap stuff connected to AMM Simplify liquidation contracts so they don't refer to dead code. other clean ups
8523532
to
2a5e393
Compare
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.
✂️ 💥
@@ -46,9 +45,11 @@ const trace = makeTracer('LiqI', false); | |||
* TODO integrate the reserve, including the above Reserve strategies. | |||
*/ | |||
|
|||
// TODO: (#7047) this file goes away shortly, and is here to keep vaults happy |
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.
👌
@@ -207,11 +200,6 @@ export const prepareVaultManagerKit = ( | |||
); | |||
|
|||
const poolIncrementSeat = provideEmptySeat(zcf, baggage, 'pool increment'); | |||
const retainedCollateralSeat = provideEmptySeat( |
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.
consider a lint suppression since it's temporary. that would retain the blame history
It'll be removed in #7074, I think, but for now it like a change in this PR.
I reverted it. It didn't need lint suppression. There's a seat. Its allocation is reported. It's empty during tests currently. |
99e0e75
to
0f1b8bf
Compare
It'll be removed in #7074, I think, but for now it like a change in this PR.
It'll be removed in #7074, I think, but for now it like a change in this PR.
* feat(auction): add an auctioneer to manage vault liquiditation Separate pieces include a scheduler that manages the phases of an auction, the AuctionBook that holds onto offers to buy, and the auctioneer, which accepts good for sale and has the APIs. Params are managed via governance. The classes are not durable. This is DRAFT, for early review. The changes to VaultFactory to make use of this approach to liquidation rather than the AMM are in a separate PR, which will be available before this PR is finalized. closes: #6992 * refactor: cleanups from working on vault liquidation * chore: cleanups suggested in review * refactor: simplify keys in sortOffers * chore: cosmetic cleanups from review * chore: auction was introduced to vaultfactory too early. It will be introduced with #7047 when vaultfactory makes use of the auction for liquidation * chore: correctly revert removal of param declaration It'll be removed in #7074, I think, but for now it like a change in this PR. * test: repair dependencies for startAuction * chore: responses to reviews * test: refactor proportional distribution test to use macros * refactor: correct sorting of orders by time Add a test for this case. make all auctionContract tests serial * chore: cleanups suggested in review for loops rather than foreach better type extraneous line * chore: clean up scheduler; add test for computeRoundTiming * chore: minor cleanups from review * chore: rename auctionKit to auctioneerKit * chore: drop auction from startPSM * chore: clean-ups from review * refactor: computeRoundTiming should not allow duration === frequency * chore: clean up governance, add invitation patterns in auctioneer * refactor: don't reschedule next if price is already locked
closes: #7055
refs: #7000
refs: #7047
Description
Remove the AMM and cleanup dependencies in bootstrap and vaults.
The most visible consequence is to vault liquidation. Some pieces are left hanging, and will be repaired by #7047.
Security Considerations
removing code usually makes security simpler.
Scaling Considerations
None
Documentation Considerations
References to the AMM should be removed.
Testing Considerations
Some tests were marked
test.skip
because liquidation doesn't work until the revised Vault liquidation using the descending clock auction is added.