Skip to content

Commit

Permalink
fix: 🐛 propellerheads
Browse files Browse the repository at this point in the history
  • Loading branch information
kvhnuke committed Mar 21, 2024
1 parent 1e2ff20 commit 3e2979a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
11 changes: 5 additions & 6 deletions packages/swap/src/providers/propeller-heads/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,14 @@ 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: [
{
sell_token: options.fromToken.address,
buy_token: options.toToken.address,
sell_amount: options.amount.toString(),
origin_address: options.fromAddress,
receiver: options.toAddress,
},
],
};
Expand All @@ -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),
Expand All @@ -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,
});
Expand Down
15 changes: 10 additions & 5 deletions packages/swap/tests/propeller-heads.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 }
);
Expand Down Expand Up @@ -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 }
);
Expand Down
4 changes: 2 additions & 2 deletions packages/swap/tests/swap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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
);
Expand Down

1 comment on commit 3e2979a

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.