Skip to content

Commit 76bddd0

Browse files
committed
feat: add order tokens helpers
1 parent 23b9a6f commit 76bddd0

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/helpers/tokens.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* Sorts two tokens in a consistent order (lexicographically by address)
3+
* @param token0 First token address
4+
* @param token1 Second token address
5+
* @returns Tuple of [token0, token1] in sorted order
6+
*/
7+
export function sortTokens(
8+
token0: `0x${string}`,
9+
token1: `0x${string}`,
10+
): [`0x${string}`, `0x${string}`] {
11+
return token0.toLowerCase() < token1.toLowerCase()
12+
? [token0, token1]
13+
: [token1, token0];
14+
}

0 commit comments

Comments
 (0)