Changelog --------- This section outlines the changes made in each version of the Avantis Trader SDK **Version 0.8.16 (2026-02-06)** - **Automatic Lazer State Detection**: - Trading methods now check ``lazerFeed.state`` before using Pyth Pro pricing. - Pairs without stable Lazer support automatically fall back to core/Hermes pricing. - Added ``is_lazer_supported(pair_index)`` to ``PairsCache``. - **Simplified Price Sourcing**: - Removed ``price_sourcing`` parameter from ``build_trade_tp_sl_update_tx``, ``build_trade_margin_update_tx``, and their delegate variants. - These methods now auto-detect the correct price source via feed-v3. **Version 0.8.15 (2026-02-04)** - **Pyth Pro Pricing for Trade Opening**: - ``build_trade_open_tx`` and ``build_trade_open_tx_delegate`` now use Pyth Lazer for price fetching. - Added ``get_latest_lazer_price(lazer_feed_ids)`` - Fetches latest prices from Pyth Lazer API. - **Documentation**: - Added ``AGENT.md`` - AI agent guide for building with the SDK. - Added ``.cursorrules`` - Cursor IDE context rules. - Simplified README with practical examples. - **Examples Updated:** - ``06_example_get_latest_price.py`` - Now demonstrates ``get_latest_lazer_price`` method. **Version 0.8.14 (2026-02-04)** - **New Features:** - **Upgraded to Pyth Pro Pricing**: - Trading methods now use Pyth Pro/Lazer for improved price accuracy and lower latency. - ``build_trade_tp_sl_update_tx``, ``build_trade_tp_sl_update_tx_delegate``, ``build_trade_margin_update_tx``, and ``build_trade_margin_update_tx_delegate`` automatically use Pyth Pro pricing. - **Feed Client Enhancements**: - Added ``get_price_update_data(pair_index)`` - Fetches price update data from the new feed-v3 API. - Added ``listen_for_lazer_price_updates(lazer_feed_ids, callback)`` - SSE streaming for Pyth Pro real-time prices with lower latency than WebSocket. - **Pairs Cache Enhancements**: - Added ``get_lazer_feed_id(pair_index)`` - Returns the Pyth Lazer feed ID for a pair. - **New Types**: - ``LazerPriceFeed`` - Single price feed from Pyth Lazer SSE stream. - ``LazerPriceFeedResponse`` - Full SSE response with timestamp and price feeds. - ``FeedV3PriceResponse`` - Response from feed-v3 API. - **ABI Updates:** - Updated Trading ABI to latest version with ``MarketOrderInitiated`` event changes. - **Examples Updated:** - ``05_example_get_realtime_prices.py`` - Now demonstrates SSE streaming for real-time prices. - ``06_example_get_latest_price.py`` - Now demonstrates feed-v3 API usage. **Version 0.8.13 (2026-01-18)** - **New Features:** - **Optimized ``get_trades`` method**: - Now fetches from API first for significantly better performance. - Falls back to paginated smart contract calls if API is unavailable or disabled. - Added ``use_api`` parameter to control fetching behavior. - Contract fetching now uses ``getPositionsForPairIndexes`` with pagination instead of fetching all at once. - **Delegate trading management**: - Added ``get_delegate(trader)`` - Gets the current delegate address for a trader. - Added ``build_set_delegate_tx(delegate, trader)`` - Sets a delegate wallet that can trade on behalf of the trader. - Added ``build_remove_delegate_tx(trader)`` - Removes the current delegate. - Added example ``21_example_delegate_trading.py`` demonstrating full delegate workflow. - Added ``execution_fee`` field to limit orders - Now returned for both API and contract responses. - **Improvements:** - Added ``AVANTIS_CORE_API_BASE_URL`` to config with optional override via ``core_api_base_url`` parameter. - Types now support both API and contract response formats with automatic field mapping. - ``TradeResponse``: Added aliases for ``collateral`` and ``openedAt``, auto-sets ``collateral_in_trade`` when not provided. - ``TradeExtendedResponse``: Added model validator to handle flat API responses. - ``PendingLimitOrderResponse``: Updated to correctly map ``collateral`` from API responses. - Removed erroneous ``self.FeedClient()`` call in ``build_trade_tp_sl_update_tx`` method. - **Breaking Changes:** - ``TradeInfo`` simplified to only contain ``loss_protection_percentage``. Removed ``open_interest_usdc``, ``tp_last_updated``, ``sl_last_updated``, ``being_market_closed``. **Version 0.8.12 (2025-12-01)** - **Bug Fixes:** - Fixed a bug where `get_trades` was not returning the trades. - **New Features:** - Added support for getting the `is_zfp`` flag for trades. **Version 0.8.11 (2025-11-07)** - **New Features:** - Added example for getting fee details when closing a trade `20_example_close_market_trade_with_fee_details.py `_. - Updated `Multicall`` contract address. - Added support for getting pair info from socket ``PairsCache.get_pair_info_from_socket`` - **Internal Changes:** - Optimized loss protection percentage calculation. **Version 0.8.9/0.8.10 (2025-10-14)** - **Internal Changes:** - Upgraded eth_account to 0.14 - Updated public socket api url - Fixed a bug where TP/SL update was not working correctly because of invalid `feed_client`. **Version 0.8.8 (2025-10-07)** - **Internal Changes:** - Update setup.py to include eth_account 0.13 **Version 0.8.7 (2025-10-07)** - **Internal Changes:** - Upgraded eth_account to 0.13 **Version 0.8.6 (2025-10-07)** - **Bug Fixes:** - Fixed a bug where the KMS signer address was not being fetched correctly. **Version 0.8.5 (2025-10-02)** - **New Features:** - Removed dependency and support for l1_provider_url. - Added support for using a custom execution fee for trade transactions. - Cached the KMS signer address for better performance. **Version 0.8.4 (2025-09-19)** - **New Features:** - Updated Trading ABI. **Version 0.8.3 (2025-07-25)** - **New Features:** - Added support for using a custom socket API for pair feeds. **Version 0.8.2 (2025-04-07)** - **Bug Fixes:** - Fixed a bug where the trade type for zero fee market trades was not being set correctly. **Version 0.8.1 (2025-04-07)** - **New Features:** - Added support for opening zero fee market trades. **Version 0.8.0 (2025-02-21)** - More Info: https://avantisfi.notion.site/avantis-contracts-v1-5-upgrade - **Breaking Changes:** - **New ABIs Introduced**: - **PairInfos ABI** - **PriceAggregator ABI** - **Trading ABI** - **TradingCallbacks ABI** - **TradingStorage ABI** - **Price Impact Spread Calculations**: - The following methods now support the **isPnl** parameter: - `get_price_impact_spread` - `get_skew_impact_spread` - `get_opening_price_impact_spread` - **Trade Transactions**: - **Open and Close Trade Transactions**: The last parameter for `execution_fee` has been **removed** in the contract. - **Previous Behavior**: Required `execution_fee` as the last parameter. - **New Behavior**: No longer requires `execution_fee`. Ensure transaction-building logic is updated accordingly. - ⚠️ *This is an important change—ensure your integration reflects this update.* - **Loss Protection Tier**: - Updated `get_loss_protection_tier` to support the new **PnL order type**. - **Referral Rebates**: - Updated `get_trade_referral_rebate_percentage`: The contract method for tiers has changed to `referralTiers`. - **Order Type Enum Update**: - The `TradeInputOrderType` enum has been updated to support the **new PnL order type**: .. code-block:: python class TradeInputOrderType(Enum): ... MARKET_PNL = 3 **Version 0.7.0 (2025-02-09)** - **Breaking Changes:** - **Modified Write Contract**: - **Previous Behavior**: The `write_contract` method would return the transaction hash. - **New Behavior**: The `write_contract` method now returns the transaction receipt. - **Modified Get Balance**: - **Previous Behavior**: The `get_balance` method would return the balance of the account in wei. - **New Behavior**: The `get_balance` method now returns the balance of the account in ETH. - **Improvements:** - Removed dependency on hardcoded pair feed ids. - Added support for fetching feed mappings dynamically from an API or trader client. - Introduced an optional `pair_fetcher` function in feed client for full customization. - Revised example to demonstrate how to use both an API or trader client to retrieve the latest price updates. **Version 0.6.0 (2025-01-24)** - **Breaking Changes:** - **Modified ABI**: - **`PairStorage` ABI**: - **Previous Behavior**: The ABI had a simpler structure for accessing pair data. - **New Behavior**: Updated to include more detailed and flexible structures for pair data access. - **Modified Data Models**: - **`PairInfo`**: - **Previous Behavior**: Limited fields for leverage and pair metrics. - **New Behavior**: Enhanced with additional fields to accommodate new metrics: - **Leverages**: - `min_leverage`: Minimum leverage for pairs. - `max_leverage`: Maximum leverage for pairs. - `pnl_min_leverage`: Minimum leverage for PnL calculations. - `pnl_max_leverage`: Maximum leverage for PnL calculations. - **Values**: - `max_gain_percentage`: Maximum allowable gain percentage. - `max_sl_percentage`: Maximum stop-loss percentage. - `max_long_oi_percentage`: Maximum open interest percentage for long trades. - `max_short_oi_percentage`: Maximum open interest percentage for short trades. - `group_open_interest_percentage`: Group-level open interest percentage limit. - `max_wallet_oi_percentage`: Maximum open interest percentage per wallet. - `is_usdc_aligned`: Boolean indicating USDC alignment. - **Additional Fields**: - `backup_feed`: Backup source for price feeds. - `constant_pnl_spread_bps`: Basis points for constant PnL spreads. - **New Data Models**: - **`PairInfoWithData`**: - Combines detailed pair data (`PairInfo`) with additional metrics (`PairData`). - Includes all new fields from `PairInfo` as well as the following: - `PairData`: Contains essential details such as `from`, `to`, and pair-related attributes. - **Improvements:** - Enhanced data model flexibility for pair configurations. - Updated documentation to reflect the new ABI structure. **Version 0.5.0 (2025-01-17)** - **Breaking Changes:** - **Modified Methods**: - **`build_trade_close_tx`**: - **Previous Behavior**: Required a 6 decimal precision float for collateral_to_close. e.g. 100500000 for 100.5 USDC - **New Behavior**: Now requires a normal float value for collateral_to_close. e.g. 100.5 for 100.5 USDC - **New Methods**: - **`build_trade_tp_sl_update_tx`**: - **Description**: Introduced a new method specifically for updating the take profit and stop loss of a trade. - **Purpose**: To allow traders to update the take profit and stop loss of a trade without having to close and open a new trade. - **Input**: Accepts a `pair_index`, `trade_index`, `take_profit_price`, `stop_loss_price`, and `trader` (optional). - **Output**: Returns the transaction object to update the take profit and stop loss of a trade. - **Improvements:** - Added warning for upcoming v1.5 contracts upgrade - Fixed margin update and USDC approval methods - Optimized fee values for margin updates - `write_contract` will now auto fill the `nonce` and `chainId` if not provided **Version 0.4.0 (2024-12-02)** - **Breaking Changes:** - **Modified Methods**: - **`get_opening_fee`**: - **Previous Behavior**: Returned a `Fee` instance with fee details based on input parameters. If the parameters included `trade_input`, it would calculate and return the final fee in USDC. - **New Behavior**: Now strictly returns fee details in **basis points (bps)** based on input parameters. It no longer accepts `trade_input` as an argument. This ensures consistent behavior and avoids ambiguity. - **New Methods**: - **`get_new_trade_opening_fee`**: - **Description**: Introduced a new method specifically for calculating the **final opening fee in USDC** for a trade, based on the provided `trade_input`. - **Purpose**: To handle trade-specific fee calculations consistently and separately from the broader `get_opening_fee` method. - **Input**: Accepts a `TradeInput` object. - **Output**: Returns the calculated opening fee in USDC, adjusted for referral rebates. **Version 0.3.1 (2024-10-23)** - Added feed ids for new pairs **Version 0.3.0 (2024-10-20)** - **Breaking Changes:** - Refactored transaction signing: Existing integrations may require updates to align with the new signing approach (see updated examples: :doc:`trade ` and `GitHub Examples `_). - Made the `trader` parameter optional in select trading methods: Ensure your code accounts for cases where `trader` may not be explicitly provided. Affected methods include: - `build_trade_close_tx` - `build_order_cancel_tx` - `build_trade_margin_update_tx` - **New Features:** - Added support for approving USDC for trading. - Introduced support for transaction signing via AWS KMS. - Implemented a `BaseSigner` class to allow custom signer integrations. - **Improvements:** - Refactored transaction signing for better flexibility and integration. - Enhanced examples to demonstrate the new allowance and approve methods. - Updated examples to utilize the new signer methods. - Expanded documentation with additional examples and use cases. **Version 0.2.2 (2024-10-16)** - Added support for Python v3.6 - Handled de-listed pairs gracefully **Version 0.2.1 (2024-08-31)** - Added support for trading. - Improved error handling and logging. - Updated to pydantic 2.0 for data validation. - Updated documentation with more examples and use cases. - Added support for price updates on demand. **Version 0.1.0 (2024-03-01)** - Initial release of the Avantis Trader SDK. - Added support for asset parameters, category parameters, trading parameters, and fee parameters. - Implemented a websocket client for real-time price feed updates.