{"_id":"@dooswap/uniswapx-sdk","name":"@dooswap/uniswapx-sdk","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@dooswap/uniswapx-sdk","author":{"name":"Uniswap"},"version":"1.0.0","license":"MIT","main":"dist/src/index.js","typings":"dist/src/index.d.ts","engines":{"node":">=10"},"scripts":{"build":"npm run typechain && tsc -p tsconfig.json","fix":"run-s fix:*","fix:prettier":"prettier \"src/**/*.ts\" --write","fix:lint":"eslint src --ext .ts --fix","test":"run-s build test:*","test:lint":"eslint src --ext .ts","test:prettier":"prettier \"src/**/*.ts\" --list-different","test:unit":"jest --testPathPattern src --detectOpenHandles --forceExit","test:integration":"yarn build && cd integration && yarn && yarn test","prepare":"npm run build","typechain":"typechain --target=ethers-v5 --out-dir src/contracts --glob ./abis/**/*.json"},"peerDependencies":{},"husky":{"hooks":{"pre-commit":"yarn fix"}},"module":"dist/uniswapx-sdk.esm.js","devDependencies":{"@typechain/ethers-v5":"^10.1.0","@types/jest":"^29.0.3","@types/node":"^18.7.16","@typescript-eslint/eslint-plugin":"^4.0.1","@typescript-eslint/parser":"^4.0.1","eslint":"^7.8.0","eslint-config-prettier":"^6.11.0","eslint-plugin-eslint-comments":"^3.2.0","eslint-plugin-functional":"^3.0.2","eslint-plugin-import":"^2.22.0","husky":"^8.0.1","jest":"^29.0.3","npm-run-all":"^4.1.5","prettier":"^2.1.1","ts-jest":"^29.0.1","ts-node":"^10.9.1","typechain":"^8.1.0","typescript":"^4.0.2"},"dependencies":{"@dooswap/sdk-core":"^3.0.2","@ethersproject/bytes":"^5.7.0","@ethersproject/providers":"^5.7.0","@uniswap/permit2-sdk":"^1.2.0","ethers":"^5.7.0"},"gitHead":"2ee8f6503d9717c2a1f1a8d8e95f33c8fea8a75a","description":"SDK for the UniswapX protocol","_id":"@dooswap/uniswapx-sdk@1.0.0","_nodeVersion":"18.16.1","_npmVersion":"9.5.1","dist":{"integrity":"sha512-TIZDDX7WaL4NvlhDji858lgpZZgce7gg3CRMOwkgcob3bVEs79/B9Tpvcd6zdEvibB4Nw7gxvEanmU9yKSs22g==","shasum":"eea25ff1a2aeb3c26b9666418e8b6c176579f517","tarball":"https://registry.npmjs.org/@dooswap/uniswapx-sdk/-/uniswapx-sdk-1.0.0.tgz","fileCount":153,"unpackedSize":887094,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCfdiISNQH+NP5G2NrCF/sbE9FBi6Cx2uuqYeyhVU2K6QIgBADDHfSzOONiUPj2AMnPUGhKutM7YQAveWWbaoBMMkY="}]},"_npmUser":{"name":"dooswap","email":"tantranly95+1@gmail.com"},"directories":{},"maintainers":[{"name":"dooswap","email":"tantranly95+1@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/uniswapx-sdk_1.0.0_1689743546996_0.6824690479802924"},"_hasShrinkwrap":false}},"time":{"created":"2023-07-19T05:12:26.926Z","1.0.0":"2023-07-19T05:12:27.196Z","modified":"2023-07-19T05:12:27.471Z"},"maintainers":[{"name":"dooswap","email":"tantranly95+1@gmail.com"}],"description":"SDK for the UniswapX protocol","author":{"name":"Uniswap"},"license":"MIT","readme":"# uniswapx-sdk\n\nSDK for the UniswapX protocol\n\n## Usage\n\nThe SDK contains bindings for two main flows: parsing serialized orders & building new orders.\n\n### Building & Signing Orders\n\n```ts\nimport { DutchOrder, NonceManager } from '@uniswap/uniswapx-sdk';\nimport { ethers } from 'ethers';\n\nconst provider = new ethers.providers.JsonRpcProvider(RPC_URL);\nconst account = await provider.getSigner().getAddress(); \nconst nonceMgr = new NonceManager(provider, 1); \nconst nonce = await nonceMgr.useNonce(account); \n\nconst chainId = 1;\nconst builder = new DutchOrderBuilder(chainId);\nconst order = builder\n  .deadline(deadline)\n  .decayEndTime(deadline)\n  .decayStartTime(deadline - 100)\n  .nonce(nonce)\n  .input({\n    token: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',\n    amount: BigNumber.from('1000000'),\n  })\n  .output({\n    token: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',\n    startAmount: BigNumber.from('1000000000000000000'),\n    endAmount: BigNumber.from('900000000000000000'),\n    recipient: '0x0000000000000000000000000000000000000000',\n  })\n  .build();\n \n// Sign the built order \nconst { domain, types, values } = order.permitData();\nconst signature = wallet._signTypedData(domain, types, values);\n\nconst serializedOrder = order.serialize();\n// submit serializedOrder and signature to order pool\n```\n\n### Parsing Orders\n```ts\nimport { parseOrder, Order, OrderValidation } from '@uniswap/uniswapx-sdk';\n\nconst serializedOrder = '0x1111222233334444555500000000234300234...';\nconst order: Order = parseOrder(serializedOrder);\n\nconst orderData = order.info;\nconst orderHash = order.hash();\n```\n### Validating Orders \n```ts\nimport { ethers } from 'ethers';\nimport { OrderValidator } from 'uniswapx-sdk';\n\nconst provider = new ethers.providers.JsonRpcProvider(RPC_URL);\nconst validator = new OrderValidator(provider, CHAIN_ID); \nconst orders: SignedOrder[] = [\n  {\n    order: order1, \n    signature: signature1\n  }, \n  {\n    order: order2, \n    signature: signature2\n  }\n]; \n\ntry {\n  const statusList: OrderValidation[] = await validator.validateBatch(orders); \n  // Do something with list of statuses \n}\ncatch(e) {\n  // Handle error\n}\n\n```\n\n### Order Object\n\n**serialize()**\n\nReturns an abi-encoded serialization of the order. This serialized format is passed into the corresponding reactor contract for execution.\n\n\n**getSigner(signature)**\n\nRecovers the address which created the given signature over the order. Used to determine the order maker.\n\n\n**permitData()**\n\nReturns 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.\n\n\n**hash()**\n\nReturns 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.\n","readmeFilename":"README.md"}