Catalog npm
PACKAGE EXPLORERView in registry

@0xabcdefg/uniswapx-sdk

npm

SDK for the UniswapX protocol

ethereumuniswap
Versions collected1
Direct dependencies24From release 1.0.0
Last observed20 Oct, 22:39 UTC

README

Current package documentation

uniswapx-sdk

SDK for the UniswapX protocol

Usage

The SDK contains bindings for two main flows: parsing serialized orders & building new orders.

Building & Signing Orders

import { DutchOrder, NonceManager } from '@uniswap/uniswapx-sdk';
import { ethers } from 'ethers';

const provider = new ethers.providers.JsonRpcProvider(RPC_URL);
const account = await provider.getSigner().getAddress(); 
const nonceMgr = new NonceManager(provider, 1); 
const nonce = await nonceMgr.useNonce(account); 

const chainId = 1;
const builder = new DutchOrderBuilder(chainId);
const order = builder
  .deadline(deadline)
  .decayEndTime(deadline)
  .decayStartTime(deadline - 100)
  .nonce(nonce)
  .input({
    token: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
    amount: BigNumber.from('1000000'),
  })
  .output({
    token: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
    startAmount: BigNumber.from('1000000000000000000'),
    endAmount: BigNumber.from('900000000000000000'),
    recipient: '0x0000000000000000000000000000000000000000',
  })
  .build();
 
// Sign the built order 
const { domain, types, values } = order.permitData();
const signature = wallet._signTypedData(domain, types, values);

const serializedOrder = order.serialize();
// submit serializedOrder and signature to order pool

Parsing Orders

import { DutchOrder, Order } from '@uniswap/uniswapx-sdk';

const serializedOrder = '0x1111222233334444555500000000234300234...';
const chainId = 1; 

const order: Order = DutchOrder.parse(serializedOrder, chainId);

const orderData = order.info;
const orderHash = order.hash();

Validating Orders

import { ethers } from 'ethers';
import { OrderValidator } from 'uniswapx-sdk';

const provider = new ethers.providers.JsonRpcProvider(RPC_URL);
const validator = new OrderValidator(provider, CHAIN_ID); 
const orders: SignedOrder[] = [
  {
    order: order1, 
    signature: signature1
  }, 
  {
    order: order2, 
    signature: signature2
  }
]; 

try {
  const statusList: OrderValidation[] = await validator.validateBatch(orders); 
  // Do something with list of statuses 
}
catch(e) {
  // Handle error
}

Order Object

serialize()

Returns an abi-encoded serialization of the order. This serialized format is passed into the corresponding reactor contract for execution.

getSigner(signature)

Recovers the address which created the given signature over the order. Used to determine the order maker.

permitData()

Returns the domain, types, and values used to generate an EIP-712 signature over the order. Note that this signature both approves the release of the order's input tokens and the execution of the order itself.

hash()

Returns the order hash. This is used as a key to track order fulfillment on-chain. It may also be useful as a unique order identifier for off-chain purposes.

Downloads & popularity

Awaiting observations

No metric observations yet

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

Versions 1

Collected releases
VersionPublishedDirect dependenciesOpen version
1.0.0Registry latest30 Aug 202524

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
uniswap/sdks

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 22:39 UTC

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

Record identity

package:40aa9d16fbab88153bcbe4897b4f770a98e61f628d0e30ab0326dab4b239e9ea