Code Monkey home page Code Monkey logo

looksrare-sdk's Introduction

@looksrare/sdk

GitHub package.json version GitHub GitHub Workflow Status

This SDK is a collection of tools used to interact with the LooksRare API and smart contracts.

Usage

This package has a peer dependency on etherjs.

Install with

yarn add @looksrare/sdk ethers

or

npm install @looksrare/sdk ethers --save

Documentation

Types

Typescript types are exported from the package and can be used in your application.

ABIs

The SDK exposes most of the LooksRare contract ABIs. For convenience, some commonly used ABIs are also exported. If you need other ABIs, you can open an issue.

import {
  AggregatorFeeSharingWithUniswapV3Abi,
  ERC20Abi,
  ERC721Abi,
  ERC1155Abi,
  FeeSharingSystemAbi,
  IExecutionStrategyAbi,
  LooksRareAirdropAbi,
  LooksRareExchangeAbi,
  MultiRewardsDistributorAbi,
  PrivateSaleWithFeeSharingAbi,
  ReverseRecordsAbi,
  RoyaltyFeeManagerAbi,
  RoyaltyFeeRegistryAbi,
  RoyaltyFeeSetterAbi,
  StakingPoolForUniswapV2TokensAbi,
  TokenDistributorAbi,
  TradingRewardsDistributorAbi,
  WETHAbi,
  TransferSelectorNFTAbi,
} from "@looksrare/sdk";

You can also export the JSON file directly:

import wethAbi from "@looksrare/sdk/dist/abis/WETHAbi.json";

Constants

Addresses

An object containing all the contract addresses for each supported chain. Refer to the Constant type to see the complete list of addresses.

import { addressesByNetwork, SupportedChainId } from "@looksrare/sdk";
const addresses = addressesByNetwork[SupportedChainId.MAINNET];

Chains

An object containing data related to supported chains. Refer to the Constant type to see the complete list of addresses.

import { CHAIN_INFO, SupportedChainId } from "@looksrare/sdk";
const currentChainInfo = CHAIN_INFO[SupportedChainId.MAINNET];

Signatures

Helpers used to build the signed typed data.

import { BigNumber } from "ethers";
import { MakerOrder, signMakerOrder, SupportedChainId } from "@looksrare/sdk";

// This is used to support different strategies. default value is just and empty array
// Types and values need to match, e.g { types: ["address"], values: [privateBuyer] } for a private sale
const paramsTypes = [];
const paramsValue = [];

const makerOrder: MakerOrder = {
  // true --> ask / false --> bid
  isOrderAsk,
  // signer address of the maker order
  signer,
  // collection address
  collection,
  // Price in WEI
  price,
  // Token ID
  tokenId,
  // amount of tokens to sell/purchase (must be 1 for ERC721, 1+ for ERC1155)
  amount,
  // strategy for trade execution (e.g., DutchAuction, StandardSaleForFixedPrice), see addresses in the SDK
  strategy,
  // currency address
  currency,
  // order nonce (must be unique unless new maker order is meant to override existing one e.g., lower ask price)
  nonce,
  // startTime timestamp in seconds
  startTime,
  // endTime timestamp in seconds
  endTime,
  // minimum ratio to be received by the user (per 10000)
  minPercentageToAsk: BigNumber.from(10000).sub(protocolFees.add(creatorFees)).toNumber(),
  // params (e.g., price, target account for private sale)
  params: paramsValue,
};

const signatureHash = await signMakerOrder(signer, SupportedChainId.MAINNET, makerOrder, paramsTypes);

Dev

Setup

Install dependencies with yarn

  • Dev: yarn dev
  • Build: yarn build

Release

  • Create a Personal access token (Don't change the default scope)
  • Create an .env (copy .env.template) and set you github personal access token.
  • yarn release will run all the checks, build, and publish the package, and publish the github release note.

looksrare-sdk's People

Contributors

0xshisui avatar niratodev avatar 0xjurassicpunk avatar wjpg avatar dependabot[bot] avatar hexacroes 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.