Skip to content
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

7266 auction status #7339

Merged
merged 10 commits into from
Apr 10, 2023
Merged

7266 auction status #7339

merged 10 commits into from
Apr 10, 2023

Conversation

Chris-Hibbert
Copy link
Contributor

closes: #7266

Description

Write important data about the auction's status to chain storage.

Security Considerations

None

Scaling Considerations

Reduces load on the chain

Documentation Considerations

Added Auction data to the README. (replacing obsolete AMM info) I dunno where else it needs to be written up.

Testing Considerations

New Tests.

@Chris-Hibbert Chris-Hibbert added Inter-protocol Overarching Inter Protocol Vaults VaultFactor (née Treasury) auction labels Apr 5, 2023
@Chris-Hibbert Chris-Hibbert added this to the Vaults EVP milestone Apr 5, 2023
@Chris-Hibbert Chris-Hibbert self-assigned this Apr 5, 2023
const scheduler = await makeScheduler(
driver,
timer,
// @ts-expect-error types are correct. How to convince TS?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

glad to see the suppression more targeted. I'll take a look at this types after pushing this review.

packages/inter-protocol/src/auction/auctioneer.js Outdated Show resolved Hide resolved
packages/inter-protocol/src/auction/scheduler.js Outdated Show resolved Hide resolved
packages/inter-protocol/src/auction/auctionBook.js Outdated Show resolved Hide resolved
packages/inter-protocol/src/auction/auctionBook.js Outdated Show resolved Hide resolved
Comment on lines 115 to 117
/*
* If stateVariable is unset, set it to amount, otherwise add amount
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addAmountToState sounds like it's adding a property to the state. this is increasing an amount stored in state. The laziness of setting it if it isn't set seems unnecessarily dynamic. Why not set them to empty amounts during initState?

Then you don't even need this function. The two places it's called can be like,

state.remainingProceedsGoal = AmountMath.add(state.remainingProceedsGoal, incrementToGoal);

which is statically analyzable. If you really want to avoid repeating the state property we could have a helper like,

increaseAmount(state, 'remainingProceedsGoal', incrementToGoal);

… and have the type checker verify that the second arg is a property in the first arg, but I think that still breaks things like "find all references".

Kind of a general challenge with immutable data when you want to change it without repeating the name of the thing being changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of these values distinguish between empty and null.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the helper. I considered renaming to addToNullable(), since state was the first arg anyway, but your comments about type checking and static analysis convinced me the function wasn't adding enough value.

Comment on lines 676 to 683
state.startCollateral = null;
state.lockedPriceForRound = null;
state.curAuctionPrice = null;
state.remainingProceedsGoal = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that the nullness of these four values has to be synchronized worries me. if they're really non or not at the same time, wouldn't it be better to bundle them in an object? then "between auctions" that single object ref is null and otherwise it's populated in a verifiable "during auction" shape

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They're not as parallel as they looked. After looking more closely,

  • startCollateral will never be null. it's reset to empty at the end of an auction, and increases when addAssets() is called
  • startProceedsGoal is reset at the end of an auction. it increases when addAssets() is called with a goal.
  • lockedPriceForRound is assigned a value to lock the price, and reset to null at the end of the auction.
  • curAuctionPrice is assigned a value at the beginning of each descending step, and reset at the end of the auction.
  • remainingProceedsGoal is assigned a value at the beginning of the auction (if there's a goal), reduced on every trade, and reset at the end of the auction.

/** @returns {Promise<{now:Timestamp, nextSchedule: Schedule}>} */
const initializeNextSchedule = async () => {
return E.when(
// XXX manualTimer returns a bigint, not a timeRecord.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exploration into burning this debt #7348

};
let { now, nextSchedule } = await initializeNextSchedule();
const setTimeMonotonically = time => {
TimeMath.compareAbs(time, now) >= 0 || Fail`Time only moves forward`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bold claim!

packages/inter-protocol/src/auction/scheduler.js Outdated Show resolved Hide resolved
packages/inter-protocol/src/auction/scheduler.js Outdated Show resolved Hide resolved
Copy link
Member

@turadg turadg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some outstanding concerns but all blockers addressed 👍

@Chris-Hibbert Chris-Hibbert added the automerge:squash Automatically squash merge label Apr 7, 2023
@github-actions
Copy link

github-actions bot commented Apr 9, 2023

@Chris-Hibbert - This PR appears to be stuck. It's had a merge label for > 24 hours

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auction automerge:squash Automatically squash merge Inter-protocol Overarching Inter Protocol Vaults VaultFactor (née Treasury)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CLI] Auction Status interface
2 participants