Sui Address Balance support and coin-model refactor#1163
Open
0xh3rman wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors the Sui integration to introduce the OwnedCoins struct, which encapsulates both individual coin objects and address-level balances. It updates balance validation, transfer builders, and staking logic to utilize this new structure. The review feedback highlights critical correctness bugs in the staking and transfer builders when the required amount is partially covered by the address balance and partially by coin objects, as well as a potential overflow panic in the coin_total calculation.
…have gasless USDC support
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.
Support Sui token transfers and swaps where the token amount lives in the per-address Balance accumulator. Gas payment still comes from a regular
Coin<SUI>object owned by the sender; sponsored / fully gasless transactions are tracked separately in #1164.Changes:
SuiClient::get_coinsjoinsListOwnedObjectswithGetBalanceand returnsOwnedCoins<Coin> { coin_type, coins, address_balance }. Spend builders route through0x2::coin::redeem_funds<T>when Address Balance covers the amount; mixed token sources use coin objects as the base and withdraw only the shortfall.SuiCoin+CoinAsset+Coininto a singleCoinmodel with strong-typedObject { object_id: Address, digest: Digest, version: u64 }. Removes theFrom<SuiCoin> for Coin/TryFrom<SuiCoin> for CoinAssetconverters andget_coin_assets_by_type.Coin<SUI>for gas; missing gas coins are rejected with"No SUI coins available for gas".Verification:
gem_sui63 tests pass (--all-features, includes live mainnet integration);swapper230 tests pass. New tests cover pure-withdraw, mixed shortfall-only withdrawal (asserts the withdrawal amount is exactlyamount - coin_total), missing-gas-coin rejection, and hybrid-native rejection.