Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 26 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ Full API documentation with TypeDoc: [https://bootnodedev.github.io/uni-dev-kit]
- [`buildSwapCallData`](#buildswapcalldata)
- [`buildAddLiquidityCallData`](#buildaddliquiditycalldata)
- [`preparePermit2BatchCallData`](#preparepermit2batchcalldata)
- [Basis Points Reference](#basis-points-reference)
- [Useful Links](#useful-links)
- [Development](#development)
- [Scripts](#scripts)
Expand Down Expand Up @@ -126,6 +127,7 @@ const poolKey = await uniDevKit.getPoolKeyFromPoolId({

### `buildSwapCallData`
Construct calldata for a Universal Router swap.

```ts
// Basic swap
const { calldata, value } = await uniDevKit.buildSwapCallData({
Expand All @@ -143,23 +145,22 @@ const permitData = await uniDevKit.preparePermit2Data({
owner: userAddress
});

const signature = await signer._signTypedData(permitData.toSign);
const signature = await signer._signTypedData(
permitData.toSign.domain,
{ PermitSingle: permitData.toSign.types.PermitSingle },
permitData.toSign.values
);

const permitWithSignature = permitData.buildPermit2DataWithSignature(signature);

const { calldata: calldataWithPermit, value: valueWithPermit } = await uniDevKit.buildSwapCallData({
tokenIn: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
amountIn: parseUnits("100", 6),
pool: pool,
const { calldata, value } = await uniDevKit.buildSwapCallData({
tokenIn,
amountIn,
pool,
slippageTolerance: 50,
recipient: "0x...",
recipient,
permit2Signature: permitWithSignature
});

const tx = await sendTransaction({
to: uniDevKit.getContractAddress('universalRouter'),
data: calldata,
value
});
```

### `buildAddLiquidityCallData`
Expand Down Expand Up @@ -213,6 +214,19 @@ const permitData = await uniDevKit.preparePermit2BatchCallData({
});
```

#### Basis Points Reference

Throughout the library, percentages are represented in basis points (bps). For example, when setting a slippage tolerance of 0.5%, you would use `50` bps. Here's a quick reference:

| Basis Points (bps) | Fraction | Percentage |
|:------------------:|:--------:|:----------:|
| 1 | 1/10_000 | 0.01% |
| 10 | 10/10_000 | 0.1% |
| 100 | 100/10_000 | 1% |
| 500 | 500/10_000 | 5% |
| 1000 | 1000/10_000 | 10% |
| 10_000 | 10_000/10_000 | 100% |

## Useful Links
- [Uniswap V4 Docs](https://docs.uniswap.org/contracts/v4/overview)

Expand Down
187 changes: 175 additions & 12 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,177 @@
{
"formatter": {
"ignore": ["dist/**/*"]
},
"linter": {
"rules": {
"recommended": true
}
},
"files": {
"include": ["src/**/*", "test/**/*"],
"ignore": ["dist/**/*"]
}
"$schema": "https://biomejs.dev/schemas/1.9.2/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"include": ["src/**/*", "test/**/*"],
"ignore": ["dist/**/*"]
},
"formatter": {
"attributePosition": "multiline",
"indentStyle": "space",
"lineWidth": 100
},
"javascript": {
"formatter": {
"quoteStyle": "single",
"semicolons": "asNeeded"
}
},
"linter": {
"rules": {
"a11y": {
"noAccessKey": "error",
"noAriaUnsupportedElements": "error",
"noAutofocus": "error",
"noBlankTarget": "error",
"noDistractingElements": "error",
"noHeaderScope": "error",
"noInteractiveElementToNoninteractiveRole": "error",
"noLabelWithoutControl": "warn",
"noNoninteractiveElementToInteractiveRole": "error",
"noNoninteractiveTabindex": "error",
"noPositiveTabindex": "error",
"noRedundantAlt": "error",
"noRedundantRoles": "error",
"noSvgWithoutTitle": "off",
"useAltText": "error",
"useAnchorContent": "error",
"useAriaActivedescendantWithTabindex": "error",
"useAriaPropsForRole": "error",
"useFocusableInteractive": "error",
"useHeadingContent": "error",
"useHtmlLang": "error",
"useIframeTitle": "error",
"useKeyWithClickEvents": "error",
"useKeyWithMouseEvents": "error",
"useMediaCaption": "error",
"useValidAnchor": "error",
"useValidAriaProps": "error",
"useValidAriaRole": "error",
"useValidAriaValues": "error"
},
"complexity": {
"noExtraBooleanCast": "error",
"noMultipleSpacesInRegularExpressionLiterals": "error",
"noUselessCatch": "error",
"noUselessTypeConstraint": "error",
"noWith": "error"
},
"correctness": {
"noChildrenProp": "error",
"noConstAssign": "error",
"noConstantCondition": "error",
"noEmptyCharacterClassInRegex": "error",
"noEmptyPattern": "error",
"noGlobalObjectCalls": "error",
"noInnerDeclarations": "error",
"noInvalidConstructorSuper": "error",
"noInvalidUseBeforeDeclaration": "error",
"noNewSymbol": "error",
"noNonoctalDecimalEscape": "error",
"noPrecisionLoss": "error",
"noSelfAssign": "error",
"noSetterReturn": "error",
"noSwitchDeclarations": "error",
"noUndeclaredVariables": "error",
"noUnreachable": "error",
"noUnreachableSuper": "error",
"noUnsafeFinally": "error",
"noUnsafeOptionalChaining": "error",
"noUnusedLabels": "error",
"noUnusedVariables": "error",
"useArrayLiterals": "off",
"useExhaustiveDependencies": "error",
"useHookAtTopLevel": "error",
"useIsNan": "error",
"useJsxKeyInIterable": "error",
"useValidForDirection": "error",
"useYield": "error"
},
"security": {
"noDangerouslySetInnerHtmlWithChildren": "error"
},
"style": {
"noNamespace": "error",
"noRestrictedGlobals": {
"level": "error",
"options": {
"deniedGlobals": ["React"]
}
},
"useAsConstAssertion": "error",
"useBlockStatements": "off"
},
"suspicious": {
"noAsyncPromiseExecutor": "error",
"noCatchAssign": "error",
"noClassAssign": "error",
"noCommentText": "error",
"noCompareNegZero": "error",
"noControlCharactersInRegex": "error",
"noDebugger": "error",
"noDuplicateCase": "error",
"noDuplicateClassMembers": "error",
"noDuplicateJsxProps": "error",
"noDuplicateObjectKeys": "error",
"noDuplicateParameters": "error",
"noEmptyBlockStatements": "error",
"noExplicitAny": "warn",
"noExtraNonNullAssertion": "error",
"noFallthroughSwitchClause": "error",
"noFunctionAssign": "error",
"noGlobalAssign": "error",
"noImportAssign": "error",
"noMisleadingCharacterClass": "error",
"noMisleadingInstantiator": "error",
"noPrototypeBuiltins": "error",
"noRedeclare": "error",
"noShadowRestrictedNames": "error",
"noSparseArray": "error",
"noUnsafeDeclarationMerging": "error",
"noUnsafeNegation": "error",
"useGetterReturn": "error",
"useNamespaceKeyword": "error",
"useValidTypeof": "error"
}
}
},
"overrides": [
{
"include": ["*.ts", "*.tsx", "*.mts", "*.cts"],
"linter": {
"rules": {
"correctness": {
"noConstAssign": "off",
"noGlobalObjectCalls": "off",
"noInvalidBuiltinInstantiation": "off",
"noInvalidConstructorSuper": "off",
"noNewSymbol": "off",
"noSetterReturn": "off",
"noUndeclaredVariables": "off",
"noUnreachable": "off",
"noUnreachableSuper": "off"
},
"style": {
"noArguments": "error",
"noVar": "error",
"useConst": "error"
},
"suspicious": {
"noDuplicateClassMembers": "off",
"noDuplicateObjectKeys": "off",
"noDuplicateParameters": "off",
"noFunctionAssign": "off",
"noImportAssign": "off",
"noRedeclare": "off",
"noUnsafeNegation": "off",
"useGetterReturn": "off"
}
}
}
}
]
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "uniswap-dev-kit",
"version": "1.0.10",
"version": "1.0.11",
"description": "A modern TypeScript library for integrating Uniswap into your dapp.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
Loading