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

Bill broker #203

Merged
merged 2 commits into from
May 30, 2024
Merged

Bill broker #203

merged 2 commits into from
May 30, 2024

Conversation

aalavandhan
Copy link
Member

Simple on-chain vault which trades SPOT <> USD.

@aalavandhan aalavandhan requested review from brandoniles and nms-7 April 1, 2024 16:43
Copy link

openzeppelin-code bot commented Apr 1, 2024

Bill broker

Generated at commit: d70161a93512a0a401bc3fe045dee9e078625ea8

🚨 Report Summary

Severity Level Results
Contracts Critical
High
Medium
Low
Note
Total
1
0
0
3
23
27
Dependencies Critical
High
Medium
Low
Note
Total
0
0
0
0
0
0

For more details view the full report in OpenZeppelin Code Inspector

@aalavandhan aalavandhan force-pushed the bill-broker branch 5 times, most recently from b94e279 to 0be78f3 Compare April 9, 2024 00:20
@aalavandhan aalavandhan force-pushed the bill-broker branch 2 times, most recently from 5071161 to 6c1cfbc Compare April 17, 2024 15:15
@aalavandhan aalavandhan force-pushed the balancer-v4 branch 3 times, most recently from b446cb6 to d996baf Compare April 18, 2024 01:34
@aalavandhan aalavandhan force-pushed the bill-broker branch 2 times, most recently from 3fc3b50 to 433e6c1 Compare April 18, 2024 14:11
@aalavandhan aalavandhan force-pushed the bill-broker branch 2 times, most recently from f14dd36 to e2ab56d Compare April 18, 2024 15:22
Copy link
Member

@brandoniles brandoniles left a comment

Choose a reason for hiding this comment

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

Still need to look at the Appraiser

spot-vaults/contracts/_external/PerpArtifacts.sol Outdated Show resolved Hide resolved
spot-vaults/contracts/_interfaces/CommonTypes.sol Outdated Show resolved Hide resolved
error InvalidARBound();

/// @notice Expected pre and post swap AR delta to be non-increasing or non-decreasing.
error UnexpectedARDelta();
Copy link
Member

Choose a reason for hiding this comment

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

Wondering the best way to organize vault code. I kind of view vaults like the BillBroker as being outside the core protocol. Should we have a Errors files inside the vault directory for ones like this?

Copy link
Member Author

Choose a reason for hiding this comment

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

I prefer breaking errors out from the main contract file, mostly because it make the file smaller. We could call these BillBrokerErrors or VaultErrors rather than ProtocolErrors?

Copy link
Member

Choose a reason for hiding this comment

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

I think the name can be whatever you think is best. The most important piece is moving it so it's clear it's "outside" the core protocol and next to the vault implementation wherever that is.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yea its a question of if we want them to be listed on the top of the BillBroker.sol file or in a different file. I'm leaning toward moving it out to BillBrokerErrors.sol

Copy link
Member

Choose a reason for hiding this comment

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

Sure that works. If BillBroker was a 1-file protocol, having them at the top would make sense.

spot-vaults/contracts/BillBroker.sol Show resolved Hide resolved
spot-vaults/contracts/BillBroker.sol Outdated Show resolved Hide resolved
spot-vaults/contracts/BillBroker.sol Outdated Show resolved Hide resolved
spot-vaults/contracts/BillBroker.sol Show resolved Hide resolved
spot-vaults/contracts/_strategies/SpotAppraiser.sol Outdated Show resolved Hide resolved
spot-vaults/contracts/_strategies/SpotAppraiser.sol Outdated Show resolved Hide resolved
@aalavandhan aalavandhan force-pushed the bill-broker branch 2 times, most recently from 9d46ac2 to fa2611c Compare May 7, 2024 02:32
@aalavandhan aalavandhan requested a review from ahnaguib May 7, 2024 18:34
spot-vaults/contracts/BillBroker.sol Outdated Show resolved Hide resolved
// If the market price of the USD coin fallen too much below 1$,
// it's an indication of some systemic issue with the USD token
// and thus its price should be considered unreliable.
return (ONE, (v && p > USD_LOWER_BOUND));
Copy link
Member

Choose a reason for hiding this comment

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

This logic is saying that if the market price of the dollar coin is less than the lower bound (.99 now), then the oracle report is bad. But, it could be a good report representing the real market value of the dollar coin.

Whether we want to operate that far outside the bands of normality is still a sane question to ask... but that's application specific rather than oracle specific. The oracle's job is to deliver data. WDYT, should we move this check into the business logic?

Copy link
Member Author

@aalavandhan aalavandhan May 15, 2024

Choose a reason for hiding this comment

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

The approach here is at times of volatility (or low confidence on the pricing function, I think of both interchangeably), the bill-broker stops all trading activity. Similar to an mm pull liquidity and waiting out the storm.

If the price of the dollar coin deviates a lot from its 1$ peg, its an indication that we now have lower confidence in the pricing function we use (ie 1 dollar coin = 1 dollar).

spot-vaults/contracts/_strategies/SpotAppraiser.sol Outdated Show resolved Hide resolved
spot-vaults/contracts/_strategies/SpotAppraiser.sol Outdated Show resolved Hide resolved
* internal audit fixes

* code review fixes

* Update spot-vaults/contracts/_interfaces/BillBrokerErrors.sol

Co-authored-by: Brandon Iles <brandon@fragments.org>

---------

Co-authored-by: Brandon Iles <brandon@fragments.org>
@aalavandhan aalavandhan changed the base branch from balancer-v4 to mint-cap-update May 30, 2024 19:30
@aalavandhan aalavandhan merged commit d1794f8 into mint-cap-update May 30, 2024
@aalavandhan aalavandhan deleted the bill-broker branch May 30, 2024 20:14
aalavandhan added a commit that referenced this pull request May 30, 2024
* updated per-tranche mint cap

* removed redundant constant

* added dr to the spot and vault interface

* added mintedSupplyPerTranche cleanup

* updated rounding

* updated unit test

* renamed constants in rollover vault to keep consistant with perp

* Bill broker (#203)

* bill broker

* BB Internal audit fixes (#210)

* internal audit fixes

* code review fixes

* Update spot-vaults/contracts/_interfaces/BillBrokerErrors.sol

Co-authored-by: Brandon Iles <brandon@fragments.org>

---------

Co-authored-by: Brandon Iles <brandon@fragments.org>

---------

Co-authored-by: Brandon Iles <brandon@fragments.org>

* updated yarn lock

* bumped up ci version

---------

Co-authored-by: Brandon Iles <brandon@fragments.org>
aalavandhan added a commit that referenced this pull request Jun 21, 2024
* spot subgraph update (#207)

* Removed fixed per-tranche mint cap  (#206)

* updated per-tranche mint cap

* removed redundant constant

* added dr to the spot and vault interface

* added mintedSupplyPerTranche cleanup

* updated rounding

* updated unit test

* renamed constants in rollover vault to keep consistant with perp

* Bill broker (#203)

* bill broker

* BB Internal audit fixes (#210)

* internal audit fixes

* code review fixes

* Update spot-vaults/contracts/_interfaces/BillBrokerErrors.sol

Co-authored-by: Brandon Iles <brandon@fragments.org>

---------

Co-authored-by: Brandon Iles <brandon@fragments.org>

---------

Co-authored-by: Brandon Iles <brandon@fragments.org>

* updated yarn lock

* bumped up ci version

---------

Co-authored-by: Brandon Iles <brandon@fragments.org>

* ci config update

* Peck audit changes (#212)

* pve001

* pve002

* using msg.sender instead of _msgSender

* Perp upgrade and bill-broker deployment (#213)

* perp min-cap upgrade deployed to testnet

* mock contracts for testnet

* tasks to interact with bb

* oz testnet deployment

* updated yarn lock

* removed todo comment

* upgraded perp on mainnet

* bb mainnet deployment

* minor task updates

* Delete spot-contracts/notes.txt

deleted unused file

---------

Co-authored-by: Brandon Iles <brandon@fragments.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants