Catalog npm
Back to packageRELEASE DETAILS

4.9.3-rc.1

npm

1inch-limit-order-sdk

SDK for 1inch Limit Order Protocol

Published11 Sept 2024
Direct dependencies27
Transitive dependenciesNot calculated

README

Current package documentation

1inch Limit Order Protocol v4 SDK

Installation

npm install '@1inch/limit-order-sdk'

Docs

Usage examples

Order creation

import {LimitOrder, MakerTraits, Address} from "@1inch/limit-order-sdk"
import {Wallet} from 'ethers'

// it is a well-known test private key, do not use it in production
const privKey =
    '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'

const maker = new Wallet(privKey)
const expiresIn = 120n // 2m
const expiration = BigInt(Math.floor(Date.now() / 1000)) + expiresIn

// see MakerTraits.ts
const makerTraits = MakerTraits.default().withExpiration(expiration)

const order = new LimitOrder({
    makerAsset: new Address('0xdac17f958d2ee523a2206206994597c13d831ec7'),
    takerAsset: new Address('0x111111111117dc0aa78b770fa6a738034120c302'),
    makingAmount: 100_000000n, // 100 USDT
    takingAmount: 10_00000000000000000n, // 10 1INCH
    maker: new Address(maker.address),
    // salt? : bigint
    // receiver? : Address
}, makerTraits)

const typedData = order.getTypedData()
const signature = await maker.signTypedData(
    typedData.domain,
    {Order: typedData.types.Order},
    typedData.message
)

RFQ Order creation

RfqOrder is a light, gas efficient version of LimitOrder, but it does not support multiple fills and extension Mainly used by market makers

import {RfqOrder, Address, randBigInt} from "@1inch/limit-order-sdk"
import {UINT_40_MAX} from "@1inch/byte-utils"
import {Wallet} from 'ethers'

// it is a well-known test private key, do not use it in production
const privKey =
    '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'

const maker = new Wallet(privKey)
const expiresIn = 120n // 2m
const expiration = BigInt(Math.floor(Date.now() / 1000)) + expiresIn

const order = new RfqOrder({
    makerAsset: new Address('0xdac17f958d2ee523a2206206994597c13d831ec7'),
    takerAsset: new Address('0x111111111117dc0aa78b770fa6a738034120c302'),
    makingAmount: 100_000000n, // 100 USDT
    takingAmount: 10_00000000000000000n, // 10 1INCH
    maker: new Address(maker.address)
}, {
    allowedSender: new Address('0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'),
    expiration,
    nonce: randBigInt(UINT_40_MAX),
})

const typedData = order.getTypedData()
const signature = await maker.signTypedData(
    typedData.domain,
    {Order: typedData.types.Order},
    typedData.message
)

API

import {Api, FetchProviderConnector, LimitOrder, HttpProviderConnector} from '@1inch/limit-order-sdk'

const networkId = 1 // ethereum
const api = new Api({
    networkId,
    authKey: 'key', // get it at https://portal.1inch.dev/
    httpConnector: new FetchProviderConnector() // or use any connector which implements `HttpProviderConnector`
})

// submit order 
const order = new LimitOrder(...) /// see `Order creation` section
const signature = '0x'
await api.submitOrder(order, signature)

// get order by hash
const orderHash = order.getOrderHash(networkId)
const orderInfo = await api.getOrderByHash(orderHash)

// get orders by maker
const orders = await api.getOrdersByMaker(order.maker)

With axios as http provider

axios package should be installed

import {Api, LimitOrder} from "@1inch/limit-order-sdk"
import {AxiosProviderConnector} from '@1inch/limit-order-sdk/axios'

const api = new Api({
    networkId: 1, // ethereum
    authKey: 'key', // get it at https://portal.1inch.dev/
    httpConnector: new AxiosProviderConnector()
})

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 28

Native requirements
27 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
@1inch/byte-utils
Environment
{
  "local_name": "@1inch/byte-utils",
  "alias": false,
  "peer_metadata": null
}
2.2.1runtime
ethers
Environment
{
  "local_name": "ethers",
  "alias": false,
  "peer_metadata": null
}
6.13.1runtime
@1inch/eslint-config
Environment
{
  "local_name": "@1inch/eslint-config",
  "alias": false,
  "peer_metadata": null
}
1.4.3development
@1inch/tsconfig
Environment
{
  "local_name": "@1inch/tsconfig",
  "alias": false,
  "peer_metadata": null
}
1.0.7development
@swc/core
Environment
{
  "local_name": "@swc/core",
  "alias": false,
  "peer_metadata": null
}
1.3.66development
@swc/jest
Environment
{
  "local_name": "@swc/jest",
  "alias": false,
  "peer_metadata": null
}
0.2.26development
@types/jest
Environment
{
  "local_name": "@types/jest",
  "alias": false,
  "peer_metadata": null
}
29.5.2development
@types/node
Environment
{
  "local_name": "@types/node",
  "alias": false,
  "peer_metadata": null
}
^18.19.36development
@typescript-eslint/eslint-plugin
Environment
{
  "local_name": "@typescript-eslint/eslint-plugin",
  "alias": false,
  "peer_metadata": null
}
~5.59.11development
@typescript-eslint/parser
Environment
{
  "local_name": "@typescript-eslint/parser",
  "alias": false,
  "peer_metadata": null
}
~5.51.0development
axios
Environment
{
  "local_name": "axios",
  "alias": false,
  "peer_metadata": null
}
^1.7.2development
eslint
Environment
{
  "local_name": "eslint",
  "alias": false,
  "peer_metadata": null
}
8.41.0development
eslint-config-prettier
Environment
{
  "local_name": "eslint-config-prettier",
  "alias": false,
  "peer_metadata": null
}
~8.3.0development
eslint-config-standard
Environment
{
  "local_name": "eslint-config-standard",
  "alias": false,
  "peer_metadata": null
}
^17.1.0development
eslint-import-resolver-typescript
Environment
{
  "local_name": "eslint-import-resolver-typescript",
  "alias": false,
  "peer_metadata": null
}
3.5.5development
eslint-plugin-import
Environment
{
  "local_name": "eslint-plugin-import",
  "alias": false,
  "peer_metadata": null
}
~2.26.0development
eslint-plugin-n
Environment
{
  "local_name": "eslint-plugin-n",
  "alias": false,
  "peer_metadata": null
}
^16.6.2development
eslint-plugin-prettier
Environment
{
  "local_name": "eslint-plugin-prettier",
  "alias": false,
  "peer_metadata": null
}
^4.2.1development
eslint-plugin-promise
Environment
{
  "local_name": "eslint-plugin-promise",
  "alias": false,
  "peer_metadata": null
}
^6.2.0development
eslint-plugin-unused-imports
Environment
{
  "local_name": "eslint-plugin-unused-imports",
  "alias": false,
  "peer_metadata": null
}
^2.0.0development
generate-changelog
Environment
{
  "local_name": "generate-changelog",
  "alias": false,
  "peer_metadata": null
}
^1.8.0development
jest
Environment
{
  "local_name": "jest",
  "alias": false,
  "peer_metadata": null
}
29.5.0development
prettier
Environment
{
  "local_name": "prettier",
  "alias": false,
  "peer_metadata": null
}
^2.8.8development
tsdoc-markdown
Environment
{
  "local_name": "tsdoc-markdown",
  "alias": false,
  "peer_metadata": null
}
0.3.0development
tslib
Environment
{
  "local_name": "tslib",
  "alias": false,
  "peer_metadata": null
}
2.6.3development
typescript
Environment
{
  "local_name": "typescript",
  "alias": false,
  "peer_metadata": null
}
4.9.4development
assert
Environment
{
  "local_name": "assert",
  "alias": false,
  "peer_metadata": {
    "optional": true
  }
}
^2.0.0peer
axios
Environment
{
  "local_name": "axios",
  "alias": false,
  "peer_metadata": {
    "optional": true
  }
}
>=1 <2peer

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "integrity": "sha512-A4hOhyrQjeEuyIxpXCw4Mj6hdxTyP1ECIEkGVFk5j/N1VBpNvGYzs20LzFLqB192q2VOxsuTFuirzzDBWqHjug==",
  "shasum": "bed6932f26fce3faf18adb815289e467021c8338",
  "tarball": "https://registry.npmjs.org/1inch-limit-order-sdk/-/1inch-limit-order-sdk-4.9.3-rc.1.tgz",
  "fileCount": 177,
  "unpackedSize": 424568,
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEQCIB5dXBczPBHOdD/6DKqgErbPmUhmH2os477jslX0sGBCAiBXhaXziadCHONs0vx80GlzDR2BjR61nr6Dhk1pM0gzsA=="
    }
  ]
}

Repository

PENDING
1inch/limit-order-sdk

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 18:30 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:021589621c275b5d0b9d8912c8b200489b6510fb8b7e461b8fa6b751bf5e0b8d

Other collected versions

View all collected versions →