Skip to content

test(cketh): compute the USD cost of a deposit for the minter - #11439

Draft
gregorydemay wants to merge 4 commits into
masterfrom
gdemay/DEFI-2991-fee
Draft

test(cketh): compute the USD cost of a deposit for the minter#11439
gregorydemay wants to merge 4 commits into
masterfrom
gdemay/DEFI-2991-fee

Conversation

@gregorydemay

@gregorydemay gregorydemay commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

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:

  • Internet Computer: balance-scan HTTPS outcalls priced from their actual batch payload sizes via the outcall fee formula, bounded by the production scan schedule, plus the threshold-ECDSA signatures (attestation, EIP-7702 authorization, transaction).
  • Ethereum: the sweep transaction's gas, amortized over the sweep batch.

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

gregorydemay and others added 4 commits September 3, 2026 14:36
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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants