diff --git a/clients/web3-wallet/CHANGELOG.md b/clients/web3-wallet/CHANGELOG.md index f485a59..63e7014 100644 --- a/clients/web3-wallet/CHANGELOG.md +++ b/clients/web3-wallet/CHANGELOG.md @@ -1,5 +1,51 @@ # Changelog +## 4.0.0 - 2026-07-29 + +### Changed (8) + +- Added parameter `feePercent` + - affected methods: + - `getAggregatedQuote()` (`GET /api/v1/dex/aggregator/quote`) + - `quoteAndBuildSwapTransaction()` (`GET /api/v1/dex/aggregator/quote-and-swap`) + - `buildSwapTransaction()` (`GET /api/v1/dex/aggregator/swap`) + - `buildSolanaSwapInstructions()` (`GET /api/v1/dex/aggregator/swap-instruction`) +- Added parameter `feeSource` + - affected methods: + - `getAggregatedQuote()` (`GET /api/v1/dex/aggregator/quote`) +- Added parameter `fromTokenReferrerWalletAddress` + - affected methods: + - `quoteAndBuildSwapTransaction()` (`GET /api/v1/dex/aggregator/quote-and-swap`) + - `buildSwapTransaction()` (`GET /api/v1/dex/aggregator/swap`) + - `buildSolanaSwapInstructions()` (`GET /api/v1/dex/aggregator/swap-instruction`) +- Added parameter `toTokenReferrerWalletAddress` + - affected methods: + - `quoteAndBuildSwapTransaction()` (`GET /api/v1/dex/aggregator/quote-and-swap`) + - `buildSwapTransaction()` (`GET /api/v1/dex/aggregator/swap`) + - `buildSolanaSwapInstructions()` (`GET /api/v1/dex/aggregator/swap-instruction`) +- Modified response for `getAggregatedQuote()` (`GET /api/v1/dex/aggregator/quote`): + - `data`.items: property `feeAmount` added + - `data`.items: property `feeToken` added + - `data`.items: property `actualSwapAmount` added + - `data`.items: item property `feeAmount` added + - `data`.items: item property `feeToken` added + - `data`.items: item property `actualSwapAmount` added + +- Modified response for `quoteAndBuildSwapTransaction()` (`GET /api/v1/dex/aggregator/quote-and-swap`): + - `data`.`routerResult`: property `actualSwapAmount` added + - `data`.`routerResult`: property `feeAmount` added + - `data`.`routerResult`: property `feeToken` added + +- Modified response for `buildSwapTransaction()` (`GET /api/v1/dex/aggregator/swap`): + - `data`.`routerResult`: property `feeAmount` added + - `data`.`routerResult`: property `feeToken` added + - `data`.`routerResult`: property `actualSwapAmount` added + +- Modified response for `buildSolanaSwapInstructions()` (`GET /api/v1/dex/aggregator/swap-instruction`): + - `data`.`routerResult`: property `feeToken` added + - `data`.`routerResult`: property `feeAmount` added + - `data`.`routerResult`: property `actualSwapAmount` added + ## 1.0.0 - 2026-07-24 ### Changed (1) diff --git a/clients/web3-wallet/docs/BuildSolanaSwapInstructionsResponseDataRouterResult.md b/clients/web3-wallet/docs/BuildSolanaSwapInstructionsResponseDataRouterResult.md index 889520d..7982dcb 100644 --- a/clients/web3-wallet/docs/BuildSolanaSwapInstructionsResponseDataRouterResult.md +++ b/clients/web3-wallet/docs/BuildSolanaSwapInstructionsResponseDataRouterResult.md @@ -19,6 +19,9 @@ Routing result (same shape and semantics as `/swap`'s `routerResult`). |**dexRouterList** | [**List<BuildSolanaSwapInstructionsResponseDataRouterResultDexRouterListInner>**](BuildSolanaSwapInstructionsResponseDataRouterResultDexRouterListInner.md) | Routing path segments (same shape as `/quote`'s `dexRouterList`). | [optional] | |**fromToken** | [**BuildSolanaSwapInstructionsResponseDataRouterResultFromToken**](BuildSolanaSwapInstructionsResponseDataRouterResultFromToken.md) | | [optional] | |**toToken** | [**BuildSolanaSwapInstructionsResponseDataRouterResultToToken**](BuildSolanaSwapInstructionsResponseDataRouterResultToToken.md) | | [optional] | +|**feeAmount** | **String** | Fee amount deducted for this swap (smallest unit, integer string). Only populated when the request enabled the custom fee; `null` otherwise. `FROM_TOKEN` direction = `originalFromCoinAmount × feePercent/100` (HALF_UP); `TO_TOKEN` direction = `originalToCoinAmount × feePercent/100` (HALF_DOWN). | [optional] | +|**feeToken** | **String** | Contract address of the token in which the fee is denominated. `FROM_TOKEN` direction = sell-token address; `TO_TOKEN` direction = buy-token address. `null` when the custom fee is not enabled. | [optional] | +|**actualSwapAmount** | **String** | Actual amount participating in the DEX swap (smallest unit, integer string). `FROM_TOKEN` direction = net amount after fee deduction (`fromTokenAmount − feeAmount`); `TO_TOKEN` direction = original input amount (fee is taken from the output side). `null` when the custom fee is not enabled. | [optional] | diff --git a/clients/web3-wallet/docs/BuildSwapTransactionResponseDataRouterResult.md b/clients/web3-wallet/docs/BuildSwapTransactionResponseDataRouterResult.md index 36b2de0..ddbe845 100644 --- a/clients/web3-wallet/docs/BuildSwapTransactionResponseDataRouterResult.md +++ b/clients/web3-wallet/docs/BuildSwapTransactionResponseDataRouterResult.md @@ -19,6 +19,9 @@ Routing result for the chosen vendor. |**dexRouterList** | [**List<BuildSwapTransactionResponseDataRouterResultDexRouterListInner>**](BuildSwapTransactionResponseDataRouterResultDexRouterListInner.md) | Routing path segments. Same shape as the `dexRouterList` returned by `/quote`. | [optional] | |**fromToken** | [**BuildSwapTransactionResponseDataRouterResultFromToken**](BuildSwapTransactionResponseDataRouterResultFromToken.md) | | [optional] | |**toToken** | [**BuildSwapTransactionResponseDataRouterResultToToken**](BuildSwapTransactionResponseDataRouterResultToToken.md) | | [optional] | +|**feeAmount** | **String** | Fee amount deducted for this swap (smallest unit, integer string). Only populated when the request enabled the custom fee; `null` otherwise. `FROM_TOKEN` direction = `originalFromCoinAmount × feePercent/100` (HALF_UP); `TO_TOKEN` direction = `originalToCoinAmount × feePercent/100` (HALF_DOWN). | [optional] | +|**feeToken** | **String** | Contract address of the token in which the fee is denominated. `FROM_TOKEN` direction = sell-token address; `TO_TOKEN` direction = buy-token address. `null` when the custom fee is not enabled. | [optional] | +|**actualSwapAmount** | **String** | Actual amount participating in the DEX swap (smallest unit, integer string). `FROM_TOKEN` direction = net amount after fee deduction (`fromTokenAmount − feeAmount`); `TO_TOKEN` direction = original input amount (fee is taken from the output side). `null` when the custom fee is not enabled. | [optional] | diff --git a/clients/web3-wallet/docs/FeeSource.md b/clients/web3-wallet/docs/FeeSource.md new file mode 100644 index 0000000..2538b32 --- /dev/null +++ b/clients/web3-wallet/docs/FeeSource.md @@ -0,0 +1,13 @@ + + +# FeeSource + +## Enum + + +* `FROM_TOKEN` (value: `"FROM_TOKEN"`) + +* `TO_TOKEN` (value: `"TO_TOKEN"`) + + + diff --git a/clients/web3-wallet/docs/GetAggregatedQuoteResponseDataInner.md b/clients/web3-wallet/docs/GetAggregatedQuoteResponseDataInner.md index fc926ef..70151d7 100644 --- a/clients/web3-wallet/docs/GetAggregatedQuoteResponseDataInner.md +++ b/clients/web3-wallet/docs/GetAggregatedQuoteResponseDataInner.md @@ -22,6 +22,9 @@ |**executionMode** | **String** | Execution mode for this route. `SWAP` = standard on-chain swap (sign the `tx` object from `/swap` and broadcast). `RFQ` = signed order flow (sign `rfq.typedDataToSign` from `/swap` with EIP-712, submit via `POST /order/submit`, poll `GET /order/{orderId}`). Equity / RWA tokens always return `RFQ`. | [optional] | |**approveTarget** | **String** | The spender contract address the backend will encode into the approve calldata for this route. To obtain that calldata, call `/approve-transaction` with `vendor=<vendorName>` (the string name, e.g. `\"PcsXRfq\"`) — the backend resolves the spender address internally from the vendor name. This field is provided for informational purposes only (e.g. to call ERC-20 `approve()` directly without going through `/approve-transaction`). Null when no approval is needed (e.g. native-token swap or already approved). | [optional] | |**isBest** | **Boolean** | Whether this route has the highest `toTokenAmount` among all routes returned in this response. At most one route per response has `isBest=true`. | [optional] | +|**feeAmount** | **String** | Fee amount deducted for this route (smallest unit, integer string). Only populated when the request enabled the custom fee (`feePercent` + `feeSource` both present); `null` otherwise. `FROM_TOKEN` direction = `originalFromCoinAmount × feePercent/100` (HALF_UP); `TO_TOKEN` direction = `originalToCoinAmount × feePercent/100` (HALF_DOWN). | [optional] | +|**feeToken** | **String** | Contract address of the token in which the fee is denominated. `FROM_TOKEN` direction = sell-token address; `TO_TOKEN` direction = buy-token address. `null` when the custom fee is not enabled. | [optional] | +|**actualSwapAmount** | **String** | Actual amount participating in the DEX swap (smallest unit, integer string). `FROM_TOKEN` direction = net amount after fee deduction (`fromTokenAmount − feeAmount`, i.e. the amountIn sent to the DEX); `TO_TOKEN` direction = original input amount (fee is taken from the output side, so the full input participates in the swap). `null` when the custom fee is not enabled. | [optional] | diff --git a/clients/web3-wallet/docs/TradingApi.md b/clients/web3-wallet/docs/TradingApi.md index 2d9f40d..ced141c 100644 --- a/clients/web3-wallet/docs/TradingApi.md +++ b/clients/web3-wallet/docs/TradingApi.md @@ -17,11 +17,11 @@ All URIs are relative to *https://web3.binance.com/build* # **buildSolanaSwapInstructions** -> BuildSolanaSwapInstructionsResponse buildSolanaSwapInstructions(binanceChainId, amount, fromTokenAddress, toTokenAddress, slippagePercent, userWalletAddress, quoteId).recvWindow(recvWindow).nonce(nonce).priceImpactProtectionPercent(priceImpactProtectionPercent).autoSlippage(autoSlippage).maxAutoSlippagePercent(maxAutoSlippagePercent).computeUnitLimit(computeUnitLimit).computeUnitPrice(computeUnitPrice).gasLevel(gasLevel).tips(tips).execute(); +> BuildSolanaSwapInstructionsResponse buildSolanaSwapInstructions(binanceChainId, amount, fromTokenAddress, toTokenAddress, slippagePercent, userWalletAddress, quoteId).recvWindow(recvWindow).nonce(nonce).priceImpactProtectionPercent(priceImpactProtectionPercent).autoSlippage(autoSlippage).maxAutoSlippagePercent(maxAutoSlippagePercent).computeUnitLimit(computeUnitLimit).computeUnitPrice(computeUnitPrice).gasLevel(gasLevel).tips(tips).feePercent(feePercent).fromTokenReferrerWalletAddress(fromTokenReferrerWalletAddress).toTokenReferrerWalletAddress(toTokenReferrerWalletAddress).execute(); Build Solana Swap Instructions -Solana-only counterpart to `/swap`. Shares the full quote → route → vendor `buildSwapTx` → priceImpact → minReceive → instruction-assembly pipeline; the only difference is the response: instead of returning a signed-and-serialized base64 transaction, this endpoint returns the **uncompiled** instruction list plus the address-lookup-table (ALT) address list, leaving v0-transaction compilation, signing, and submission to the caller. Use this when the caller needs to: - prepend / append their own instructions (e.g. fee splitting, custom logging) before signing; - reuse the platform-curated route, slippage, PS-variant rewriting, ALT injection, ComputeBudget overwrite, and ATA batching while still controlling the final wire format. Only supports `binanceChainId=CT_501` (Solana). Other chains return `CHAIN_NOT_SUPPORTED` (40411). Parameters mirror the Solana subset of `/swap` (no EVM-only `approveTransaction` / `approveAmount` / `gasLimit`). +Solana-only counterpart to `/swap`. Shares the full quote → route → vendor `buildSwapTx` → priceImpact → minReceive → instruction-assembly pipeline; the only difference is the response: instead of returning a signed-and-serialized base64 transaction, this endpoint returns the **uncompiled** instruction list plus the address-lookup-table (ALT) address list, leaving v0-transaction compilation, signing, and submission to the caller. Use this when the caller needs to: - prepend / append their own instructions (e.g. fee splitting, custom logging) before signing; - reuse the platform-curated route, slippage, PS-variant rewriting, ALT injection, ComputeBudget overwrite, and ATA batching while still controlling the final wire format. Only supports `binanceChainId=CT_501` (Solana). Other chains return `CHAIN_NOT_SUPPORTED` (40411). Parameters mirror the Solana subset of `/swap` (no EVM-only `approveTransaction` / `approveAmount` / `gasLimit`). Supports the custom-fee (Add Fee / referral fee) parameters (`feePercent` + `fromTokenReferrerWalletAddress` / `toTokenReferrerWalletAddress`), with the same semantics as `/swap` — the fee instructions are injected into the returned uncompiled instruction list. ### Example ```java @@ -54,6 +54,9 @@ public class Example { String computeUnitPrice = "1000"; // String | Priority fee per compute unit (micro-lamports). When omitted, the platform computes a value either from the `gasLevel` tier or from chain-side defaults. GasLevel gasLevel = GasLevel.fromValue("slow"); // GasLevel | Priority-fee tier; consulted only when `computeUnitPrice` is omitted. Defaults to \"average\". String tips = "0.001"; // String | Jito tips in SOL for MEV protection. Valid range [0.000000001, 2] (minimum 1 lamport). When specified, it is recommended to set `computeUnitPrice=0`. The platform picks one of Jito's tip accounts at random per request. + String feePercent = "1.5"; // String | Custom fee (referral fee / Add Fee) percentage as a decimal string. Must be paired with exactly one of `fromTokenReferrerWalletAddress` or `toTokenReferrerWalletAddress` (the two referrer addresses are mutually exclusive). Same semantics as `/swap`. **Range (Solana):** `(0, 10]` — greater than 0, up to 10 inclusive, max 2 decimal places. `\"1.5\"` means 1.5%. Values exceeding 2 decimal places are rejected with `INVALID_FEE_PERCENT` (40466). **`four.meme` tokens are not supported** — do not pass fee parameters when either side of the pair is a `four.meme` token. + String fromTokenReferrerWalletAddress = "J5CBzXpcYn6WR2JBah8zU4Yxct985CAFGwXRcFaX2pbS"; // String | Wallet address that receives the fee deducted from the sell token (`FROM_TOKEN` direction). Mutually exclusive with `toTokenReferrerWalletAddress` — providing both returns `CONFLICT_REFERRER_PARAMS` (40468). Solana requires a Base58 pubkey; an invalid format returns `INVALID_REFERRER_ADDRESS` (40467). Must be paired with `feePercent`. + String toTokenReferrerWalletAddress = "J5CBzXpcYn6WR2JBah8zU4Yxct985CAFGwXRcFaX2pbS"; // String | Wallet address that receives the fee deducted from the buy-token output (`TO_TOKEN` direction). Mutually exclusive with `fromTokenReferrerWalletAddress` — providing both returns `CONFLICT_REFERRER_PARAMS` (40468). Solana requires a Base58 pubkey; an invalid format returns `INVALID_REFERRER_ADDRESS` (40467). Must be paired with `feePercent`. The referrer must already be activated (funded with some SOL) or the request returns `REFERRER_NOT_ACTIVATED` (40469). try { BuildSolanaSwapInstructionsResponse result = apiInstance.buildSolanaSwapInstructions(binanceChainId, amount, fromTokenAddress, toTokenAddress, slippagePercent, userWalletAddress, quoteId) .recvWindow(recvWindow) @@ -65,6 +68,9 @@ public class Example { .computeUnitPrice(computeUnitPrice) .gasLevel(gasLevel) .tips(tips) + .feePercent(feePercent) + .fromTokenReferrerWalletAddress(fromTokenReferrerWalletAddress) + .toTokenReferrerWalletAddress(toTokenReferrerWalletAddress) .execute(); System.out.println(result); } catch (ApiException e) { @@ -98,6 +104,9 @@ public class Example { | **computeUnitPrice** | **String**| Priority fee per compute unit (micro-lamports). When omitted, the platform computes a value either from the `gasLevel` tier or from chain-side defaults. | [optional] | | **gasLevel** | [**GasLevel**](.md)| Priority-fee tier; consulted only when `computeUnitPrice` is omitted. Defaults to \"average\". | [optional] [enum: slow, average, fast] | | **tips** | **String**| Jito tips in SOL for MEV protection. Valid range [0.000000001, 2] (minimum 1 lamport). When specified, it is recommended to set `computeUnitPrice=0`. The platform picks one of Jito's tip accounts at random per request. | [optional] | +| **feePercent** | **String**| Custom fee (referral fee / Add Fee) percentage as a decimal string. Must be paired with exactly one of `fromTokenReferrerWalletAddress` or `toTokenReferrerWalletAddress` (the two referrer addresses are mutually exclusive). Same semantics as `/swap`. **Range (Solana):** `(0, 10]` — greater than 0, up to 10 inclusive, max 2 decimal places. `\"1.5\"` means 1.5%. Values exceeding 2 decimal places are rejected with `INVALID_FEE_PERCENT` (40466). **`four.meme` tokens are not supported** — do not pass fee parameters when either side of the pair is a `four.meme` token. | [optional] | +| **fromTokenReferrerWalletAddress** | **String**| Wallet address that receives the fee deducted from the sell token (`FROM_TOKEN` direction). Mutually exclusive with `toTokenReferrerWalletAddress` — providing both returns `CONFLICT_REFERRER_PARAMS` (40468). Solana requires a Base58 pubkey; an invalid format returns `INVALID_REFERRER_ADDRESS` (40467). Must be paired with `feePercent`. | [optional] | +| **toTokenReferrerWalletAddress** | **String**| Wallet address that receives the fee deducted from the buy-token output (`TO_TOKEN` direction). Mutually exclusive with `fromTokenReferrerWalletAddress` — providing both returns `CONFLICT_REFERRER_PARAMS` (40468). Solana requires a Base58 pubkey; an invalid format returns `INVALID_REFERRER_ADDRESS` (40467). Must be paired with `feePercent`. The referrer must already be activated (funded with some SOL) or the request returns `REFERRER_NOT_ACTIVATED` (40469). | [optional] | ### Return type @@ -122,7 +131,7 @@ No authorization required # **buildSwapTransaction** -> BuildSwapTransactionResponse buildSwapTransaction(binanceChainId, amount, fromTokenAddress, toTokenAddress, userWalletAddress, quoteId).recvWindow(recvWindow).nonce(nonce).slippagePercent(slippagePercent).approveTransaction(approveTransaction).approveAmount(approveAmount).gasLimit(gasLimit).gasLevel(gasLevel).priceImpactProtectionPercent(priceImpactProtectionPercent).autoSlippage(autoSlippage).maxAutoSlippagePercent(maxAutoSlippagePercent).computeUnitLimit(computeUnitLimit).computeUnitPrice(computeUnitPrice).tips(tips).execute(); +> BuildSwapTransactionResponse buildSwapTransaction(binanceChainId, amount, fromTokenAddress, toTokenAddress, userWalletAddress, quoteId).recvWindow(recvWindow).nonce(nonce).slippagePercent(slippagePercent).approveTransaction(approveTransaction).approveAmount(approveAmount).gasLimit(gasLimit).gasLevel(gasLevel).priceImpactProtectionPercent(priceImpactProtectionPercent).autoSlippage(autoSlippage).maxAutoSlippagePercent(maxAutoSlippagePercent).computeUnitLimit(computeUnitLimit).computeUnitPrice(computeUnitPrice).tips(tips).feePercent(feePercent).fromTokenReferrerWalletAddress(fromTokenReferrerWalletAddress).toTokenReferrerWalletAddress(toTokenReferrerWalletAddress).execute(); Build Swap Transaction @@ -162,6 +171,9 @@ public class Example { String computeUnitLimit = "1400000"; // String | Solana only — maximum compute units the transaction may consume (analogous to EVM gasLimit). Applies only when `binanceChainId=CT_501`. String computeUnitPrice = "1000"; // String | Solana only — priority fee per compute unit (micro-lamports), analogous to EVM gasPrice. When omitted, the platform computes a value dynamically. Applies only when `binanceChainId=CT_501`. String tips = "0.001"; // String | Solana only — Jito tips in SOL for MEV protection. Valid range [0.000000001, 2] (minimum 1 lamport). When specified, it is recommended to set `computeUnitPrice=0`. Applies only when `binanceChainId=CT_501`. + String feePercent = "1.5"; // String | Custom fee (referral fee / Add Fee) percentage as a decimal string. Must be paired with exactly one of `fromTokenReferrerWalletAddress` or `toTokenReferrerWalletAddress` (the two referrer addresses are mutually exclusive). **Range by chain:** `(0, 5]` for EVM chains (BSC, Ethereum, Base, etc.) and `(0, 10]` for Solana (`CT_501`) — greater than 0, up to the chain-specific maximum inclusive, max 2 decimal places. `\"1.5\"` means 1.5%. Values exceeding 2 decimal places are rejected with `INVALID_FEE_PERCENT` (40466). **`four.meme` tokens are not supported** — do not pass fee parameters when either side of the pair is a `four.meme` token. + String fromTokenReferrerWalletAddress = "0xCbF2B6E6e3D7e9e4e4e4e4e4e4e4e4e4e4e4e4e4"; // String | Wallet address that receives the fee deducted from the sell token (`FROM_TOKEN` direction). Mutually exclusive with `toTokenReferrerWalletAddress` — providing both returns `CONFLICT_REFERRER_PARAMS` (40468). Address format depends on the chain: EVM chains require `0x` + 40 hex chars; Solana (`CT_501`) requires a Base58 pubkey. An invalid format returns `INVALID_REFERRER_ADDRESS` (40467). Must be paired with `feePercent`. + String toTokenReferrerWalletAddress = "0xCbF2B6E6e3D7e9e4e4e4e4e4e4e4e4e4e4e4e4e4"; // String | Wallet address that receives the fee deducted from the buy-token output (`TO_TOKEN` direction). Mutually exclusive with `fromTokenReferrerWalletAddress` — providing both returns `CONFLICT_REFERRER_PARAMS` (40468). Address format depends on the chain: EVM chains require `0x` + 40 hex chars; Solana (`CT_501`) requires a Base58 pubkey. An invalid format returns `INVALID_REFERRER_ADDRESS` (40467). Must be paired with `feePercent`. On Solana, the referrer must already be activated (funded with some SOL) or the request returns `REFERRER_NOT_ACTIVATED` (40469). try { BuildSwapTransactionResponse result = apiInstance.buildSwapTransaction(binanceChainId, amount, fromTokenAddress, toTokenAddress, userWalletAddress, quoteId) .recvWindow(recvWindow) @@ -177,6 +189,9 @@ public class Example { .computeUnitLimit(computeUnitLimit) .computeUnitPrice(computeUnitPrice) .tips(tips) + .feePercent(feePercent) + .fromTokenReferrerWalletAddress(fromTokenReferrerWalletAddress) + .toTokenReferrerWalletAddress(toTokenReferrerWalletAddress) .execute(); System.out.println(result); } catch (ApiException e) { @@ -213,6 +228,9 @@ public class Example { | **computeUnitLimit** | **String**| Solana only — maximum compute units the transaction may consume (analogous to EVM gasLimit). Applies only when `binanceChainId=CT_501`. | [optional] | | **computeUnitPrice** | **String**| Solana only — priority fee per compute unit (micro-lamports), analogous to EVM gasPrice. When omitted, the platform computes a value dynamically. Applies only when `binanceChainId=CT_501`. | [optional] | | **tips** | **String**| Solana only — Jito tips in SOL for MEV protection. Valid range [0.000000001, 2] (minimum 1 lamport). When specified, it is recommended to set `computeUnitPrice=0`. Applies only when `binanceChainId=CT_501`. | [optional] | +| **feePercent** | **String**| Custom fee (referral fee / Add Fee) percentage as a decimal string. Must be paired with exactly one of `fromTokenReferrerWalletAddress` or `toTokenReferrerWalletAddress` (the two referrer addresses are mutually exclusive). **Range by chain:** `(0, 5]` for EVM chains (BSC, Ethereum, Base, etc.) and `(0, 10]` for Solana (`CT_501`) — greater than 0, up to the chain-specific maximum inclusive, max 2 decimal places. `\"1.5\"` means 1.5%. Values exceeding 2 decimal places are rejected with `INVALID_FEE_PERCENT` (40466). **`four.meme` tokens are not supported** — do not pass fee parameters when either side of the pair is a `four.meme` token. | [optional] | +| **fromTokenReferrerWalletAddress** | **String**| Wallet address that receives the fee deducted from the sell token (`FROM_TOKEN` direction). Mutually exclusive with `toTokenReferrerWalletAddress` — providing both returns `CONFLICT_REFERRER_PARAMS` (40468). Address format depends on the chain: EVM chains require `0x` + 40 hex chars; Solana (`CT_501`) requires a Base58 pubkey. An invalid format returns `INVALID_REFERRER_ADDRESS` (40467). Must be paired with `feePercent`. | [optional] | +| **toTokenReferrerWalletAddress** | **String**| Wallet address that receives the fee deducted from the buy-token output (`TO_TOKEN` direction). Mutually exclusive with `fromTokenReferrerWalletAddress` — providing both returns `CONFLICT_REFERRER_PARAMS` (40468). Address format depends on the chain: EVM chains require `0x` + 40 hex chars; Solana (`CT_501`) requires a Base58 pubkey. An invalid format returns `INVALID_REFERRER_ADDRESS` (40467). Must be paired with `feePercent`. On Solana, the referrer must already be activated (funded with some SOL) or the request returns `REFERRER_NOT_ACTIVATED` (40469). | [optional] | ### Return type @@ -237,7 +255,7 @@ No authorization required # **getAggregatedQuote** -> GetAggregatedQuoteResponse getAggregatedQuote(binanceChainId, amount, fromTokenAddress, toTokenAddress).recvWindow(recvWindow).nonce(nonce).userWalletAddress(userWalletAddress).execute(); +> GetAggregatedQuoteResponse getAggregatedQuote(binanceChainId, amount, fromTokenAddress, toTokenAddress).recvWindow(recvWindow).nonce(nonce).userWalletAddress(userWalletAddress).feePercent(feePercent).feeSource(feeSource).execute(); Get Aggregated Quote @@ -265,11 +283,15 @@ public class Example { Long recvWindow = 5000L; // Long | Allowed time deviation in milliseconds (default: 5000, max: 60000). String nonce = "unique-nonce-string"; // String | Unique request identifier for anti-replay; falls back to X-OC-SIGN if omitted. String userWalletAddress = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"; // String | User wallet address. Required when quoting RFQ routes (equity / RWA tokens such as Ondo and BStock). This address is used as the receiver in the RFQ order and must match the wallet that signs `rfq.typedDataToSign` in the subsequent `/swap` call. + String feePercent = "1.5"; // String | Custom fee (referral fee / Add Fee) percentage as a decimal string. Must be paired with `feeSource` — either both present or both absent. **Range by chain:** `(0, 5]` for EVM chains (BSC, Ethereum, Base, etc.) and `(0, 10]` for Solana (`CT_501`) — greater than 0, up to the chain-specific maximum inclusive, max 2 decimal places. `\"1.5\"` means 1.5%. Values exceeding 2 decimal places are rejected with `INVALID_FEE_PERCENT` (40466). **`four.meme` tokens are not supported** — do not pass fee parameters when either side of the pair is a `four.meme` token. + FeeSource feeSource = FeeSource.fromValue("FROM_TOKEN"); // FeeSource | Fee deduction direction. `FROM_TOKEN` = deduct the fee from the sell token (the amount passed to the DEX is reduced to a net amount); `TO_TOKEN` = deduct the fee from the buy-token output (the user's actual received amount is reduced). Must be paired with `feePercent`. try { GetAggregatedQuoteResponse result = apiInstance.getAggregatedQuote(binanceChainId, amount, fromTokenAddress, toTokenAddress) .recvWindow(recvWindow) .nonce(nonce) .userWalletAddress(userWalletAddress) + .feePercent(feePercent) + .feeSource(feeSource) .execute(); System.out.println(result); } catch (ApiException e) { @@ -294,6 +316,8 @@ public class Example { | **recvWindow** | **Long**| Allowed time deviation in milliseconds (default: 5000, max: 60000). | [optional] | | **nonce** | **String**| Unique request identifier for anti-replay; falls back to X-OC-SIGN if omitted. | [optional] | | **userWalletAddress** | **String**| User wallet address. Required when quoting RFQ routes (equity / RWA tokens such as Ondo and BStock). This address is used as the receiver in the RFQ order and must match the wallet that signs `rfq.typedDataToSign` in the subsequent `/swap` call. | [optional] | +| **feePercent** | **String**| Custom fee (referral fee / Add Fee) percentage as a decimal string. Must be paired with `feeSource` — either both present or both absent. **Range by chain:** `(0, 5]` for EVM chains (BSC, Ethereum, Base, etc.) and `(0, 10]` for Solana (`CT_501`) — greater than 0, up to the chain-specific maximum inclusive, max 2 decimal places. `\"1.5\"` means 1.5%. Values exceeding 2 decimal places are rejected with `INVALID_FEE_PERCENT` (40466). **`four.meme` tokens are not supported** — do not pass fee parameters when either side of the pair is a `four.meme` token. | [optional] | +| **feeSource** | [**FeeSource**](.md)| Fee deduction direction. `FROM_TOKEN` = deduct the fee from the sell token (the amount passed to the DEX is reduced to a net amount); `TO_TOKEN` = deduct the fee from the buy-token output (the user's actual received amount is reduced). Must be paired with `feePercent`. | [optional] [enum: FROM_TOKEN, TO_TOKEN] | ### Return type @@ -616,7 +640,7 @@ No authorization required # **quoteAndBuildSwapTransaction** -> QuoteAndBuildSwapTransactionResponse quoteAndBuildSwapTransaction(binanceChainId, amount, fromTokenAddress, toTokenAddress, userWalletAddress, vendor).recvWindow(recvWindow).nonce(nonce).slippagePercent(slippagePercent).approveTransaction(approveTransaction).approveAmount(approveAmount).gasLimit(gasLimit).gasLevel(gasLevel).priceImpactProtectionPercent(priceImpactProtectionPercent).autoSlippage(autoSlippage).maxAutoSlippagePercent(maxAutoSlippagePercent).computeUnitLimit(computeUnitLimit).computeUnitPrice(computeUnitPrice).tips(tips).execute(); +> QuoteAndBuildSwapTransactionResponse quoteAndBuildSwapTransaction(binanceChainId, amount, fromTokenAddress, toTokenAddress, userWalletAddress, vendor).recvWindow(recvWindow).nonce(nonce).slippagePercent(slippagePercent).approveTransaction(approveTransaction).approveAmount(approveAmount).gasLimit(gasLimit).gasLevel(gasLevel).priceImpactProtectionPercent(priceImpactProtectionPercent).autoSlippage(autoSlippage).maxAutoSlippagePercent(maxAutoSlippagePercent).computeUnitLimit(computeUnitLimit).computeUnitPrice(computeUnitPrice).tips(tips).feePercent(feePercent).fromTokenReferrerWalletAddress(fromTokenReferrerWalletAddress).toTokenReferrerWalletAddress(toTokenReferrerWalletAddress).execute(); Quote and Build Swap Transaction (Flash API) @@ -656,6 +680,9 @@ public class Example { String computeUnitLimit = "1400000"; // String | Solana only — maximum compute units the transaction may consume (analogous to EVM gasLimit). Applies only when `binanceChainId=CT_501`. String computeUnitPrice = "1000"; // String | Solana only — priority fee per compute unit (micro-lamports), analogous to EVM gasPrice. When omitted, the platform computes a value dynamically. Applies only when `binanceChainId=CT_501`. String tips = "0.001"; // String | Solana only — Jito tips in SOL for MEV protection. Valid range [0.000000001, 2] (minimum 1 lamport). When specified, it is recommended to set `computeUnitPrice=0`. Applies only when `binanceChainId=CT_501`. + String feePercent = "1.5"; // String | Custom fee (referral fee / Add Fee) percentage as a decimal string. Must be paired with exactly one of `fromTokenReferrerWalletAddress` or `toTokenReferrerWalletAddress` (the two referrer addresses are mutually exclusive). **Range by chain:** `(0, 5]` for EVM chains (BSC, Ethereum, Base, etc.) and `(0, 10]` for Solana (`CT_501`) — greater than 0, up to the chain-specific maximum inclusive, max 2 decimal places. `\"1.5\"` means 1.5%. Values exceeding 2 decimal places are rejected with `INVALID_FEE_PERCENT` (40466). **`four.meme` tokens are not supported** — do not pass fee parameters when either side of the pair is a `four.meme` token. + String fromTokenReferrerWalletAddress = "0xCbF2B6E6e3D7e9e4e4e4e4e4e4e4e4e4e4e4e4e4"; // String | Wallet address that receives the fee deducted from the sell token (`FROM_TOKEN` direction). Mutually exclusive with `toTokenReferrerWalletAddress` — providing both returns `CONFLICT_REFERRER_PARAMS` (40468). Address format depends on the chain: EVM chains require `0x` + 40 hex chars; Solana (`CT_501`) requires a Base58 pubkey. An invalid format returns `INVALID_REFERRER_ADDRESS` (40467). Must be paired with `feePercent`. + String toTokenReferrerWalletAddress = "0xCbF2B6E6e3D7e9e4e4e4e4e4e4e4e4e4e4e4e4e4"; // String | Wallet address that receives the fee deducted from the buy-token output (`TO_TOKEN` direction). Mutually exclusive with `fromTokenReferrerWalletAddress` — providing both returns `CONFLICT_REFERRER_PARAMS` (40468). Address format depends on the chain: EVM chains require `0x` + 40 hex chars; Solana (`CT_501`) requires a Base58 pubkey. An invalid format returns `INVALID_REFERRER_ADDRESS` (40467). Must be paired with `feePercent`. On Solana, the referrer must already be activated (funded with some SOL) or the request returns `REFERRER_NOT_ACTIVATED` (40469). try { QuoteAndBuildSwapTransactionResponse result = apiInstance.quoteAndBuildSwapTransaction(binanceChainId, amount, fromTokenAddress, toTokenAddress, userWalletAddress, vendor) .recvWindow(recvWindow) @@ -671,6 +698,9 @@ public class Example { .computeUnitLimit(computeUnitLimit) .computeUnitPrice(computeUnitPrice) .tips(tips) + .feePercent(feePercent) + .fromTokenReferrerWalletAddress(fromTokenReferrerWalletAddress) + .toTokenReferrerWalletAddress(toTokenReferrerWalletAddress) .execute(); System.out.println(result); } catch (ApiException e) { @@ -707,6 +737,9 @@ public class Example { | **computeUnitLimit** | **String**| Solana only — maximum compute units the transaction may consume (analogous to EVM gasLimit). Applies only when `binanceChainId=CT_501`. | [optional] | | **computeUnitPrice** | **String**| Solana only — priority fee per compute unit (micro-lamports), analogous to EVM gasPrice. When omitted, the platform computes a value dynamically. Applies only when `binanceChainId=CT_501`. | [optional] | | **tips** | **String**| Solana only — Jito tips in SOL for MEV protection. Valid range [0.000000001, 2] (minimum 1 lamport). When specified, it is recommended to set `computeUnitPrice=0`. Applies only when `binanceChainId=CT_501`. | [optional] | +| **feePercent** | **String**| Custom fee (referral fee / Add Fee) percentage as a decimal string. Must be paired with exactly one of `fromTokenReferrerWalletAddress` or `toTokenReferrerWalletAddress` (the two referrer addresses are mutually exclusive). **Range by chain:** `(0, 5]` for EVM chains (BSC, Ethereum, Base, etc.) and `(0, 10]` for Solana (`CT_501`) — greater than 0, up to the chain-specific maximum inclusive, max 2 decimal places. `\"1.5\"` means 1.5%. Values exceeding 2 decimal places are rejected with `INVALID_FEE_PERCENT` (40466). **`four.meme` tokens are not supported** — do not pass fee parameters when either side of the pair is a `four.meme` token. | [optional] | +| **fromTokenReferrerWalletAddress** | **String**| Wallet address that receives the fee deducted from the sell token (`FROM_TOKEN` direction). Mutually exclusive with `toTokenReferrerWalletAddress` — providing both returns `CONFLICT_REFERRER_PARAMS` (40468). Address format depends on the chain: EVM chains require `0x` + 40 hex chars; Solana (`CT_501`) requires a Base58 pubkey. An invalid format returns `INVALID_REFERRER_ADDRESS` (40467). Must be paired with `feePercent`. | [optional] | +| **toTokenReferrerWalletAddress** | **String**| Wallet address that receives the fee deducted from the buy-token output (`TO_TOKEN` direction). Mutually exclusive with `fromTokenReferrerWalletAddress` — providing both returns `CONFLICT_REFERRER_PARAMS` (40468). Address format depends on the chain: EVM chains require `0x` + 40 hex chars; Solana (`CT_501`) requires a Base58 pubkey. An invalid format returns `INVALID_REFERRER_ADDRESS` (40467). Must be paired with `feePercent`. On Solana, the referrer must already be activated (funded with some SOL) or the request returns `REFERRER_NOT_ACTIVATED` (40469). | [optional] | ### Return type diff --git a/clients/web3-wallet/example_rest.md b/clients/web3-wallet/example_rest.md index 1766171..61c50c2 100644 --- a/clients/web3-wallet/example_rest.md +++ b/clients/web3-wallet/example_rest.md @@ -58,11 +58,11 @@ ## Trading -[GET /api/v1/dex/aggregator/swap-instruction](https://web3.binance.com/en/dev-docs/catalog/web3-wallet/api/rest-api/trading-api#build-solana-swap-instructions) - buildSolanaSwapInstructions - [BuildSolanaSwapInstructionsExample.java:50](/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/trading/BuildSolanaSwapInstructionsExample.java#L50) +[GET /api/v1/dex/aggregator/swap-instruction](https://web3.binance.com/en/dev-docs/catalog/web3-wallet/api/rest-api/trading-api#build-solana-swap-instructions) - buildSolanaSwapInstructions - [BuildSolanaSwapInstructionsExample.java:53](/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/trading/BuildSolanaSwapInstructionsExample.java#L53) [GET /api/v1/dex/aggregator/swap](https://web3.binance.com/en/dev-docs/catalog/web3-wallet/api/rest-api/trading-api#build-swap-transaction) - buildSwapTransaction - [BuildSwapTransactionExample.java:42](/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/trading/BuildSwapTransactionExample.java#L42) -[GET /api/v1/dex/aggregator/quote](https://web3.binance.com/en/dev-docs/catalog/web3-wallet/api/rest-api/trading-api#get-aggregated-quote) - getAggregatedQuote - [GetAggregatedQuoteExample.java:38](/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/trading/GetAggregatedQuoteExample.java#L38) +[GET /api/v1/dex/aggregator/quote](https://web3.binance.com/en/dev-docs/catalog/web3-wallet/api/rest-api/trading-api#get-aggregated-quote) - getAggregatedQuote - [GetAggregatedQuoteExample.java:39](/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/trading/GetAggregatedQuoteExample.java#L39) [GET /api/v1/dex/aggregator/supported/chain](https://web3.binance.com/en/dev-docs/catalog/web3-wallet/api/rest-api/trading-api#get-aggregator-supported-chains) - getAggregatorSupportedChains - [GetAggregatorSupportedChainsExample.java:38](/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/trading/GetAggregatorSupportedChainsExample.java#L38) diff --git a/clients/web3-wallet/pom.xml b/clients/web3-wallet/pom.xml index 898bdd1..9e88e33 100644 --- a/clients/web3-wallet/pom.xml +++ b/clients/web3-wallet/pom.xml @@ -5,7 +5,7 @@ 4.0.0 binance-web3-wallet web3-wallet - 3.0.0 + 4.0.0 jar diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/AddressPortfolioApi.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/AddressPortfolioApi.java index ce77a4a..f8e17d8 100644 --- a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/AddressPortfolioApi.java +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/AddressPortfolioApi.java @@ -53,7 +53,7 @@ public class AddressPortfolioApi { private static final String USER_AGENT = String.format( - "binance-web3-wallet/3.0.0 (Java/%s; %s; %s)", + "binance-web3-wallet/4.0.0 (Java/%s; %s; %s)", SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); private static final boolean HAS_TIME_UNIT = false; diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/GeneralDataApi.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/GeneralDataApi.java index 2376b3c..494fdde 100644 --- a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/GeneralDataApi.java +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/GeneralDataApi.java @@ -58,7 +58,7 @@ public class GeneralDataApi { private static final String USER_AGENT = String.format( - "binance-web3-wallet/3.0.0 (Java/%s; %s; %s)", + "binance-web3-wallet/4.0.0 (Java/%s; %s; %s)", SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); private static final boolean HAS_TIME_UNIT = false; diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/RwaDataApi.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/RwaDataApi.java index dd9271e..731cae0 100644 --- a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/RwaDataApi.java +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/RwaDataApi.java @@ -48,7 +48,7 @@ public class RwaDataApi { private static final String USER_AGENT = String.format( - "binance-web3-wallet/3.0.0 (Java/%s; %s; %s)", + "binance-web3-wallet/4.0.0 (Java/%s; %s; %s)", SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); private static final boolean HAS_TIME_UNIT = false; diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/TradingApi.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/TradingApi.java index 92ca0e6..ef85882 100644 --- a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/TradingApi.java +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/TradingApi.java @@ -24,6 +24,7 @@ import com.binance.connector.client.web3_wallet.rest.model.BinanceChainId; import com.binance.connector.client.web3_wallet.rest.model.BuildSolanaSwapInstructionsResponse; import com.binance.connector.client.web3_wallet.rest.model.BuildSwapTransactionResponse; +import com.binance.connector.client.web3_wallet.rest.model.FeeSource; import com.binance.connector.client.web3_wallet.rest.model.GasLevel; import com.binance.connector.client.web3_wallet.rest.model.GetAggregatedQuoteResponse; import com.binance.connector.client.web3_wallet.rest.model.GetAggregatorSupportedChainsResponse; @@ -57,7 +58,7 @@ public class TradingApi { private static final String USER_AGENT = String.format( - "binance-web3-wallet/3.0.0 (Java/%s; %s; %s)", + "binance-web3-wallet/4.0.0 (Java/%s; %s; %s)", SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); private static final boolean HAS_TIME_UNIT = false; @@ -110,7 +111,10 @@ private okhttp3.Call buildSolanaSwapInstructionsCall( String computeUnitLimit, String computeUnitPrice, GasLevel gasLevel, - String tips) + String tips, + String feePercent, + String fromTokenReferrerWalletAddress, + String toTokenReferrerWalletAddress) throws ApiException { String basePath = null; // Operation Servers @@ -204,6 +208,22 @@ private okhttp3.Call buildSolanaSwapInstructionsCall( localVarQueryParams.addAll(localVarApiClient.parameterToPair("tips", tips)); } + if (feePercent != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("feePercent", feePercent)); + } + + if (fromTokenReferrerWalletAddress != null) { + localVarQueryParams.addAll( + localVarApiClient.parameterToPair( + "fromTokenReferrerWalletAddress", fromTokenReferrerWalletAddress)); + } + + if (toTokenReferrerWalletAddress != null) { + localVarQueryParams.addAll( + localVarApiClient.parameterToPair( + "toTokenReferrerWalletAddress", toTokenReferrerWalletAddress)); + } + final String[] localVarAccepts = {"application/json"}; final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) { @@ -260,7 +280,10 @@ private okhttp3.Call buildSolanaSwapInstructionsValidateBeforeCall( String computeUnitLimit, String computeUnitPrice, GasLevel gasLevel, - String tips) + String tips, + String feePercent, + String fromTokenReferrerWalletAddress, + String toTokenReferrerWalletAddress) throws ApiException { try { Validator validator = @@ -287,7 +310,10 @@ private okhttp3.Call buildSolanaSwapInstructionsValidateBeforeCall( computeUnitLimit, computeUnitPrice, gasLevel, - tips + tips, + feePercent, + fromTokenReferrerWalletAddress, + toTokenReferrerWalletAddress }; Method method = this.getClass() @@ -308,6 +334,9 @@ private okhttp3.Call buildSolanaSwapInstructionsValidateBeforeCall( String.class, String.class, GasLevel.class, + String.class, + String.class, + String.class, String.class); Set> violations = executableValidator.validateParameters(this, method, parameterValues); @@ -329,7 +358,10 @@ private okhttp3.Call buildSolanaSwapInstructionsValidateBeforeCall( computeUnitLimit, computeUnitPrice, gasLevel, - tips); + tips, + feePercent, + fromTokenReferrerWalletAddress, + toTokenReferrerWalletAddress); } else { throw new ConstraintViolationException((Set) violations); } @@ -358,7 +390,10 @@ public ApiResponse buildSolanaSwapInstructi String computeUnitLimit, String computeUnitPrice, GasLevel gasLevel, - String tips) + String tips, + String feePercent, + String fromTokenReferrerWalletAddress, + String toTokenReferrerWalletAddress) throws ApiException { okhttp3.Call localVarCall = buildSolanaSwapInstructionsValidateBeforeCall( @@ -377,7 +412,10 @@ public ApiResponse buildSolanaSwapInstructi computeUnitLimit, computeUnitPrice, gasLevel, - tips); + tips, + feePercent, + fromTokenReferrerWalletAddress, + toTokenReferrerWalletAddress); java.lang.reflect.Type localVarReturnType = new TypeToken() {}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); @@ -401,7 +439,10 @@ public ApiResponse buildSolanaSwapInstructi request.getComputeUnitLimit(), request.getComputeUnitPrice(), request.getGasLevel(), - request.getTips()); + request.getTips(), + request.getFeePercent(), + request.getFromTokenReferrerWalletAddress(), + request.getToTokenReferrerWalletAddress()); } public static class BuildSolanaSwapInstructionsRequest { @@ -421,6 +462,9 @@ public static class BuildSolanaSwapInstructionsRequest { private String computeUnitPrice; private GasLevel gasLevel; private String tips; + private String feePercent; + private String fromTokenReferrerWalletAddress; + private String toTokenReferrerWalletAddress; public BinanceChainId getBinanceChainId() { return binanceChainId; @@ -486,6 +530,18 @@ public String getTips() { return tips; } + public String getFeePercent() { + return feePercent; + } + + public String getFromTokenReferrerWalletAddress() { + return fromTokenReferrerWalletAddress; + } + + public String getToTokenReferrerWalletAddress() { + return toTokenReferrerWalletAddress; + } + public BuildSolanaSwapInstructionsRequest( BinanceChainId binanceChainId, String amount, @@ -615,6 +671,60 @@ public BuildSolanaSwapInstructionsRequest tips(String tips) { this.tips = tips; return this; } + + /** + * Set feePercent + * + * @param feePercent Custom fee (referral fee / Add Fee) percentage as a decimal string. + * Must be paired with exactly one of `fromTokenReferrerWalletAddress` or + * `toTokenReferrerWalletAddress` (the two referrer addresses are mutually + * exclusive). Same semantics as `/swap`. **Range (Solana):** `(0, + * 10]` — greater than 0, up to 10 inclusive, max 2 decimal places. + * `\"1.5\"` means 1.5%. Values exceeding 2 decimal places are + * rejected with `INVALID_FEE_PERCENT` (40466). **`four.meme` tokens + * are not supported** — do not pass fee parameters when either side of the pair is a + * `four.meme` token. (optional) + * @return BuildSolanaSwapInstructionsRequest + */ + public BuildSolanaSwapInstructionsRequest feePercent(String feePercent) { + this.feePercent = feePercent; + return this; + } + + /** + * Set fromTokenReferrerWalletAddress + * + * @param fromTokenReferrerWalletAddress Wallet address that receives the fee deducted from + * the sell token (`FROM_TOKEN` direction). Mutually exclusive with + * `toTokenReferrerWalletAddress` — providing both returns + * `CONFLICT_REFERRER_PARAMS` (40468). Solana requires a Base58 pubkey; an + * invalid format returns `INVALID_REFERRER_ADDRESS` (40467). Must be paired + * with `feePercent`. (optional) + * @return BuildSolanaSwapInstructionsRequest + */ + public BuildSolanaSwapInstructionsRequest fromTokenReferrerWalletAddress( + String fromTokenReferrerWalletAddress) { + this.fromTokenReferrerWalletAddress = fromTokenReferrerWalletAddress; + return this; + } + + /** + * Set toTokenReferrerWalletAddress + * + * @param toTokenReferrerWalletAddress Wallet address that receives the fee deducted from + * the buy-token output (`TO_TOKEN` direction). Mutually exclusive with + * `fromTokenReferrerWalletAddress` — providing both returns + * `CONFLICT_REFERRER_PARAMS` (40468). Solana requires a Base58 pubkey; an + * invalid format returns `INVALID_REFERRER_ADDRESS` (40467). Must be paired + * with `feePercent`. The referrer must already be activated (funded with some + * SOL) or the request returns `REFERRER_NOT_ACTIVATED` (40469). (optional) + * @return BuildSolanaSwapInstructionsRequest + */ + public BuildSolanaSwapInstructionsRequest toTokenReferrerWalletAddress( + String toTokenReferrerWalletAddress) { + this.toTokenReferrerWalletAddress = toTokenReferrerWalletAddress; + return this; + } } private okhttp3.Call buildSwapTransactionCall( @@ -636,7 +746,10 @@ private okhttp3.Call buildSwapTransactionCall( String maxAutoSlippagePercent, String computeUnitLimit, String computeUnitPrice, - String tips) + String tips, + String feePercent, + String fromTokenReferrerWalletAddress, + String toTokenReferrerWalletAddress) throws ApiException { String basePath = null; // Operation Servers @@ -744,6 +857,22 @@ private okhttp3.Call buildSwapTransactionCall( localVarQueryParams.addAll(localVarApiClient.parameterToPair("tips", tips)); } + if (feePercent != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("feePercent", feePercent)); + } + + if (fromTokenReferrerWalletAddress != null) { + localVarQueryParams.addAll( + localVarApiClient.parameterToPair( + "fromTokenReferrerWalletAddress", fromTokenReferrerWalletAddress)); + } + + if (toTokenReferrerWalletAddress != null) { + localVarQueryParams.addAll( + localVarApiClient.parameterToPair( + "toTokenReferrerWalletAddress", toTokenReferrerWalletAddress)); + } + final String[] localVarAccepts = {"application/json"}; final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) { @@ -803,7 +932,10 @@ private okhttp3.Call buildSwapTransactionValidateBeforeCall( String maxAutoSlippagePercent, String computeUnitLimit, String computeUnitPrice, - String tips) + String tips, + String feePercent, + String fromTokenReferrerWalletAddress, + String toTokenReferrerWalletAddress) throws ApiException { try { Validator validator = @@ -833,7 +965,10 @@ private okhttp3.Call buildSwapTransactionValidateBeforeCall( maxAutoSlippagePercent, computeUnitLimit, computeUnitPrice, - tips + tips, + feePercent, + fromTokenReferrerWalletAddress, + toTokenReferrerWalletAddress }; Method method = this.getClass() @@ -857,6 +992,9 @@ private okhttp3.Call buildSwapTransactionValidateBeforeCall( String.class, String.class, String.class, + String.class, + String.class, + String.class, String.class); Set> violations = executableValidator.validateParameters(this, method, parameterValues); @@ -881,7 +1019,10 @@ private okhttp3.Call buildSwapTransactionValidateBeforeCall( maxAutoSlippagePercent, computeUnitLimit, computeUnitPrice, - tips); + tips, + feePercent, + fromTokenReferrerWalletAddress, + toTokenReferrerWalletAddress); } else { throw new ConstraintViolationException((Set) violations); } @@ -913,7 +1054,10 @@ public ApiResponse buildSwapTransaction( String maxAutoSlippagePercent, String computeUnitLimit, String computeUnitPrice, - String tips) + String tips, + String feePercent, + String fromTokenReferrerWalletAddress, + String toTokenReferrerWalletAddress) throws ApiException { okhttp3.Call localVarCall = buildSwapTransactionValidateBeforeCall( @@ -935,7 +1079,10 @@ public ApiResponse buildSwapTransaction( maxAutoSlippagePercent, computeUnitLimit, computeUnitPrice, - tips); + tips, + feePercent, + fromTokenReferrerWalletAddress, + toTokenReferrerWalletAddress); java.lang.reflect.Type localVarReturnType = new TypeToken() {}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); @@ -962,7 +1109,10 @@ public ApiResponse buildSwapTransaction( request.getMaxAutoSlippagePercent(), request.getComputeUnitLimit(), request.getComputeUnitPrice(), - request.getTips()); + request.getTips(), + request.getFeePercent(), + request.getFromTokenReferrerWalletAddress(), + request.getToTokenReferrerWalletAddress()); } public static class BuildSwapTransactionRequest { @@ -985,6 +1135,9 @@ public static class BuildSwapTransactionRequest { private String computeUnitLimit; private String computeUnitPrice; private String tips; + private String feePercent; + private String fromTokenReferrerWalletAddress; + private String toTokenReferrerWalletAddress; public String getBinanceChainId() { return binanceChainId; @@ -1062,6 +1215,18 @@ public String getTips() { return tips; } + public String getFeePercent() { + return feePercent; + } + + public String getFromTokenReferrerWalletAddress() { + return fromTokenReferrerWalletAddress; + } + + public String getToTokenReferrerWalletAddress() { + return toTokenReferrerWalletAddress; + } + public BuildSwapTransactionRequest( String binanceChainId, String amount, @@ -1250,6 +1415,66 @@ public BuildSwapTransactionRequest tips(String tips) { this.tips = tips; return this; } + + /** + * Set feePercent + * + * @param feePercent Custom fee (referral fee / Add Fee) percentage as a decimal string. + * Must be paired with exactly one of `fromTokenReferrerWalletAddress` or + * `toTokenReferrerWalletAddress` (the two referrer addresses are mutually + * exclusive). **Range by chain:** `(0, 5]` for EVM chains (BSC, Ethereum, + * Base, etc.) and `(0, 10]` for Solana (`CT_501`) — greater than 0, + * up to the chain-specific maximum inclusive, max 2 decimal places. + * `\"1.5\"` means 1.5%. Values exceeding 2 decimal places are + * rejected with `INVALID_FEE_PERCENT` (40466). **`four.meme` tokens + * are not supported** — do not pass fee parameters when either side of the pair is a + * `four.meme` token. (optional) + * @return BuildSwapTransactionRequest + */ + public BuildSwapTransactionRequest feePercent(String feePercent) { + this.feePercent = feePercent; + return this; + } + + /** + * Set fromTokenReferrerWalletAddress + * + * @param fromTokenReferrerWalletAddress Wallet address that receives the fee deducted from + * the sell token (`FROM_TOKEN` direction). Mutually exclusive with + * `toTokenReferrerWalletAddress` — providing both returns + * `CONFLICT_REFERRER_PARAMS` (40468). Address format depends on the chain: + * EVM chains require `0x` + 40 hex chars; Solana (`CT_501`) + * requires a Base58 pubkey. An invalid format returns + * `INVALID_REFERRER_ADDRESS` (40467). Must be paired with + * `feePercent`. (optional) + * @return BuildSwapTransactionRequest + */ + public BuildSwapTransactionRequest fromTokenReferrerWalletAddress( + String fromTokenReferrerWalletAddress) { + this.fromTokenReferrerWalletAddress = fromTokenReferrerWalletAddress; + return this; + } + + /** + * Set toTokenReferrerWalletAddress + * + * @param toTokenReferrerWalletAddress Wallet address that receives the fee deducted from + * the buy-token output (`TO_TOKEN` direction). Mutually exclusive with + * `fromTokenReferrerWalletAddress` — providing both returns + * `CONFLICT_REFERRER_PARAMS` (40468). Address format depends on the chain: + * EVM chains require `0x` + 40 hex chars; Solana (`CT_501`) + * requires a Base58 pubkey. An invalid format returns + * `INVALID_REFERRER_ADDRESS` (40467). Must be paired with + * `feePercent`. On Solana, the referrer must already be activated (funded + * with some SOL) or the request returns `REFERRER_NOT_ACTIVATED` (40469). + * (optional) + * @return BuildSwapTransactionRequest + */ + public BuildSwapTransactionRequest toTokenReferrerWalletAddress( + String toTokenReferrerWalletAddress) { + this.toTokenReferrerWalletAddress = toTokenReferrerWalletAddress; + return this; + } } private okhttp3.Call getAggregatedQuoteCall( @@ -1259,7 +1484,9 @@ private okhttp3.Call getAggregatedQuoteCall( String toTokenAddress, Long recvWindow, String nonce, - String userWalletAddress) + String userWalletAddress, + String feePercent, + FeeSource feeSource) throws ApiException { String basePath = null; // Operation Servers @@ -1309,6 +1536,14 @@ private okhttp3.Call getAggregatedQuoteCall( localVarApiClient.parameterToPair("userWalletAddress", userWalletAddress)); } + if (feePercent != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("feePercent", feePercent)); + } + + if (feeSource != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("feeSource", feeSource)); + } + final String[] localVarAccepts = {"application/json"}; final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) { @@ -1356,7 +1591,9 @@ private okhttp3.Call getAggregatedQuoteValidateBeforeCall( String toTokenAddress, Long recvWindow, String nonce, - String userWalletAddress) + String userWalletAddress, + String feePercent, + FeeSource feeSource) throws ApiException { try { Validator validator = @@ -1374,7 +1611,9 @@ private okhttp3.Call getAggregatedQuoteValidateBeforeCall( toTokenAddress, recvWindow, nonce, - userWalletAddress + userWalletAddress, + feePercent, + feeSource }; Method method = this.getClass() @@ -1386,7 +1625,9 @@ private okhttp3.Call getAggregatedQuoteValidateBeforeCall( String.class, Long.class, String.class, - String.class); + String.class, + String.class, + FeeSource.class); Set> violations = executableValidator.validateParameters(this, method, parameterValues); @@ -1398,7 +1639,9 @@ private okhttp3.Call getAggregatedQuoteValidateBeforeCall( toTokenAddress, recvWindow, nonce, - userWalletAddress); + userWalletAddress, + feePercent, + feeSource); } else { throw new ConstraintViolationException((Set) violations); } @@ -1418,7 +1661,9 @@ public ApiResponse getAggregatedQuote( @NotNull String toTokenAddress, Long recvWindow, String nonce, - String userWalletAddress) + String userWalletAddress, + String feePercent, + FeeSource feeSource) throws ApiException { okhttp3.Call localVarCall = getAggregatedQuoteValidateBeforeCall( @@ -1428,7 +1673,9 @@ public ApiResponse getAggregatedQuote( toTokenAddress, recvWindow, nonce, - userWalletAddress); + userWalletAddress, + feePercent, + feeSource); java.lang.reflect.Type localVarReturnType = new TypeToken() {}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); @@ -1443,7 +1690,9 @@ public ApiResponse getAggregatedQuote( request.getToTokenAddress(), request.getRecvWindow(), request.getNonce(), - request.getUserWalletAddress()); + request.getUserWalletAddress(), + request.getFeePercent(), + request.getFeeSource()); } public static class GetAggregatedQuoteRequest { @@ -1454,6 +1703,8 @@ public static class GetAggregatedQuoteRequest { private Long recvWindow; private String nonce; private String userWalletAddress; + private String feePercent; + private FeeSource feeSource; public String getBinanceChainId() { return binanceChainId; @@ -1483,6 +1734,14 @@ public String getUserWalletAddress() { return userWalletAddress; } + public String getFeePercent() { + return feePercent; + } + + public FeeSource getFeeSource() { + return feeSource; + } + public GetAggregatedQuoteRequest( String binanceChainId, String amount, @@ -1531,6 +1790,40 @@ public GetAggregatedQuoteRequest userWalletAddress(String userWalletAddress) { this.userWalletAddress = userWalletAddress; return this; } + + /** + * Set feePercent + * + * @param feePercent Custom fee (referral fee / Add Fee) percentage as a decimal string. + * Must be paired with `feeSource` — either both present or both absent. + * **Range by chain:** `(0, 5]` for EVM chains (BSC, Ethereum, Base, etc.) and + * `(0, 10]` for Solana (`CT_501`) — greater than 0, up to the + * chain-specific maximum inclusive, max 2 decimal places. `\"1.5\"` + * means 1.5%. Values exceeding 2 decimal places are rejected with + * `INVALID_FEE_PERCENT` (40466). **`four.meme` tokens are not + * supported** — do not pass fee parameters when either side of the pair is a + * `four.meme` token. (optional) + * @return GetAggregatedQuoteRequest + */ + public GetAggregatedQuoteRequest feePercent(String feePercent) { + this.feePercent = feePercent; + return this; + } + + /** + * Set feeSource + * + * @param feeSource Fee deduction direction. `FROM_TOKEN` = deduct the fee + * from the sell token (the amount passed to the DEX is reduced to a net amount); + * `TO_TOKEN` = deduct the fee from the buy-token output (the user's + * actual received amount is reduced). Must be paired with `feePercent`. + * (optional) + * @return GetAggregatedQuoteRequest + */ + public GetAggregatedQuoteRequest feeSource(FeeSource feeSource) { + this.feeSource = feeSource; + return this; + } } private okhttp3.Call getAggregatorSupportedChainsCall( @@ -2338,7 +2631,10 @@ private okhttp3.Call quoteAndBuildSwapTransactionCall( String maxAutoSlippagePercent, String computeUnitLimit, String computeUnitPrice, - String tips) + String tips, + String feePercent, + String fromTokenReferrerWalletAddress, + String toTokenReferrerWalletAddress) throws ApiException { String basePath = null; // Operation Servers @@ -2446,6 +2742,22 @@ private okhttp3.Call quoteAndBuildSwapTransactionCall( localVarQueryParams.addAll(localVarApiClient.parameterToPair("tips", tips)); } + if (feePercent != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("feePercent", feePercent)); + } + + if (fromTokenReferrerWalletAddress != null) { + localVarQueryParams.addAll( + localVarApiClient.parameterToPair( + "fromTokenReferrerWalletAddress", fromTokenReferrerWalletAddress)); + } + + if (toTokenReferrerWalletAddress != null) { + localVarQueryParams.addAll( + localVarApiClient.parameterToPair( + "toTokenReferrerWalletAddress", toTokenReferrerWalletAddress)); + } + final String[] localVarAccepts = {"application/json"}; final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) { @@ -2505,7 +2817,10 @@ private okhttp3.Call quoteAndBuildSwapTransactionValidateBeforeCall( String maxAutoSlippagePercent, String computeUnitLimit, String computeUnitPrice, - String tips) + String tips, + String feePercent, + String fromTokenReferrerWalletAddress, + String toTokenReferrerWalletAddress) throws ApiException { try { Validator validator = @@ -2535,7 +2850,10 @@ private okhttp3.Call quoteAndBuildSwapTransactionValidateBeforeCall( maxAutoSlippagePercent, computeUnitLimit, computeUnitPrice, - tips + tips, + feePercent, + fromTokenReferrerWalletAddress, + toTokenReferrerWalletAddress }; Method method = this.getClass() @@ -2559,6 +2877,9 @@ private okhttp3.Call quoteAndBuildSwapTransactionValidateBeforeCall( String.class, String.class, String.class, + String.class, + String.class, + String.class, String.class); Set> violations = executableValidator.validateParameters(this, method, parameterValues); @@ -2583,7 +2904,10 @@ private okhttp3.Call quoteAndBuildSwapTransactionValidateBeforeCall( maxAutoSlippagePercent, computeUnitLimit, computeUnitPrice, - tips); + tips, + feePercent, + fromTokenReferrerWalletAddress, + toTokenReferrerWalletAddress); } else { throw new ConstraintViolationException((Set) violations); } @@ -2615,7 +2939,10 @@ public ApiResponse quoteAndBuildSwapTransa String maxAutoSlippagePercent, String computeUnitLimit, String computeUnitPrice, - String tips) + String tips, + String feePercent, + String fromTokenReferrerWalletAddress, + String toTokenReferrerWalletAddress) throws ApiException { okhttp3.Call localVarCall = quoteAndBuildSwapTransactionValidateBeforeCall( @@ -2637,7 +2964,10 @@ public ApiResponse quoteAndBuildSwapTransa maxAutoSlippagePercent, computeUnitLimit, computeUnitPrice, - tips); + tips, + feePercent, + fromTokenReferrerWalletAddress, + toTokenReferrerWalletAddress); java.lang.reflect.Type localVarReturnType = new TypeToken() {}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); @@ -2664,7 +2994,10 @@ public ApiResponse quoteAndBuildSwapTransa request.getMaxAutoSlippagePercent(), request.getComputeUnitLimit(), request.getComputeUnitPrice(), - request.getTips()); + request.getTips(), + request.getFeePercent(), + request.getFromTokenReferrerWalletAddress(), + request.getToTokenReferrerWalletAddress()); } public static class QuoteAndBuildSwapTransactionRequest { @@ -2687,6 +3020,9 @@ public static class QuoteAndBuildSwapTransactionRequest { private String computeUnitLimit; private String computeUnitPrice; private String tips; + private String feePercent; + private String fromTokenReferrerWalletAddress; + private String toTokenReferrerWalletAddress; public String getBinanceChainId() { return binanceChainId; @@ -2764,6 +3100,18 @@ public String getTips() { return tips; } + public String getFeePercent() { + return feePercent; + } + + public String getFromTokenReferrerWalletAddress() { + return fromTokenReferrerWalletAddress; + } + + public String getToTokenReferrerWalletAddress() { + return toTokenReferrerWalletAddress; + } + public QuoteAndBuildSwapTransactionRequest( String binanceChainId, String amount, @@ -2948,6 +3296,66 @@ public QuoteAndBuildSwapTransactionRequest tips(String tips) { this.tips = tips; return this; } + + /** + * Set feePercent + * + * @param feePercent Custom fee (referral fee / Add Fee) percentage as a decimal string. + * Must be paired with exactly one of `fromTokenReferrerWalletAddress` or + * `toTokenReferrerWalletAddress` (the two referrer addresses are mutually + * exclusive). **Range by chain:** `(0, 5]` for EVM chains (BSC, Ethereum, + * Base, etc.) and `(0, 10]` for Solana (`CT_501`) — greater than 0, + * up to the chain-specific maximum inclusive, max 2 decimal places. + * `\"1.5\"` means 1.5%. Values exceeding 2 decimal places are + * rejected with `INVALID_FEE_PERCENT` (40466). **`four.meme` tokens + * are not supported** — do not pass fee parameters when either side of the pair is a + * `four.meme` token. (optional) + * @return QuoteAndBuildSwapTransactionRequest + */ + public QuoteAndBuildSwapTransactionRequest feePercent(String feePercent) { + this.feePercent = feePercent; + return this; + } + + /** + * Set fromTokenReferrerWalletAddress + * + * @param fromTokenReferrerWalletAddress Wallet address that receives the fee deducted from + * the sell token (`FROM_TOKEN` direction). Mutually exclusive with + * `toTokenReferrerWalletAddress` — providing both returns + * `CONFLICT_REFERRER_PARAMS` (40468). Address format depends on the chain: + * EVM chains require `0x` + 40 hex chars; Solana (`CT_501`) + * requires a Base58 pubkey. An invalid format returns + * `INVALID_REFERRER_ADDRESS` (40467). Must be paired with + * `feePercent`. (optional) + * @return QuoteAndBuildSwapTransactionRequest + */ + public QuoteAndBuildSwapTransactionRequest fromTokenReferrerWalletAddress( + String fromTokenReferrerWalletAddress) { + this.fromTokenReferrerWalletAddress = fromTokenReferrerWalletAddress; + return this; + } + + /** + * Set toTokenReferrerWalletAddress + * + * @param toTokenReferrerWalletAddress Wallet address that receives the fee deducted from + * the buy-token output (`TO_TOKEN` direction). Mutually exclusive with + * `fromTokenReferrerWalletAddress` — providing both returns + * `CONFLICT_REFERRER_PARAMS` (40468). Address format depends on the chain: + * EVM chains require `0x` + 40 hex chars; Solana (`CT_501`) + * requires a Base58 pubkey. An invalid format returns + * `INVALID_REFERRER_ADDRESS` (40467). Must be paired with + * `feePercent`. On Solana, the referrer must already be activated (funded + * with some SOL) or the request returns `REFERRER_NOT_ACTIVATED` (40469). + * (optional) + * @return QuoteAndBuildSwapTransactionRequest + */ + public QuoteAndBuildSwapTransactionRequest toTokenReferrerWalletAddress( + String toTokenReferrerWalletAddress) { + this.toTokenReferrerWalletAddress = toTokenReferrerWalletAddress; + return this; + } } private okhttp3.Call submitRfqOrderCall( diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/TransactionApi.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/TransactionApi.java index 2e53cc3..d51e0ab 100644 --- a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/TransactionApi.java +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/TransactionApi.java @@ -52,7 +52,7 @@ public class TransactionApi { private static final String USER_AGENT = String.format( - "binance-web3-wallet/3.0.0 (Java/%s; %s; %s)", + "binance-web3-wallet/4.0.0 (Java/%s; %s; %s)", SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); private static final boolean HAS_TIME_UNIT = false; diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/WalletApi.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/WalletApi.java index fe650d6..a7bc067 100644 --- a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/WalletApi.java +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/WalletApi.java @@ -49,7 +49,7 @@ public class WalletApi { private static final String USER_AGENT = String.format( - "binance-web3-wallet/3.0.0 (Java/%s; %s; %s)", + "binance-web3-wallet/4.0.0 (Java/%s; %s; %s)", SystemUtil.getJavaVersion(), SystemUtil.getOs(), SystemUtil.getArch()); private static final boolean HAS_TIME_UNIT = false; diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/Web3WalletRestApi.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/Web3WalletRestApi.java index e9dfdb1..48aaead 100644 --- a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/Web3WalletRestApi.java +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/api/Web3WalletRestApi.java @@ -13,6 +13,7 @@ import com.binance.connector.client.web3_wallet.rest.model.BroadcastTransactionsResponse; import com.binance.connector.client.web3_wallet.rest.model.BuildSolanaSwapInstructionsResponse; import com.binance.connector.client.web3_wallet.rest.model.BuildSwapTransactionResponse; +import com.binance.connector.client.web3_wallet.rest.model.FeeSource; import com.binance.connector.client.web3_wallet.rest.model.GasLevel; import com.binance.connector.client.web3_wallet.rest.model.GetAddressPnLForSpecificTokenResponse; import com.binance.connector.client.web3_wallet.rest.model.GetAddressPortfolioOverviewResponse; @@ -1511,7 +1512,10 @@ public ApiResponse buildSolanaSwapInstructi * supports `binanceChainId=CT_501` (Solana). Other chains return * `CHAIN_NOT_SUPPORTED` (40411). Parameters mirror the Solana subset of * `/swap` (no EVM-only `approveTransaction` / `approveAmount` / - * `gasLimit`). + * `gasLimit`). Supports the custom-fee (Add Fee / referral fee) parameters + * (`feePercent` + `fromTokenReferrerWalletAddress` / + * `toTokenReferrerWalletAddress`), with the same semantics as `/swap` — the + * fee instructions are injected into the returned uncompiled instruction list. * * @param binanceChainId Chain identifier. Only `CT_501` (Solana) is accepted; other * values return `CHAIN_NOT_SUPPORTED` (40411). (required) @@ -1545,6 +1549,28 @@ public ApiResponse buildSolanaSwapInstructi * @param tips Jito tips in SOL for MEV protection. Valid range [0.000000001, 2] (minimum 1 * lamport). When specified, it is recommended to set `computeUnitPrice=0`. * The platform picks one of Jito's tip accounts at random per request. (optional) + * @param feePercent Custom fee (referral fee / Add Fee) percentage as a decimal string. Must be + * paired with exactly one of `fromTokenReferrerWalletAddress` or + * `toTokenReferrerWalletAddress` (the two referrer addresses are mutually + * exclusive). Same semantics as `/swap`. **Range (Solana):** `(0, 10]` + * — greater than 0, up to 10 inclusive, max 2 decimal places. `\"1.5\"` + * means 1.5%. Values exceeding 2 decimal places are rejected with + * `INVALID_FEE_PERCENT` (40466). **`four.meme` tokens are not + * supported** — do not pass fee parameters when either side of the pair is a + * `four.meme` token. (optional) + * @param fromTokenReferrerWalletAddress Wallet address that receives the fee deducted from the + * sell token (`FROM_TOKEN` direction). Mutually exclusive with + * `toTokenReferrerWalletAddress` — providing both returns + * `CONFLICT_REFERRER_PARAMS` (40468). Solana requires a Base58 pubkey; an invalid + * format returns `INVALID_REFERRER_ADDRESS` (40467). Must be paired with + * `feePercent`. (optional) + * @param toTokenReferrerWalletAddress Wallet address that receives the fee deducted from the + * buy-token output (`TO_TOKEN` direction). Mutually exclusive with + * `fromTokenReferrerWalletAddress` — providing both returns + * `CONFLICT_REFERRER_PARAMS` (40468). Solana requires a Base58 pubkey; an invalid + * format returns `INVALID_REFERRER_ADDRESS` (40467). Must be paired with + * `feePercent`. The referrer must already be activated (funded with some SOL) or + * the request returns `REFERRER_NOT_ACTIVATED` (40469). (optional) * @return ApiResponse<BuildSolanaSwapInstructionsResponse> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the * response body @@ -1578,7 +1604,10 @@ public ApiResponse buildSolanaSwapInstructi String computeUnitLimit, String computeUnitPrice, GasLevel gasLevel, - String tips) + String tips, + String feePercent, + String fromTokenReferrerWalletAddress, + String toTokenReferrerWalletAddress) throws ApiException { return tradingApi.buildSolanaSwapInstructions( binanceChainId, @@ -1596,7 +1625,10 @@ public ApiResponse buildSolanaSwapInstructi computeUnitLimit, computeUnitPrice, gasLevel, - tips); + tips, + feePercent, + fromTokenReferrerWalletAddress, + toTokenReferrerWalletAddress); } public ApiResponse buildSwapTransaction( @@ -1660,6 +1692,32 @@ public ApiResponse buildSwapTransaction( * (minimum 1 lamport). When specified, it is recommended to set * `computeUnitPrice=0`. Applies only when * `binanceChainId=CT_501`. (optional) + * @param feePercent Custom fee (referral fee / Add Fee) percentage as a decimal string. Must be + * paired with exactly one of `fromTokenReferrerWalletAddress` or + * `toTokenReferrerWalletAddress` (the two referrer addresses are mutually + * exclusive). **Range by chain:** `(0, 5]` for EVM chains (BSC, Ethereum, Base, + * etc.) and `(0, 10]` for Solana (`CT_501`) — greater than 0, up to the + * chain-specific maximum inclusive, max 2 decimal places. `\"1.5\"` + * means 1.5%. Values exceeding 2 decimal places are rejected with + * `INVALID_FEE_PERCENT` (40466). **`four.meme` tokens are not + * supported** — do not pass fee parameters when either side of the pair is a + * `four.meme` token. (optional) + * @param fromTokenReferrerWalletAddress Wallet address that receives the fee deducted from the + * sell token (`FROM_TOKEN` direction). Mutually exclusive with + * `toTokenReferrerWalletAddress` — providing both returns + * `CONFLICT_REFERRER_PARAMS` (40468). Address format depends on the chain: EVM + * chains require `0x` + 40 hex chars; Solana (`CT_501`) requires a + * Base58 pubkey. An invalid format returns `INVALID_REFERRER_ADDRESS` (40467). + * Must be paired with `feePercent`. (optional) + * @param toTokenReferrerWalletAddress Wallet address that receives the fee deducted from the + * buy-token output (`TO_TOKEN` direction). Mutually exclusive with + * `fromTokenReferrerWalletAddress` — providing both returns + * `CONFLICT_REFERRER_PARAMS` (40468). Address format depends on the chain: EVM + * chains require `0x` + 40 hex chars; Solana (`CT_501`) requires a + * Base58 pubkey. An invalid format returns `INVALID_REFERRER_ADDRESS` (40467). + * Must be paired with `feePercent`. On Solana, the referrer must already be + * activated (funded with some SOL) or the request returns + * `REFERRER_NOT_ACTIVATED` (40469). (optional) * @return ApiResponse<BuildSwapTransactionResponse> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the * response body @@ -1696,7 +1754,10 @@ public ApiResponse buildSwapTransaction( String maxAutoSlippagePercent, String computeUnitLimit, String computeUnitPrice, - String tips) + String tips, + String feePercent, + String fromTokenReferrerWalletAddress, + String toTokenReferrerWalletAddress) throws ApiException { return tradingApi.buildSwapTransaction( binanceChainId, @@ -1717,7 +1778,10 @@ public ApiResponse buildSwapTransaction( maxAutoSlippagePercent, computeUnitLimit, computeUnitPrice, - tips); + tips, + feePercent, + fromTokenReferrerWalletAddress, + toTokenReferrerWalletAddress); } public ApiResponse getAggregatedQuote( @@ -1747,6 +1811,19 @@ public ApiResponse getAggregatedQuote( * tokens such as Ondo and BStock). This address is used as the receiver in the RFQ order * and must match the wallet that signs `rfq.typedDataToSign` in the subsequent * `/swap` call. (optional) + * @param feePercent Custom fee (referral fee / Add Fee) percentage as a decimal string. Must be + * paired with `feeSource` — either both present or both absent. **Range by + * chain:** `(0, 5]` for EVM chains (BSC, Ethereum, Base, etc.) and `(0, + * 10]` for Solana (`CT_501`) — greater than 0, up to the chain-specific + * maximum inclusive, max 2 decimal places. `\"1.5\"` means 1.5%. Values + * exceeding 2 decimal places are rejected with `INVALID_FEE_PERCENT` (40466). + * **`four.meme` tokens are not supported** — do not pass fee parameters when + * either side of the pair is a `four.meme` token. (optional) + * @param feeSource Fee deduction direction. `FROM_TOKEN` = deduct the fee from + * the sell token (the amount passed to the DEX is reduced to a net amount); + * `TO_TOKEN` = deduct the fee from the buy-token output (the user's + * actual received amount is reduced). Must be paired with `feePercent`. + * (optional) * @return ApiResponse<GetAggregatedQuoteResponse> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the * response body @@ -1771,7 +1848,9 @@ public ApiResponse getAggregatedQuote( String toTokenAddress, Long recvWindow, String nonce, - String userWalletAddress) + String userWalletAddress, + String feePercent, + FeeSource feeSource) throws ApiException { return tradingApi.getAggregatedQuote( binanceChainId, @@ -1780,7 +1859,9 @@ public ApiResponse getAggregatedQuote( toTokenAddress, recvWindow, nonce, - userWalletAddress); + userWalletAddress, + feePercent, + feeSource); } public ApiResponse getAggregatorSupportedChains( @@ -2024,6 +2105,32 @@ public ApiResponse quoteAndBuildSwapTransa * (minimum 1 lamport). When specified, it is recommended to set * `computeUnitPrice=0`. Applies only when * `binanceChainId=CT_501`. (optional) + * @param feePercent Custom fee (referral fee / Add Fee) percentage as a decimal string. Must be + * paired with exactly one of `fromTokenReferrerWalletAddress` or + * `toTokenReferrerWalletAddress` (the two referrer addresses are mutually + * exclusive). **Range by chain:** `(0, 5]` for EVM chains (BSC, Ethereum, Base, + * etc.) and `(0, 10]` for Solana (`CT_501`) — greater than 0, up to the + * chain-specific maximum inclusive, max 2 decimal places. `\"1.5\"` + * means 1.5%. Values exceeding 2 decimal places are rejected with + * `INVALID_FEE_PERCENT` (40466). **`four.meme` tokens are not + * supported** — do not pass fee parameters when either side of the pair is a + * `four.meme` token. (optional) + * @param fromTokenReferrerWalletAddress Wallet address that receives the fee deducted from the + * sell token (`FROM_TOKEN` direction). Mutually exclusive with + * `toTokenReferrerWalletAddress` — providing both returns + * `CONFLICT_REFERRER_PARAMS` (40468). Address format depends on the chain: EVM + * chains require `0x` + 40 hex chars; Solana (`CT_501`) requires a + * Base58 pubkey. An invalid format returns `INVALID_REFERRER_ADDRESS` (40467). + * Must be paired with `feePercent`. (optional) + * @param toTokenReferrerWalletAddress Wallet address that receives the fee deducted from the + * buy-token output (`TO_TOKEN` direction). Mutually exclusive with + * `fromTokenReferrerWalletAddress` — providing both returns + * `CONFLICT_REFERRER_PARAMS` (40468). Address format depends on the chain: EVM + * chains require `0x` + 40 hex chars; Solana (`CT_501`) requires a + * Base58 pubkey. An invalid format returns `INVALID_REFERRER_ADDRESS` (40467). + * Must be paired with `feePercent`. On Solana, the referrer must already be + * activated (funded with some SOL) or the request returns + * `REFERRER_NOT_ACTIVATED` (40469). (optional) * @return ApiResponse<QuoteAndBuildSwapTransactionResponse> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the * response body @@ -2060,7 +2167,10 @@ public ApiResponse quoteAndBuildSwapTransa String maxAutoSlippagePercent, String computeUnitLimit, String computeUnitPrice, - String tips) + String tips, + String feePercent, + String fromTokenReferrerWalletAddress, + String toTokenReferrerWalletAddress) throws ApiException { return tradingApi.quoteAndBuildSwapTransaction( binanceChainId, @@ -2081,7 +2191,10 @@ public ApiResponse quoteAndBuildSwapTransa maxAutoSlippagePercent, computeUnitLimit, computeUnitPrice, - tips); + tips, + feePercent, + fromTokenReferrerWalletAddress, + toTokenReferrerWalletAddress); } /** diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/model/BuildSolanaSwapInstructionsResponseDataRouterResult.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/model/BuildSolanaSwapInstructionsResponseDataRouterResult.java index f6d8462..fcaf118 100644 --- a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/model/BuildSolanaSwapInstructionsResponseDataRouterResult.java +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/model/BuildSolanaSwapInstructionsResponseDataRouterResult.java @@ -113,6 +113,24 @@ public class BuildSolanaSwapInstructionsResponseDataRouterResult { @jakarta.annotation.Nullable private BuildSolanaSwapInstructionsResponseDataRouterResultToToken toToken; + public static final String SERIALIZED_NAME_FEE_AMOUNT = "feeAmount"; + + @SerializedName(SERIALIZED_NAME_FEE_AMOUNT) + @jakarta.annotation.Nullable + private String feeAmount; + + public static final String SERIALIZED_NAME_FEE_TOKEN = "feeToken"; + + @SerializedName(SERIALIZED_NAME_FEE_TOKEN) + @jakarta.annotation.Nullable + private String feeToken; + + public static final String SERIALIZED_NAME_ACTUAL_SWAP_AMOUNT = "actualSwapAmount"; + + @SerializedName(SERIALIZED_NAME_ACTUAL_SWAP_AMOUNT) + @jakarta.annotation.Nullable + private String actualSwapAmount; + public BuildSolanaSwapInstructionsResponseDataRouterResult() {} public BuildSolanaSwapInstructionsResponseDataRouterResult binanceChainId( @@ -364,6 +382,74 @@ public void setToToken( this.toToken = toToken; } + public BuildSolanaSwapInstructionsResponseDataRouterResult feeAmount( + @jakarta.annotation.Nullable String feeAmount) { + this.feeAmount = feeAmount; + return this; + } + + /** + * Fee amount deducted for this swap (smallest unit, integer string). Only populated when the + * request enabled the custom fee; `null` otherwise. `FROM_TOKEN` direction + * = `originalFromCoinAmount × feePercent/100` (HALF_UP); `TO_TOKEN` + * direction = `originalToCoinAmount × feePercent/100` (HALF_DOWN). + * + * @return feeAmount + */ + @jakarta.annotation.Nullable + public String getFeeAmount() { + return feeAmount; + } + + public void setFeeAmount(@jakarta.annotation.Nullable String feeAmount) { + this.feeAmount = feeAmount; + } + + public BuildSolanaSwapInstructionsResponseDataRouterResult feeToken( + @jakarta.annotation.Nullable String feeToken) { + this.feeToken = feeToken; + return this; + } + + /** + * Contract address of the token in which the fee is denominated. `FROM_TOKEN` + * direction = sell-token address; `TO_TOKEN` direction = buy-token address. + * `null` when the custom fee is not enabled. + * + * @return feeToken + */ + @jakarta.annotation.Nullable + public String getFeeToken() { + return feeToken; + } + + public void setFeeToken(@jakarta.annotation.Nullable String feeToken) { + this.feeToken = feeToken; + } + + public BuildSolanaSwapInstructionsResponseDataRouterResult actualSwapAmount( + @jakarta.annotation.Nullable String actualSwapAmount) { + this.actualSwapAmount = actualSwapAmount; + return this; + } + + /** + * Actual amount participating in the DEX swap (smallest unit, integer string). + * `FROM_TOKEN` direction = net amount after fee deduction (`fromTokenAmount + * − feeAmount`); `TO_TOKEN` direction = original input amount (fee is taken + * from the output side). `null` when the custom fee is not enabled. + * + * @return actualSwapAmount + */ + @jakarta.annotation.Nullable + public String getActualSwapAmount() { + return actualSwapAmount; + } + + public void setActualSwapAmount(@jakarta.annotation.Nullable String actualSwapAmount) { + this.actualSwapAmount = actualSwapAmount; + } + @Override public boolean equals(Object o) { if (this == o) { @@ -404,7 +490,15 @@ public boolean equals(Object o) { this.fromToken, buildSolanaSwapInstructionsResponseDataRouterResult.fromToken) && Objects.equals( - this.toToken, buildSolanaSwapInstructionsResponseDataRouterResult.toToken); + this.toToken, buildSolanaSwapInstructionsResponseDataRouterResult.toToken) + && Objects.equals( + this.feeAmount, + buildSolanaSwapInstructionsResponseDataRouterResult.feeAmount) + && Objects.equals( + this.feeToken, buildSolanaSwapInstructionsResponseDataRouterResult.feeToken) + && Objects.equals( + this.actualSwapAmount, + buildSolanaSwapInstructionsResponseDataRouterResult.actualSwapAmount); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -429,7 +523,10 @@ public int hashCode() { priceImpactPercent, dexRouterList, fromToken, - toToken); + toToken, + feeAmount, + feeToken, + actualSwapAmount); } private static int hashCodeNullable(JsonNullable a) { @@ -456,6 +553,9 @@ public String toString() { sb.append(" dexRouterList: ").append(toIndentedString(dexRouterList)).append("\n"); sb.append(" fromToken: ").append(toIndentedString(fromToken)).append("\n"); sb.append(" toToken: ").append(toIndentedString(toToken)).append("\n"); + sb.append(" feeAmount: ").append(toIndentedString(feeAmount)).append("\n"); + sb.append(" feeToken: ").append(toIndentedString(feeToken)).append("\n"); + sb.append(" actualSwapAmount: ").append(toIndentedString(actualSwapAmount)).append("\n"); sb.append("}"); return sb.toString(); } @@ -512,6 +612,18 @@ public String toUrlQueryString() { String toTokenValueAsString = ""; toTokenValueAsString = toTokenValue.toString(); sb.append("toToken=").append(urlEncode(toTokenValueAsString)).append(""); + Object feeAmountValue = getFeeAmount(); + String feeAmountValueAsString = ""; + feeAmountValueAsString = feeAmountValue.toString(); + sb.append("feeAmount=").append(urlEncode(feeAmountValueAsString)).append(""); + Object feeTokenValue = getFeeToken(); + String feeTokenValueAsString = ""; + feeTokenValueAsString = feeTokenValue.toString(); + sb.append("feeToken=").append(urlEncode(feeTokenValueAsString)).append(""); + Object actualSwapAmountValue = getActualSwapAmount(); + String actualSwapAmountValueAsString = ""; + actualSwapAmountValueAsString = actualSwapAmountValue.toString(); + sb.append("actualSwapAmount=").append(urlEncode(actualSwapAmountValueAsString)).append(""); return sb.toString(); } @@ -551,6 +663,9 @@ private String toIndentedString(Object o) { openapiFields.add("dexRouterList"); openapiFields.add("fromToken"); openapiFields.add("toToken"); + openapiFields.add("feeAmount"); + openapiFields.add("feeToken"); + openapiFields.add("actualSwapAmount"); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(); @@ -673,6 +788,31 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti BuildSolanaSwapInstructionsResponseDataRouterResultToToken.validateJsonElement( jsonObj.get("toToken")); } + if ((jsonObj.get("feeAmount") != null && !jsonObj.get("feeAmount").isJsonNull()) + && !jsonObj.get("feeAmount").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `feeAmount` to be a primitive type in the JSON" + + " string but got `%s`", + jsonObj.get("feeAmount").toString())); + } + if ((jsonObj.get("feeToken") != null && !jsonObj.get("feeToken").isJsonNull()) + && !jsonObj.get("feeToken").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `feeToken` to be a primitive type in the JSON" + + " string but got `%s`", + jsonObj.get("feeToken").toString())); + } + if ((jsonObj.get("actualSwapAmount") != null + && !jsonObj.get("actualSwapAmount").isJsonNull()) + && !jsonObj.get("actualSwapAmount").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `actualSwapAmount` to be a primitive type in the" + + " JSON string but got `%s`", + jsonObj.get("actualSwapAmount").toString())); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/model/BuildSwapTransactionResponseDataRouterResult.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/model/BuildSwapTransactionResponseDataRouterResult.java index 61fdc8d..8a4cdfd 100644 --- a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/model/BuildSwapTransactionResponseDataRouterResult.java +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/model/BuildSwapTransactionResponseDataRouterResult.java @@ -111,6 +111,24 @@ public class BuildSwapTransactionResponseDataRouterResult { @jakarta.annotation.Nullable private BuildSwapTransactionResponseDataRouterResultToToken toToken; + public static final String SERIALIZED_NAME_FEE_AMOUNT = "feeAmount"; + + @SerializedName(SERIALIZED_NAME_FEE_AMOUNT) + @jakarta.annotation.Nullable + private String feeAmount; + + public static final String SERIALIZED_NAME_FEE_TOKEN = "feeToken"; + + @SerializedName(SERIALIZED_NAME_FEE_TOKEN) + @jakarta.annotation.Nullable + private String feeToken; + + public static final String SERIALIZED_NAME_ACTUAL_SWAP_AMOUNT = "actualSwapAmount"; + + @SerializedName(SERIALIZED_NAME_ACTUAL_SWAP_AMOUNT) + @jakarta.annotation.Nullable + private String actualSwapAmount; + public BuildSwapTransactionResponseDataRouterResult() {} public BuildSwapTransactionResponseDataRouterResult binanceChainId( @@ -358,6 +376,74 @@ public void setToToken( this.toToken = toToken; } + public BuildSwapTransactionResponseDataRouterResult feeAmount( + @jakarta.annotation.Nullable String feeAmount) { + this.feeAmount = feeAmount; + return this; + } + + /** + * Fee amount deducted for this swap (smallest unit, integer string). Only populated when the + * request enabled the custom fee; `null` otherwise. `FROM_TOKEN` direction + * = `originalFromCoinAmount × feePercent/100` (HALF_UP); `TO_TOKEN` + * direction = `originalToCoinAmount × feePercent/100` (HALF_DOWN). + * + * @return feeAmount + */ + @jakarta.annotation.Nullable + public String getFeeAmount() { + return feeAmount; + } + + public void setFeeAmount(@jakarta.annotation.Nullable String feeAmount) { + this.feeAmount = feeAmount; + } + + public BuildSwapTransactionResponseDataRouterResult feeToken( + @jakarta.annotation.Nullable String feeToken) { + this.feeToken = feeToken; + return this; + } + + /** + * Contract address of the token in which the fee is denominated. `FROM_TOKEN` + * direction = sell-token address; `TO_TOKEN` direction = buy-token address. + * `null` when the custom fee is not enabled. + * + * @return feeToken + */ + @jakarta.annotation.Nullable + public String getFeeToken() { + return feeToken; + } + + public void setFeeToken(@jakarta.annotation.Nullable String feeToken) { + this.feeToken = feeToken; + } + + public BuildSwapTransactionResponseDataRouterResult actualSwapAmount( + @jakarta.annotation.Nullable String actualSwapAmount) { + this.actualSwapAmount = actualSwapAmount; + return this; + } + + /** + * Actual amount participating in the DEX swap (smallest unit, integer string). + * `FROM_TOKEN` direction = net amount after fee deduction (`fromTokenAmount + * − feeAmount`); `TO_TOKEN` direction = original input amount (fee is taken + * from the output side). `null` when the custom fee is not enabled. + * + * @return actualSwapAmount + */ + @jakarta.annotation.Nullable + public String getActualSwapAmount() { + return actualSwapAmount; + } + + public void setActualSwapAmount(@jakarta.annotation.Nullable String actualSwapAmount) { + this.actualSwapAmount = actualSwapAmount; + } + @Override public boolean equals(Object o) { if (this == o) { @@ -394,7 +480,14 @@ public boolean equals(Object o) { && Objects.equals( this.fromToken, buildSwapTransactionResponseDataRouterResult.fromToken) && Objects.equals( - this.toToken, buildSwapTransactionResponseDataRouterResult.toToken); + this.toToken, buildSwapTransactionResponseDataRouterResult.toToken) + && Objects.equals( + this.feeAmount, buildSwapTransactionResponseDataRouterResult.feeAmount) + && Objects.equals( + this.feeToken, buildSwapTransactionResponseDataRouterResult.feeToken) + && Objects.equals( + this.actualSwapAmount, + buildSwapTransactionResponseDataRouterResult.actualSwapAmount); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -419,7 +512,10 @@ public int hashCode() { priceImpactPercent, dexRouterList, fromToken, - toToken); + toToken, + feeAmount, + feeToken, + actualSwapAmount); } private static int hashCodeNullable(JsonNullable a) { @@ -446,6 +542,9 @@ public String toString() { sb.append(" dexRouterList: ").append(toIndentedString(dexRouterList)).append("\n"); sb.append(" fromToken: ").append(toIndentedString(fromToken)).append("\n"); sb.append(" toToken: ").append(toIndentedString(toToken)).append("\n"); + sb.append(" feeAmount: ").append(toIndentedString(feeAmount)).append("\n"); + sb.append(" feeToken: ").append(toIndentedString(feeToken)).append("\n"); + sb.append(" actualSwapAmount: ").append(toIndentedString(actualSwapAmount)).append("\n"); sb.append("}"); return sb.toString(); } @@ -502,6 +601,18 @@ public String toUrlQueryString() { String toTokenValueAsString = ""; toTokenValueAsString = toTokenValue.toString(); sb.append("toToken=").append(urlEncode(toTokenValueAsString)).append(""); + Object feeAmountValue = getFeeAmount(); + String feeAmountValueAsString = ""; + feeAmountValueAsString = feeAmountValue.toString(); + sb.append("feeAmount=").append(urlEncode(feeAmountValueAsString)).append(""); + Object feeTokenValue = getFeeToken(); + String feeTokenValueAsString = ""; + feeTokenValueAsString = feeTokenValue.toString(); + sb.append("feeToken=").append(urlEncode(feeTokenValueAsString)).append(""); + Object actualSwapAmountValue = getActualSwapAmount(); + String actualSwapAmountValueAsString = ""; + actualSwapAmountValueAsString = actualSwapAmountValue.toString(); + sb.append("actualSwapAmount=").append(urlEncode(actualSwapAmountValueAsString)).append(""); return sb.toString(); } @@ -541,6 +652,9 @@ private String toIndentedString(Object o) { openapiFields.add("dexRouterList"); openapiFields.add("fromToken"); openapiFields.add("toToken"); + openapiFields.add("feeAmount"); + openapiFields.add("feeToken"); + openapiFields.add("actualSwapAmount"); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(); @@ -662,6 +776,31 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti BuildSwapTransactionResponseDataRouterResultToToken.validateJsonElement( jsonObj.get("toToken")); } + if ((jsonObj.get("feeAmount") != null && !jsonObj.get("feeAmount").isJsonNull()) + && !jsonObj.get("feeAmount").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `feeAmount` to be a primitive type in the JSON" + + " string but got `%s`", + jsonObj.get("feeAmount").toString())); + } + if ((jsonObj.get("feeToken") != null && !jsonObj.get("feeToken").isJsonNull()) + && !jsonObj.get("feeToken").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `feeToken` to be a primitive type in the JSON" + + " string but got `%s`", + jsonObj.get("feeToken").toString())); + } + if ((jsonObj.get("actualSwapAmount") != null + && !jsonObj.get("actualSwapAmount").isJsonNull()) + && !jsonObj.get("actualSwapAmount").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `actualSwapAmount` to be a primitive type in the" + + " JSON string but got `%s`", + jsonObj.get("actualSwapAmount").toString())); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/model/FeeSource.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/model/FeeSource.java new file mode 100644 index 0000000..130c1a5 --- /dev/null +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/model/FeeSource.java @@ -0,0 +1,73 @@ +/* + * Binance Web3 API + * Cross-chain wallet, market, trading, and transaction APIs for the Binance Web3 API platform. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.binance.connector.client.web3_wallet.rest.model; + +import com.google.gson.JsonElement; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import jakarta.validation.constraints.*; +import java.io.IOException; +import org.hibernate.validator.constraints.*; + +/** Gets or Sets feeSource */ +@JsonAdapter(FeeSource.Adapter.class) +public enum FeeSource { + FROM_TOKEN("FROM_TOKEN"), + + TO_TOKEN("TO_TOKEN"); + + private String value; + + FeeSource(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static FeeSource fromValue(String value) { + for (FeeSource b : FeeSource.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final FeeSource enumeration) + throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public FeeSource read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return FeeSource.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + FeeSource.fromValue(value); + } +} diff --git a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/model/GetAggregatedQuoteResponseDataInner.java b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/model/GetAggregatedQuoteResponseDataInner.java index 92d4e56..6fe1b92 100644 --- a/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/model/GetAggregatedQuoteResponseDataInner.java +++ b/clients/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/model/GetAggregatedQuoteResponseDataInner.java @@ -134,6 +134,24 @@ public class GetAggregatedQuoteResponseDataInner { @jakarta.annotation.Nullable private Boolean isBest; + public static final String SERIALIZED_NAME_FEE_AMOUNT = "feeAmount"; + + @SerializedName(SERIALIZED_NAME_FEE_AMOUNT) + @jakarta.annotation.Nullable + private String feeAmount; + + public static final String SERIALIZED_NAME_FEE_TOKEN = "feeToken"; + + @SerializedName(SERIALIZED_NAME_FEE_TOKEN) + @jakarta.annotation.Nullable + private String feeToken; + + public static final String SERIALIZED_NAME_ACTUAL_SWAP_AMOUNT = "actualSwapAmount"; + + @SerializedName(SERIALIZED_NAME_ACTUAL_SWAP_AMOUNT) + @jakarta.annotation.Nullable + private String actualSwapAmount; + public GetAggregatedQuoteResponseDataInner() {} public GetAggregatedQuoteResponseDataInner quoteId( @@ -467,6 +485,76 @@ public void setIsBest(@jakarta.annotation.Nullable Boolean isBest) { this.isBest = isBest; } + public GetAggregatedQuoteResponseDataInner feeAmount( + @jakarta.annotation.Nullable String feeAmount) { + this.feeAmount = feeAmount; + return this; + } + + /** + * Fee amount deducted for this route (smallest unit, integer string). Only populated when the + * request enabled the custom fee (`feePercent` + `feeSource` both present); + * `null` otherwise. `FROM_TOKEN` direction = + * `originalFromCoinAmount × feePercent/100` (HALF_UP); `TO_TOKEN` direction + * = `originalToCoinAmount × feePercent/100` (HALF_DOWN). + * + * @return feeAmount + */ + @jakarta.annotation.Nullable + public String getFeeAmount() { + return feeAmount; + } + + public void setFeeAmount(@jakarta.annotation.Nullable String feeAmount) { + this.feeAmount = feeAmount; + } + + public GetAggregatedQuoteResponseDataInner feeToken( + @jakarta.annotation.Nullable String feeToken) { + this.feeToken = feeToken; + return this; + } + + /** + * Contract address of the token in which the fee is denominated. `FROM_TOKEN` + * direction = sell-token address; `TO_TOKEN` direction = buy-token address. + * `null` when the custom fee is not enabled. + * + * @return feeToken + */ + @jakarta.annotation.Nullable + public String getFeeToken() { + return feeToken; + } + + public void setFeeToken(@jakarta.annotation.Nullable String feeToken) { + this.feeToken = feeToken; + } + + public GetAggregatedQuoteResponseDataInner actualSwapAmount( + @jakarta.annotation.Nullable String actualSwapAmount) { + this.actualSwapAmount = actualSwapAmount; + return this; + } + + /** + * Actual amount participating in the DEX swap (smallest unit, integer string). + * `FROM_TOKEN` direction = net amount after fee deduction (`fromTokenAmount + * − feeAmount`, i.e. the amountIn sent to the DEX); `TO_TOKEN` direction = + * original input amount (fee is taken from the output side, so the full input participates in + * the swap). `null` when the custom fee is not enabled. + * + * @return actualSwapAmount + */ + @jakarta.annotation.Nullable + public String getActualSwapAmount() { + return actualSwapAmount; + } + + public void setActualSwapAmount(@jakarta.annotation.Nullable String actualSwapAmount) { + this.actualSwapAmount = actualSwapAmount; + } + @Override public boolean equals(Object o) { if (this == o) { @@ -500,7 +588,12 @@ public boolean equals(Object o) { this.executionMode, getAggregatedQuoteResponseDataInner.executionMode) && Objects.equals( this.approveTarget, getAggregatedQuoteResponseDataInner.approveTarget) - && Objects.equals(this.isBest, getAggregatedQuoteResponseDataInner.isBest); + && Objects.equals(this.isBest, getAggregatedQuoteResponseDataInner.isBest) + && Objects.equals(this.feeAmount, getAggregatedQuoteResponseDataInner.feeAmount) + && Objects.equals(this.feeToken, getAggregatedQuoteResponseDataInner.feeToken) + && Objects.equals( + this.actualSwapAmount, + getAggregatedQuoteResponseDataInner.actualSwapAmount); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -529,7 +622,10 @@ public int hashCode() { dexRouterList, executionMode, approveTarget, - isBest); + isBest, + feeAmount, + feeToken, + actualSwapAmount); } private static int hashCodeNullable(JsonNullable a) { @@ -560,6 +656,9 @@ public String toString() { sb.append(" executionMode: ").append(toIndentedString(executionMode)).append("\n"); sb.append(" approveTarget: ").append(toIndentedString(approveTarget)).append("\n"); sb.append(" isBest: ").append(toIndentedString(isBest)).append("\n"); + sb.append(" feeAmount: ").append(toIndentedString(feeAmount)).append("\n"); + sb.append(" feeToken: ").append(toIndentedString(feeToken)).append("\n"); + sb.append(" actualSwapAmount: ").append(toIndentedString(actualSwapAmount)).append("\n"); sb.append("}"); return sb.toString(); } @@ -632,6 +731,18 @@ public String toUrlQueryString() { String isBestValueAsString = ""; isBestValueAsString = isBestValue.toString(); sb.append("isBest=").append(urlEncode(isBestValueAsString)).append(""); + Object feeAmountValue = getFeeAmount(); + String feeAmountValueAsString = ""; + feeAmountValueAsString = feeAmountValue.toString(); + sb.append("feeAmount=").append(urlEncode(feeAmountValueAsString)).append(""); + Object feeTokenValue = getFeeToken(); + String feeTokenValueAsString = ""; + feeTokenValueAsString = feeTokenValue.toString(); + sb.append("feeToken=").append(urlEncode(feeTokenValueAsString)).append(""); + Object actualSwapAmountValue = getActualSwapAmount(); + String actualSwapAmountValueAsString = ""; + actualSwapAmountValueAsString = actualSwapAmountValue.toString(); + sb.append("actualSwapAmount=").append(urlEncode(actualSwapAmountValueAsString)).append(""); return sb.toString(); } @@ -675,6 +786,9 @@ private String toIndentedString(Object o) { openapiFields.add("executionMode"); openapiFields.add("approveTarget"); openapiFields.add("isBest"); + openapiFields.add("feeAmount"); + openapiFields.add("feeToken"); + openapiFields.add("actualSwapAmount"); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(); @@ -818,6 +932,31 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti + " string but got `%s`", jsonObj.get("approveTarget").toString())); } + if ((jsonObj.get("feeAmount") != null && !jsonObj.get("feeAmount").isJsonNull()) + && !jsonObj.get("feeAmount").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `feeAmount` to be a primitive type in the JSON" + + " string but got `%s`", + jsonObj.get("feeAmount").toString())); + } + if ((jsonObj.get("feeToken") != null && !jsonObj.get("feeToken").isJsonNull()) + && !jsonObj.get("feeToken").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `feeToken` to be a primitive type in the JSON" + + " string but got `%s`", + jsonObj.get("feeToken").toString())); + } + if ((jsonObj.get("actualSwapAmount") != null + && !jsonObj.get("actualSwapAmount").isJsonNull()) + && !jsonObj.get("actualSwapAmount").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `actualSwapAmount` to be a primitive type in the" + + " JSON string but got `%s`", + jsonObj.get("actualSwapAmount").toString())); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/examples/web3-wallet/pom.xml b/examples/web3-wallet/pom.xml index 8f74a77..ffb2cc5 100644 --- a/examples/web3-wallet/pom.xml +++ b/examples/web3-wallet/pom.xml @@ -31,7 +31,7 @@ io.github.binance binance-web3-wallet - 3.0.0 + 4.0.0 \ No newline at end of file diff --git a/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/trading/BuildSolanaSwapInstructionsExample.java b/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/trading/BuildSolanaSwapInstructionsExample.java index bb8069a..2440e2c 100644 --- a/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/trading/BuildSolanaSwapInstructionsExample.java +++ b/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/trading/BuildSolanaSwapInstructionsExample.java @@ -43,7 +43,10 @@ public Web3WalletRestApi getApi() { * the final wire format. Only supports `binanceChainId=CT_501` (Solana). Other * chains return `CHAIN_NOT_SUPPORTED` (40411). Parameters mirror the Solana subset of * `/swap` (no EVM-only `approveTransaction` / `approveAmount` / - * `gasLimit`). + * `gasLimit`). Supports the custom-fee (Add Fee / referral fee) parameters + * (`feePercent` + `fromTokenReferrerWalletAddress` / + * `toTokenReferrerWalletAddress`), with the same semantics as `/swap` — the + * fee instructions are injected into the returned uncompiled instruction list. * * @throws ApiException if the Api call fails */ @@ -64,6 +67,9 @@ public void buildSolanaSwapInstructionsExample() throws ApiException { String computeUnitPrice = "1000"; GasLevel gasLevel = GasLevel.slow; String tips = "0.001"; + String feePercent = "1.5"; + String fromTokenReferrerWalletAddress = "J5CBzXpcYn6WR2JBah8zU4Yxct985CAFGwXRcFaX2pbS"; + String toTokenReferrerWalletAddress = "J5CBzXpcYn6WR2JBah8zU4Yxct985CAFGwXRcFaX2pbS"; TradingApi.BuildSolanaSwapInstructionsRequest request = new TradingApi.BuildSolanaSwapInstructionsRequest( binanceChainId, diff --git a/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/trading/BuildSwapTransactionExample.java b/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/trading/BuildSwapTransactionExample.java index 3aa2c76..25e1cef 100644 --- a/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/trading/BuildSwapTransactionExample.java +++ b/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/trading/BuildSwapTransactionExample.java @@ -59,6 +59,9 @@ public void buildSwapTransactionExample() throws ApiException { String computeUnitLimit = "1400000"; String computeUnitPrice = "1000"; String tips = "0.001"; + String feePercent = "1.5"; + String fromTokenReferrerWalletAddress = "0xCbF2B6E6e3D7e9e4e4e4e4e4e4e4e4e4e4e4e4e4"; + String toTokenReferrerWalletAddress = "0xCbF2B6E6e3D7e9e4e4e4e4e4e4e4e4e4e4e4e4e4"; TradingApi.BuildSwapTransactionRequest request = new TradingApi.BuildSwapTransactionRequest( binanceChainId, diff --git a/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/trading/GetAggregatedQuoteExample.java b/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/trading/GetAggregatedQuoteExample.java index 677dea1..8fdce42 100644 --- a/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/trading/GetAggregatedQuoteExample.java +++ b/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/trading/GetAggregatedQuoteExample.java @@ -7,6 +7,7 @@ import com.binance.connector.client.web3_wallet.rest.Web3WalletRestApiUtil; import com.binance.connector.client.web3_wallet.rest.api.TradingApi; import com.binance.connector.client.web3_wallet.rest.api.Web3WalletRestApi; +import com.binance.connector.client.web3_wallet.rest.model.FeeSource; import com.binance.connector.client.web3_wallet.rest.model.GetAggregatedQuoteResponse; /** API examples for TradingApi */ @@ -43,6 +44,8 @@ public void getAggregatedQuoteExample() throws ApiException { Long recvWindow = 5000L; String nonce = "unique-nonce-string"; String userWalletAddress = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"; + String feePercent = "1.5"; + FeeSource feeSource = FeeSource.FROM_TOKEN; TradingApi.GetAggregatedQuoteRequest request = new TradingApi.GetAggregatedQuoteRequest( binanceChainId, amount, fromTokenAddress, toTokenAddress); diff --git a/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/trading/QuoteAndBuildSwapTransactionExample.java b/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/trading/QuoteAndBuildSwapTransactionExample.java index 3eb090b..28bff9e 100644 --- a/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/trading/QuoteAndBuildSwapTransactionExample.java +++ b/examples/web3-wallet/src/main/java/com/binance/connector/client/web3_wallet/rest/trading/QuoteAndBuildSwapTransactionExample.java @@ -63,6 +63,9 @@ public void quoteAndBuildSwapTransactionExample() throws ApiException { String computeUnitLimit = "1400000"; String computeUnitPrice = "1000"; String tips = "0.001"; + String feePercent = "1.5"; + String fromTokenReferrerWalletAddress = "0xCbF2B6E6e3D7e9e4e4e4e4e4e4e4e4e4e4e4e4e4"; + String toTokenReferrerWalletAddress = "0xCbF2B6E6e3D7e9e4e4e4e4e4e4e4e4e4e4e4e4e4"; TradingApi.QuoteAndBuildSwapTransactionRequest request = new TradingApi.QuoteAndBuildSwapTransactionRequest( binanceChainId,