Skip to content

Commit

Permalink
devop: 🔧 propeller heads
Browse files Browse the repository at this point in the history
  • Loading branch information
kvhnuke committed Mar 19, 2024
1 parent 25ba092 commit 9c127f9
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 33 deletions.
2 changes: 1 addition & 1 deletion packages/swap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"scripts": {
"build": "tsup src/index.ts --format esm,cjs --dts --clean",
"lint": "prettier --write .",
"test": "ts-mocha -p tsconfig.json tests/**/*.test.ts"
"test": "ts-mocha -p tsconfig.json tests/**/prope*.test.ts"
},
"engines": {
"node": ">=14.15.0"
Expand Down
5 changes: 2 additions & 3 deletions packages/swap/src/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,13 @@ const FEE_CONFIGS: ProvidersFeeConfigs = {
fee: 0.025,
},
},
// TODO: update referrer addresses
[ProviderName.propellerHeads]: {
[WalletIdentifier.enkrypt]: {
referrer: "0xabe295bac4b5bce0edcf42d180a3a952ef718b9e",
referrer: "0x48ae878bf9f752ee65679c017e32e4cafac51696",
fee: 0.00875,
},
[WalletIdentifier.mew]: {
referrer: "0x48ae878bf9f752ee65679c017e32e4cafac51696",
referrer: "0x4718cbb9f2bce9c587127b81d5ea88f44cd0324b",
fee: 0.025,
},
},
Expand Down
31 changes: 3 additions & 28 deletions packages/swap/src/providers/propeller-heads/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import dotenv from "dotenv";
import Web3Eth from "web3-eth";
import { numberToHex, stringToHex, toBN } from "web3-utils";
import {
Expand Down Expand Up @@ -37,14 +36,6 @@ import {
} from "../../utils/approvals";
import { isEVMAddress } from "../../utils/common";

dotenv.config();

const { PROPELLER_HEADS_API_KEY } = process.env;

if (!PROPELLER_HEADS_API_KEY) {
throw new Error("PROPELLER_HEADS_API_KEY is not set");
}

const supportedNetworks: {
[key in SupportedNetworkName]?: { approvalAddress: string; chainId: string };
} = {
Expand All @@ -56,22 +47,16 @@ const supportedNetworks: {
approvalAddress: "0xe832e655E4C3c36b2be5256915ECF8536a642f59",
chainId: "324",
},
[SupportedNetworkName.Starknet]: {
approvalAddress:
"0x060b1a6a696cbd77df0b6be6a2a951cf0fc7b951304a9371eac2f5d05a77357f",
chainId: "0x534e5f4d41494e",
},
};

const NetworkNamesToSupportedProppellerHeadsBlockchains: Partial<
Record<SupportedNetworkName, string>
> = {
[SupportedNetworkName.Ethereum]: "ethereum",
[SupportedNetworkName.Zksync]: "zksync",
[SupportedNetworkName.Starknet]: "starknet",
};

const BASE_URL = "https://api.propellerheads.xyz/partner/v2";
const BASE_URL = "https://partners.mewapi.io/propellerheads/v2";

class PropellerHeads extends ProviderClass {
tokenList: TokenType[];
Expand Down Expand Up @@ -169,20 +154,10 @@ class PropellerHeads extends ProviderClass {
return fetch(`${BASE_URL}/solver/quote?${params.toString()}`, {
method: "POST",
body: JSON.stringify(body),
headers: {
"x-api-key": PROPELLER_HEADS_API_KEY,
accept: "application/json",
"Content-Type": "application/json",
},
})
.then((res) => res.json())
.then(async (response: PropellerHeadsResponseType) => {
const transactions: SwapTransaction[] = [];
const transactionType: TransactionType =
this.network === SupportedNetworkName.Starknet
? TransactionType.generic
: TransactionType.evm;

if (options.fromToken.address !== NATIVE_TOKEN_ADDRESS) {
const approvalTxs = await getAllowanceTransactions({
infinityApproval: meta.infiniteApproval,
Expand All @@ -194,15 +169,15 @@ class PropellerHeads extends ProviderClass {
});
transactions.push(...approvalTxs);
}
console.log(response);
transactions.push({
from: options.fromAddress,
gasLimit: GAS_LIMITS.swap,
to: options.fromAddress,
value: numberToHex(options.amount),
data: stringToHex(JSON.stringify(response)),
type: transactionType,
type: TransactionType.evm,
});

return {
transactions,
toTokenAmount: toBN(response.quotes[0].buy_amount),
Expand Down
1 change: 0 additions & 1 deletion packages/types/src/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ export enum NetworkNames {
Dogecoin = "DOGE",
ArtheraTest = "AATest",
Arthera = "AA",
Starknet = "Starknet",
FormTestnet = "FormTestnet",
}

Expand Down

0 comments on commit 9c127f9

Please sign in to comment.