fix(sim): track swap output token in wallet-balance snapshots#65
Open
dglowinski wants to merge 1 commit into
Open
fix(sim): track swap output token in wallet-balance snapshots#65dglowinski wants to merge 1 commit into
dglowinski wants to merge 1 commit into
Conversation
LeonardEulerXYZ
approved these changes
Jun 25, 2026
LeonardEulerXYZ
left a comment
There was a problem hiding this comment.
Reviewed head: 504e268
Verdict: Approved
Scope reviewed:
- packages/euler-v2-sdk/src/services/executionService/simulate.ts
- packages/euler-v2-sdk/test/simulate.test.ts
What changed:
- Simulation wallet-balance discovery now decodes SwapVerifier
verifyAmountMinAndTransfer(address,address,uint256,uint256)calls and includes the transfer asset in per-layer walletbalanceOf(owner)snapshots. - Added a regression test proving a transferMin swap verifier call causes the output token to be included in wallet-balance reads.
Evidence and validation:
- Full PR diff inspected against
origin/developmentat base 82feb80. - Active issue comments, formal reviews, and inline review comments inspected; there were no existing Leonard or bot comments to update or clean up.
- Security/supply-chain sweep over the diff: no dependency, lockfile, workflow, package-export, network, secret, env, install-script, or generated-client changes; only simulation code and tests changed.
- ABI fixture check after build:
verifyAmountMinAndTransfer(address,address,uint256,uint256)selector resolves to0xcbe0a971, the encoded calldata decodes back toverifyAmountMinAndTransfer, and arg0 is the transfer asset being added to the wallet-balance token set. pnpm --filter @eulerxyz/euler-v2-sdk test -- simulate.test.tspassed. Vitest executed the package suite: 26 files / 322 tests passed.pnpm --filter @eulerxyz/euler-v2-sdk typecheckpassed.pnpm --filter @eulerxyz/euler-v2-sdk buildpassed.pnpm --filter @eulerxyz/euler-v2-sdk lintexited 0; it reported pre-existing warnings in unrelatedsrc/utils/*files, not in this PR's changed files.gh pr checksreported no checks on the branch.
Scalability / maintainability hygiene pass:
- Started from the intended consumer behavior: Euler Lite stitches
simulatedWalletBalancesand surfacesinsufficientWalletAssets; missing the swap output token means a wallet-receiving swap can be invisible to later wallet-sourced operations and wallet delta display. - Sibling wallet-balance discovery paths in this module were checked: touched vault assets, required wallet-balance tokens, operation-provided
walletBalanceTokens, claim reward tokens, and rEUL unlock tokens. This patch fits the existing reusable discovery pattern rather than duplicating display logic downstream. - Sibling swap verifier flows were checked:
TransferMinis the wallet-output verifier;SkimMindeposits/skims into vaults and remains covered by touched-vault assets;DebtMaxrepays debt and remains outside wallet-output tracking. I did not find a missed parallel transfer-output flow. - Cross-repo consumer pass: current Euler Lite
developmentconsumessimulateTransactionPlan,simulatedWalletBalances, andinsufficientWalletAssetsincomposables/useTxBatch.ts; this SDK-side fix is the narrow producer-side abstraction needed by that consumer. No Lite code change is required, aside from normal SDK version uptake/release sequencing.
Bot/reviewer feedback:
- No active CodeRabbit/other bot comments or prior Leonard comments were present on the PR at review time.
Screenshots:
- Not applicable; this is SDK simulation logic with no direct UI surface changed in the PR.
Comment lifecycle: none found; no Leonard comments or inline review comments needed cleanup.
Wallet-receiving swaps (withdraw/redeem/wallet swaps) transfer the swapped-in token to the wallet via verifyAmountMinAndTransfer(asset, ...), but the balance-snapshot discovery in buildSimulationBatch only covered touched-vault underlyings, required-approval (debited) tokens, and claim/unlock tokens. The swap output token was never snapshotted, so it stayed invisible to the wallet-balance display and to later wallet-sourced batch operations. Decode the verifyAmountMinAndTransfer verifier item and add its asset to the snapshotted wallet tokens (collectSwapWalletBalanceTokens), mirroring collectClaimWalletBalanceTokens. Adds a unit test. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
504e268 to
3796c15
Compare
LeonardEulerXYZ
approved these changes
Jun 25, 2026
LeonardEulerXYZ
left a comment
There was a problem hiding this comment.
Reviewed head: 3796c15
Verdict: Approved
Scope reviewed:
- packages/euler-v2-sdk/src/services/executionService/simulate.ts
- packages/euler-v2-sdk/test/simulate.test.ts
What changed:
- Simulation wallet-balance discovery now decodes SwapVerifier
verifyAmountMinAndTransfer(address,address,uint256,uint256)verifier calls and includes the transferassetin the walletbalanceOf(owner)snapshot token set. - Added a regression test covering the transferMin wallet-output case.
Validation performed:
pnpm install --frozen-lockfilefrom a fresh clonepnpm test -- simulate.test.ts -t "simulateTransactionPlan tracks swap-verifier wallet output tokens"— passed; Vitest executed the package test set, 26 files / 347 tests passedpnpm typecheck— passedpnpm build— passedpnpm lint— exit 0; reported pre-existing warnings outside this PR’s touched files (src/utils/*)git diff --check origin/main...HEAD— clean- malicious/supply-chain sweep over the diff — no package, lockfile, workflow, dependency, secret, network, env, or script-surface changes found
Scalability / maintainability hygiene pass:
- Searched sibling simulation and transaction paths for
walletBalanceTokens,simulatedWalletBalances,verifyAmountMinAndTransfer, andswapVerifierAbiusage. - The change is correctly centralized in simulation wallet-balance discovery rather than patching a downstream consumer display path.
- Existing explicit
walletBalanceTokensproducers for rewards/rEUL remain compatible; this PR covers the missing implicit verifier-derived transfer token. - Deposit/skim verifier variants intentionally remain out of scope because they land output into a vault, not directly into the wallet snapshot being fixed here.
Bot / reviewer feedback:
- No active CodeRabbit or other bot comments were present to verify/refute.
- Previous Leonard approval was attached to stale head
504e2682...; this review supersedes it for the current head.
Screenshots:
- Not applicable: SDK simulation logic/test-only change, no user-visible UI was exercised.
No blocking correctness, API-compatibility, generated-package, dependency, build, type-safety, protocol-integration, or downstream consumer risks found.
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.
Problem
Wallet-receiving swaps (withdraw / redeem / wallet swaps) transfer the swapped-in token to the wallet via
verifyAmountMinAndTransfer(asset, …). The wallet-balance snapshot discovery inbuildSimulationBatchonly covered touched-vault underlyings, required-approval (debited) tokens, and claim/unlock tokens — so the swap output token was never snapshotted insimulatedWalletBalances. As a result the output stayed invisible to consumers (e.g. a withdraw → swap-to-PT-AUSD feeding a multiply showed a0available balance), and to later wallet-sourced batch operations.extractBalanceRequirementsonly covers debited tokens, so it doesn't help here.Fix
Add
collectSwapWalletBalanceTokens(batch)— mirroringcollectClaimWalletBalanceTokens— that decodes theverifyAmountMinAndTransferverifier item and adds itsassetto the snapshotted wallet tokens, wired intobuildSimulationBatchnext to the claim-token loop.Scope: the
transferMin(wallet-receive) verifier only. The deposit/skim verifier variants land output into a vault (a different balance) and are out of scope.Test
Adds
simulateTransactionPlan tracks swap-verifier wallet output tokens. Full suite green (322 tests).🤖 Generated with Claude Code