Skip to content
Open
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
5 changes: 5 additions & 0 deletions .changeset/lucky-jars-fetch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@uniswap/universal-router-sdk": minor
---

Export `encodeSwapStep` from the package root so consumers can compose per-step `{commands, inputs}` plans into their own RoutePlanner without the `encodeSwaps` envelope (no Permit2 ingress, fee, or final sweep).
5 changes: 5 additions & 0 deletions sdks/universal-router-sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ export {
UniversalRouterVersion,
isAtLeastV2_1_1,
} from './utils/constants'
// Per-step {commands, inputs} composition for callers that own the surrounding
// plan: writes one step's command into the caller's RoutePlanner and applies no
// ingress or settlement (no Permit2 transfer, fee, or sweep) — unlike
// SwapRouter.encodeSwaps, which owns the full safety envelope.
export { encodeSwapStep } from './utils/encodeSwapStep'
export { CommandParser, GenericCommandParser } from './utils/commandParser'
export type { UniversalRouterCommand, UniversalRouterCall, Param, CommandsDefinition } from './utils/commandParser'
export type { Permit2Permit } from './utils/inputTokens'
Expand Down
26 changes: 26 additions & 0 deletions sdks/universal-router-sdk/test/unit/exports.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { expect } from 'chai'
import { encodeSwapStep as encodeSwapStepFromRoot, RoutePlanner, UniversalRouterVersion } from '../../src'
import { encodeSwapStep } from '../../src/utils/encodeSwapStep'
import { V3SwapExactIn } from '../../src/types/encodeSwaps'
import { ROUTER_AS_RECIPIENT } from '../../src/utils/constants'
import { CommandType } from '../../src/utils/routerCommands'

describe('package exports', () => {
it('re-exports encodeSwapStep from the package root', () => {
expect(encodeSwapStepFromRoot).to.equal(encodeSwapStep)

// Sanity: the export is usable standalone — one step, one command, no envelope.
const planner = new RoutePlanner()
const step: V3SwapExactIn = {
type: 'V3_SWAP_EXACT_IN',
recipient: ROUTER_AS_RECIPIENT,
amountIn: '1000000',
amountOutMin: '0',
// USDC -(500)-> WETH packed path
path: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb480001f4c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
}
encodeSwapStepFromRoot(planner, step, UniversalRouterVersion.V2_0)
expect(planner.commands).to.equal('0x' + CommandType.V3_SWAP_EXACT_IN.toString(16).padStart(2, '0'))
expect(planner.inputs.length).to.equal(1)
})
})
Loading