Created
March 5, 2026 14:04
-
-
Save pkoch/63fa08c54fb3a76d17ad2aa2532e832f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/script/initial-distribution/src/abiChecker.ts b/script/initial-distribution/src/abiChecker.ts | |
| index 23e11ae..dbc4cf4 100644 | |
| --- a/script/initial-distribution/src/abiChecker.ts | |
| +++ b/script/initial-distribution/src/abiChecker.ts | |
| @@ -72,7 +72,7 @@ export function checkAbiAgainstArtifact( | |
| } | |
| const ARTIFACTS = [ | |
| - ["ContinuousClearingAuction.sol/ContinuousClearingAuction.json", "CCA"] as const, | |
| + //["ContinuousClearingAuction.sol/ContinuousClearingAuction.json", "CCA"] as const, | |
| ["CCADisbursementTracker.sol/CCADisbursementTracker.json", "Tracker"] as const, | |
| ["ERC20.sol/ERC20.json", "ERC20"] as const, | |
| ["TDEDisbursement.sol/TDEDisbursement.json", "TDEDisbursement"] as const, | |
| @@ -93,7 +93,7 @@ function resolveArtifactPath(exactPath: string): string | null { | |
| const ABI_DRIFT_SUFFIX = "Update script/initial-distribution/src/abis.ts to match the contract."; | |
| export function assertAbisMatchArtifacts(abis: { | |
| - ccaAbi: AbiEntry; | |
| + //ccaAbi: AbiEntry; | |
| trackerAbi: AbiEntry; | |
| erc20Abi: AbiEntry; | |
| tdeDisbursementAbi: AbiEntry; | |
| @@ -121,7 +121,7 @@ export function assertAbisMatchArtifacts(abis: { | |
| } | |
| const abiByLabel = { | |
| - CCA: abis.ccaAbi, | |
| + //CCA: abis.ccaAbi, | |
| Tracker: abis.trackerAbi, | |
| ERC20: abis.erc20Abi, | |
| TDEDisbursement: abis.tdeDisbursementAbi, | |
| diff --git a/script/initial-distribution/src/abis.ts b/script/initial-distribution/src/abis.ts | |
| index c8e96d6..5cc9c42 100644 | |
| --- a/script/initial-distribution/src/abis.ts | |
| +++ b/script/initial-distribution/src/abis.ts | |
| @@ -67,136 +67,659 @@ export const trackerAbi = [ | |
| export const ccaAbi = [ | |
| { | |
| + inputs: [ | |
| + { internalType: "address", name: "_token", type: "address" }, | |
| + { internalType: "uint128", name: "_totalSupply", type: "uint128" }, | |
| + { | |
| + components: [ | |
| + { internalType: "address", name: "currency", type: "address" }, | |
| + { internalType: "address", name: "tokensRecipient", type: "address" }, | |
| + { internalType: "address", name: "fundsRecipient", type: "address" }, | |
| + { internalType: "uint64", name: "startBlock", type: "uint64" }, | |
| + { internalType: "uint64", name: "endBlock", type: "uint64" }, | |
| + { internalType: "uint64", name: "claimBlock", type: "uint64" }, | |
| + { internalType: "uint256", name: "tickSpacing", type: "uint256" }, | |
| + { internalType: "address", name: "validationHook", type: "address" }, | |
| + { internalType: "uint256", name: "floorPrice", type: "uint256" }, | |
| + { internalType: "uint128", name: "requiredCurrencyRaised", type: "uint128" }, | |
| + { internalType: "bytes", name: "auctionStepsData", type: "bytes" }, | |
| + ], | |
| + internalType: "struct AuctionParameters", | |
| + name: "_parameters", | |
| + type: "tuple", | |
| + }, | |
| + ], | |
| + stateMutability: "nonpayable", | |
| + type: "constructor", | |
| + }, | |
| + { inputs: [], name: "AuctionIsNotFinalized", type: "error" }, | |
| + { inputs: [], name: "AuctionIsNotOver", type: "error" }, | |
| + { inputs: [], name: "AuctionIsOver", type: "error" }, | |
| + { inputs: [], name: "AuctionNotStarted", type: "error" }, | |
| + { inputs: [], name: "AuctionSoldOut", type: "error" }, | |
| + { | |
| + inputs: [ | |
| + { internalType: "address", name: "expectedOwner", type: "address" }, | |
| + { internalType: "address", name: "receivedOwner", type: "address" }, | |
| + ], | |
| + name: "BatchClaimDifferentOwner", | |
| + type: "error", | |
| + }, | |
| + { inputs: [], name: "BidAlreadyExited", type: "error" }, | |
| + { inputs: [], name: "BidAmountTooSmall", type: "error" }, | |
| + { | |
| + inputs: [{ internalType: "uint256", name: "bidId", type: "uint256" }], | |
| + name: "BidIdDoesNotExist", | |
| + type: "error", | |
| + }, | |
| + { inputs: [], name: "BidMustBeAboveClearingPrice", type: "error" }, | |
| + { inputs: [], name: "BidNotExited", type: "error" }, | |
| + { inputs: [], name: "BidOwnerCannotBeZeroAddress", type: "error" }, | |
| + { inputs: [], name: "CannotExitBid", type: "error" }, | |
| + { inputs: [], name: "CannotPartiallyExitBidBeforeEndBlock", type: "error" }, | |
| + { inputs: [], name: "CannotPartiallyExitBidBeforeGraduation", type: "error" }, | |
| + { inputs: [], name: "CannotSweepCurrency", type: "error" }, | |
| + { inputs: [], name: "CannotSweepTokens", type: "error" }, | |
| + { inputs: [], name: "CannotUpdateUninitializedTick", type: "error" }, | |
| + { inputs: [], name: "CheckpointBlockNotIncreasing", type: "error" }, | |
| + { inputs: [], name: "ClaimBlockIsBeforeEndBlock", type: "error" }, | |
| + { inputs: [], name: "CurrencyIsNotNative", type: "error" }, | |
| + { inputs: [], name: "ERC20TransferFailed", type: "error" }, | |
| + { | |
| + inputs: [ | |
| + { internalType: "uint256", name: "nextTick", type: "uint256" }, | |
| + { internalType: "uint256", name: "maxBidPrice", type: "uint256" }, | |
| + ], | |
| + name: "FloorPriceAndTickSpacingGreaterThanMaxBidPrice", | |
| + type: "error", | |
| + }, | |
| + { inputs: [], name: "FloorPriceAndTickSpacingTooLarge", type: "error" }, | |
| + { inputs: [], name: "FloorPriceIsZero", type: "error" }, | |
| + { inputs: [], name: "FloorPriceTooLow", type: "error" }, | |
| + { inputs: [], name: "FundsRecipientIsZero", type: "error" }, | |
| + { inputs: [], name: "InvalidAmount", type: "error" }, | |
| + { inputs: [], name: "InvalidAuctionDataLength", type: "error" }, | |
| + { | |
| + inputs: [ | |
| + { internalType: "uint256", name: "maxPrice", type: "uint256" }, | |
| + { internalType: "uint256", name: "maxBidPrice", type: "uint256" }, | |
| + ], | |
| + name: "InvalidBidPriceTooHigh", | |
| + type: "error", | |
| + }, | |
| + { inputs: [], name: "InvalidBidUnableToClear", type: "error" }, | |
| + { inputs: [], name: "InvalidEndBlock", type: "error" }, | |
| + { | |
| + inputs: [ | |
| + { internalType: "uint64", name: "actualEndBlock", type: "uint64" }, | |
| + { internalType: "uint64", name: "expectedEndBlock", type: "uint64" }, | |
| + ], | |
| + name: "InvalidEndBlockGivenStepData", | |
| + type: "error", | |
| + }, | |
| + { inputs: [], name: "InvalidLastFullyFilledCheckpointHint", type: "error" }, | |
| + { inputs: [], name: "InvalidOutbidBlockCheckpointHint", type: "error" }, | |
| + { | |
| + inputs: [ | |
| + { internalType: "uint256", name: "actualMps", type: "uint256" }, | |
| + { internalType: "uint256", name: "expectedMps", type: "uint256" }, | |
| + ], | |
| + name: "InvalidStepDataMps", | |
| + type: "error", | |
| + }, | |
| + { inputs: [], name: "InvalidTickPrice", type: "error" }, | |
| + { inputs: [], name: "InvalidTokenAmountReceived", type: "error" }, | |
| + { inputs: [], name: "MpsRemainingIsZero", type: "error" }, | |
| + { inputs: [], name: "NativeTransferFailed", type: "error" }, | |
| + { inputs: [], name: "NotClaimable", type: "error" }, | |
| + { inputs: [], name: "NotGraduated", type: "error" }, | |
| + { inputs: [], name: "Reentrancy", type: "error" }, | |
| + { inputs: [], name: "StepBlockDeltaCannotBeZero", type: "error" }, | |
| + { inputs: [], name: "StepLib__InvalidOffsetNotAtStepBoundary", type: "error" }, | |
| + { inputs: [], name: "StepLib__InvalidOffsetTooLarge", type: "error" }, | |
| + { | |
| + inputs: [ | |
| + { internalType: "uint256", name: "tickPrice", type: "uint256" }, | |
| + { internalType: "uint256", name: "nextActiveTickPrice", type: "uint256" }, | |
| + ], | |
| + name: "TickHintMustBeGreaterThanNextActiveTickPrice", | |
| + type: "error", | |
| + }, | |
| + { inputs: [], name: "TickNotInitialized", type: "error" }, | |
| + { inputs: [], name: "TickPreviousPriceInvalid", type: "error" }, | |
| + { inputs: [], name: "TickPriceNotAtBoundary", type: "error" }, | |
| + { inputs: [], name: "TickPriceNotIncreasing", type: "error" }, | |
| + { inputs: [], name: "TickSpacingTooSmall", type: "error" }, | |
| + { inputs: [], name: "TokenAndCurrencyCannotBeTheSame", type: "error" }, | |
| + { inputs: [], name: "TokenIsAddressZero", type: "error" }, | |
| + { inputs: [], name: "TokenTransferFailed", type: "error" }, | |
| + { inputs: [], name: "TokensNotReceived", type: "error" }, | |
| + { inputs: [], name: "TokensRecipientIsZero", type: "error" }, | |
| + { inputs: [], name: "TotalSupplyIsTooLarge", type: "error" }, | |
| + { inputs: [], name: "TotalSupplyIsZero", type: "error" }, | |
| + { | |
| + inputs: [{ internalType: "bytes", name: "reason", type: "bytes" }], | |
| + name: "ValidationHookCallFailed", | |
| + type: "error", | |
| + }, | |
| + { | |
| + anonymous: false, | |
| + inputs: [ | |
| + { indexed: false, internalType: "uint256", name: "startBlock", type: "uint256" }, | |
| + { indexed: false, internalType: "uint256", name: "endBlock", type: "uint256" }, | |
| + { indexed: false, internalType: "uint24", name: "mps", type: "uint24" }, | |
| + ], | |
| + name: "AuctionStepRecorded", | |
| + type: "event", | |
| + }, | |
| + { | |
| + anonymous: false, | |
| + inputs: [ | |
| + { indexed: true, internalType: "uint256", name: "bidId", type: "uint256" }, | |
| + { indexed: true, internalType: "address", name: "owner", type: "address" }, | |
| + { indexed: false, internalType: "uint256", name: "tokensFilled", type: "uint256" }, | |
| + { indexed: false, internalType: "uint256", name: "currencyRefunded", type: "uint256" }, | |
| + ], | |
| + name: "BidExited", | |
| type: "event", | |
| + }, | |
| + { | |
| + anonymous: false, | |
| + inputs: [ | |
| + { indexed: true, internalType: "uint256", name: "id", type: "uint256" }, | |
| + { indexed: true, internalType: "address", name: "owner", type: "address" }, | |
| + { indexed: false, internalType: "uint256", name: "price", type: "uint256" }, | |
| + { indexed: false, internalType: "uint128", name: "amount", type: "uint128" }, | |
| + ], | |
| name: "BidSubmitted", | |
| + type: "event", | |
| + }, | |
| + { | |
| + anonymous: false, | |
| + inputs: [ | |
| + { indexed: false, internalType: "uint256", name: "blockNumber", type: "uint256" }, | |
| + { indexed: false, internalType: "uint256", name: "clearingPrice", type: "uint256" }, | |
| + { indexed: false, internalType: "uint24", name: "cumulativeMps", type: "uint24" }, | |
| + ], | |
| + name: "CheckpointUpdated", | |
| + type: "event", | |
| + }, | |
| + { | |
| + anonymous: false, | |
| inputs: [ | |
| - { name: "id", type: "uint256", indexed: true }, | |
| - { name: "owner", type: "address", indexed: true }, | |
| - { name: "price", type: "uint256", indexed: false }, | |
| - { name: "amount", type: "uint128", indexed: false }, | |
| + { indexed: false, internalType: "uint256", name: "blockNumber", type: "uint256" }, | |
| + { indexed: false, internalType: "uint256", name: "clearingPrice", type: "uint256" }, | |
| ], | |
| + name: "ClearingPriceUpdated", | |
| + type: "event", | |
| }, | |
| { | |
| + anonymous: false, | |
| + inputs: [ | |
| + { indexed: true, internalType: "address", name: "fundsRecipient", type: "address" }, | |
| + { indexed: false, internalType: "uint256", name: "currencyAmount", type: "uint256" }, | |
| + ], | |
| + name: "CurrencySwept", | |
| type: "event", | |
| - name: "TokensClaimed", | |
| + }, | |
| + { | |
| + anonymous: false, | |
| + inputs: [{ indexed: false, internalType: "uint256", name: "price", type: "uint256" }], | |
| + name: "NextActiveTickUpdated", | |
| + type: "event", | |
| + }, | |
| + { | |
| + anonymous: false, | |
| + inputs: [{ indexed: false, internalType: "uint256", name: "price", type: "uint256" }], | |
| + name: "TickInitialized", | |
| + type: "event", | |
| + }, | |
| + { | |
| + anonymous: false, | |
| inputs: [ | |
| - { name: "bidId", type: "uint256", indexed: true }, | |
| - { name: "owner", type: "address", indexed: true }, | |
| - { name: "tokensFilled", type: "uint256", indexed: false }, | |
| + { indexed: true, internalType: "uint256", name: "bidId", type: "uint256" }, | |
| + { indexed: true, internalType: "address", name: "owner", type: "address" }, | |
| + { indexed: false, internalType: "uint256", name: "tokensFilled", type: "uint256" }, | |
| ], | |
| + name: "TokensClaimed", | |
| + type: "event", | |
| }, | |
| { | |
| + anonymous: false, | |
| + inputs: [{ indexed: false, internalType: "uint256", name: "totalSupply", type: "uint256" }], | |
| + name: "TokensReceived", | |
| type: "event", | |
| + }, | |
| + { | |
| + anonymous: false, | |
| + inputs: [ | |
| + { indexed: true, internalType: "address", name: "tokensRecipient", type: "address" }, | |
| + { indexed: false, internalType: "uint256", name: "tokensAmount", type: "uint256" }, | |
| + ], | |
| name: "TokensSwept", | |
| + type: "event", | |
| + }, | |
| + { | |
| + inputs: [], | |
| + name: "MAX_BID_PRICE", | |
| + outputs: [{ internalType: "uint256", name: "", type: "uint256" }], | |
| + stateMutability: "view", | |
| + type: "function", | |
| + }, | |
| + { | |
| + inputs: [], | |
| + name: "MAX_BLOCK_NUMBER", | |
| + outputs: [{ internalType: "uint64", name: "", type: "uint64" }], | |
| + stateMutability: "view", | |
| + type: "function", | |
| + }, | |
| + { | |
| + inputs: [], | |
| + name: "MAX_TICK_PTR", | |
| + outputs: [{ internalType: "uint256", name: "", type: "uint256" }], | |
| + stateMutability: "view", | |
| + type: "function", | |
| + }, | |
| + { | |
| + inputs: [{ internalType: "uint256", name: "bidId", type: "uint256" }], | |
| + name: "bids", | |
| + outputs: [ | |
| + { | |
| + components: [ | |
| + { internalType: "uint64", name: "startBlock", type: "uint64" }, | |
| + { internalType: "uint24", name: "startCumulativeMps", type: "uint24" }, | |
| + { internalType: "uint64", name: "exitedBlock", type: "uint64" }, | |
| + { internalType: "uint256", name: "maxPrice", type: "uint256" }, | |
| + { internalType: "address", name: "owner", type: "address" }, | |
| + { internalType: "uint256", name: "amountQ96", type: "uint256" }, | |
| + { internalType: "uint256", name: "tokensFilled", type: "uint256" }, | |
| + ], | |
| + internalType: "struct Bid", | |
| + name: "", | |
| + type: "tuple", | |
| + }, | |
| + ], | |
| + stateMutability: "view", | |
| + type: "function", | |
| + }, | |
| + { | |
| + inputs: [], | |
| + name: "checkpoint", | |
| + outputs: [ | |
| + { | |
| + components: [ | |
| + { internalType: "uint256", name: "clearingPrice", type: "uint256" }, | |
| + { internalType: "ValueX7", name: "currencyRaisedAtClearingPriceQ96_X7", type: "uint256" }, | |
| + { internalType: "uint256", name: "cumulativeMpsPerPrice", type: "uint256" }, | |
| + { internalType: "uint24", name: "cumulativeMps", type: "uint24" }, | |
| + { internalType: "uint64", name: "prev", type: "uint64" }, | |
| + { internalType: "uint64", name: "next", type: "uint64" }, | |
| + ], | |
| + internalType: "struct Checkpoint", | |
| + name: "", | |
| + type: "tuple", | |
| + }, | |
| + ], | |
| + stateMutability: "nonpayable", | |
| + type: "function", | |
| + }, | |
| + { | |
| + inputs: [{ internalType: "uint64", name: "blockNumber", type: "uint64" }], | |
| + name: "checkpoints", | |
| + outputs: [ | |
| + { | |
| + components: [ | |
| + { internalType: "uint256", name: "clearingPrice", type: "uint256" }, | |
| + { internalType: "ValueX7", name: "currencyRaisedAtClearingPriceQ96_X7", type: "uint256" }, | |
| + { internalType: "uint256", name: "cumulativeMpsPerPrice", type: "uint256" }, | |
| + { internalType: "uint24", name: "cumulativeMps", type: "uint24" }, | |
| + { internalType: "uint64", name: "prev", type: "uint64" }, | |
| + { internalType: "uint64", name: "next", type: "uint64" }, | |
| + ], | |
| + internalType: "struct Checkpoint", | |
| + name: "", | |
| + type: "tuple", | |
| + }, | |
| + ], | |
| + stateMutability: "view", | |
| + type: "function", | |
| + }, | |
| + { | |
| + inputs: [], | |
| + name: "claimBlock", | |
| + outputs: [{ internalType: "uint64", name: "", type: "uint64" }], | |
| + stateMutability: "view", | |
| + type: "function", | |
| + }, | |
| + { | |
| + inputs: [{ internalType: "uint256", name: "_bidId", type: "uint256" }], | |
| + name: "claimTokens", | |
| + outputs: [], | |
| + stateMutability: "nonpayable", | |
| + type: "function", | |
| + }, | |
| + { | |
| inputs: [ | |
| - { name: "tokensRecipient", type: "address", indexed: true }, | |
| - { name: "tokensAmount", type: "uint256", indexed: false }, | |
| + { internalType: "address", name: "_owner", type: "address" }, | |
| + { internalType: "uint256[]", name: "_bidIds", type: "uint256[]" }, | |
| ], | |
| + name: "claimTokensBatch", | |
| + outputs: [], | |
| + stateMutability: "nonpayable", | |
| + type: "function", | |
| }, | |
| { | |
| + inputs: [], | |
| + name: "clearingPrice", | |
| + outputs: [{ internalType: "uint256", name: "", type: "uint256" }], | |
| + stateMutability: "view", | |
| type: "function", | |
| - name: "startBlock", | |
| + }, | |
| + { | |
| inputs: [], | |
| - outputs: [{ name: "", type: "uint64" }], | |
| + name: "currency", | |
| + outputs: [{ internalType: "address", name: "", type: "address" }], | |
| stateMutability: "view", | |
| + type: "function", | |
| }, | |
| { | |
| + inputs: [], | |
| + name: "currencyRaised", | |
| + outputs: [{ internalType: "uint256", name: "", type: "uint256" }], | |
| + stateMutability: "view", | |
| type: "function", | |
| - name: "endBlock", | |
| + }, | |
| + { | |
| inputs: [], | |
| - outputs: [{ name: "", type: "uint64" }], | |
| + name: "currencyRaisedQ96_X7", | |
| + outputs: [{ internalType: "ValueX7", name: "", type: "uint256" }], | |
| stateMutability: "view", | |
| + type: "function", | |
| }, | |
| { | |
| + inputs: [], | |
| + name: "endBlock", | |
| + outputs: [{ internalType: "uint64", name: "", type: "uint64" }], | |
| + stateMutability: "view", | |
| type: "function", | |
| - name: "claimBlock", | |
| + }, | |
| + { | |
| + inputs: [{ internalType: "uint256", name: "_bidId", type: "uint256" }], | |
| + name: "exitBid", | |
| + outputs: [], | |
| + stateMutability: "nonpayable", | |
| + type: "function", | |
| + }, | |
| + { | |
| + inputs: [ | |
| + { internalType: "uint256", name: "_bidId", type: "uint256" }, | |
| + { internalType: "uint64", name: "_lastFullyFilledCheckpointBlock", type: "uint64" }, | |
| + { internalType: "uint64", name: "_outbidBlock", type: "uint64" }, | |
| + ], | |
| + name: "exitPartiallyFilledBid", | |
| + outputs: [], | |
| + stateMutability: "nonpayable", | |
| + type: "function", | |
| + }, | |
| + { | |
| inputs: [], | |
| - outputs: [{ name: "", type: "uint64" }], | |
| + name: "floorPrice", | |
| + outputs: [{ internalType: "uint256", name: "", type: "uint256" }], | |
| stateMutability: "view", | |
| + type: "function", | |
| }, | |
| { | |
| + inputs: [{ internalType: "uint256", name: "_untilTickPrice", type: "uint256" }], | |
| + name: "forceIterateOverTicks", | |
| + outputs: [{ internalType: "uint256", name: "", type: "uint256" }], | |
| + stateMutability: "nonpayable", | |
| type: "function", | |
| - name: "nextBidId", | |
| + }, | |
| + { | |
| inputs: [], | |
| - outputs: [{ name: "", type: "uint256" }], | |
| + name: "fundsRecipient", | |
| + outputs: [{ internalType: "address", name: "", type: "address" }], | |
| stateMutability: "view", | |
| + type: "function", | |
| }, | |
| { | |
| + inputs: [], | |
| + name: "isGraduated", | |
| + outputs: [{ internalType: "bool", name: "", type: "bool" }], | |
| + stateMutability: "view", | |
| type: "function", | |
| - name: "bids", | |
| - inputs: [{ name: "bidId", type: "uint256" }], | |
| + }, | |
| + { | |
| + inputs: [], | |
| + name: "lastCheckpointedBlock", | |
| + outputs: [{ internalType: "uint64", name: "", type: "uint64" }], | |
| + stateMutability: "view", | |
| + type: "function", | |
| + }, | |
| + { | |
| + inputs: [], | |
| + name: "latestCheckpoint", | |
| outputs: [ | |
| { | |
| + components: [ | |
| + { internalType: "uint256", name: "clearingPrice", type: "uint256" }, | |
| + { internalType: "ValueX7", name: "currencyRaisedAtClearingPriceQ96_X7", type: "uint256" }, | |
| + { internalType: "uint256", name: "cumulativeMpsPerPrice", type: "uint256" }, | |
| + { internalType: "uint24", name: "cumulativeMps", type: "uint24" }, | |
| + { internalType: "uint64", name: "prev", type: "uint64" }, | |
| + { internalType: "uint64", name: "next", type: "uint64" }, | |
| + ], | |
| + internalType: "struct Checkpoint", | |
| name: "", | |
| type: "tuple", | |
| + }, | |
| + ], | |
| + stateMutability: "view", | |
| + type: "function", | |
| + }, | |
| + { | |
| + inputs: [], | |
| + name: "lbpInitializationParams", | |
| + outputs: [ | |
| + { | |
| components: [ | |
| - { name: "startBlock", type: "uint64" }, | |
| - { name: "startCumulativeMps", type: "uint24" }, | |
| - { name: "exitedBlock", type: "uint64" }, | |
| - { name: "maxPrice", type: "uint256" }, | |
| - { name: "owner", type: "address" }, | |
| - { name: "amountQ96", type: "uint256" }, | |
| - { name: "tokensFilled", type: "uint256" }, | |
| + { internalType: "uint256", name: "initialPriceX96", type: "uint256" }, | |
| + { internalType: "uint256", name: "tokensSold", type: "uint256" }, | |
| + { internalType: "uint256", name: "currencyRaised", type: "uint256" }, | |
| ], | |
| + internalType: "struct LBPInitializationParams", | |
| + name: "params", | |
| + type: "tuple", | |
| }, | |
| ], | |
| stateMutability: "view", | |
| + type: "function", | |
| }, | |
| { | |
| + inputs: [], | |
| + name: "nextActiveTickPrice", | |
| + outputs: [{ internalType: "uint256", name: "", type: "uint256" }], | |
| + stateMutability: "view", | |
| type: "function", | |
| - name: "exitBid", | |
| - inputs: [{ name: "_bidId", type: "uint256" }], | |
| + }, | |
| + { | |
| + inputs: [], | |
| + name: "nextBidId", | |
| + outputs: [{ internalType: "uint256", name: "", type: "uint256" }], | |
| + stateMutability: "view", | |
| + type: "function", | |
| + }, | |
| + { | |
| + inputs: [], | |
| + name: "onTokensReceived", | |
| outputs: [], | |
| stateMutability: "nonpayable", | |
| + type: "function", | |
| }, | |
| { | |
| + inputs: [], | |
| + name: "pointer", | |
| + outputs: [{ internalType: "address", name: "", type: "address" }], | |
| + stateMutability: "view", | |
| type: "function", | |
| - name: "exitPartiallyFilledBid", | |
| + }, | |
| + { | |
| + inputs: [], | |
| + name: "startBlock", | |
| + outputs: [{ internalType: "uint64", name: "", type: "uint64" }], | |
| + stateMutability: "view", | |
| + type: "function", | |
| + }, | |
| + { | |
| + inputs: [], | |
| + name: "step", | |
| + outputs: [ | |
| + { | |
| + components: [ | |
| + { internalType: "uint24", name: "mps", type: "uint24" }, | |
| + { internalType: "uint64", name: "startBlock", type: "uint64" }, | |
| + { internalType: "uint64", name: "endBlock", type: "uint64" }, | |
| + ], | |
| + internalType: "struct AuctionStep", | |
| + name: "", | |
| + type: "tuple", | |
| + }, | |
| + ], | |
| + stateMutability: "view", | |
| + type: "function", | |
| + }, | |
| + { | |
| inputs: [ | |
| - { name: "_bidId", type: "uint256" }, | |
| - { name: "_lastFullyFilledCheckpointBlock", type: "uint64" }, | |
| - { name: "_outbidBlock", type: "uint64" }, | |
| + { internalType: "uint256", name: "_maxPrice", type: "uint256" }, | |
| + { internalType: "uint128", name: "_amount", type: "uint128" }, | |
| + { internalType: "address", name: "_owner", type: "address" }, | |
| + { internalType: "bytes", name: "_hookData", type: "bytes" }, | |
| ], | |
| - outputs: [], | |
| - stateMutability: "nonpayable", | |
| + name: "submitBid", | |
| + outputs: [{ internalType: "uint256", name: "", type: "uint256" }], | |
| + stateMutability: "payable", | |
| + type: "function", | |
| }, | |
| { | |
| + inputs: [ | |
| + { internalType: "uint256", name: "_maxPrice", type: "uint256" }, | |
| + { internalType: "uint128", name: "_amount", type: "uint128" }, | |
| + { internalType: "address", name: "_owner", type: "address" }, | |
| + { internalType: "uint256", name: "_prevTickPrice", type: "uint256" }, | |
| + { internalType: "bytes", name: "_hookData", type: "bytes" }, | |
| + ], | |
| + name: "submitBid", | |
| + outputs: [{ internalType: "uint256", name: "", type: "uint256" }], | |
| + stateMutability: "payable", | |
| type: "function", | |
| - name: "claimTokens", | |
| - inputs: [{ name: "_bidId", type: "uint256" }], | |
| + }, | |
| + { | |
| + inputs: [], | |
| + name: "sumCurrencyDemandAboveClearingQ96", | |
| + outputs: [{ internalType: "uint256", name: "", type: "uint256" }], | |
| + stateMutability: "view", | |
| + type: "function", | |
| + }, | |
| + { | |
| + inputs: [{ internalType: "bytes4", name: "interfaceId", type: "bytes4" }], | |
| + name: "supportsInterface", | |
| + outputs: [{ internalType: "bool", name: "", type: "bool" }], | |
| + stateMutability: "pure", | |
| + type: "function", | |
| + }, | |
| + { | |
| + inputs: [], | |
| + name: "sweepCurrency", | |
| outputs: [], | |
| stateMutability: "nonpayable", | |
| + type: "function", | |
| }, | |
| { | |
| + inputs: [], | |
| + name: "sweepCurrencyBlock", | |
| + outputs: [{ internalType: "uint256", name: "", type: "uint256" }], | |
| + stateMutability: "view", | |
| type: "function", | |
| - name: "claimTokensBatch", | |
| - inputs: [ | |
| - { name: "_owner", type: "address" }, | |
| - { name: "_bidIds", type: "uint256[]" }, | |
| - ], | |
| + }, | |
| + { | |
| + inputs: [], | |
| + name: "sweepUnsoldTokens", | |
| outputs: [], | |
| stateMutability: "nonpayable", | |
| + type: "function", | |
| }, | |
| { | |
| - type: "function", | |
| + inputs: [], | |
| name: "sweepUnsoldTokensBlock", | |
| + outputs: [{ internalType: "uint256", name: "", type: "uint256" }], | |
| + stateMutability: "view", | |
| + type: "function", | |
| + }, | |
| + { | |
| inputs: [], | |
| - outputs: [{ name: "", type: "uint256" }], | |
| + name: "tickSpacing", | |
| + outputs: [{ internalType: "uint256", name: "", type: "uint256" }], | |
| stateMutability: "view", | |
| + type: "function", | |
| }, | |
| { | |
| + inputs: [{ internalType: "uint256", name: "price", type: "uint256" }], | |
| + name: "ticks", | |
| + outputs: [ | |
| + { | |
| + components: [ | |
| + { internalType: "uint256", name: "next", type: "uint256" }, | |
| + { internalType: "uint256", name: "currencyDemandQ96", type: "uint256" }, | |
| + ], | |
| + internalType: "struct Tick", | |
| + name: "", | |
| + type: "tuple", | |
| + }, | |
| + ], | |
| + stateMutability: "view", | |
| + type: "function", | |
| + }, | |
| + { | |
| + inputs: [], | |
| + name: "token", | |
| + outputs: [{ internalType: "address", name: "", type: "address" }], | |
| + stateMutability: "view", | |
| type: "function", | |
| + }, | |
| + { | |
| + inputs: [], | |
| name: "tokensRecipient", | |
| + outputs: [{ internalType: "address", name: "", type: "address" }], | |
| + stateMutability: "view", | |
| + type: "function", | |
| + }, | |
| + { | |
| inputs: [], | |
| - outputs: [{ name: "", type: "address" }], | |
| + name: "totalCleared", | |
| + outputs: [{ internalType: "uint256", name: "", type: "uint256" }], | |
| stateMutability: "view", | |
| + type: "function", | |
| }, | |
| { | |
| + inputs: [], | |
| + name: "totalClearedQ96_X7", | |
| + outputs: [{ internalType: "ValueX7", name: "", type: "uint256" }], | |
| + stateMutability: "view", | |
| type: "function", | |
| - name: "sweepUnsoldTokens", | |
| + }, | |
| + { | |
| inputs: [], | |
| - outputs: [], | |
| - stateMutability: "nonpayable", | |
| + name: "totalSupply", | |
| + outputs: [{ internalType: "uint128", name: "", type: "uint128" }], | |
| + stateMutability: "view", | |
| + type: "function", | |
| + }, | |
| + { | |
| + inputs: [], | |
| + name: "validationHook", | |
| + outputs: [{ internalType: "contract IValidationHook", name: "", type: "address" }], | |
| + stateMutability: "view", | |
| + type: "function", | |
| }, | |
| ] as const; | |
| @@ -357,7 +880,7 @@ export const erc20Abi = [ | |
| ] as const; | |
| assertAbisMatchArtifacts({ | |
| - ccaAbi, | |
| + //ccaAbi, | |
| trackerAbi, | |
| erc20Abi, | |
| tdeDisbursementAbi, | |
| diff --git a/script/initial-distribution/src/chains.ts b/script/initial-distribution/src/chains.ts | |
| index 7009e9a..4957be4 100644 | |
| --- a/script/initial-distribution/src/chains.ts | |
| +++ b/script/initial-distribution/src/chains.ts | |
| @@ -6,7 +6,7 @@ import { | |
| http, | |
| type PublicClient, | |
| } from "viem"; | |
| -import { privateKeyToAccount } from "viem/accounts"; | |
| +import { type PrivateKeyToAccountOptions, privateKeyToAccount } from "viem/accounts"; | |
| import { arbitrum, arbitrumSepolia, sepolia } from "viem/chains"; | |
| import { assertCondition } from "./lib.js"; | |
| @@ -41,8 +41,13 @@ export async function chainSetup(chainId: string, rpcUrl: string) { | |
| return { chain, transport, publicClient }; | |
| } | |
| -export function makeWallet(chain: Chain, transport: ReturnType<typeof http>, privateKey: Hex) { | |
| - const account = privateKeyToAccount(privateKey); | |
| +export function makeWallet( | |
| + chain: Chain, | |
| + transport: ReturnType<typeof http>, | |
| + privateKey: Hex, | |
| + accountOptions?: PrivateKeyToAccountOptions, | |
| +) { | |
| + const account = privateKeyToAccount(privateKey, accountOptions); | |
| const walletClient = createWalletClient({ account, chain, transport }); | |
| return { account, walletClient }; | |
| } | |
| diff --git a/script/initial-distribution/src/claimAllBids.ts b/script/initial-distribution/src/claimAllBids.ts | |
| index f28314f..2cc86cf 100644 | |
| --- a/script/initial-distribution/src/claimAllBids.ts | |
| +++ b/script/initial-distribution/src/claimAllBids.ts | |
| @@ -9,7 +9,8 @@ | |
| */ | |
| import "dotenv/config"; | |
| -import { type Address, getAddress, getContract } from "viem"; | |
| +import { type Address, getAddress, getContract, type PublicClient } from "viem"; | |
| +import { nonceManager } from "viem/accounts"; | |
| import { ccaAbi } from "./abis.js"; | |
| import { chainSetup, makeWallet } from "./chains.js"; | |
| import { | |
| @@ -28,7 +29,9 @@ const TRACKER_DISBURSER_PRIVATE_KEY = ensureHex(requireEnv("TRACKER_DISBURSER_PR | |
| const RPC_URL = requireEnv("RPC_URL"); | |
| const { chain, transport, publicClient } = await chainSetup(CHAIN_ID, RPC_URL); | |
| -const trackerDisburser = makeWallet(chain, transport, TRACKER_DISBURSER_PRIVATE_KEY); | |
| +const trackerDisburser = makeWallet(chain, transport, TRACKER_DISBURSER_PRIVATE_KEY, { | |
| + nonceManager, | |
| +}); | |
| const ccaContract = getContract({ | |
| address: CCA_ADDRESS, | |
| @@ -38,6 +41,60 @@ const ccaContract = getContract({ | |
| type BidState = Awaited<ReturnType<typeof ccaContract.read.bids>>; | |
| +/** Checkpoint tuple from CCA: clearingPrice, currencyRaisedAtClearingPriceQ96_X7, cumulativeMpsPerPrice, cumulativeMps, prev, next */ | |
| +type Checkpoint = { | |
| + clearingPrice: bigint; | |
| + currencyRaisedAtClearingPriceQ96_X7: bigint; | |
| + cumulativeMpsPerPrice: bigint; | |
| + cumulativeMps: number; | |
| + prev: bigint; | |
| + next: bigint; | |
| +}; | |
| + | |
| +/** | |
| + * Find the last checkpoint block where clearingPrice < bid.maxPrice and the next checkpoint has clearingPrice >= bid.maxPrice. | |
| + * Required by exitPartiallyFilledBid as _lastFullyFilledCheckpointBlock. | |
| + */ | |
| +async function getLastFullyFilledCheckpointBlock( | |
| + publicClient: PublicClient, | |
| + ccaAddress: Address, | |
| + bid: BidState, | |
| +): Promise<bigint | null> { | |
| + const bidMaxPrice = bid.maxPrice; | |
| + let block = bid.startBlock; | |
| + let prevBlock: bigint | null = null; | |
| + | |
| + for (;;) { | |
| + const cp = (await publicClient.readContract({ | |
| + address: ccaAddress, | |
| + abi: ccaAbi, | |
| + functionName: "checkpoints", | |
| + args: [block], | |
| + })) as unknown as Checkpoint; | |
| + | |
| + if (cp.next === 0n) { | |
| + // End of chain. The last fully filled is the one before this if this (final) checkpoint has clearing >= bidMaxPrice. | |
| + if (cp.clearingPrice >= bidMaxPrice && prevBlock !== null) return prevBlock; | |
| + return null; | |
| + } | |
| + | |
| + const nextCp = (await publicClient.readContract({ | |
| + address: ccaAddress, | |
| + abi: ccaAbi, | |
| + functionName: "checkpoints", | |
| + args: [cp.next], | |
| + })) as unknown as Checkpoint; | |
| + | |
| + if (cp.clearingPrice < bidMaxPrice && nextCp.clearingPrice >= bidMaxPrice) { | |
| + // This block is the last where clearing < bidMaxPrice; next checkpoint is at or above. | |
| + return block; | |
| + } | |
| + | |
| + prevBlock = block; | |
| + block = cp.next; | |
| + } | |
| +} | |
| + | |
| async function main() { | |
| assertCondition( | |
| await contractHasCode(publicClient, ccaContract), | |
| @@ -115,11 +172,20 @@ async function main() { | |
| const msg = e instanceof Error ? e.message : String(e); | |
| const isCannotExitBid = msg.includes("CannotExitBid") || msg.includes("0x0ba98457"); // CannotExitBid() selector | |
| if (!isCannotExitBid) throw e; | |
| - // Partially filled: try exit at end (outbidBlock = 0) then outbid (outbidBlock = endBlock - 1) | |
| + // Partially filled: resolve checkpoint hint by walking the chain, then try exit at end then outbid | |
| + const lastFullyFilled = await getLastFullyFilledCheckpointBlock( | |
| + publicClient, | |
| + CCA_ADDRESS, | |
| + bid, | |
| + ); | |
| + assertCondition( | |
| + lastFullyFilled !== null, | |
| + `Bid ${bidId}: could not find last fully filled checkpoint (partially filled but chain walk failed).`, | |
| + ); | |
| try { | |
| await receiptFor( | |
| publicClient, | |
| - await ccaContract.write.exitPartiallyFilledBid([bidId, ccaStartBlock, 0n]), | |
| + await ccaContract.write.exitPartiallyFilledBid([bidId, lastFullyFilled, 0n]), | |
| ); | |
| console.log(`Exited bid ${bidId} (partially filled at end)`); | |
| } catch (err) { | |
| @@ -127,12 +193,13 @@ async function main() { | |
| const isPartiallyFilledAtEndRevert = | |
| msg.includes("CannotExitBid") || | |
| msg.includes("InvalidLastFullyFilledCheckpointHint") || | |
| + msg.includes("InvalidOutbidBlockCheckpointHint") || | |
| msg.includes("CannotPartiallyExitBidBeforeEndBlock"); | |
| if (!isPartiallyFilledAtEndRevert) throw err; | |
| const outbidBlock = ccaEndBlock > 0n ? ccaEndBlock - 1n : 0n; | |
| await receiptFor( | |
| publicClient, | |
| - await ccaContract.write.exitPartiallyFilledBid([bidId, ccaStartBlock, outbidBlock]), | |
| + await ccaContract.write.exitPartiallyFilledBid([bidId, lastFullyFilled, outbidBlock]), | |
| ); | |
| console.log(`Exited bid ${bidId} (outbid)`); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment