Skip to content

Commit

Permalink
wip: add changelly to rootstock
Browse files Browse the repository at this point in the history
  • Loading branch information
NickKelly1 committed Aug 15, 2024
1 parent 8c76488 commit 5ee1d99
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 2 deletions.
25 changes: 25 additions & 0 deletions packages/swap/src/common/supportedNetworks.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { SignerType } from "@enkryptcom/types";
import { NetworkInfo, NetworkType, SupportedNetworkName } from "../types";

/**
* Sometimes you can get decimals and token info from here `https://raw.githubusercontent.com/MyEtherWallet/ethereum-lists/master/dist/master-file.json`
*/
const NetworkDetails: Record<SupportedNetworkName, NetworkInfo> = {
[SupportedNetworkName.Bitcoin]: {
id: SupportedNetworkName.Bitcoin,
Expand Down Expand Up @@ -239,6 +242,28 @@ const NetworkDetails: Record<SupportedNetworkName, NetworkInfo> = {
signerType: [SignerType.secp256k1btc],
type: NetworkType.Bitcoin,
},
[SupportedNetworkName.Rootstock]: {
id: SupportedNetworkName.Rootstock,
decimals: 18,
logoURI: "https://coin-images.coingecko.com/coins/images/5070/large/RBTC-logo.png?1718152038",
name: "Rootstock",
symbol: "RBTC",
cgId: "rbtc",
rank: 19,
signerType: [SignerType.secp256k1btc],
type: NetworkType.EVM,
},
// [SupportedNetworkName.Rootstock]: {
// id: SupportedNetworkName.Rootstock,
// decimals: 18,
// logoURI: "https://coin-images.coingecko.com/coins/images/5070/large/RBTC-logo.png?1718152038",
// name: "Rootstock",
// symbol: "RBTC",
// cgId: "rbtc",
// rank: 19,
// signerType: [SignerType.secp256k1btc],
// type: NetworkType.EVM,
// },
};
export const isSupportedNetwork = (networkName: SupportedNetworkName) =>
!!NetworkDetails[networkName];
Expand Down
1 change: 1 addition & 0 deletions packages/swap/src/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const TOKEN_LISTS: {
[NetworkNames.ZkSync]: `https://raw.githubusercontent.com/enkryptcom/dynamic-data/main/swaplists/${SupportedNetworkName.Zksync}.json`,
[NetworkNames.Base]: `https://raw.githubusercontent.com/enkryptcom/dynamic-data/main/swaplists/${SupportedNetworkName.Base}.json`,
[NetworkNames.MaticZK]: `https://raw.githubusercontent.com/enkryptcom/dynamic-data/main/swaplists/${SupportedNetworkName.MaticZK}.json`,
[NetworkNames.Rootstock]: `https://raw.githubusercontent.com/enkryptcom/dynamic-data/main/swaplists/${SupportedNetworkName.Rootstock}.json`,
};

const CHANGELLY_LIST =
Expand Down
2 changes: 1 addition & 1 deletion packages/swap/src/providers/changelly/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ class Changelly extends ProviderClass {
const result = response.result[0];
const evmGasLimit =
options.fromToken.address === NATIVE_TOKEN_ADDRESS &&
options.fromToken.type === NetworkType.EVM
options.fromToken.type === NetworkType.EVM
? 21000
: toBN(GAS_LIMITS.transferToken).toNumber();
const retResponse: ProviderQuoteResponse = {
Expand Down
10 changes: 10 additions & 0 deletions packages/swap/src/providers/changelly/supported.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { isPolkadotAddress, isEVMAddress } from "../../utils/common";
import { SupportedNetworkName } from "../../types";

/**
* ```sh
* curl https://partners.mewapi.io/changelly-v2 -X POST -H Accept:application/json -H Content-Type:application/json --data '{"id":"1","jsonrpc":"2.0","method":"getCurrenciesFull","params":{}}'
* ````
*/
const supportedNetworks: {
[key in SupportedNetworkName]?: {
changellyName: string;
Expand Down Expand Up @@ -50,6 +55,11 @@ const supportedNetworks: {
[SupportedNetworkName.Dogecoin]: {
changellyName: "doge",
},
[SupportedNetworkName.Rootstock]: {
changellyName: "rootstock",
// changellyName: "RBTC",
// isAddress: (address: string) => Promise.resolve(isEVMAddress(address)),
},
};

export default supportedNetworks;
27 changes: 26 additions & 1 deletion packages/swap/src/providers/rango/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,25 @@ import { isEVMAddress } from "../../utils/common";

const RANGO_PUBLIC_API_KEY = "ee7da377-0ed8-4d42-aaf9-fa978a32b18d";
const rangoClient = new RangoClient(RANGO_PUBLIC_API_KEY);

/**
* `name` is the blockchain id on Rango
*
* You can use the Rango API to get a list of tokens to figure out the Rango name of a network
*
* @see https://rango-api.readme.io/reference/meta
*
* ```sh
* curl 'https://api.rango.exchange/basic/meta?apiKey=c6381a79-2817-4602-83bf-6a641a409e32' -H 'Accept:application/json'
* ```
*/
const supportedNetworks: {
[key in SupportedNetworkName]?: { chainId: string; name: string };
[key in SupportedNetworkName]?: {
/** Standard base10 chain ID, can be obtained from `https://chainlist.org` */
chainId: string;
/** Rango name (Rango's identifier for the chain) of a network */
name: string;
};
} = {
[SupportedNetworkName.Ethereum]: {
chainId: "1",
Expand Down Expand Up @@ -86,6 +103,14 @@ const supportedNetworks: {
chainId: "1284",
name: "MOONBEAM",
},
[SupportedNetworkName.Blast]: {
chainId: "81457",
name: "BLAST",
},
[SupportedNetworkName.Telos]: {
chainId: "40",
name: "TELOS",
},
};

class Rango extends ProviderClass {
Expand Down
3 changes: 3 additions & 0 deletions packages/swap/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ export enum SupportedNetworkName {
Zksync = NetworkNames.ZkSync,
Base = NetworkNames.Base,
MaticZK = NetworkNames.MaticZK,
Blast = NetworkNames.Blast,
Telos = NetworkNames.Telos,
Rootstock = NetworkNames.Rootstock,
}

// eslint-disable-next-line no-shadow
Expand Down

1 comment on commit 5ee1d99

@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.