-
Notifications
You must be signed in to change notification settings - Fork 0
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
Identify modules that will require an updated #3
Comments
VaultsFor each vault liquidated and added to an auction we need:
What we have:
How the vault node is created and manipulatedsequenceDiagram
participant VM as Vault Manager
participant V as Vault
participant VK as VaultKit
participant VH as VaultHolder
VM ->> VM : create vaultStorageNode
VM ->> V: makeVault(manager, vaultId, vaultStorageNode)
V ->> VK: makeVaultKit(self, storageNode)
VK ->> VH: makeVaultHolder(vault, storageNode)
VH ->> VH: makeRecorderKit(storageNode);
VH -->> VK: recorder
VK ->> VK: vaultUpdater: recorder
VK-->>V: VaultKit
V ->> V: outerUpdater = vaultKit.vaultUpdater
V -->> VM : Vault self facet
At Note: if the vault phase is set to CLOSED, the node will record its final state
updateUiState() {
const { state, facets } = this;
const { outerUpdater } = state;
if (!outerUpdater) {
// It's not an error to change to liquidating during transfer
return;
}
const { phase } = state;
const uiState = facets.helper.getStateSnapshot(phase);
const brand = facets.helper.collateralBrand();
trace(brand, 'updateUiState', state.idInManager, uiState);
switch (phase) {
case Phase.ACTIVE:
case Phase.LIQUIDATING:
case Phase.LIQUIDATED:
void outerUpdater.write(uiState);
break;
case Phase.CLOSED:
void outerUpdater.writeFinal(uiState);
state.outerUpdater = null;
break;
default:
throw Error(`unreachable vault phase: ${phase}`);
}
},
getStateSnapshot(newPhase) {
const { state, facets } = this;
const { debtSnapshot: debt, interestSnapshot: interest } = state;
/** @type {VaultNotification} */
return harden({
debtSnapshot: { debt, interest },
locked: facets.self.getCollateralAmount(),
// newPhase param is so that makeTransferInvitation can finish without setting the vault's phase
// TODO refactor https://github.com/Agoric/agoric-sdk/issues/4415
vaultState: newPhase,
});
}, |
AuctionFor each auction run we need:
What we have:
sequenceDiagram
participant A as Auctioneer
participant AB as AuctionBook
A ->> A : create bNode
A ->> AB: makeAuctionBook(brands.Bid, brand, priceAuthority, bNode)
AB ->> AB: makeRecorderKit(bNode);
AB -->> A : auctionBook self facet
At
publishBookData() {
const { state } = this;
const allocation = state.collateralSeat.getCurrentAllocation();
const collateralAvailable =
'Collateral' in allocation
? allocation.Collateral
: makeEmpty(state.collateralBrand);
const bookData = harden({
startPrice: state.capturedPriceForRound,
startProceedsGoal: state.startProceedsGoal,
remainingProceedsGoal: state.remainingProceedsGoal,
proceedsRaised: allocation.Bid,
startCollateral: state.startCollateral,
collateralAvailable,
currentPriceLevel: state.curAuctionPrice,
});
return state.bookDataKit.recorder.write(bookData);
}, |
Post-auctionFor each post-auction we need the following data about funds distribution:
What we have:
When an auction is finalised, the
All transactions recorded on the transfers list will be atomically executed at the end of the distributeProceeds process. IDEA Maybe we can deconstruct the transfers list and provide the relevant content to the Vstorage. Collateral sent to Reserve (a*)1- Multiple deposits made to the collateral. Collateral returned to vault (b*)1 - A single deposit was made for this Collateral 2- Multiple deposits made and none of the participants specified a goal or If proceeds are less than the total specified goals (case A and B) 3- Multiple deposits made and proceeds precisely match the total specified goals 4- Multiple deposits made and proceeds exceed the total specified goals, and depositor did not specified goal 5- Multiple deposits made and proceeds exceed the total specified goals, and if proceedsGoal + value of unsoldCollateral >= limitedShare 6- Multiple deposits made and proceeds exceed the total specified goals, and there is not enough collateral to completely cover the gap above the proceedsGoal amount. Debt returned to vault (c*)1- Multiple deposits made and none of the participants specified a goal or If proceeds are less than the total specified goals (case A and B) 2- Multiple deposits made and proceeds precisely match the total specified goals 3- Multiple deposits made and proceeds exceed the total specified goals, and depositor did not specified goal 4- Multiple deposits made and proceeds exceed the total specified goals, and if proceedsGoal + value of unsoldCollateral >= limitedShare WIP graph LR
A[Auction Outcome] --> B{Proportional Distribution?}
B -- Yes --> C[Proceeds <= Proceeds Goal?]
B -- No --> D[Proceeds > Proceeds Goal]
C -- Yes --> E[Proportional Distribution]
C -- No --> F[Allocate Based on Goals]
D --> G[Calculate Collateral Multiplier]
G --> H[Handle Cases with Limits]
H --> I[Proportional Allocation with Limits]
H --> J[Distribute Proportional Shares]
I --> J
J --> K[Reserve Transfer]
K --> L{Collateral Left?}
L -- Yes --> M[Collateral to Reserve]
L -- No --> N[Proceeds to Reserve]
Shortfall sent to Reserve (d*)The shortfall sent to Reserve can be retrieved at the vaultsManager when the liquidateVaults method is executed via the
|
Connect all dataStoryThe liquidationWaker is provided to the setWakeupsForNextAuction method at the vaultDirector. At the vaultDirector, the liquidationWaker is provided as an argument for the setWakeupsForNextAuction method of liquidations.js which will set the respective wakeup. ToDo: follow the nextAuctionSchedule and nominalStart thread... Now the nominalStart time is reached and the wakeup is triggered. The vaultDirector will call the liquidateVaults method of all vaultManager registered. The vaultManager will get the totalDebt, totalCollateral, vaultData, liqSeat from the Liquidatable Vaults and make a deposit on the auctioneer, providing the totalCollateral to be sold and the totalDebt as the goal. At this moment, we need to know:
From here we can used the book storage node (published.auction.bookID) to query the details of each auction run. When the auction is finalised:
The post-auction data detailed above cannot currently be found on the Vstorage. Connect dataThe challenge is to connect
manager <--> vaults
vaults <--> auctions
auction <--> transfers |
Liquidation Visibility Analysis [DRAFT]Problem DefinitionCurrently when there are liquidatable vaults present in one of the Solution RequestedAgoric OpCo(maybe tag rowland here) requested below information to be exposed to
Solution AnalysisDuring our analysis, below are what we've found; Auction Details
Information Per Vault
No data correlating individual vaults to liquidations can be found in const { totalDebt, totalCollateral, vaultData, liqSeat } =
getLiquidatableVaults(
zcf,
{
quote: lockedQuote,
interest: compoundedInterest,
margin: liqMargin,
},
prioritizedVaults,
liquidatingVaults,
debtBrand,
collateralBrand,
); Where /**
* @type {MapStore<
* Vault,
* { collateralAmount: Amount<'nat'>; debtAmount: Amount<'nat'> }
* >}
*/ This means For the Post Auction Details
First of all, we want to clarify how we interpreted the phrase Having said all of above, currently However, we've located where this data is in the vaultManager; for (const [vault, balances] of bestToWorst) {
vaultsInPlan.push(vault);
vaultsBalances.push({
collateral: balances.collateralAmount,
// if interest accrued during sale, the current debt will be higher
presaleDebt: balances.debtAmount,
currentDebt: vault.getCurrentDebt(),
});
}
harden(vaultsInPlan);
harden(vaultsBalances);
const plan = calculateDistributionPlan({
proceeds,
totalDebt,
totalCollateral,
oraclePriceAtStart: oraclePriceAtStart.quoteAmount.value[0],
vaultsBalances,
penaltyRate,
});
return { plan, vaultsInPlan }; Notice that we know what vaults are reinstated or marked as /**
* @typedef {{
* overage: Amount<'nat'>,
* shortfallToReserve: Amount<'nat'>,
* collateralForReserve: Amount<'nat'>,
* actualCollateralSold: Amount<'nat'>,
* collateralSold: Amount<'nat'>,
* collatRemaining: Amount<'nat'>,
* debtToBurn: Amount<'nat'>,
* mintedForReserve: Amount<'nat'>,
* mintedProceeds: Amount<'nat'>,
* phantomDebt: Amount<'nat'>,
* totalPenalty: Amount<'nat'>,
* transfersToVault: Array<[number, AmountKeywordRecord]>,
* vaultsToReinstate: Array<number>
* }} DistributionPlan This
DeliverablesWe'll use this section what to deliver exactly. We aim to clarify the work scope here. Will Deliver
Might Deliver
Considerations
cc for review @Jorge-Lopes |
Review of Solution AnalysisAuction detailsAligned with my understanding Vaults detailsIt seems I misunderstood the requested Collateral and Debt at moment of liquidation. Post Auction DetailsRegarding the post auctions details, if it is true that we should discard the distribution made by the auctioneer, I agree that the plan would solve most of our problems. In case we need to consider the distribution made by the auctioneer we should rethink our strategy with something similar to this |
Current relevant data recorded on Vstorage:
Vaults:
Auctions
The text was updated successfully, but these errors were encountered: