Skip to main content
avnu SDK v4 introduces significant improvements including a new paymaster architecture leveraging starknet.js, streamlined function naming, enhanced type safety with Zod validation, and new services for market data and staking. If you encounter any missing changes, please let us know and we will update this guide.
This guide covers breaking changes that require code modifications. Review each section carefully before upgrading.

Quick Summary

  • Function Renaming: fetch* functions renamed to get* (e.g., fetchQuotesgetQuotes)
  • Paymaster Architecture: Now uses starknet.js PaymasterInterface instead of SDK-internal handling
  • executeSwap Signature: Changed from positional arguments to a single params object
  • DCA Service: Refactored with new *ToCalls + execute* pattern
  • Type Changes: Quote, Route, Page, and other types have structural changes
  • Slippage: Now expressed as decimal (0.01 = 1%) consistently

Prerequisites

Before migrating, ensure you have:
Node.js >= 22 is required for SDK v4.0.0.

Breaking Changes

Swap Service

Function Renaming

New Function

  • calculateMaxSpendAmount(amount, slippage) - Calculate max spend amount for exactTokenTo swaps

Removed Functions

  • fetchPrices() - Use getQuotes() or the new Impulse service getPrices()
  • fetchBuildSwapTypedData() - Paymaster flow refactored
  • fetchExecuteSwapTransaction() - Paymaster flow refactored

executeSwap Signature Change

quoteToCalls Change

DCA Service

The DCA service has been refactored with a new pattern separating call building from execution.

Function Renaming

Removed Functions

These low-level functions have been removed in favor of the new pattern:
  • fetchEstimateFeeCreateOrder()
  • fetchEstimateFeeCancelOrder()
  • fetchBuildCreateOrderTypedData()
  • fetchBuildCancelOrderTypedData()
  • fetchExecuteCreateOrder()
  • fetchExecuteCancelOrder()

Type Renaming

DCA Migration Example

Paymaster (Critical Change)

The paymaster architecture has fundamentally changed. V3’s built-in gasless handling has been replaced with starknet.js PaymasterInterface integration.

v3 Approach (Removed)

In v3, gasless transactions were handled internally by the SDK:

v4 Approach (New)

In v4, you must use a PaymasterInterface from starknet.js:

New Paymaster Functions

The SDK now exposes dedicated paymaster functions for advanced use cases:
  • buildPaymasterTransaction() - Build a transaction for the paymaster
  • signPaymasterTransaction() - Sign the typed data
  • executePaymasterTransaction() - Execute the signed transaction
  • executeAllPaymasterFlow() - Helper that chains all three steps
For detailed paymaster configuration, refer to the starknet.js documentation and the avnu Paymaster docs.

Token Service

The token service has minimal breaking changes. New functions have been added:
  • fetchTokenByAddress(tokenAddress) - Get a specific token by address
  • fetchVerifiedTokenBySymbol(symbol) - Get a verified token by symbol

Type Changes

Quote Type

Route Type

Source Type

SourceType Enum

Page<T> Type

Slippage Semantics

Slippage is now consistently expressed as a decimal value.

Gas Fees Denomination

Gas fees are now denominated in STRK instead of ETH.
In v3, the gasFees field in quotes was denominated in ETH (WEI). Starting from v4, gas fees are denominated in STRK (FRI).

New Features (Non-Breaking)

Impulse Service (Market Data)

New service for market data, prices, volume, and TVL:

Staking Service

New service for avnu stake delegation:

Zod Validation

All API responses are now validated and transformed using Zod schemas:
  • Automatic hex string to BigInt conversion
  • Automatic ISO string to Date conversion
  • Runtime type safety

Migration Checklist

1

Update Dependencies

2

Update Function Imports

Replace fetch* imports with get*:
3

Update executeSwap Calls

Change from positional arguments to params object:
4

Update Paymaster Integration

If using gasless transactions, implement PaymasterInterface from starknet.js.
5

Update DCA Calls

Replace old DCA functions with new pattern:
  • fetchGetOrdersgetDcaOrders
  • executeCreateOrderexecuteCreateDca
  • executeCancelOrderexecuteCancelDca
6

Update Type References

  • Page.numberPage.page
  • Route.routeInfo is now Record<string, string> instead of Map
  • Access fees via quote.fee instead of individual fee fields
7

Verify Slippage Values

Ensure all slippage values are decimals (0.01 = 1%).
8

Test Your Integration

Run your test suite and verify all functionality works as expected.

Troubleshooting

The function has been renamed to getQuotes. Update your import:
The Page type’s number field has been renamed to page:
Gasless handling has moved to starknet.js PaymasterInterface. You need to:
  1. Create a PaymasterInterface implementation
  2. Pass it via the paymaster parameter
See the Paymaster section for details.
Fee fields are now consolidated under quote.fee:
routeInfo changed from Map<string, string> to Record<string, string>:

Resources