Giter Site home page Giter Site logo

ocdbytes / hypersdk Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 1.82 MB

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.

License: MIT License

Solidity 31.80% TypeScript 38.59% Shell 0.18% JavaScript 29.44%
base-l2 defi layerzero optimism-l2 sdk solidity typescript uniswap

hypersdk's Introduction

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

Param Optional Description
rpc_url_1 true RPC URL for chain 1
rpc_url_2 true RPC URL for chain 2
name_1 true Name of chain 1
name_2 true Name of chain 2
signer_1 true Ethers Signer for chain 1
signer_2 true Ethers Signer for chain 2

Functions

Name Params Description
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
_estimateFeeFrom1to2 Return the estimated relayer fee from chain 1 to chain 2
_estimateFeeFrom2to1 Return the estimated relayer fee from chain 2 to chain 1
_getTransactionStatusLZ_1 txn_hash:string Return the transaction status for chain 1
_getTransactionStatusLZ_2 txn_hash:string Return the transaction status for chain 2
_getFullTransactionStatusLZ_1 txn_hash:string Return the full transaction status for chain 1
_getFullTransactionStatusLZ_2 txn_hash:string Return the full transaction status for chain 2
getNativeWrappedTokenAddressChain1 Return the tWETH address for chain 1
getNativeWrappedTokenAddressChain2 Return the tWETH address for chain 2
getNativeWrappedTokenBalanceContract1 Return the tWETH balance for chain 1 contract
getNativeWrappedTokenBalanceContract2 Return the tWETH balance for chain 2 contract

hypersdk's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.