Skip to content

feat(fee): transfer tokens in fee deposit and withdraw (#1187) - #1383

Closed
lienhoatienphung-svg wants to merge 1 commit into
CalloraOrg:mainfrom
lienhoatienphung-svg:feature/1187-fee-token-transfers
Closed

lienhoatienphung-svg wants to merge 1 commit into
CalloraOrg:mainfrom
lienhoatienphung-svg:feature/1187-fee-token-transfers

Conversation

@lienhoatienphung-svg

Copy link
Copy Markdown

Closes #1187

Summary

Updates FeeContract so fee accounting is backed 1:1 by real token transfers:

  1. Stores DataKey::Token during init(env, admin, token) and exposes it via get_token(env).
  2. Pulls amount from caller to the contract via token::Client::new(&env, &token_addr).transfer(&caller, &contract_addr, &amount) during deposit.
  3. Pushes amount from the contract to recipient via token::Client::transfer during withdraw after verifying both accumulated >= amount and on-ledger token balance.

Acceptance Criteria Mapping

  • Deposit increases contract token balance and counter equally: Verified in test_deposit_and_withdraw and test_deposit_without_token_balance_fails_and_keeps_counter_in_sync.
  • Withdraw decreases both equally: Verified in test_deposit_and_withdraw and test_withdraw_to_valid_recipient_succeeds.
  • Counter can never exceed token balance in tests: Asserted across deposit/withdraw unit tests (client.get_accumulated() <= token_client.balance(&contract_id)).
  • Token address exposed via a getter: Implemented FeeContract::get_token(env: Env) -> Result<Address, ContractError> with TTL extension and auth snapshot coverage.

Validation

  • cargo test -p callora-fee

Payout Wallet (Base Mainnet USDC / EVM): 0x3806cd592a508d1992Ed007C2F53de251C2E7452

@lienhoatienphung-svg
lienhoatienphung-svg force-pushed the feature/1187-fee-token-transfers branch from cefbb1c to 379dcf4 Compare October 16, 2026 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Transfer tokens in fee deposit and withdraw

2 participants