Skip to content

feat(adapters): add type discriminant field to VaultV2 adapter interfaces#535

Closed
Foulks-Plb wants to merge 2 commits intomainfrom
feature/consu-4386-fix-usdt-bug-sdk-core
Closed

feat(adapters): add type discriminant field to VaultV2 adapter interfaces#535
Foulks-Plb wants to merge 2 commits intomainfrom
feature/consu-4386-fix-usdt-bug-sdk-core

Conversation

@Foulks-Plb
Copy link
Copy Markdown
Contributor

Summary

  • Add a type string literal field to each VaultV2 adapter interface (VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter)
  • This enables easy type narrowing via adapter.type === "VaultV2MorphoMarketV1Adapter" instead of relying on instanceof checks, which don't work reliably with plain objects or across serialization boundaries

Test plan

  • TypeScript compilation passes on blue-sdk, blue-sdk-viem, and simulation-sdk

Foulks-Plb and others added 2 commits January 16, 2026 10:45
…aces

Add a `type` string literal field to each adapter interface to enable
easy type narrowing via type assertion instead of instanceof checks.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1cf149a8b5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 161 to 164
if (erc20Allowances.permit2 < amount) {
if (
APPROVE_ONLY_ONCE_TOKENS[data.chainId]?.includes(address) &&
erc20Allowances.permit2 > 0n
)
operations.push({
type: "Erc20_Approve",
sender: from,
address,
args: {
amount: 0n,
spender: permit2,
},
});
operations.push({
type: "Erc20_Approve",
sender: from,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Restore zero-reset before approve-only token Permit2 approvals

populateInputTransfer now emits a single positive Erc20_Approve whenever erc20Allowances.permit2 < amount, but for APPROVE_ONLY_ONCE_TOKENS (USDT/CRV) any non-zero existing allowance must be reset to zero first. finalizeBundle/encodeOperation simulate this operation via handleErc20ApproveOperation, which throws NonZeroAllowanceError when allowance is already > 0, so bundle construction fails before encodeErc20Approval can inject the extra zero-approval transaction requirement. This breaks users with partial existing Permit2 allowances (e.g., approved 60, now need 80), and the same pattern also affects the simple-transfer approval branch.

Useful? React with 👍 / 👎.

@Foulks-Plb Foulks-Plb closed this Mar 28, 2026
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