@uniswap/universal-router-sdk 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # narhwal-sdk
@@ -0,0 +1,7 @@
1
+ import { RoutePlanner } from '../utils/routerCommands';
2
+ export declare type TradeConfig = {
3
+ allowRevert: boolean;
4
+ };
5
+ export interface Command {
6
+ encode(planner: RoutePlanner, config: TradeConfig): void;
7
+ }
@@ -0,0 +1,41 @@
1
+ import { BigNumberish } from 'ethers';
2
+ import { SeaportData } from './protocols/seaport';
3
+ import { FoundationData } from './protocols/foundation';
4
+ import { NFTXData } from './protocols/nftx';
5
+ import { NFT20Data } from './protocols/nft20';
6
+ import { RoutePlanner } from '../utils/routerCommands';
7
+ import { Command, TradeConfig } from './Command';
8
+ import { LooksRareData } from './protocols/looksRare';
9
+ import { SudoswapData } from './protocols/sudoswap';
10
+ import { CryptopunkData } from './protocols/cryptopunk';
11
+ import { X2Y2Data } from './protocols/x2y2';
12
+ export declare type SupportedProtocolsData = SeaportData | FoundationData | NFTXData | LooksRareData | X2Y2Data | CryptopunkData | NFT20Data | SudoswapData;
13
+ export declare abstract class NFTTrade<T> implements Command {
14
+ readonly orders: T[];
15
+ readonly market: Market;
16
+ constructor(market: Market, orders: T[]);
17
+ abstract encode(planner: RoutePlanner, config: TradeConfig): void;
18
+ abstract getBuyItems(): BuyItem[];
19
+ abstract getTotalPrice(): BigNumberish;
20
+ }
21
+ export declare type BuyItem = {
22
+ tokenAddress: string;
23
+ tokenId: BigNumberish;
24
+ tokenType: TokenType;
25
+ amount?: BigNumberish;
26
+ };
27
+ export declare enum Market {
28
+ Foundation = "foundation",
29
+ LooksRare = "looksrare",
30
+ NFT20 = "nft20",
31
+ NFTX = "nftx",
32
+ Seaport = "seaport",
33
+ Sudoswap = "Sudoswap",
34
+ Cryptopunks = "cryptopunks",
35
+ X2Y2 = "x2y2"
36
+ }
37
+ export declare enum TokenType {
38
+ ERC721 = "ERC721",
39
+ ERC1155 = "ERC1155",
40
+ Cryptopunk = "Cryptopunk"
41
+ }
@@ -0,0 +1,2 @@
1
+ export * from './protocols';
2
+ export * from './NFTTrade';
@@ -0,0 +1,16 @@
1
+ import { TradeConfig } from '../Command';
2
+ import { NFTTrade, BuyItem } from '../NFTTrade';
3
+ import { RoutePlanner } from '../../utils/routerCommands';
4
+ import { BigNumberish } from 'ethers';
5
+ export declare type CryptopunkData = {
6
+ tokenId: BigNumberish;
7
+ recipient: string;
8
+ value: BigNumberish;
9
+ };
10
+ export declare class CryptopunkTrade extends NFTTrade<CryptopunkData> {
11
+ static CRYPTOPUNK_ADDRESS: string;
12
+ constructor(orders: CryptopunkData[]);
13
+ encode(planner: RoutePlanner, config: TradeConfig): void;
14
+ getBuyItems(): BuyItem[];
15
+ getTotalPrice(): BigNumberish;
16
+ }
@@ -0,0 +1,19 @@
1
+ import { Interface } from '@ethersproject/abi';
2
+ import { BuyItem, NFTTrade } from '../NFTTrade';
3
+ import { TradeConfig } from '../Command';
4
+ import { RoutePlanner } from '../../utils/routerCommands';
5
+ import { BigNumberish } from 'ethers';
6
+ export declare type FoundationData = {
7
+ recipient: string;
8
+ tokenAddress: string;
9
+ tokenId: BigNumberish;
10
+ price: BigNumberish;
11
+ referrer: string;
12
+ };
13
+ export declare class FoundationTrade extends NFTTrade<FoundationData> {
14
+ static INTERFACE: Interface;
15
+ constructor(orders: FoundationData[]);
16
+ encode(planner: RoutePlanner, config: TradeConfig): void;
17
+ getBuyItems(): BuyItem[];
18
+ getTotalPrice(): BigNumberish;
19
+ }
@@ -0,0 +1,9 @@
1
+ export * from './cryptopunk';
2
+ export * from './foundation';
3
+ export * from './looksRare';
4
+ export * from './nft20';
5
+ export * from './nftx';
6
+ export * from './seaport';
7
+ export * from './uniswap';
8
+ export * from './sudoswap';
9
+ export * from './x2y2';
@@ -0,0 +1,44 @@
1
+ import { Interface } from '@ethersproject/abi';
2
+ import { BuyItem, NFTTrade, TokenType } from '../NFTTrade';
3
+ import { TradeConfig } from '../Command';
4
+ import { RoutePlanner } from '../../utils/routerCommands';
5
+ import { BigNumberish } from 'ethers';
6
+ export declare type MakerOrder = {
7
+ collection: string;
8
+ tokenId: BigNumberish;
9
+ isOrderAsk: true;
10
+ signer: string;
11
+ strategy: string;
12
+ currency: string;
13
+ amount: BigNumberish;
14
+ price: BigNumberish;
15
+ minPercentageToAsk: BigNumberish;
16
+ nonce: BigNumberish;
17
+ startTime: BigNumberish;
18
+ endTime: BigNumberish;
19
+ v: BigNumberish;
20
+ r: string;
21
+ s: string;
22
+ params: string;
23
+ };
24
+ export declare type TakerOrder = {
25
+ minPercentageToAsk: BigNumberish;
26
+ price: BigNumberish;
27
+ taker: string;
28
+ tokenId: BigNumberish;
29
+ isOrderAsk: boolean;
30
+ params: string;
31
+ };
32
+ export declare type LooksRareData = {
33
+ makerOrder: MakerOrder;
34
+ takerOrder: TakerOrder;
35
+ recipient: string;
36
+ tokenType: TokenType;
37
+ };
38
+ export declare class LooksRareTrade extends NFTTrade<LooksRareData> {
39
+ static INTERFACE: Interface;
40
+ constructor(orders: LooksRareData[]);
41
+ encode(planner: RoutePlanner, config: TradeConfig): void;
42
+ getBuyItems(): BuyItem[];
43
+ getTotalPrice(): BigNumberish;
44
+ }
@@ -0,0 +1,21 @@
1
+ import { Interface } from '@ethersproject/abi';
2
+ import { TradeConfig } from '../Command';
3
+ import { NFTTrade, BuyItem } from '../NFTTrade';
4
+ import { RoutePlanner } from '../../utils/routerCommands';
5
+ import { BigNumberish } from 'ethers';
6
+ export declare type NFT20Data = {
7
+ tokenAddress: string;
8
+ tokenIds: BigNumberish[];
9
+ tokenAmounts: BigNumberish[];
10
+ recipient: string;
11
+ fee: BigNumberish;
12
+ isV3: boolean;
13
+ value: BigNumberish;
14
+ };
15
+ export declare class NFT20Trade extends NFTTrade<NFT20Data> {
16
+ static INTERFACE: Interface;
17
+ constructor(orders: NFT20Data[]);
18
+ encode(planner: RoutePlanner, config: TradeConfig): void;
19
+ getBuyItems(): BuyItem[];
20
+ getTotalPrice(): BigNumberish;
21
+ }
@@ -0,0 +1,20 @@
1
+ import { Interface } from '@ethersproject/abi';
2
+ import { BuyItem, NFTTrade } from '../NFTTrade';
3
+ import { TradeConfig } from '../Command';
4
+ import { RoutePlanner } from '../../utils/routerCommands';
5
+ import { BigNumber, BigNumberish } from 'ethers';
6
+ export declare type NFTXData = {
7
+ recipient: string;
8
+ vaultAddress: string;
9
+ vaultId: BigNumberish;
10
+ tokenAddress: string;
11
+ tokenIds: BigNumberish[];
12
+ value: BigNumber;
13
+ };
14
+ export declare class NFTXTrade extends NFTTrade<NFTXData> {
15
+ static INTERFACE: Interface;
16
+ constructor(orders: NFTXData[]);
17
+ encode(planner: RoutePlanner, config: TradeConfig): void;
18
+ getBuyItems(): BuyItem[];
19
+ getTotalPrice(): BigNumberish;
20
+ }
@@ -0,0 +1,57 @@
1
+ import { BigNumber, BigNumberish } from 'ethers';
2
+ import { Interface } from '@ethersproject/abi';
3
+ import { BuyItem, NFTTrade } from '../NFTTrade';
4
+ import { TradeConfig } from '../Command';
5
+ import { RoutePlanner } from '../../utils/routerCommands';
6
+ export declare type SeaportData = {
7
+ items: Order[];
8
+ recipient: string;
9
+ };
10
+ export declare type FulfillmentComponent = {
11
+ orderIndex: BigNumberish;
12
+ itemIndex: BigNumberish;
13
+ };
14
+ export declare type OfferItem = {
15
+ itemType: BigNumberish;
16
+ token: string;
17
+ identifierOrCriteria: BigNumberish;
18
+ startAmount: BigNumberish;
19
+ endAmount: BigNumberish;
20
+ };
21
+ export declare type ConsiderationItem = OfferItem & {
22
+ recipient: string;
23
+ };
24
+ export declare type Order = {
25
+ parameters: OrderParameters;
26
+ signature: string;
27
+ };
28
+ declare type OrderParameters = {
29
+ offerer: string;
30
+ offer: OfferItem[];
31
+ consideration: ConsiderationItem[];
32
+ orderType: BigNumberish;
33
+ startTime: BigNumberish;
34
+ endTime: BigNumberish;
35
+ zoneHash: string;
36
+ zone: string;
37
+ salt: BigNumberish;
38
+ conduitKey: string;
39
+ totalOriginalConsiderationItems: BigNumberish;
40
+ };
41
+ export declare type AdvancedOrder = Order & {
42
+ numerator: BigNumber;
43
+ denominator: BigNumber;
44
+ extraData: string;
45
+ };
46
+ export declare class SeaportTrade extends NFTTrade<SeaportData> {
47
+ static INTERFACE: Interface;
48
+ static OPENSEA_CONDUIT_KEY: string;
49
+ constructor(orders: SeaportData[]);
50
+ encode(planner: RoutePlanner, config: TradeConfig): void;
51
+ getBuyItems(): BuyItem[];
52
+ getTotalPrice(): BigNumber;
53
+ private getConsiderationFulfillments;
54
+ private getAdvancedOrderParams;
55
+ private calculateValue;
56
+ }
57
+ export {};
@@ -0,0 +1,27 @@
1
+ import { Interface } from '@ethersproject/abi';
2
+ import { BuyItem, NFTTrade } from '../NFTTrade';
3
+ import { TradeConfig } from '../Command';
4
+ import { RoutePlanner } from '../../utils/routerCommands';
5
+ import { BigNumberish } from 'ethers';
6
+ declare type PairSwap = {
7
+ swapInfo: {
8
+ pair: string;
9
+ nftIds: BigNumberish[];
10
+ };
11
+ tokenAddress: string;
12
+ maxCost: BigNumberish;
13
+ };
14
+ export declare type SudoswapData = {
15
+ swaps: PairSwap[];
16
+ nftRecipient: string;
17
+ ethRecipient: string;
18
+ deadline: BigNumberish;
19
+ };
20
+ export declare class SudoswapTrade extends NFTTrade<SudoswapData> {
21
+ static INTERFACE: Interface;
22
+ constructor(orders: SudoswapData[]);
23
+ encode(planner: RoutePlanner, config: TradeConfig): void;
24
+ getBuyItems(): BuyItem[];
25
+ getTotalPrice(): BigNumberish;
26
+ }
27
+ export {};
@@ -0,0 +1,14 @@
1
+ import { RoutePlanner } from '../../utils/routerCommands';
2
+ import { Trade as RouterTrade, SwapOptions as RouterSwapOptions } from '@uniswap/router-sdk';
3
+ import { Permit2Permit } from '../../utils/permit2';
4
+ import { Currency, TradeType } from '@uniswap/sdk-core';
5
+ import { Command, TradeConfig } from '../Command';
6
+ export declare type SwapOptions = Omit<RouterSwapOptions, 'inputTokenPermit'> & {
7
+ inputTokenPermit?: Permit2Permit;
8
+ };
9
+ export declare class UniswapTrade implements Command {
10
+ trade: RouterTrade<Currency, Currency, TradeType>;
11
+ options: SwapOptions;
12
+ constructor(trade: RouterTrade<Currency, Currency, TradeType>, options: SwapOptions);
13
+ encode(planner: RoutePlanner, _config: TradeConfig): void;
14
+ }
@@ -0,0 +1,28 @@
1
+ import { Interface } from '@ethersproject/abi';
2
+ import { BuyItem, NFTTrade, TokenType } from '../NFTTrade';
3
+ import { TradeConfig } from '../Command';
4
+ import { RoutePlanner } from '../../utils/routerCommands';
5
+ import { BigNumberish } from 'ethers';
6
+ declare type X2Y2PartialData = {
7
+ signedInput: string;
8
+ recipient: string;
9
+ tokenAddress: string;
10
+ tokenId: BigNumberish;
11
+ price: BigNumberish;
12
+ };
13
+ export declare type X2Y2_721_Data = X2Y2PartialData & {
14
+ tokenType: TokenType.ERC721;
15
+ };
16
+ export declare type X2Y2_1155_Data = X2Y2PartialData & {
17
+ tokenType: TokenType.ERC1155;
18
+ tokenAmount: BigNumberish;
19
+ };
20
+ export declare type X2Y2Data = X2Y2_721_Data | X2Y2_1155_Data;
21
+ export declare class X2Y2Trade extends NFTTrade<X2Y2Data> {
22
+ static INTERFACE: Interface;
23
+ constructor(orders: X2Y2Data[]);
24
+ encode(planner: RoutePlanner, config: TradeConfig): void;
25
+ getBuyItems(): BuyItem[];
26
+ getTotalPrice(): BigNumberish;
27
+ }
28
+ export {};
@@ -0,0 +1,2 @@
1
+ export { SwapRouter } from './swapRouter';
2
+ export * from './entities';
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+
2
+ 'use strict'
3
+
4
+ if (process.env.NODE_ENV === 'production') {
5
+ module.exports = require('./universal-router-sdk.cjs.production.min.js')
6
+ } else {
7
+ module.exports = require('./universal-router-sdk.cjs.development.js')
8
+ }
@@ -0,0 +1,32 @@
1
+ import { Interface } from '@ethersproject/abi';
2
+ import { BigNumberish } from 'ethers';
3
+ import { MethodParameters } from '@uniswap/v3-sdk';
4
+ import { Trade as RouterTrade } from '@uniswap/router-sdk';
5
+ import { Currency, TradeType } from '@uniswap/sdk-core';
6
+ import { NFTTrade, SupportedProtocolsData } from './entities/NFTTrade';
7
+ import { SwapOptions } from './entities/protocols/uniswap';
8
+ export declare type SwapRouterConfig = {
9
+ sender?: string;
10
+ deadline?: BigNumberish;
11
+ };
12
+ export declare abstract class SwapRouter {
13
+ static INTERFACE: Interface;
14
+ /**
15
+ * Produces the on-chain method name to call and the hex encoded parameters to pass as arguments for a given swap.
16
+ * @param trades to produce call parameters for
17
+ */
18
+ static swapGenieCallParameters(trades: NFTTrade<SupportedProtocolsData>[], config: SwapRouterConfig): MethodParameters;
19
+ /**
20
+ * Produces the on-chain method name to call and the hex encoded parameters to pass as arguments for a given trade.
21
+ * @param trades to produce call parameters for
22
+ * @param options options for the call parameters
23
+ */
24
+ static swapERC20CallParameters(trades: RouterTrade<Currency, Currency, TradeType>, options: SwapOptions): MethodParameters;
25
+ /**
26
+ * Encodes a planned route into a method name and parameters for the Router contract.
27
+ * @param planner the planned route
28
+ * @param nativeCurrencyValue the native currency value of the planned route
29
+ * @param config the router config
30
+ */
31
+ private static encodePlan;
32
+ }