Skip to content

Commit

Permalink
Merge pull request #237 from Axis-Fi/fbp-patch
Browse files Browse the repository at this point in the history
Bug fix: Fixed Price Batch Rounding
  • Loading branch information
Oighty authored Dec 13, 2024
2 parents 6798a87 + f20380e commit a2443d2
Show file tree
Hide file tree
Showing 29 changed files with 297 additions and 38 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 1.0.3

- Fixed a bug in the Fixed Price Batch module calculating the payout of a partially filled bid. This was introduced in v1.0.2 when the underflow bug was fixed.

## 1.0.2

- Fixed a bug in the Fixed Price Batch module that could result in an underflow when an auction was settled

## 1.0.1

- Seller can now be a referrer to an auction and earn the referrer fee. This allows them to effectively not pay a fee when they direct traffic to their own auction
Expand Down
3 changes: 3 additions & 0 deletions deployments/.arbitrum-one-v1.0.2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"deployments.auctionModules.FixedPriceBatch": "0xB1e9E16a40321Fe06Cfd797619C345c143D11Aa7"
}
3 changes: 3 additions & 0 deletions deployments/.arbitrum-one-v1.0.3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"deployments.auctionModules.FixedPriceBatch": "0x04974BcFC715c148818724d9Caab3Fe8d0391b8b"
}
3 changes: 3 additions & 0 deletions deployments/.arbitrum-sepolia-v1.0.2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"deployments.auctionModules.FixedPriceBatch": "0x43ce692c6C538C76eFeA6f495AdA280B60a7ceCA"
}
3 changes: 3 additions & 0 deletions deployments/.arbitrum-sepolia-v1.0.3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"deployments.auctionModules.FixedPriceBatch": "0xAF4AaFC046FB329EB1181c0094a95DA7Cee38211"
}
3 changes: 3 additions & 0 deletions deployments/.base-sepolia-v1.0.2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"deployments.auctionModules.FixedPriceBatch": "0xd13d64dD95F3DB8d1B3E1E65a1ef3F952ee1FC73"
}
3 changes: 3 additions & 0 deletions deployments/.base-sepolia-v1.0.3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"deployments.auctionModules.FixedPriceBatch": "0x1A6Ba70B8e5957bCd03C20f9CF42D9e6D3d9b514"
}
3 changes: 3 additions & 0 deletions deployments/.base-v1.0.2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"deployments.auctionModules.FixedPriceBatch": "0xc83Cbb79072CE3341f25326C6a3ad0Cefe36AfdD"
}
3 changes: 3 additions & 0 deletions deployments/.base-v1.0.3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"deployments.auctionModules.FixedPriceBatch": "0x4042D4F2236D055212d485E028E8FE4939252F88"
}
3 changes: 3 additions & 0 deletions deployments/.berachain-bartio-v1.0.2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"deployments.auctionModules.FixedPriceBatch": "0x68a8d91d9936b5Ef8b65f516F8a5AAB6c7b1E43e"
}
3 changes: 3 additions & 0 deletions deployments/.berachain-bartio-v1.0.3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"deployments.auctionModules.FixedPriceBatch": "0x4044d6dE91FB3049A9eBA24e4299d0d7ec7E53a3"
}
3 changes: 3 additions & 0 deletions deployments/.blast-sepolia-v1.0.2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"deployments.auctionModules.FixedPriceBatch": "0x527Bec0Ed0660c7fc4Dcf64b741eb4CfCDEA1615"
}
3 changes: 3 additions & 0 deletions deployments/.blast-sepolia-v1.0.3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"deployments.auctionModules.FixedPriceBatch": "0xf1E5FA9008fC3a62D90c7e569E02D98315C19DC3"
}
3 changes: 3 additions & 0 deletions deployments/.blast-v1.0.2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"deployments.auctionModules.FixedPriceBatch": "0xCaAE490470305a9d6f58b026cdD36cc747F8F0b9"
}
3 changes: 3 additions & 0 deletions deployments/.blast-v1.0.3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"deployments.auctionModules.FixedPriceBatch": "0x0e4996960731Fec8E7C9DBbD51383fC71174DD88"
}
8 changes: 4 additions & 4 deletions deployments/.mainnet-v1.0.1.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"deployments.BatchAuctionHouse": "0xBA000020Fed3cf3bF473f09Ca0A72Ba123e20926",
"deployments.BatchCatalogue": "0xD33e5cC03ad1C8F73cc57053f8a749ac76F14988",
"deployments.auctionModules.FixedPriceBatch": "0xC891eC53b389edc1ebC38305B2D400c9E47A33Db",
"deployments.derivativeModules.BatchLinearVesting": "0x605A7105CA51FD5F107258362f52d8269eeA851A"
"deployments.BatchAuctionHouse": "0xBA000020Fed3cf3bF473f09Ca0A72Ba123e20926",
"deployments.BatchCatalogue": "0xD33e5cC03ad1C8F73cc57053f8a749ac76F14988",
"deployments.auctionModules.FixedPriceBatch": "0xC891eC53b389edc1ebC38305B2D400c9E47A33Db",
"deployments.derivativeModules.BatchLinearVesting": "0x605A7105CA51FD5F107258362f52d8269eeA851A"
}
3 changes: 3 additions & 0 deletions deployments/.mainnet-v1.0.2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"deployments.auctionModules.FixedPriceBatch": "0xaC9957282BeA578f371078ddc4cD12A135B105d6"
}
3 changes: 3 additions & 0 deletions deployments/.mainnet-v1.0.3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"deployments.auctionModules.FixedPriceBatch": "0x4ED7160dA0020070ADf1AB149c730E8A4bD73d15"
}
3 changes: 3 additions & 0 deletions deployments/.mode-sepolia-v1.0.2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"deployments.auctionModules.FixedPriceBatch": "0xa9458b5C26810F4bE972d9fB50147e5E2395dC3E"
}
3 changes: 3 additions & 0 deletions deployments/.mode-sepolia-v1.0.3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"deployments.auctionModules.FixedPriceBatch": "0x8e5a555bcaB474C91dcA326bE3DFdDa7e30c3765"
}
3 changes: 3 additions & 0 deletions deployments/.mode-v1.0.2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"deployments.auctionModules.FixedPriceBatch": "0x4044d6dE91FB3049A9eBA24e4299d0d7ec7E53a3"
}
3 changes: 3 additions & 0 deletions deployments/.mode-v1.0.3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"deployments.auctionModules.FixedPriceBatch": "0x3A327c856AF41EcF4d783975CE38f669dEeaB298"
}
8 changes: 8 additions & 0 deletions script/deploy/sequences/fixed-batch-module.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"sequence": [
{
"name": "FixedPriceBatch",
"installBatchAuctionHouse": false
}
]
}
20 changes: 10 additions & 10 deletions script/env.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"BatchCatalogue": "0xA17fC2B153222bdC549AE22Af5AcA7aC773979Fc",
"auctionModules": {
"EncryptedMarginalPrice": "0xA06A0A5D22E31D8d19c49FFd65c8FC37477077e2",
"FixedPriceBatch": "0xA74E9a7726b084968a314bE71D60646AA6805109"
"FixedPriceBatch": "0x04974BcFC715c148818724d9Caab3Fe8d0391b8b"
},
"derivativeModules": {
"BatchLinearVesting": "0xCaAE490470305a9d6f58b026cdD36cc747F8F0b9"
Expand All @@ -33,7 +33,7 @@
"BatchCatalogue": "0xBC1a6e1327c0CdA84Bc6feC65f99cdfCA976DD97",
"auctionModules": {
"EncryptedMarginalPrice": "0x9099dd8Db39B8aD5D31d9865F013F1d2278c3506",
"FixedPriceBatch": "0x4E2DE4DB0DB1D28B0751B9D0A6b6db222E64Fd43"
"FixedPriceBatch": "0xAF4AaFC046FB329EB1181c0094a95DA7Cee38211"
},
"derivativeModules": {
"BatchLinearVesting": "0x14726B9D69d4Fb957e4F3C736bda029Fd96e1FFb"
Expand All @@ -53,7 +53,7 @@
"BatchCatalogue": "0x2B63Aa737a1AD617A6d6894698Abd043F95cCecb",
"auctionModules": {
"EncryptedMarginalPrice": "0x408fB738592232372069B592022F03BF3a241613",
"FixedPriceBatch": "0xB4d895191fEE12aa5147D057fcFe720f7c0Dc76C"
"FixedPriceBatch": "0x4042D4F2236D055212d485E028E8FE4939252F88"
},
"derivativeModules": {
"BatchLinearVesting": "0x5C439EAa3F039Bac9Bf1ea4Eb6121d5767C63864"
Expand All @@ -73,7 +73,7 @@
"BatchCatalogue": "0x97145edD2F06ADF1d91CB9Aa5eb52D842a3f5c54",
"auctionModules": {
"EncryptedMarginalPrice": "0xf0a4d1f805312438ea146E5df873bD8d64D9dBe4",
"FixedPriceBatch": "0xDF09C4de6B937a1C555052e15Ad6F3EE673618Ae"
"FixedPriceBatch": "0x1A6Ba70B8e5957bCd03C20f9CF42D9e6D3d9b514"
},
"derivativeModules": {
"BatchLinearVesting": "0x909F26919989167d051312fBB0a1Df4CD93Bf70b"
Expand All @@ -93,7 +93,7 @@
"BatchCatalogue": "0x37886d0667c16f41F73F6586f087166Ae3CF1155",
"auctionModules": {
"EncryptedMarginalPrice": "0x2C7aE1A3989f17a6d9935382bDe7F1b021055083",
"FixedPriceBatch": "0x8Db46375e73545226E99b5e8cBfe2794ac835D38"
"FixedPriceBatch": "0x4044d6dE91FB3049A9eBA24e4299d0d7ec7E53a3"
},
"derivativeModules": {
"BatchLinearVesting": "0xD55227c0C37C97Fa2619a9C7F658C173883C1E2a"
Expand All @@ -118,7 +118,7 @@
"BatchCatalogue": "0xBFfBef6f8a0Ef38121716860E2Ff824c018a467d",
"auctionModules": {
"EncryptedMarginalPrice": "0x16D5Aab9d35f8B3ac7BD086eEDcCe5343682D5F0",
"FixedPriceBatch": "0x37886d0667c16f41F73F6586f087166Ae3CF1155"
"FixedPriceBatch": "0x0e4996960731Fec8E7C9DBbD51383fC71174DD88"
},
"derivativeModules": {
"BatchLinearVesting": "0x5998a28a71e6BDc2b592c14e3517212391782db0"
Expand All @@ -143,7 +143,7 @@
"BatchCatalogue": "0x26e5Fd9ea25a5719D4EbA3b1966dd4864c48e517",
"auctionModules": {
"EncryptedMarginalPrice": "0x1043ef1f242e3FC5E90fd67Bb5a1B1356b102b39",
"FixedPriceBatch": "0x562456ca4Cc0Bc964D383aCDe53ED04A15880149"
"FixedPriceBatch": "0xf1E5FA9008fC3a62D90c7e569E02D98315C19DC3"
},
"derivativeModules": {
"BatchLinearVesting": "0x9011aC431f91Fd92437cBfdAE30a4ee4b76fEE1F"
Expand All @@ -163,7 +163,7 @@
"BatchCatalogue": "0xD33e5cC03ad1C8F73cc57053f8a749ac76F14988",
"auctionModules": {
"EncryptedMarginalPrice": "0x0000000000000000000000000000000000000000",
"FixedPriceBatch": "0xC891eC53b389edc1ebC38305B2D400c9E47A33Db"
"FixedPriceBatch": "0x4ED7160dA0020070ADf1AB149c730E8A4bD73d15"
},
"derivativeModules": {
"BatchLinearVesting": "0x605A7105CA51FD5F107258362f52d8269eeA851A"
Expand Down Expand Up @@ -223,7 +223,7 @@
"BatchCatalogue": "0x8Db46375e73545226E99b5e8cBfe2794ac835D38",
"auctionModules": {
"EncryptedMarginalPrice": "0xA17fC2B153222bdC549AE22Af5AcA7aC773979Fc",
"FixedPriceBatch": "0x0599DA010907835037A0beC4525Dc5D600e790EB"
"FixedPriceBatch": "0x3A327c856AF41EcF4d783975CE38f669dEeaB298"
},
"derivativeModules": {
"BatchLinearVesting": "0xc20918b09dE9708d2A7997dfFc3c5ACB34d4a15b"
Expand All @@ -243,7 +243,7 @@
"BatchCatalogue": "0x2eF571199c0BA4923FCf18cB802e302C0aF544Ef",
"auctionModules": {
"EncryptedMarginalPrice": "0xD6F9425776eE91b7181a16256768fAB9aB8B20a4",
"FixedPriceBatch": "0xfF5f4fF1b91178b66eDE0E0e2697861F362c29c0"
"FixedPriceBatch": "0x8e5a555bcaB474C91dcA326bE3DFdDa7e30c3765"
},
"derivativeModules": {
"BatchLinearVesting": "0xE8546C3f5d5dB707081ffAfDB5416d808758D120"
Expand Down
39 changes: 18 additions & 21 deletions soldeer.lock
Original file line number Diff line number Diff line change
@@ -1,33 +1,30 @@
[[dependencies]]
name = "@openzeppelin-contracts"
version = "4.9.2"
url = "https://soldeer-revisions.s3.amazonaws.com/@openzeppelin-contracts/4_9_2_22-01-2024_13:13:52_contracts.zip"
checksum = "0f4450671798ea5659e6391876a3cf443ca50a696d9b556ac622ec7660bce306"
integrity = "f69bd90f264280204b2a1172a02a2d20f3611f5993a61e5215647bec696a8420"

[[dependencies]]
name = "clones-with-immutable-args"
version = "1.1.1"
git = "git@github.com:wighawag/clones-with-immutable-args.git"
rev = "f5ca191afea933d50a36d101009b5644dc28bc99"

[[dependencies]]
name = "forge-std"
version = "1.9.1"
url = "https://soldeer-revisions.s3.amazonaws.com/forge-std/v1_9_1_03-07-2024_14:44:59_forge-std-v1.9.1.zip"
source = "https://soldeer-revisions.s3.amazonaws.com/forge-std/v1_9_1_03-07-2024_14:44:59_forge-std-v1.9.1.zip"
checksum = "110b35ad3604d91a919c521c71206c18cd07b29c750bd90b5cbbaf37288c9636"
integrity = "389f8bfe6b6aad01915b1e38e6d4839f8189e8d4792b42be4e10d0a96a358e3f"

[[dependencies]]
name = "solmate"
version = "6.8.0"
source = "https://soldeer-revisions.s3.amazonaws.com/solmate/6_8_0_29-10-2024_19:01:45_solmate.zip"
checksum = "e3ec0f0182cb3bbedecf8a0bcc39897266534a795ec732b2b03dafa285d78a5b"

[[dependencies]]
name = "solady"
version = "0.0.124"
url = "https://soldeer-revisions.s3.amazonaws.com/solady/0_0_124_22-01-2024_13:28:04_solady.zip"
source = "https://soldeer-revisions.s3.amazonaws.com/solady/0_0_124_22-01-2024_13:28:04_solady.zip"
checksum = "9342385eaad08f9bb5408be0b41b241dd2b974c001f7da8c3b1ac552b52ce16b"
integrity = "29d93e52694d8e858cf5a737257f4a6f21aefccaf803174fd00b9d686172ab27"

[[dependencies]]
name = "solmate"
version = "6.8.0"
url = "https://soldeer-revisions.s3.amazonaws.com/solmate/6_8_0_29-10-2024_19:01:45_solmate.zip"
checksum = "e3ec0f0182cb3bbedecf8a0bcc39897266534a795ec732b2b03dafa285d78a5b"
integrity = "a22e5a352de0231f671ee8adf5667bbe83c50012670083987bd1099a69feb429"
name = "@openzeppelin-contracts"
version = "4.9.2"
source = "https://soldeer-revisions.s3.amazonaws.com/@openzeppelin-contracts/4_9_2_22-01-2024_13:13:52_contracts.zip"
checksum = "0f4450671798ea5659e6391876a3cf443ca50a696d9b556ac622ec7660bce306"

[[dependencies]]
name = "clones-with-immutable-args"
version = "1.1.1"
source = "git@github.com:wighawag/clones-with-immutable-args.git"
checksum = "f5ca191afea933d50a36d101009b5644dc28bc99"
9 changes: 6 additions & 3 deletions src/modules/auctions/batch/FPB.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ contract FixedPriceBatch is BatchAuctionModule, IFixedPriceBatch {

/// @inheritdoc Module
function VEECODE() public pure override returns (Veecode) {
return toVeecode("01FPBA");
return toVeecode("03FPBA");
}

// ========== AUCTION ========== //
Expand Down Expand Up @@ -122,8 +122,11 @@ contract FixedPriceBatch is BatchAuctionModule, IFixedPriceBatch {

// Refund will be within the bounds of uint96
// bidAmount is uint96, excess < fullFill, so bidAmount * excess / fullFill < bidAmount < uint96 max
uint96 refund = uint96(Math.fullMulDiv(bidAmount_, excess, fullFill));
uint256 payout = fullFill - excess;
// We round up here to avoid over filling the auction, which has downstream effects
uint96 refund = uint96(Math.fullMulDivUp(bidAmount_, excess, fullFill));
// Calculate the payout for the bid amount minus the refund
// We do this again instead of using the fullFill - excess to avoid rounding errors
uint256 payout = Math.fullMulDiv(bidAmount_ - refund, baseScale_, price_);

return (PartialFill({bidId: bidId_, refund: refund, payout: payout}));
}
Expand Down
1 change: 1 addition & 0 deletions test/modules/auctions/FPB/FPBTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ abstract contract FpbTest is Test, Permit2User {
uint48 internal constant _DURATION = 1 days;
uint24 internal constant _MIN_FILL_PERCENT = 50e2; // 50%
uint256 internal constant _PRICE = 2e18;
uint24 internal constant _ONE_HUNDRED_PERCENT = 100e2;

BatchAuctionHouse internal _auctionHouse;
FixedPriceBatch internal _module;
Expand Down
Loading

0 comments on commit a2443d2

Please sign in to comment.