diff --git a/src/entities/protocols/uniswap.ts b/src/entities/protocols/uniswap.ts index b44c96a5..41638895 100644 --- a/src/entities/protocols/uniswap.ts +++ b/src/entities/protocols/uniswap.ts @@ -30,8 +30,9 @@ export type FlatFeeOptions = { // the existing router permit object doesn't include enough data for permit2 // so we extend swap options with the permit2 permit // when safe mode is enabled, the SDK will add an extra ETH sweep for security +// when useRouterBalance is enabled the SDK will use the balance in the router for the swap export type SwapOptions = Omit & { - directSend?: boolean + useRouterBalance?: boolean inputTokenPermit?: Permit2Permit flatFee?: FlatFeeOptions safeMode?: boolean @@ -55,7 +56,7 @@ export class UniswapTrade implements Command { if (!!options.fee && !!options.flatFee) throw new Error('Only one fee option permitted') if (this.inputRequiresWrap) this.payerIsUser = false - else if (this.options.directSend) this.payerIsUser = false + else if (this.options.useRouterBalance) this.payerIsUser = false else this.payerIsUser = true } @@ -65,7 +66,7 @@ export class UniswapTrade implements Command { encode(planner: RoutePlanner, _config: TradeConfig): void { // If the input currency is the native currency, we need to wrap it with the router as the recipient - if (this.trade.inputAmount.currency.isNative) { + if (this.inputRequiresWrap) { // TODO: optimize if only one v2 pool we can directly send this to the pool planner.addCommand(CommandType.WRAP_ETH, [ ROUTER_AS_RECIPIENT, diff --git a/src/utils/constants.ts b/src/utils/constants.ts index 1e504859..c1262557 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -1,4 +1,3 @@ -import { ChainId, Token } from '@uniswap/sdk-core' import { BigNumber } from 'ethers' type ChainConfig = { diff --git a/test/forge/interop.json b/test/forge/interop.json index d4c1e555..0bc773c9 100644 --- a/test/forge/interop.json +++ b/test/forge/interop.json @@ -247,4 +247,4 @@ "calldata": "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030b000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000000000000000120000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000003eb3459f0ce6ae000b00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000042c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000bb8a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480001f46b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000000000000000000000000000000000000000000000", "value": "1000000000000000000" } -} +} \ No newline at end of file