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

LSBBA / Migrate batch auctions code to benefit from atomic auction changes #23

Merged
merged 88 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
15d1c5b
Documentation
0xJem Jan 11, 2024
429b08d
Merge branch 'jem/auction-management' into jem/atomic-auctions
0xJem Jan 11, 2024
b3805d0
Document purchase()
0xJem Jan 11, 2024
7d56dff
Modifier for valid lot
0xJem Jan 11, 2024
d91ad15
Use modifier
0xJem Jan 11, 2024
e2cb3ba
WIP tests for atomic purchase
0xJem Jan 11, 2024
eaf5ec7
Shift parameters to purchase() into struct. WIP tests.
0xJem Jan 11, 2024
f30d5ac
Comments
0xJem Jan 11, 2024
b2aadc0
forge install: permit2
0xJem Jan 11, 2024
d1687db
Remove permit2 library. Add basic interface and clone.
0xJem Jan 11, 2024
360552f
Documentation TODOs
0xJem Jan 12, 2024
6fc997c
Refactor test TODOs for purchase using branching technique
0xJem Jan 12, 2024
f2e07be
TODOs
0xJem Jan 12, 2024
689fd43
Merge branch 'master' into jem/atomic-auctions
0xJem Jan 12, 2024
9c58c0f
Compile fix
0xJem Jan 12, 2024
216e063
Use solhint-community
0xJem Jan 12, 2024
e7abe1d
Add new solhint rules
0xJem Jan 12, 2024
6f0b598
Disable solhint rule
0xJem Jan 12, 2024
b909d7f
chore: linting fixes
0xJem Jan 12, 2024
3a6e6a1
WIP refactoring of payment collection into Router
0xJem Jan 12, 2024
469fc21
transfer and pre-hook implementation
0xJem Jan 15, 2024
d3a5294
Tests and implementation for Permit2 transfers
0xJem Jan 15, 2024
db34c90
Documentation
0xJem Jan 15, 2024
19a2541
Fix cancelled test
0xJem Jan 15, 2024
5f5ba74
Fix test function names
0xJem Jan 15, 2024
777b78b
Simplify Permit2 signing. Add tests for allowlist.
0xJem Jan 15, 2024
601180a
WIP tests for _collectPayout
0xJem Jan 15, 2024
30f757d
More test TODOs. Implement _collectPayout().
0xJem Jan 16, 2024
9cd7ec1
Cleanup
0xJem Jan 16, 2024
32e6cb7
sendPayment()
0xJem Jan 16, 2024
7edc9f1
Add overall purchase check with invariants
0xJem Jan 16, 2024
47e5115
Tests and implementation for sendPayout()
0xJem Jan 16, 2024
bb65a37
Put the purchase() components together
0xJem Jan 16, 2024
e3d140f
Rename variable
0xJem Jan 16, 2024
a76a2d7
Add test for derivative module in purchase()
0xJem Jan 16, 2024
52f66d4
WIP tests for derivative payout
0xJem Jan 17, 2024
4dd14e5
Move file
0xJem Jan 17, 2024
87a0138
Shift transfer functions to AuctionHouse
0xJem Jan 17, 2024
e3adb13
Simplify interface to _collectPayout()
0xJem Jan 17, 2024
8c2ca1a
Adds support for derivatives in _collectPayout()
0xJem Jan 17, 2024
36e1c75
Shift _sendPayout() to take Routing parameters
0xJem Jan 17, 2024
7f5b4cc
Tests for condenser support in _sendPayout()
0xJem Jan 17, 2024
35292ee
Add structs for module parameters
0xJem Jan 17, 2024
b7a394c
Check for invalid params with condenser
0xJem Jan 17, 2024
a681c44
Amend derivative test for purchase()
0xJem Jan 17, 2024
0f5cade
Support for allowlist proof
0xJem Jan 17, 2024
06fa50c
Change visibility
0xJem Jan 17, 2024
7a7239d
Tests and implementation for wrapped derivative
0xJem Jan 17, 2024
63d0a6d
Obsolete import
0xJem Jan 17, 2024
ba58792
Remove checks for token balance and allowance
0xJem Jan 18, 2024
af8e8bc
Add collateral token to deployment parameters for the mock derivative…
0xJem Jan 18, 2024
1ca17df
Remove deploy from AuctionHouse and Derivatizer interface
0xJem Jan 18, 2024
c25ee5f
Merge branch 'jem/atomic-auctions' into jem/batch-auctions
0xJem Jan 18, 2024
ff5319d
Use pre-defined transfer functions. Linting. Compile fixes.
0xJem Jan 18, 2024
6d388ad
Rename internal function
0xJem Jan 18, 2024
82b2ef5
Comment improvements
0xJem Jan 18, 2024
3605cde
Extract shared functions. Partial implementation of AuctionHouse.bid()
0xJem Jan 18, 2024
9ea9196
Reconcile signatures for bid functions
0xJem Jan 18, 2024
7bc9988
Add settle function for local storage, external settlement
0xJem Jan 18, 2024
be3c092
Shift to _isAllowed() function
0xJem Jan 18, 2024
b9f3479
Shift fee implementation
0xJem Jan 18, 2024
824eb90
Adjust bid/settle signatures. Remove unused functions.
0xJem Jan 19, 2024
c7b701c
wip: initial LSBBA implementation (not complete)
Oighty Jan 19, 2024
0506ec1
feat: LSBBA updates
Oighty Jan 20, 2024
4b97dcb
feat: add priority queue implementation to LSSBA
Oighty Jan 20, 2024
eb9c1ae
feat: add settlement function to LSBBA
Oighty Jan 20, 2024
55acd28
feat: add auction, cancelAuction, and claimRefund functions to LSBBA
Oighty Jan 21, 2024
5fb4ca4
Notes
0xJem Jan 22, 2024
f6a0583
transferFrom
0xJem Jan 22, 2024
7b1b42d
Add underlying token to deploy/mint functions. Correct implementation…
0xJem Jan 22, 2024
c7c6911
Merge branch 'jem/batch-auctions' of github.com:Bond-Protocol/moonrak…
0xJem Jan 22, 2024
89e47c2
chore: linting
0xJem Jan 22, 2024
8ff6fc7
Complete migration of lotId to uint96. Fix compilation errors.
0xJem Jan 22, 2024
114334a
Fix stack too deep error
0xJem Jan 22, 2024
681be7b
Rename test file
0xJem Jan 22, 2024
5651472
Revert "Rename test file"
0xJem Jan 22, 2024
214a6f5
Tests for bid()
0xJem Jan 22, 2024
9df2923
Adjust type for auctionParam
0xJem Jan 22, 2024
bbb1f80
Documentation
0xJem Jan 22, 2024
11803e3
Document behaviour
0xJem Jan 22, 2024
da6dbe6
Add stub for claimRefund(). Consistent type for bidId.
0xJem Jan 22, 2024
09e0e24
Test for cancelBid()
0xJem Jan 22, 2024
629a146
docs: design updates
Oighty Jan 22, 2024
ffa9e0d
docs: more design updates for LSBBA
Oighty Jan 22, 2024
923895e
docs: add'l design
Oighty Jan 22, 2024
cf69992
Merge pull request #21 from Bond-Protocol/jem/atomic-auctions
Oighty Jan 22, 2024
84183c6
Remove redundant parameter to bid()
0xJem Jan 23, 2024
1a2793d
Merge branch 'master' into jem/batch-auctions
0xJem Jan 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions .solhint.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,33 @@
{
"extends": "solhint:recommended",
"extends": "solhint:recommended",
"rules": {
"compiler-version": ["error",">=0.7.0"],
"compiler-version": [
"error",
">=0.7.0"
],
"avoid-low-level-calls": "off",
"const-name-snakecase": "off",
"var-name-mixedcase": "off",
"const-name-snakecase": "warn",
"var-name-mixedcase": "warn",
"func-name-mixedcase": "off",
"immutable-name-snakecase": "warn",
"modifier-name-mixedcase": "warn",
"private-vars-leading-underscore": "warn",
"not-rely-on-time": "off",
"func-visibility": [ "warn", { "ignoreConstructors":true }],
"func-visibility": [
"warn",
{
"ignoreConstructors": true
}
],
"no-inline-assembly": "off",
"reason-string": "off",
"no-empty-blocks": "off",
"no-console": "off",
"no-global-import": "off"
"no-global-import": "warn",
"no-unused-import": "warn",
"no-unused-vars": "warn",
"avoid-tx-origin": "error",
"reentrancy": "error",
"state-visibility": "warn"
}
}
}
2 changes: 1 addition & 1 deletion design/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ classDiagram
struct AuctionParams
+bool allowNewMarkets
+uint48 minAuctionDuration
~uint48 ONE_HUNDRED_PERCENT = 1e5
~uint48 _ONE_HUNDRED_PERCENT = 1e5
+mapping[uint256 lotId => Lot] lotData
+purchase(uint256 lotId, uint256 amount, bytes auctionData) (uint256, bytes)
+bid(uint256 lotId, uint256 amount, uint256 minAmountOut, bytes auctionData) (uint256, bytes)
Expand Down
324 changes: 324 additions & 0 deletions design/LSBBA.md

Large diffs are not rendered by default.

47 changes: 47 additions & 0 deletions design/SEALED_VERSIONS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Sealed Bid Auction Development

## Context

Bond Protocol, rebranding to Axis, is changing directions from our current "atomic" auction products to focus on developing and deploying a Sealed Bid Batch Auction product. The primary expected use cases are token sales and issuing token derivatives. We believe a decentralized sealed bid batch auction can allow for superior price discovery and outcomes for teams over current market solutions.

## Design

### Base Auction Flow
There are three main steps to any batch auction:
1. Bid submission - Users submit bids over an alloted time period
2. Evaluation - The submitted bids are evaluated using the auction logic and winners are determined
3. Settlement - The proceeds of the auction are distributed to the winners and the auction is closed

It's important to note that any of these three steps can be performed on-chain or off-chain.

### Auction Fairness
An auction system must assure users of inclusion and fair treatment of their bids. Specifically, it needs to provide guarantees around:
1. Completeness - All bids that are submitted are evaluated
2. Accuracy - The evaluation of bids is performed correctly

Depending on the design of the system, these properties may be inherent or difficult to achieve. There is typically a tradeoff between UX/efficiency and these guarantees.

### Types of Batch Auctions
There are four main types of batch auctions that could be built based on where the bids are submitted and where the bid evaluation logic is performed. We will refer to these as "local", for on-chain, and "external", for off-chain, to avoid using similar hyphenated words. Settlement is assumed to be on-chain.
1. Local (aka on-chain) bid submission and evaluation
Fully on-chain auction, similar to Gnosis auction, but with encryption. Since you cannot pre-sort the bids, it requires an intermediate step to decrypt and sort all submitted bids before settlement to avoid issues with the gas limit. The risk of DoS attacks is decreased by requiring bid deposits, but this leaks some information. This solution natively guarantees both "completeness" and "accuracy" of the bids.

2. External bid submission and local evaluation

Bids are collected off-chain, filtered for bids that aren't valid (e.g. below min price or too small), sorted, and submitted on-chain, where the auction price logic is performed to determine the winners. This version natively adheres to the "accuracy" guarantee through on-chain evaluation of bids, but requires trusting the "completeness" property of the bids that are submitted for evaluation. This is difficult to do in a decentralized way.

3. Local submission and external evaluation

Bids are submitted on-chain (encrypted). Once the auction ends, an external party can decrypt the bid data, perform bid evaluation off-chain, and submit the winning bids with a validity proof of the evaluation. This version natively adheres to the "completness" property, but requires trusting the "accuracy" of the submitted evaluation. A validity proof can provide this in a decentralized way. This may be a workable solution if a ZK proof could be constructed correctly to verify the off-chain evaluation. Currently, we are running into issues with the size of the required circuit(s). More information on this below.

4. External bid submission and evaluation
Bids are collected off-chain and the settlement algorithm is performed to determine the winning bids. the winning bids are submitted on-chain for settlement of payments. This would have the best UX and is most gas efficient, but is the least decentralized. It requires trusting both the "completeness" and "accuracy" of the submitted evaluation.

There is also a fifth option where Settlement is also performed externally and proved locally, which equates to a validium, but that isn't considered in detail here.

There are many potential product designs that we have considered. Each has tradeoffs along a few major dimensions:
- Decentralization
- User Experience
- Level of privacy
- Efficiency (i.e. gas costs)

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"build": "forge build",
"fmt": "forge fmt",
"fmt:check": "forge fmt --check",
"solhint": "solhint --fix --noPrompt --config ./.solhint.json 'src/**/*.sol'",
"solhint": "solhint --fix --config ./.solhint.json 'src/**/*.sol'",
"solhint:check": "solhint --config ./.solhint.json 'src/**/*.sol'",
"lint": "npm run fmt && npm run solhint",
"lint:check": "pnpm run fmt:check && pnpm run solhint:check",
Expand All @@ -20,7 +20,7 @@
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"solhint": "^4.1.1"
"dependencies": {
"solhint-community": "^3.7.0"
}
}
Loading
Loading