From 3e2979a7303559bc36b5303c0f685ab2dab1cf95 Mon Sep 17 00:00:00 2001 From: kvhnuke <10602065+kvhnuke@users.noreply.github.com> Date: Thu, 21 Mar 2024 14:01:44 -0700 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20propellerheads?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../swap/src/providers/propeller-heads/index.ts | 11 +++++------ packages/swap/tests/propeller-heads.test.ts | 15 ++++++++++----- packages/swap/tests/swap.test.ts | 4 ++-- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/packages/swap/src/providers/propeller-heads/index.ts b/packages/swap/src/providers/propeller-heads/index.ts index 8b3b4146e..ce6ac532f 100644 --- a/packages/swap/src/providers/propeller-heads/index.ts +++ b/packages/swap/src/providers/propeller-heads/index.ts @@ -132,10 +132,6 @@ class PropellerHeads extends ProviderClass { this.network !== options.toToken.networkInfo.name ) return Promise.resolve(null); - - if (options.fromAddress.toLowerCase() !== options.toAddress.toLowerCase()) - return Promise.resolve(null); - const body = { orders: [ { @@ -143,6 +139,7 @@ class PropellerHeads extends ProviderClass { buy_token: options.toToken.address, sell_amount: options.amount.toString(), origin_address: options.fromAddress, + receiver: options.toAddress, }, ], }; @@ -151,7 +148,6 @@ class PropellerHeads extends ProviderClass { blockchain: NetworkNamesToSupportedProppellerHeadsBlockchains[this.network], }); - return fetch(`${BASE_URL}/solver/solve?${params.toString()}`, { method: "POST", body: JSON.stringify(body), @@ -174,7 +170,10 @@ class PropellerHeads extends ProviderClass { from: options.fromAddress, gasLimit: GAS_LIMITS.swap, to: options.fromAddress, - value: numberToHex(options.amount), + value: + options.fromToken.address === NATIVE_TOKEN_ADDRESS + ? numberToHex(options.amount) + : "0x0", data: response.solutions[0].call_data, type: TransactionType.evm, }); diff --git a/packages/swap/tests/propeller-heads.test.ts b/packages/swap/tests/propeller-heads.test.ts index 6b70e055d..0fac51323 100644 --- a/packages/swap/tests/propeller-heads.test.ts +++ b/packages/swap/tests/propeller-heads.test.ts @@ -7,7 +7,12 @@ import { SupportedNetworkName, WalletIdentifier, } from "../src/types"; -import { fromTokenWBTC, toToken, nodeURL } from "./fixtures/mainnet/configs"; +import { + fromTokenWBTC, + toToken, + nodeURL, + toAddress, +} from "./fixtures/mainnet/configs"; describe("Propeller Heads Provider", () => { const web3eth = new Web3Eth(nodeURL); @@ -22,10 +27,10 @@ describe("Propeller Heads Provider", () => { const quote = await propellerHeads.getQuote( { amount: localAmount, - fromAddress: "0x9ff58f4ffb29fa2266ab25e75e2a8b3503311656", // aave + fromAddress: "0x6daB3bCbFb336b29d06B9C793AEF7eaA57888922", // random address fromToken: fromTokenWBTC, toToken, - toAddress: "0x9ff58f4ffb29fa2266ab25e75e2a8b3503311656", // aave + toAddress, }, { infiniteApproval: true, walletIdentifier: WalletIdentifier.enkrypt } ); @@ -53,10 +58,10 @@ describe("Propeller Heads Provider", () => { const quote = await propellerHeads.getQuote( { amount: localAmount, - fromAddress: "0x9ff58f4ffb29fa2266ab25e75e2a8b3503311656", // aave + fromAddress: "0x6daB3bCbFb336b29d06B9C793AEF7eaA57888922", // random address fromToken: fromTokenWBTC, toToken, - toAddress: "0x9ff58f4ffb29fa2266ab25e75e2a8b3503311656", // aave + toAddress, }, { infiniteApproval: false, walletIdentifier: WalletIdentifier.enkrypt } ); diff --git a/packages/swap/tests/swap.test.ts b/packages/swap/tests/swap.test.ts index a20822d15..979b797d7 100644 --- a/packages/swap/tests/swap.test.ts +++ b/packages/swap/tests/swap.test.ts @@ -76,7 +76,7 @@ describe("Swap", () => { const propellerHeadsQuote = quotes.find( (q) => q.provider === ProviderName.propellerHeads ); - if (quotes?.length > 3) { + if (quotes?.length > 4) { const rangoQuote = quotes.find((q) => q.provider === ProviderName.rango); expect(rangoQuote!.provider).to.be.eq(ProviderName.rango); } @@ -102,7 +102,7 @@ describe("Swap", () => { toToken, toAddress: fromAddress, }); - expect(quotes?.length).to.be.gte(4); + expect(quotes?.length).to.be.gte(5); const oneInceQuote = quotes.find( (q) => q.provider === ProviderName.oneInch );