Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@brydge-network/direct-nft-protocol

Package Overview
Dependencies
Maintainers
7
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@brydge-network/direct-nft-protocol

  • 1.9.1
  • latest
  • npm
  • Socket score

Version published
Maintainers
7
Created
Source

Brydge - Multichain Portal

Brydge is a multichain protocol built on top of Stargate and LayerZero that enables users to buy digital assets and invest in DeFi using any token from any chain.

Setup

  • include MNEMONIC in a .env file
  • yarn install

Testing

yarn test
yarn test:integration

  • Files:
    • Unit Tests
    • Integration Tests

Design

  • See Docs for more detailed overview
  • There are two primary contracts deployed on each chain that handle cross-chain transactions: MultichainPortal and MultichainRouter.
    • MultichainPortal contains all the logic to swap tokens, send transactions cross chain, and execute functionality on the destination chain.
    • MultichainRouter handles all direct interactions and approvals - transfering tokens and subsequently calling functions present in MultichainPortal. The router contract was introduced to handle a specific vulnerability that was exploited here

Functions

Four main functions house all functionality needed to support purchasing digital assets using any token on any chain:

function swapERC20AndCall(
    address tokenIn,
    uint256 amountIn,
    address user,
    address swapRouter,
    bytes calldata swapArguments,
    Types.ICall[] calldata calls
) external;

function swapNativeAndCall(
    address swapRouter,
    bytes calldata swapArguments,
    Types.ICall[] calldata calls
) external payable;

function swapERC20AndSend(
    uint amountIn,
    uint amountUSDC,
    address user,
    address tokenIn,
    address swapRouter,
    bytes calldata swapArguments,
    StargateArgs memory stargateArgs
) external payable;

function swapNativeAndSend(
    uint amountIn,
    uint amountUSDC,
    uint lzFee,
    address user,
    address swapRouter,
    bytes calldata swapArguments,
    IMultichainPortal.StargateArgs memory stargateArgs
) external payable;

All four functions are present both in MultichainPortal.sol and MultichainRouter.sol. They are intended to be called by users (through our widget) in MultichainRouter.sol which forwards the call to MultichainPortal.sol where the primary logic is stored. The first two functions (swapERC20AndCall and swapNativeAndCall) are utilized when a user has any arbitrary token and wants to purchase/interact with a dapp on the same chain. Information in order to perform the swap into the desired token is passed in through arguments swapRouter and swapArguments and any subsequent contract interactions are encoded and passed as an array of calldata that is looped through and executed. The last two functions (swapERC20AndSend and swapNativeAndSend) are utilized when a user has any arbitrary token but wants to purchase/interact with a dapp on a different chain. Here we utilized Stargate's cross-chain usdc pools and messaging protocol in order to:

  1. Swap tokens into usdc on the source chain
  2. Use stargate to send them (and a payload) cross chain to our MultichainPortal contract deployed on the destination chain, and
  3. Decode the payload into arguments in order to call swapERC20AndCall on the destination cahin.

LICENSING

The primary license for Brydge is the Business Source License 1.1 (BUSL-1.1). see LICENSE.

FAQs

Package last updated on 02 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc