1.1.0 • Published 2 years ago

@arun89-crypto/hypersdk v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

HyperSDK 🌀

Hyper Bridge Project: Seamlessly links Base & Optimism blockchains via Layer Zero Router. Swap native & wrapped tokens effortlessly. Empowers devs with user-friendly SDK for cross-chain interaction. Unlocking DeFi potential & blockchain adoption.

NATIVE TO WRAPPED NATIVE SWAPPER

Cross Chain Swap Time : 10 sec to 1 min

Simple to use

import { HyperSwapper } from '@arun89-crypto/hypersdk';
import { ethers } from 'ethers';

const main = async () => {
  // Declaring the providers
  const provider1 = new ethers.JsonRpcProvider(RPC_OPT);
  const provider2 = new ethers.JsonRpcProvider(RPC_BASE);

  // Declaring the signers
  const signer1 = new ethers.Wallet(P_KEY, provider1);
  const signer2 = new ethers.Wallet(P_KEY, provider2);

  // Initiating the swapper
  const swapper = new HyperSwapper({
    rpc_url_1: RPC_OPT, // RPC URL : chain 1
    rpc_url_2: RPC_BASE, // RPC URL : chain 2
    name_1: 'OPTIMISM', // Chain 1 Name
    name_2: 'BASE', // Chain 2 Name
    signer1: signer1, // Signer : chain 1
    signer2: signer2, // Signer : chain 2
  });

  // Swapping from Optimism -> Base
  const swap = await swapper.Swap1to2('0.0001');

  console.log(swap);
  /*
  Returns :

  interface SwapResult {
    result: TransactionResult;
    TransactionHash?: string;
    TransactionData?: string;
  }

  enum TransactionResult {
    ACCEPTED,
    REJECTED,
  }
  */
};

Supported Chains (Testnet)

  • Optimism Göerli
  • Base Göerli
  • Polygon Mumbai (Coming soon .....)
  • Ethereum Göerli (Coming soon .....)

Tech Stack

  • Typescript
  • Solidity
  • EthersJS
  • Layer Zero
  • UniswapV3

How to install ?

npm i @arun89-crypto/hypersdk
--
yarn add @arun89-crypto/hypersdk

Config

ParamOptionalDescription
rpc_url_1trueRPC URL for chain 1
rpc_url_2trueRPC URL for chain 2
name_1trueName of chain 1
name_2trueName of chain 2
signer_1trueEthers Signer for chain 1
signer_2trueEthers Signer for chain 2

Functions

NameParamsDescription
Swap1to2_amount:string Eg : "0.001"Swap assets from chain 1 to chain 2
Swap2to1_amount:string Eg : "0.001"Swap assets from chain 2 to chain 1
_estimateFeeFrom1to2Return the estimated relayer fee from chain 1 to chain 2
_estimateFeeFrom2to1Return the estimated relayer fee from chain 2 to chain 1
_getTransactionStatusLZ_1txn_hash:stringReturn the transaction status for chain 1
_getTransactionStatusLZ_2txn_hash:stringReturn the transaction status for chain 2
_getFullTransactionStatusLZ_1txn_hash:stringReturn the full transaction status for chain 1
_getFullTransactionStatusLZ_2txn_hash:stringReturn the full transaction status for chain 2
getNativeWrappedTokenAddressChain1Return the tWETH address for chain 1
getNativeWrappedTokenAddressChain2Return the tWETH address for chain 2
getNativeWrappedTokenBalanceContract1Return the tWETH balance for chain 1 contract
getNativeWrappedTokenBalanceContract2Return the tWETH balance for chain 2 contract
1.1.0

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago