fix: convert builder_fee bps to chain units before sending to contract#16
Merged
fix: convert builder_fee bps to chain units before sending to contract#16
Conversation
50401c1 to
8972a58
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the Python SDK to convert builder fee inputs from basis points (bps) into on-chain fee units before submitting transactions, and removes the legacy “netna” network/ABI configuration in favor of testnet/mainnet defaults.
Changes:
- Added
bps_to_chain_units()and applied conversion inplace_order(),place_twap_order(), andapprove_max_builder_fee()(async + sync). - Removed NETNA config/ABI handling and updated ABI registry/generator behavior and associated tests.
- Updated docs and examples to use
TESTNET_CONFIGand added a market-maker bot example.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/abi/test_registry.py | Updates ABI registry tests for new default/fallback behavior and removes netna-specific assertions. |
| src/decibel/write/_types.py | Updates typed args to allow max_fee as `int |
| src/decibel/write/init.py | Converts builder fee bps inputs to contract fee units before calling entry functions (async + sync). |
| src/decibel/abi/json/netna.json | Removes the netna ABI JSON artifact. |
| src/decibel/abi/generate.py | Drops netna-specific filename selection logic for ABI generation. |
| src/decibel/abi/_registry.py | Removes netna chain id support; defaults/unknown-chain fallback now use testnet ABIs. |
| src/decibel/_utils.py | Adds bps_to_chain_units() utility and exports it via __all__. |
| src/decibel/_fee_pay.py | Removes netna-specific gas station URL fallback. |
| src/decibel/_constants.py | Removes NETNA_CONFIG and the netna entry from NAMED_CONFIGS. |
| src/decibel/init.py | Removes NETNA_CONFIG from the public package exports. |
| examples/write/withdraw_from_vault.py | Switches example config from NETNA to TESTNET. |
| examples/write/withdraw.py | Switches example config from NETNA to TESTNET. |
| examples/write/update_tp_sl_order.py | Switches example config from NETNA to TESTNET and updates derived addresses accordingly. |
| examples/write/trigger_matching.py | Switches example config from NETNA to TESTNET and updates derived addresses accordingly. |
| examples/write/revoke_delegation.py | Switches example config from NETNA to TESTNET. |
| examples/write/revoke_builder_fee.py | Switches example config from NETNA to TESTNET. |
| examples/write/place_twap_order.py | Switches example config from NETNA to TESTNET. |
| examples/write/place_tp_sl_for_position.py | Switches example config from NETNA to TESTNET and updates derived addresses accordingly. |
| examples/write/place_stop_order.py | Switches example config from NETNA to TESTNET. |
| examples/write/place_order_with_tp_sl.py | Switches example config from NETNA to TESTNET. |
| examples/write/place_market_order.py | Switches example config from NETNA to TESTNET. |
| examples/write/place_limit_order.py | Switches example config from NETNA to TESTNET. |
| examples/write/place_bulk_orders.py | Switches example config from NETNA to TESTNET. |
| examples/write/market_maker_bot.py | Adds a new end-to-end example bot demonstrating quoting/canceling using the SDK. |
| examples/write/deposit_to_vault.py | Switches example config from NETNA to TESTNET and updates derived addresses accordingly. |
| examples/write/deposit.py | Switches example config from NETNA to TESTNET. |
| examples/write/delegate_vault_actions.py | Switches example config from NETNA to TESTNET. |
| examples/write/delegate_trading.py | Switches example config from NETNA to TESTNET and updates derived addresses accordingly. |
| examples/write/deactivate_subaccount.py | Switches example config from NETNA to TESTNET. |
| examples/write/create_vault.py | Switches example config from NETNA to TESTNET. |
| examples/write/create_subaccount.py | Switches example config from NETNA to TESTNET. |
| examples/write/configure_market_settings.py | Switches example config from NETNA to TESTNET and updates derived addresses accordingly. |
| examples/write/cancel_twap_order.py | Switches example config from NETNA to TESTNET and updates derived addresses accordingly. |
| examples/write/cancel_tp_sl_order.py | Switches example config from NETNA to TESTNET and updates derived addresses accordingly. |
| examples/write/cancel_order_by_client_id.py | Switches example config from NETNA to TESTNET. |
| examples/write/cancel_order.py | Switches example config from NETNA to TESTNET. |
| examples/write/cancel_bulk_order.py | Switches example config from NETNA to TESTNET. |
| examples/write/approve_builder_fee.py | Switches example config from NETNA to TESTNET. |
| examples/write/activate_vault.py | Switches example config from NETNA to TESTNET. |
| examples/read/ws/subscribe_user_trade_history.py | Switches example config from NETNA to TESTNET. |
| examples/read/ws/subscribe_user_positions.py | Switches example config from NETNA to TESTNET. |
| examples/read/ws/subscribe_user_order_history.py | Switches example config from NETNA to TESTNET. |
| examples/read/ws/subscribe_user_open_orders.py | Switches example config from NETNA to TESTNET. |
| examples/read/ws/subscribe_user_notifications.py | Switches example config from NETNA to TESTNET. |
| examples/read/ws/subscribe_user_bulk_orders.py | Switches example config from NETNA to TESTNET. |
| examples/read/ws/subscribe_user_active_twaps.py | Switches example config from NETNA to TESTNET. |
| examples/read/ws/subscribe_market_trades.py | Switches example config from NETNA to TESTNET. |
| examples/read/ws/subscribe_market_price.py | Switches example config from NETNA to TESTNET. |
| examples/read/ws/subscribe_market_depth.py | Switches example config from NETNA to TESTNET. |
| examples/read/ws/subscribe_candlesticks.py | Switches example config from NETNA to TESTNET. |
| examples/read/ws/subscribe_all_market_prices.py | Switches example config from NETNA to TESTNET. |
| examples/read/ws/subscribe_account_overview.py | Switches example config from NETNA to TESTNET. |
| examples/read/list_market_addresses.py | Switches example config from NETNA to TESTNET. |
| examples/read/get_user_twap_history.py | Switches example config from NETNA to TESTNET. |
| examples/read/get_user_trade_history.py | Switches example config from NETNA to TESTNET. |
| examples/read/get_user_subaccounts.py | Switches example config from NETNA to TESTNET. |
| examples/read/get_user_positions.py | Switches example config from NETNA to TESTNET. |
| examples/read/get_user_order_history.py | Switches example config from NETNA to TESTNET. |
| examples/read/get_user_open_orders.py | Switches example config from NETNA to TESTNET. |
| examples/read/get_user_funding_history.py | Switches example config from NETNA to TESTNET. |
| examples/read/get_user_fund_history.py | Switches example config from NETNA to TESTNET. |
| examples/read/get_user_bulk_orders.py | Switches example config from NETNA to TESTNET. |
| examples/read/get_user_active_twaps.py | Switches example config from NETNA to TESTNET. |
| examples/read/get_trading_points.py | Switches example config from NETNA to TESTNET. |
| examples/read/get_portfolio_chart.py | Switches example config from NETNA to TESTNET. |
| examples/read/get_market_trades.py | Switches example config from NETNA to TESTNET. |
| examples/read/get_market_price.py | Switches example config from NETNA to TESTNET. |
| examples/read/get_market_depth.py | Switches example config from NETNA to TESTNET. |
| examples/read/get_market_contexts.py | Switches example config from NETNA to TESTNET. |
| examples/read/get_leaderboard.py | Switches example config from NETNA to TESTNET. |
| examples/read/get_delegations.py | Switches example config from NETNA to TESTNET. |
| examples/read/get_candlesticks.py | Switches example config from NETNA to TESTNET. |
| examples/read/get_all_markets.py | Switches example config from NETNA to TESTNET. |
| examples/read/get_all_market_prices.py | Switches example config from NETNA to TESTNET. |
| examples/read/get_account_overview.py | Switches example config from NETNA to TESTNET. |
| README.md | Updates documentation examples and “Network Configs” section to remove NETNA and reference TESTNET. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
blakezimmerman
approved these changes
Apr 15, 2026
- Add bps_to_chain_units() utility function to convert basis points to chain units (multiply by 100, aligning with FEE_PRECISION = 10000 in contract) - Update place_order() and place_twap_order() to convert builder_fee/builder_fees - Update approve_max_builder_fee() to accept int|float and convert to chain units - Sync both async and sync versions of these methods - Update ApproveBuilderFeeArgs type definition to accept int|float This matches the TypeScript SDK implementation and fixes precision issues.
8972a58 to
e8f8f4c
Compare
gregnazario
approved these changes
Apr 15, 2026
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.
Summary
Convert builder fee basis points (bps) to chain units before sending to the contract, aligning with TypeScript SDK implementation.
bps_to_chain_units()utility function to convert basis points to chain units (multiply by 100)place_order(),place_twap_order(), andapprove_max_builder_fee()methodsChanges
bps_to_chain_units(bps)in_utils.pythat converts bps to chain unitsint | floatfor builder_fee parameters_types.pyExample