Skip to content

Commit

Permalink
Merge pull request #216 from Axis-Fi/ref-fee-by-auction
Browse files Browse the repository at this point in the history
feat: Set referrer fee by auction
  • Loading branch information
Oighty authored Jul 8, 2024
2 parents 27ed43d + b91ecd3 commit 22d310d
Show file tree
Hide file tree
Showing 53 changed files with 408 additions and 293 deletions.
6 changes: 3 additions & 3 deletions script/ops/test/FixedPriceBatch-BaseDTL/TestData.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ contract TestData is Script, WithEnvironment {

routingParams.callbackData = abi.encode(
BaseDirectToLiquidity.OnCreateParams({
proceedsUtilisationPercent: 50_000, // 50%
proceedsUtilisationPercent: 5000, // 50%
vestingStart: 0,
vestingExpiry: 0,
recipient: msg.sender,
Expand All @@ -80,7 +80,7 @@ contract TestData is Script, WithEnvironment {

IFixedPriceBatch.AuctionDataParams memory auctionDataParams;
auctionDataParams.price = 2e18; // 2 quote tokens per base token
auctionDataParams.minFillPercent = uint24(10_000); // 10%
auctionDataParams.minFillPercent = uint24(1000); // 10%
bytes memory implParams = abi.encode(auctionDataParams);

uint48 duration = 86_400; // 1 day
Expand Down Expand Up @@ -152,7 +152,7 @@ contract TestData is Script, WithEnvironment {
console2.log("Timestamp is", block.timestamp);

bytes memory callbackData =
abi.encode(UniswapV2DirectToLiquidity.OnSettleParams({maxSlippage: 500})); // 0.5%
abi.encode(UniswapV2DirectToLiquidity.OnSettleParams({maxSlippage: 50})); // 0.5%

vm.broadcast();
auctionHouse.settle(lotId_, 100, callbackData);
Expand Down
2 changes: 1 addition & 1 deletion script/ops/test/FixedPriceBatch/TestData.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ contract TestData is Script, WithEnvironment {

IFixedPriceBatch.AuctionDataParams memory auctionDataParams;
auctionDataParams.price = 1e18; // 1 quote tokens per base token
auctionDataParams.minFillPercent = uint24(10_000); // 10%
auctionDataParams.minFillPercent = uint24(1000); // 10%
bytes memory implParams = abi.encode(auctionDataParams);

uint48 duration = 86_400; // 1 day
Expand Down
2 changes: 1 addition & 1 deletion script/ops/test/TestData.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ contract TestData is Script {

EncryptedMarginalPrice.AuctionDataParams memory auctionDataParams;
auctionDataParams.minPrice = 2e18; // 2 quote tokens per base token
auctionDataParams.minFillPercent = uint24(10_000); // 10%
auctionDataParams.minFillPercent = uint24(1000); // 10%
auctionDataParams.minBidSize = 2e17; // 0.2 quote tokens
auctionDataParams.publicKey = publicKey;
bytes memory implParams = abi.encode(auctionDataParams);
Expand Down
58 changes: 29 additions & 29 deletions script/salts/salts.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,51 +50,51 @@
"0xed4ba02077e70f78db70ce191509333d2dcccfff136d30dcb011f567305e88ad": "0x2b8bc588174d409692f1bd993942e3806c9a11344dbe674f46aed32a030aacf1"
},
"Test_AllocatedMerkleAllowlist": {
"0x1242d528fb3d9259e7192f83e1faf95370bfd8d7f2b1bae5d3ea350d3d9c563c": "0x28e7327bdc82ee44449f42101aa212b1e74f2a93096f042ff8e37b4241f6f6bc",
"0x7cca57da19a5847b2b87641c1b721a32d4778e3e58641d6771cd14ed112b3bc3": "0x29bd6d7f6b3a5ddb3bf649b30def344e7f58341330dd7a9a790c796c50a1389e"
"0xb17794250569bcd64aae2ec1312399120db92167bf0a2602821e0ee953dd3d31": "0xa8a4fc4fb8d721bdce27342cdd381eb510362146f49e56698a8bcb6c639306ff",
"0xecbee26b3d0e662be84e4cef678b23166957f507ca68f32eaa49e60ceb567981": "0x1598e58155ab6f6f2d8b2813c5c763f04ab980c3e65dffe2b3a312e8ccba4ae7"
},
"Test_CappedMerkleAllowlist": {
"0x2e55fe4d6c3005f7bf152a42653bd234155cdac7f621582ba16b664c115ba76b": "0xc961b67b98b4a302830734a6b25bbfd43e1588d7dc8864ef0cbec61eae24ea6b",
"0xbd19b648b51fb3fe1bd9e42ad4018b839966abea0f4e25a9149dffdc7cc86a4e": "0x224b2bdc957fe4361ef23a7f6f187185518d32edb7b74298665c5f67b6252b88"
"0xa0ed568f98efa2efd4e93f21a5445970919a333349a8f5369a28ae93271d9cca": "0x6fb3e2a45254801d17269019f8afcadbd132d417f4dde1bfc65dd8f440256a56",
"0xfd2c28cb6c38931a1f784078c41d21d7bf8fc3653231edca225a5fbbc50529dc": "0x88a482ab0eacd2d6c1fc7b3858bfba29aa92b8abfc6239e02e6952640c3ebdf7"
},
"Test_GUniFactory": {
"0x3bf0e882023640f31bf861e1f13d306fd4fbb7afb7860e21a489062cbefcf885": "0x397acf3db4cc9c81f8c1975a5505e392e6b5f8eb3b22efcc094b3e0f39f6739b"
"0xa8ee5069b769099da4dbc8c5d4c95cb74d416554203119678be4d0eba33f5962": "0x767e6faad4f8e62d6ab897930a0eb497cb71ebc75f90856dc13996fb00b907d3"
},
"Test_MockCallback": {
"0x0825d99059fe0dc95e0b5cd7b853a5f3f50b58f25c5812fc7fd01d69ff4ec679": "0xb7a4a5d87212f8332bfc341e299c38bad62191c76db3d8908bc03edf21619f3a",
"0x51526251ca3003df174c65f2fb581f61820ce57c14720e0d67480ed8c8b77925": "0x546f04b8a6c02b7020fdd76e00b310c3cd6529edbf16df4bba15bd1cf87c1ebb",
"0x6206c9845f35f3006fc507c15aaaf4a719380265cf472773a270ffe6d5eb5299": "0xf2a3e0322592715d20bb1488f7c78a951b042efe6dc00626c72a93a5ce6d71ca",
"0x6b7fa77ae82f95cc8c5fe53dca64702ea0dc8e3dad74749dc8cd77de2884e704": "0x36031ea9a844fbdcd342bbe4ecfdfe4fa11bcc9cb101f3e7ad066817d6885c5e",
"0x7310243dabd76344326f3659aabda0b846a9c8e9e7d50b990261c14f2b44d560": "0x87cb2e6062af84c8c97bb3a862450588e07e9e5f4524dd4533b97fd5558681af",
"0x7602309c05771de8281f2f3f08e74ec9f19f1bfdaac8cd970d9f7a8d62173b6e": "0xc79ce4088cc3768ea80f75cf09382e910a6a3bda6820425f59a135d904d19e7a",
"0x892e1120a976151ae5375dca978040abe705c8cbdd3c7b64b41ff1087ee01c22": "0x827a5abbfe10744fb2b7996f5fcd778e5ec24b1b66842b508404ab88e0482ffb",
"0x8a69dcb863773a3bb971a969233286e75cba80abf6ec8d881cada7ea0ad674b0": "0x961da2f1f56f28f5f611b28eaee534e4ab9fb97f667c87c206b17c318950b3a6",
"0x8d8681a539f3b359e94a05239187dc55cb9cb2dcfe01726d3053573206efe25f": "0xd12e9def75c53f609c70b267b8559f101b03bb58050adf7f3e812e34782e4e88",
"0x918d87a20c837fa93ce3089d2cb6386b66f79bbfd0f09bd6784bc52108b69938": "0x1fabbf534809aa468599d96ffc3c1611bd4458f987f1acec148c357e57337016",
"0x9569f58e5e127ceb73049eea8119bb21f8c4328d3b4770da5a67075be3f77c12": "0x20e7f82882d05c6863060ca2595a71559399f6dc1385df42614b05abc3eff00f",
"0x96f0481f00eeec717fa8c0d41efd04b6e3fdccbebbaa223ee2118449ebea2406": "0xbc9e61c0cdccc55ffd76261116dfb060ac0fcd0b31ff2a2ea72514203c0a3827",
"0x9c35a3189126603f4b187149f54e09082403dac10b3e899a503e28e897edd6f9": "0x1fecf5b8fd3291d3880a530457a7bc463de1bdb81f68fd83758b4ecfbd5c3659",
"0x9db4bc605469ede684fbaa475d320b3fbe6a707deaa953ee1ba29ecb3c1125fb": "0xda4a90b47357900f3e1c38792de6662d56ece5aed01c3f3ac5020ff32e08032c",
"0xb8e0b3cbd7273e83cfdbcb8269e5c3510a28892e815fe28bc0f515be0df2c8f9": "0xe8492376ab5a5d642160463b00d38a9b5b87e2fc8afce127983dc6d1dc97d776",
"0xc38bb4813ebdb9978d2485ae5ad92e1152f8a955430a63210b69b2277eed9477": "0xcedce64703d22ccb65bdc86d9fe6d0abea6ec29792c91b423152594bd5336976",
"0xd75e639b43b1d29e1703abcd2616b6b67f3ae232d53915d472f3a5b6aae6083c": "0x521b594ba447613faa8fb22609d92fc85fe3d1644b8d5804b23fffa496e30317",
"0xf2644573f57aea10dffac6e7215b409fa19236ae57b735b20b9fac9834391850": "0x2cd20318c8db20614867990e6284ceff46a54997d19f3213179292f7f2922e47"
"0x052a304d0a4a19a819c4e1501b45b4f1b49f73d1a7cac910386fe5fc509633a4": "0x1416c5dbf5cb95f1d5793df295de71f9fd1f46cf6e2cbdf08863e720fa750dbb",
"0x211f0c56d141fbeca1844d250c6a356beb00eaecc7afef8cd01797aa6b730ba6": "0x3370640c5c28a175b894e158639b0f4816d1e4bcf325f5f89a4050de8ccf411e",
"0x409bf08f08583ee56edee5cf91c507ce0ee7cd3a33d6b176505cde7e6fab5212": "0x81186eaf6b4b0d7f71f87e99e0aaeafcde574f4e20f864336048af6101a7a659",
"0x42425e602c9c169d71be77da2f8ca1fc0718c859fc8a1a8940e010485b9b2db4": "0xce98aa80db26c48c509f9d86fdf44077cd284e0baf845ed61ea1e54ff438faf3",
"0x4eb19888c437940923b0c1e78a04f1afe2a75dae78812574ba219f022fc5395a": "0x092aa8eb4b28032933998f30facb211484b12b7207ce3f676234b237acbe4c4f",
"0x65861ca173680f85c64b5ecb1041d69eba8addf2e4f3acde8ae4b0ec5f2625f5": "0xf3606e9e86d1e343eaf312d9bb5d5d7257ae7c4ee4dea7b6144be39404ae7566",
"0x732ffa915e7dee8ddde1f40a62d2a275e439a4fc180fa652b48e733b460fdd52": "0xf0b1ff5d2cc49cf228765a5ad0047c9029db01c999dc9139fc0c080c971ec3ad",
"0x819496f5a9c8dd326fdaaafa185159c136315d5abee91896f192dbdf2212768d": "0x1d38cc38fc757c41118353c34f871675a39b3843c62020f07e63f2dcaa267b7f",
"0x9df1908fad57611d75eb1b9d9a581ddc43baeaa767a14f5ddd26fe371bbcf06b": "0xfac5b6eb0f88cdab581445b9cb6f317d8ad097e988541ab3ab74334638e247e1",
"0xb10e85dc047de055ec7bcc8d8933f859c8c220aa1540e8d61f36e6391d5975fd": "0x30087b2a5b449b4fb632f6858e86243c9476b6521991f8256527f621a8a8af81",
"0xb262c3f41c3ffc3d264c72a40f60b02c497017ed75f73524e008f3ead803a998": "0xc4fb6028a62a1ebb3e33910ba5f875777b3e1877daa1fd1a465b075a8dc3548e",
"0xb582fee2a3f0fd5f455d98b1278099ceadb1a7c9d46e93e5100c8cc86aa4a388": "0xa34430ed6623eef78717e4bcb59843758b68c7ea37ef50bb4ba472534a156bda",
"0xbcd87b9a1206b37ef12053cbcac10515fbf400962837441462e04daa9e2ddc98": "0x7e913e29cef66a3db4d682a778c4db37601378be8d4144f9a5be8f5430f7cf62",
"0xc9ae4a5f6e1baf9009493d9068d9f61f8461a99a23532a7f8ed98393106ef560": "0x2200c04638ed027c9286c69d17b96121b7b182997133e3a68460cfd38cc1b2b4",
"0xd3e19abee55b3295d081f5777c0e642f7c7023552b5ae035ecc53f706fd90e63": "0x44747a53705f7f43c295715c328bf7e7b6ba483a82a77c644a35545c078c4e22",
"0xf12ef8015ea1ab65c40a62ad74a87c7a97bbc2736afd3f81f1cec73bc2290b45": "0xfa7bd314eaf70ba7c05504a7fc24ad5d4e5277d6852a6e357580a234fa7dd999",
"0xf36332cb1efc8bc6ea44da0a8971f853fc081b8487c5d4d3e09c1de201a68bc5": "0xa1a3bbe1723fe51343e379b98391874b47fa2b0a932ea45167f2416b400cb845",
"0xf745ee60388fc42e05923e38f1c09237e8514387e3a4b328c576a52aaa29c9b3": "0xa8370ffde74fd9bb4b68b57ffbf14b5957a28f1d86f7a8ae87242469ffee9f6d"
},
"Test_TokenAllowlist": {
"0x11e024c2f0ada4ce2ce048af08354dfa64f38ad959564c55e6bbf48d2ed3822e": "0x8f58340cfc39502e9dc50b771cdb06a14b3204f685adf563f2f5020d483feacf",
"0x78a7c23f669f5df656575693f45f928b7af2ed4bc981cf6dec77bef2c03bb081": "0xd06371a3e80e11b111e5c68c712d696aa236bf4d29808847295a7a6324af4f84"
"0x11e024c2f0ada4ce2ce048af08354dfa64f38ad959564c55e6bbf48d2ed3822e": "0xc763d91027e5243c9d7020f419199d114f74f8e8c2e2e668a0e25ff5bb66c6e8",
"0x78a7c23f669f5df656575693f45f928b7af2ed4bc981cf6dec77bef2c03bb081": "0xf0bc4482fcf2593df36fb9fb83ee5d273e7ee6a3caa9414d9c24eeee96567b6f"
},
"Test_UniswapV2DirectToLiquidity": {
"0xbce774b5c75ce6af2b000bd157d0966753042aba6fde38f5ea2eca76b585791f": "0x55208611cec0a88da835309df48d0102dbdb45baa128b2555052f0a2fcd526d8"
"0x9c33aa54294ebd7a8909181ebd6aed2b967b0eb4b0fb95467495624e6c211a67": "0xba73f6582c497ae5c4d38c53ba8bfb98266aa3566aaafef6d00f65d327effd66"
},
"Test_UniswapV2Router": {
"0xe6204aa211921628df345ff0b909c863298684cd8ca65de5479af6b70662e622": "0xf508fd71ff40f5d0640b01b9384f98d35db43c7ddb0d4abe274d61fdf1ea967f"
"0xe6204aa211921628df345ff0b909c863298684cd8ca65de5479af6b70662e622": "0xf5700f795856223d45b9e1b76fa0f23db9d770b25c44cae8f556ae6d1e7bee5e"
},
"Test_UniswapV3DirectToLiquidity": {
"0x58b7674df101688da4f68d9cfad65390f1f35abe1c999bd0a251069b8883f528": "0x6382557258b960eca0a5069b80205235e370fb2ce399d29ec5a9307e66799c49"
"0xca7cd77c52253f2e1eec58c25dbb3b89ccaa938974767ed31217819f71d2db06": "0xdb4b3fa1df0a6205daaeb852a4b456a86df10140fd1d479072f7c62ea9ba7a79"
},
"Test_UniswapV3Factory": {
"0xbcd657c3390ecd2e1782b6473400c51fa124922eb98b69f1b5192eb0f8e3d3df": "0x3448ebb18cb03fae2e9153c621d46f1b9b8941cc66e7063b587fe4a284490b01"
"0xbcd657c3390ecd2e1782b6473400c51fa124922eb98b69f1b5192eb0f8e3d3df": "0xfad08a6eaa7974f06cec79e15064de7f6fa17b22ecdb3764988b2c4b1571c613"
},
"TokenAllowlist": {
"0x09db47d395a68db033a3b222b9d1a212cec8422b03aeafc313aa4d2813c6dd60": "0xe07a005213f35e1f050a4da040d6bc3cae2ad333647b51a6ffa2e7941980043a",
Expand Down
2 changes: 1 addition & 1 deletion script/salts/test/test_salts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fi
# Check if saltKey is specified
if [ -z "$saltKey" ]
then
echo "No salt key specified. Provide the salt key after the --key flag."
echo "No salt key specified. Provide the salt key after the --saltKey flag."
exit 1
fi

Expand Down
9 changes: 3 additions & 6 deletions src/AtomicAuctionHouse.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import {AuctionHouse} from "src/bases/AuctionHouse.sol";
import {AuctionModule} from "src/modules/Auction.sol";
import {AtomicAuctionModule} from "src/modules/auctions/AtomicAuctionModule.sol";

import {Keycode, keycodeFromVeecode} from "src/modules/Keycode.sol";

/// @title AtomicAuctionHouse
/// @notice As its name implies, the AtomicAuctionHouse is where atomic auction lots are created and purchased. The core protocol logic is implemented here.
contract AtomicAuctionHouse is IAtomicAuctionHouse, AuctionHouse {
Expand Down Expand Up @@ -112,13 +110,12 @@ contract AtomicAuctionHouse is IAtomicAuctionHouse, AuctionHouse {
Routing storage routing = lotRouting[params_.lotId];

// Calculate quote fees for purchase
// Note: this enables protocol and referrer fees to be changed between purchases
// Fees were cached on auction creation, so they are consistent for an auction
uint256 amountLessFees;
{
Keycode auctionKeycode = keycodeFromVeecode(routing.auctionReference);
uint256 totalFees = _allocateQuoteFees(
fees[auctionKeycode].protocol,
fees[auctionKeycode].referrer,
lotFees[params_.lotId].protocolFee,
lotFees[params_.lotId].referrerFee,
params_.referrer,
routing.seller,
ERC20(routing.quoteToken),
Expand Down
2 changes: 1 addition & 1 deletion src/AtomicCatalogue.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ contract AtomicCatalogue is IAtomicCatalogue, Catalogue {
IFeeManager(auctionHouse).calculateQuoteFees(protocolFee, referrerFee, true, amount_);

// Get payout from module
return module.payoutFor(lotId_, amount_ - uint96(toProtocol) - uint96(toReferrer));
return module.payoutFor(lotId_, amount_ - toProtocol - toReferrer);
}

/// @inheritdoc IAtomicCatalogue
Expand Down
18 changes: 13 additions & 5 deletions src/bases/AuctionHouse.sol
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,15 @@ abstract contract AuctionHouse is IAuctionHouse, WithModules, ReentrancyGuard, F
uint48 curatorFee = auctionFees.curator[routing_.curator];
lotFee.curatorFee = curatorFee > maxCuratorFee ? maxCuratorFee : curatorFee;

// Snapshot the protocol and referrer fees
// Check that the referrer fee does not exceed the max.
// If it does, revert. We revert here since the value is provided by the submitter
// and can be changed whereas the curator fee above is set by someone else.
// Otherwise, set the value.
if (routing_.referrerFee > auctionFees.maxReferrerFee) revert InvalidParams();
lotFee.referrerFee = routing_.referrerFee;

// Snapshot the protocol fee
lotFee.protocolFee = auctionFees.protocol;
lotFee.referrerFee = auctionFees.referrer;
}

// Derivative
Expand Down Expand Up @@ -435,11 +441,13 @@ abstract contract AuctionHouse is IAuctionHouse, WithModules, ReentrancyGuard, F
if (fee_ > _FEE_DECIMALS) revert InvalidFee();

// Set fee based on type
// Or a combination of protocol and referrer fee since they are both in the quoteToken?
// Protocol and max referrer fee cannot exceed 100%
if (type_ == FeeType.Protocol) {
if (fee_ + fees[auctionType_].maxReferrerFee > _FEE_DECIMALS) revert InvalidFee();
fees[auctionType_].protocol = fee_;
} else if (type_ == FeeType.Referrer) {
fees[auctionType_].referrer = fee_;
} else if (type_ == FeeType.MaxReferrer) {
if (fee_ + fees[auctionType_].protocol > _FEE_DECIMALS) revert InvalidFee();
fees[auctionType_].maxReferrerFee = fee_;
} else if (type_ == FeeType.MaxCurator) {
fees[auctionType_].maxCuratorFee = fee_;
}
Expand Down
4 changes: 2 additions & 2 deletions src/bases/Catalogue.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ abstract contract Catalogue is ICatalogue {
/// @inheritdoc ICatalogue
address public auctionHouse;

/// @notice Fees are in basis points (3 decimals). 1% equals 1000.
uint48 internal constant _FEE_DECIMALS = 1e5;
/// @notice Fees are in basis points (hundredths of a percent). 1% equals 100.
uint48 internal constant _FEE_DECIMALS = 100e2;

// ========== CONSTRUCTOR ========== //

Expand Down
8 changes: 4 additions & 4 deletions src/bases/FeeManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import {Keycode} from "src/modules/Keycode.sol";
abstract contract FeeManager is IFeeManager, ReentrancyGuard {
// ========== STATE VARIABLES ========== //

/// @notice Fees are in basis points (3 decimals). 1% equals 1000.
uint48 internal constant _FEE_DECIMALS = 1e5;
/// @notice Fees are in basis points (hundredths of a percent). 1% equals 100.
uint48 internal constant _FEE_DECIMALS = 100e2;

/// @notice Address the protocol receives fees at
address internal _protocol;
Expand Down Expand Up @@ -90,10 +90,10 @@ abstract contract FeeManager is IFeeManager, ReentrancyGuard {
external
view
override
returns (uint48 protocol, uint48 referrer, uint48 maxCuratorFee)
returns (uint48 protocol, uint48 maxReferrerFee, uint48 maxCuratorFee)
{
Fees storage fee = fees[auctionType_];
return (fee.protocol, fee.referrer, fee.maxCuratorFee);
return (fee.protocol, fee.maxReferrerFee, fee.maxCuratorFee);
}

/// @inheritdoc IFeeManager
Expand Down
20 changes: 10 additions & 10 deletions src/callbacks/liquidity/BaseDTL.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ abstract contract BaseDirectToLiquidity is BaseCallback {
/// @param recipient The recipient of the LP tokens
/// @param lotCapacity The capacity of the lot
/// @param lotCuratorPayout The maximum curator payout of the lot
/// @param proceedsUtilisationPercent The percentage of the proceeds to deposit into the pool
/// @param proceedsUtilisationPercent The percentage of the proceeds to deposit into the pool, in basis points (1% = 100)
/// @param vestingStart The start of the vesting period for the LP tokens (0 if disabled)
/// @param vestingExpiry The end of the vesting period for the LP tokens (0 if disabled)
/// @param linearVestingModule The LinearVesting module for the LP tokens (only set if linear vesting is enabled)
Expand Down Expand Up @@ -76,7 +76,7 @@ abstract contract BaseDirectToLiquidity is BaseCallback {

// ========== STATE VARIABLES ========== //

uint24 public constant MAX_PERCENT = 1e5;
uint24 public constant ONE_HUNDRED_PERCENT = 100e2;
bytes5 public constant LINEAR_VESTING_KEYCODE = 0x4c49560000; // "LIV"

/// @notice Maps the lot id to the DTL configuration
Expand Down Expand Up @@ -136,10 +136,10 @@ abstract contract BaseDirectToLiquidity is BaseCallback {
// Proceeds utilisation
if (
params.proceedsUtilisationPercent == 0
|| params.proceedsUtilisationPercent > MAX_PERCENT
|| params.proceedsUtilisationPercent > ONE_HUNDRED_PERCENT
) {
revert Callback_Params_PercentOutOfBounds(
params.proceedsUtilisationPercent, 1, MAX_PERCENT
params.proceedsUtilisationPercent, 1, ONE_HUNDRED_PERCENT
);
}

Expand Down Expand Up @@ -311,9 +311,9 @@ abstract contract BaseDirectToLiquidity is BaseCallback {
// 11 refund
// Utilisation = 1 - 11/110 = 90%
uint256 utilisationPercent =
1e5 - refund_ * 1e5 / (config.lotCapacity + config.lotCuratorPayout);
100e2 - refund_ * 100e2 / (config.lotCapacity + config.lotCuratorPayout);

capacityUtilised = (config.lotCapacity * utilisationPercent) / MAX_PERCENT;
capacityUtilised = (config.lotCapacity * utilisationPercent) / ONE_HUNDRED_PERCENT;
}

// Calculate the base tokens required to create the pool
Expand Down Expand Up @@ -409,18 +409,18 @@ abstract contract BaseDirectToLiquidity is BaseCallback {
uint256 amount_,
uint24 slippage_
) internal pure returns (uint256) {
if (slippage_ > MAX_PERCENT) {
revert Callback_Params_PercentOutOfBounds(slippage_, 0, MAX_PERCENT);
if (slippage_ > ONE_HUNDRED_PERCENT) {
revert Callback_Params_PercentOutOfBounds(slippage_, 0, ONE_HUNDRED_PERCENT);
}

return (amount_ * (MAX_PERCENT - slippage_)) / MAX_PERCENT;
return (amount_ * (ONE_HUNDRED_PERCENT - slippage_)) / ONE_HUNDRED_PERCENT;
}

function _tokensRequiredForPool(
uint256 amount_,
uint24 proceedsUtilisationPercent_
) internal pure returns (uint256) {
return (amount_ * proceedsUtilisationPercent_) / MAX_PERCENT;
return (amount_ * proceedsUtilisationPercent_) / ONE_HUNDRED_PERCENT;
}

function _getLatestLinearVestingModule() internal view returns (address) {
Expand Down
Loading

0 comments on commit 22d310d

Please sign in to comment.