Skip to content

Add txTo to Transfer entity + credit boughtCap on approved tx.to#63

Merged
thedavidmeister merged 1 commit into
mainfrom
2026-04-20-add-txto-to-transfer
Apr 20, 2026
Merged

Add txTo to Transfer entity + credit boughtCap on approved tx.to#63
thedavidmeister merged 1 commit into
mainfrom
2026-04-20-add-txto-to-transfer

Conversation

@thedavidmeister

Copy link
Copy Markdown
Contributor

Summary

DEX aggregators (e.g. OpenOcean) may route cy-token buys through an intermediate adapter contract. Under the old rule, these aggregator-routed trades left the buyer with `boughtCap=0` because `Transfer.from` is the unrecognized adapter, not the aggregator.

Changes

  • Add `txTo` (optional Bytes) and `txToIsApprovedSource` (Boolean) to the `Transfer` entity
  • In `handleTransfer`, compute an `isApprovedBuy` flag as `fromIsApprovedSource OR txToIsApprovedSource` and credit `boughtCap` accordingly
  • Short-circuit to skip redundant `factory()` calls when `fromIsApprovedSource` is already true, or when `txTo` is null, or when `txTo == event.address` (the cy token itself, never approved)

Tests

  • Adds two new tests exercising the txTo path (approved-aggregator credit + unapproved control)
  • Updates existing test setup to mock `factory()` revert on `defaultAddress` and `SparkdexV3LiquidityManager` (required because handler now calls `isApprovedSource(txTo)` even when `from` is an internal/EOA address)
  • 109 matchstick tests pass locally

Paired with

cyclofinance/cyclo.rewards#??? — rewards pipeline consumes the new `txTo` field.

Context

Investigation: cyclofinance/cyclo.rewards#215 — an LP with 12k cysFLR LP'd via Sparkdex but earned zero because their OpenOcean-routed cysFLR purchases went through an unrecognized intermediate.

🤖 Generated with Claude Code

DEX aggregators (e.g. OpenOcean) may route cy-token buys through an
intermediate adapter contract, so Transfer.from is the adapter rather
than the aggregator itself. Under the old rule, these legitimate
aggregator-routed purchases were treated as non-approved transfers,
leaving the buyer with boughtCap=0 and zero reward eligibility.

Add txTo / txToIsApprovedSource to the Transfer entity and use the
tx-level target as a secondary approval signal. If either
Transfer.from or tx.to is approved, the recipient is credited.

Short-circuit to avoid redundant factory() calls:
- when fromIsApprovedSource already true
- when txTo is null (contract creation)
- when txTo equals the cy token itself (direct token-contract call)

Closes cyclofinance/cyclo.rewards#215

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@thedavidmeister thedavidmeister merged commit 6e1f2d6 into main Apr 20, 2026
1 check passed
thedavidmeister added a commit to cyclofinance/cyclo.site that referenced this pull request Apr 22, 2026
Bumps cyclo-arbitrum-one from 2025-12-30-00a4 to 2026-04-20-e5f8.
The new deploy (from the April 20 matrix deploy triggered after
cyclofinance/cyclo.subgraph#63 merged) includes the txTo field and the
eligibleShare removal.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant