Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
@uniswap/uniswapx-sdk
Advanced tools
SDK for the UniswapX protocol
The SDK contains bindings for two main flows: parsing serialized orders & building new 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
import { parseOrder, Order, OrderValidation } from '@uniswap/uniswapx-sdk';
const serializedOrder = '0x1111222233334444555500000000234300234...';
const order: Order = parseOrder(serializedOrder);
const orderData = order.info;
const orderHash = order.hash();
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
}
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.
FAQs
SDK for the UniswapX protocol
The npm package @uniswap/uniswapx-sdk receives a total of 4,678 weekly downloads. As such, @uniswap/uniswapx-sdk popularity was classified as popular.
We found that @uniswap/uniswapx-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 23 open source maintainers collaborating on the project.
Did you know?
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.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.