test(cketh): compute the USD cost of a deposit for the minter - #11439
Draft
gregorydemay wants to merge 4 commits into
Draft
test(cketh): compute the USD cost of a deposit for the minter#11439gregorydemay wants to merge 4 commits into
gregorydemay wants to merge 4 commits into
Conversation
Table-driven unit test estimating what one automatic deposit costs the minter across its three fee components (gas, threshold ECDSA, HTTPS outcalls), under varying gas price, ETH/USD price, sweep batch size and balance-scan amortization (DEFI-2991). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016Yv31YXb6YH1Gp71G54cL9
Sketch a scenario builder that prices the balance scans from their actual batch payload sizes via the HTTPS outcall fee formula, bounds them by the production scan schedule, and prices the sweep step's signatures and gas per batch. Expose the scan and sweep batch-size constants crate-wide for it (DEFI-2991). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016Yv31YXb6YH1Gp71G54cL9
Rework the deposit-cost table so each scenario is a builder chain of balance-scan and sweep steps under explicit market conditions, asserting the amortized USD cost split by chain (Ethereum gas vs Internet Computer cycles). Delete the superseded flat-conditions model (DEFI-2991). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016Yv31YXb6YH1Gp71G54cL9
…round Keep three scenarios: a best case with everything amortized under calm markets, a middle ground where a lone deposit is found within the hour, and a worst case combining a 20 gwei spike, expensive ether and a full 24h of solo scanning (DEFI-2991). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016Yv31YXb6YH1Gp71G54cL9
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The 24-hour scan count and sweep-gas model produce inaccurate cost estimates.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds a test-only model estimating automatic ckETH deposit costs across IC and Ethereum resources.
Changes:
- Adds three cost scenarios.
- Models HTTPS outcalls, signatures, and sweep gas.
- Exposes production limits to test code.
File summaries
| File | Description |
|---|---|
balance_scan/mod.rs |
Exposes batch-size limit. |
automatic_deposits/mod.rs |
Exposes scan schedule. |
sweep/mod.rs |
Exposes sweep-size limit. |
lib.rs |
Registers cost-test module. |
deposit_cost/mod.rs |
Declares test module. |
deposit_cost/tests.rs |
Implements cost model and scenarios. |
Review details
- Files reviewed: 6/6 changed files
- Comments generated: 2
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| .with_balance_scans([1; SCANS_WITHIN_FIRST_HOUR]) | ||
| .expecting("0.5484", "0.1184", "0.6668"), | ||
| ScenarioBuilder::new("worst case: gas spike, expensive ether, scanned alone for 24h") | ||
| .with_balance_scans([1; SCAN_GAP_SECS.len()]) |
Comment on lines
+192
to
+195
| fn gas_cost(&self) -> GasAmount { | ||
| const FIXED_GAS_COST: u128 = 26_000; | ||
| const PER_ITEM_GAS_COST: u128 = 65_400; | ||
| GasAmount::new(FIXED_GAS_COST + self.batch_size as u128 * PER_ITEM_GAS_COST) |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
First step for DEFI-2991 (deduct a fee on automatic deposits): a table-driven unit test estimating what one automatic deposit costs the minter in USD, to inform the choice of the fee.
The cost model lives entirely in a test-only module and prices the two chains separately:
Three scenarios document the envelope: a best case with everything amortized under calm markets (about $0.14 per deposit), a middle ground with a lone deposit found within the hour (about $0.67), and a worst case combining a 20 gwei spike, expensive ether and 24h of solo scanning (about $9.29).
Resolves ticket: DEFI-2991
🤖 Generated with Claude Code
https://claude.ai/code/session_016Yv31YXb6YH1Gp71G54cL9