sushi 6.3.0 → 6.4.0

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.
Files changed (209) hide show
  1. package/_cjs/evm/api/quote.js +60 -27
  2. package/_cjs/evm/api/quote.js.map +1 -1
  3. package/_cjs/evm/api/swap.js +53 -20
  4. package/_cjs/evm/api/swap.js.map +1 -1
  5. package/_cjs/evm/currency/currency.js +35 -2
  6. package/_cjs/evm/currency/currency.js.map +1 -1
  7. package/_cjs/generic/chain/chains.js +4 -2
  8. package/_cjs/generic/chain/chains.js.map +1 -1
  9. package/_cjs/generic/currency/serialized-currency.js +2 -0
  10. package/_cjs/generic/currency/serialized-currency.js.map +1 -1
  11. package/_cjs/svm/chain/chains.js +54 -0
  12. package/_cjs/svm/chain/chains.js.map +1 -0
  13. package/_cjs/svm/chain/define-chain.js +13 -0
  14. package/_cjs/svm/chain/define-chain.js.map +1 -0
  15. package/_cjs/svm/chain/index.js +19 -0
  16. package/_cjs/svm/chain/index.js.map +1 -0
  17. package/_cjs/svm/config/index.js +19 -0
  18. package/_cjs/svm/config/index.js.map +1 -0
  19. package/_cjs/svm/config/simple-constants.js +6 -0
  20. package/_cjs/svm/config/simple-constants.js.map +1 -0
  21. package/_cjs/svm/config/tokens/index.js +19 -0
  22. package/_cjs/svm/config/tokens/index.js.map +1 -0
  23. package/_cjs/svm/config/tokens/token-maps/default-bases.js +21 -0
  24. package/_cjs/svm/config/tokens/token-maps/default-bases.js.map +1 -0
  25. package/_cjs/svm/config/tokens/token-maps/default-quote.js +13 -0
  26. package/_cjs/svm/config/tokens/token-maps/default-quote.js.map +1 -0
  27. package/_cjs/svm/config/tokens/token-maps/index.js +20 -0
  28. package/_cjs/svm/config/tokens/token-maps/index.js.map +1 -0
  29. package/_cjs/svm/config/tokens/token-maps/stables.js +20 -0
  30. package/_cjs/svm/config/tokens/token-maps/stables.js.map +1 -0
  31. package/_cjs/svm/config/tokens/tokens/USDC.js +18 -0
  32. package/_cjs/svm/config/tokens/tokens/USDC.js.map +1 -0
  33. package/_cjs/svm/config/tokens/tokens/USDT.js +18 -0
  34. package/_cjs/svm/config/tokens/tokens/USDT.js.map +1 -0
  35. package/_cjs/svm/config/tokens/tokens/WBTC.js +18 -0
  36. package/_cjs/svm/config/tokens/tokens/WBTC.js.map +1 -0
  37. package/_cjs/svm/config/tokens/tokens/WETH.js +18 -0
  38. package/_cjs/svm/config/tokens/tokens/WETH.js.map +1 -0
  39. package/_cjs/svm/config/tokens/tokens/WSOL.js +18 -0
  40. package/_cjs/svm/config/tokens/tokens/WSOL.js.map +1 -0
  41. package/_cjs/svm/config/tokens/tokens/index.js +22 -0
  42. package/_cjs/svm/config/tokens/tokens/index.js.map +1 -0
  43. package/_cjs/svm/config/tokens/wrapped-native.js +12 -0
  44. package/_cjs/svm/config/tokens/wrapped-native.js.map +1 -0
  45. package/_cjs/svm/currency/currency.js +17 -0
  46. package/_cjs/svm/currency/currency.js.map +1 -0
  47. package/_cjs/svm/currency/deserialize-currency.js +14 -0
  48. package/_cjs/svm/currency/deserialize-currency.js.map +1 -0
  49. package/_cjs/svm/currency/index.js +22 -0
  50. package/_cjs/svm/currency/index.js.map +1 -0
  51. package/_cjs/svm/currency/native.js +90 -0
  52. package/_cjs/svm/currency/native.js.map +1 -0
  53. package/_cjs/svm/currency/token.js +88 -0
  54. package/_cjs/svm/currency/token.js.map +1 -0
  55. package/_cjs/svm/currency/unwrap-token.js +15 -0
  56. package/_cjs/svm/currency/unwrap-token.js.map +1 -0
  57. package/_cjs/svm/index.js +20 -0
  58. package/_cjs/svm/index.js.map +1 -0
  59. package/_esm/evm/api/quote.js +1 -1
  60. package/_esm/evm/api/quote.js.map +1 -1
  61. package/_esm/evm/api/swap.js +1 -1
  62. package/_esm/evm/api/swap.js.map +1 -1
  63. package/_esm/evm/currency/currency.js +1 -1
  64. package/_esm/evm/currency/currency.js.map +1 -1
  65. package/_esm/generic/chain/chains.js +2 -0
  66. package/_esm/generic/chain/chains.js.map +1 -1
  67. package/_esm/generic/currency/serialized-currency.js +2 -0
  68. package/_esm/generic/currency/serialized-currency.js.map +1 -1
  69. package/_esm/svm/chain/chains.js +46 -0
  70. package/_esm/svm/chain/chains.js.map +1 -0
  71. package/_esm/svm/chain/define-chain.js +10 -0
  72. package/_esm/svm/chain/define-chain.js.map +1 -0
  73. package/_esm/svm/chain/index.js +3 -0
  74. package/_esm/svm/chain/index.js.map +1 -0
  75. package/_esm/svm/config/index.js +3 -0
  76. package/_esm/svm/config/index.js.map +1 -0
  77. package/_esm/svm/config/simple-constants.js +3 -0
  78. package/_esm/svm/config/simple-constants.js.map +1 -0
  79. package/_esm/svm/config/tokens/index.js +3 -0
  80. package/_esm/svm/config/tokens/index.js.map +1 -0
  81. package/_esm/svm/config/tokens/token-maps/default-bases.js +18 -0
  82. package/_esm/svm/config/tokens/token-maps/default-bases.js.map +1 -0
  83. package/_esm/svm/config/tokens/token-maps/default-quote.js +10 -0
  84. package/_esm/svm/config/tokens/token-maps/default-quote.js.map +1 -0
  85. package/_esm/svm/config/tokens/token-maps/index.js +4 -0
  86. package/_esm/svm/config/tokens/token-maps/index.js.map +1 -0
  87. package/_esm/svm/config/tokens/token-maps/stables.js +16 -0
  88. package/_esm/svm/config/tokens/token-maps/stables.js.map +1 -0
  89. package/_esm/svm/config/tokens/tokens/USDC.js +15 -0
  90. package/_esm/svm/config/tokens/tokens/USDC.js.map +1 -0
  91. package/_esm/svm/config/tokens/tokens/USDT.js +15 -0
  92. package/_esm/svm/config/tokens/tokens/USDT.js.map +1 -0
  93. package/_esm/svm/config/tokens/tokens/WBTC.js +15 -0
  94. package/_esm/svm/config/tokens/tokens/WBTC.js.map +1 -0
  95. package/_esm/svm/config/tokens/tokens/WETH.js +15 -0
  96. package/_esm/svm/config/tokens/tokens/WETH.js.map +1 -0
  97. package/_esm/svm/config/tokens/tokens/WSOL.js +15 -0
  98. package/_esm/svm/config/tokens/tokens/WSOL.js.map +1 -0
  99. package/_esm/svm/config/tokens/tokens/index.js +6 -0
  100. package/_esm/svm/config/tokens/tokens/index.js.map +1 -0
  101. package/_esm/svm/config/tokens/wrapped-native.js +9 -0
  102. package/_esm/svm/config/tokens/wrapped-native.js.map +1 -0
  103. package/_esm/svm/currency/currency.js +16 -0
  104. package/_esm/svm/currency/currency.js.map +1 -0
  105. package/_esm/svm/currency/deserialize-currency.js +12 -0
  106. package/_esm/svm/currency/deserialize-currency.js.map +1 -0
  107. package/_esm/svm/currency/index.js +6 -0
  108. package/_esm/svm/currency/index.js.map +1 -0
  109. package/_esm/svm/currency/native.js +52 -0
  110. package/_esm/svm/currency/native.js.map +1 -0
  111. package/_esm/svm/currency/token.js +49 -0
  112. package/_esm/svm/currency/token.js.map +1 -0
  113. package/_esm/svm/currency/unwrap-token.js +12 -0
  114. package/_esm/svm/currency/unwrap-token.js.map +1 -0
  115. package/_esm/svm/index.js +4 -0
  116. package/_esm/svm/index.js.map +1 -0
  117. package/_types/evm/api/quote.d.ts +1 -1
  118. package/_types/evm/api/quote.d.ts.map +1 -1
  119. package/_types/evm/api/swap.d.ts +1 -1
  120. package/_types/evm/api/swap.d.ts.map +1 -1
  121. package/_types/evm/currency/currency.d.ts +1 -1
  122. package/_types/evm/currency/currency.d.ts.map +1 -1
  123. package/_types/generic/chain/chains.d.ts +25 -1
  124. package/_types/generic/chain/chains.d.ts.map +1 -1
  125. package/_types/generic/chain/interface.d.ts +2 -1
  126. package/_types/generic/chain/interface.d.ts.map +1 -1
  127. package/_types/generic/currency/serialized-currency.d.ts +20 -2
  128. package/_types/generic/currency/serialized-currency.d.ts.map +1 -1
  129. package/_types/svm/chain/chains.d.ts +42 -0
  130. package/_types/svm/chain/chains.d.ts.map +1 -0
  131. package/_types/svm/chain/define-chain.d.ts +22 -0
  132. package/_types/svm/chain/define-chain.d.ts.map +1 -0
  133. package/_types/svm/chain/index.d.ts +3 -0
  134. package/_types/svm/chain/index.d.ts.map +1 -0
  135. package/_types/svm/config/index.d.ts +3 -0
  136. package/_types/svm/config/index.d.ts.map +1 -0
  137. package/_types/svm/config/simple-constants.d.ts +2 -0
  138. package/_types/svm/config/simple-constants.d.ts.map +1 -0
  139. package/_types/svm/config/tokens/index.d.ts +3 -0
  140. package/_types/svm/config/tokens/index.d.ts.map +1 -0
  141. package/_types/svm/config/tokens/token-maps/default-bases.d.ts +5 -0
  142. package/_types/svm/config/tokens/token-maps/default-bases.d.ts.map +1 -0
  143. package/_types/svm/config/tokens/token-maps/default-quote.d.ts +8 -0
  144. package/_types/svm/config/tokens/token-maps/default-quote.d.ts.map +1 -0
  145. package/_types/svm/config/tokens/token-maps/index.d.ts +4 -0
  146. package/_types/svm/config/tokens/token-maps/index.d.ts.map +1 -0
  147. package/_types/svm/config/tokens/token-maps/stables.d.ts +7 -0
  148. package/_types/svm/config/tokens/token-maps/stables.d.ts.map +1 -0
  149. package/_types/svm/config/tokens/tokens/USDC.d.ts +8 -0
  150. package/_types/svm/config/tokens/tokens/USDC.d.ts.map +1 -0
  151. package/_types/svm/config/tokens/tokens/USDT.d.ts +8 -0
  152. package/_types/svm/config/tokens/tokens/USDT.d.ts.map +1 -0
  153. package/_types/svm/config/tokens/tokens/WBTC.d.ts +8 -0
  154. package/_types/svm/config/tokens/tokens/WBTC.d.ts.map +1 -0
  155. package/_types/svm/config/tokens/tokens/WETH.d.ts +8 -0
  156. package/_types/svm/config/tokens/tokens/WETH.d.ts.map +1 -0
  157. package/_types/svm/config/tokens/tokens/WSOL.d.ts +8 -0
  158. package/_types/svm/config/tokens/tokens/WSOL.d.ts.map +1 -0
  159. package/_types/svm/config/tokens/tokens/index.d.ts +6 -0
  160. package/_types/svm/config/tokens/tokens/index.d.ts.map +1 -0
  161. package/_types/svm/config/tokens/wrapped-native.d.ts +7 -0
  162. package/_types/svm/config/tokens/wrapped-native.d.ts.map +1 -0
  163. package/_types/svm/currency/currency.d.ts +30 -0
  164. package/_types/svm/currency/currency.d.ts.map +1 -0
  165. package/_types/svm/currency/deserialize-currency.d.ts +6 -0
  166. package/_types/svm/currency/deserialize-currency.d.ts.map +1 -0
  167. package/_types/svm/currency/index.d.ts +6 -0
  168. package/_types/svm/currency/index.d.ts.map +1 -0
  169. package/_types/svm/currency/native.d.ts +25 -0
  170. package/_types/svm/currency/native.d.ts.map +1 -0
  171. package/_types/svm/currency/token.d.ts +31 -0
  172. package/_types/svm/currency/token.d.ts.map +1 -0
  173. package/_types/svm/currency/unwrap-token.d.ts +3 -0
  174. package/_types/svm/currency/unwrap-token.d.ts.map +1 -0
  175. package/_types/svm/index.d.ts +4 -0
  176. package/_types/svm/index.d.ts.map +1 -0
  177. package/evm/api/quote.ts +1 -1
  178. package/evm/api/swap.ts +1 -1
  179. package/evm/currency/currency.ts +1 -1
  180. package/generic/chain/chains.test.ts +7 -0
  181. package/generic/chain/chains.ts +2 -0
  182. package/generic/chain/interface.ts +2 -0
  183. package/generic/currency/currency.test-d.ts +56 -1
  184. package/generic/currency/serialized-currency.ts +7 -0
  185. package/package.json +18 -1
  186. package/svm/chain/chains.ts +93 -0
  187. package/svm/chain/define-chain.ts +50 -0
  188. package/svm/chain/index.ts +2 -0
  189. package/svm/config/index.ts +2 -0
  190. package/svm/config/simple-constants.ts +3 -0
  191. package/svm/config/tokens/index.ts +2 -0
  192. package/svm/config/tokens/token-maps/default-bases.ts +19 -0
  193. package/svm/config/tokens/token-maps/default-quote.ts +14 -0
  194. package/svm/config/tokens/token-maps/index.ts +3 -0
  195. package/svm/config/tokens/token-maps/stables.ts +22 -0
  196. package/svm/config/tokens/tokens/USDC.ts +18 -0
  197. package/svm/config/tokens/tokens/USDT.ts +18 -0
  198. package/svm/config/tokens/tokens/WBTC.ts +18 -0
  199. package/svm/config/tokens/tokens/WETH.ts +18 -0
  200. package/svm/config/tokens/tokens/WSOL.ts +18 -0
  201. package/svm/config/tokens/tokens/index.ts +5 -0
  202. package/svm/config/tokens/wrapped-native.ts +10 -0
  203. package/svm/currency/currency.ts +31 -0
  204. package/svm/currency/deserialize-currency.ts +17 -0
  205. package/svm/currency/index.ts +5 -0
  206. package/svm/currency/native.ts +81 -0
  207. package/svm/currency/token.ts +89 -0
  208. package/svm/currency/unwrap-token.ts +15 -0
  209. package/svm/index.ts +3 -0
@@ -2,6 +2,7 @@ import { evmChains } from '../../evm/chain/index.js'
2
2
  import { kvmChains } from '../../kvm/chain/chains.js'
3
3
  import { mvmChains } from '../../mvm/chain/chains.js'
4
4
  import { stellarChains } from '../../stellar/chain/chains.js'
5
+ import { svmChains } from '../../svm/chain/chains.js'
5
6
  import { tvmChains } from '../../tvm/chain/chains.js'
6
7
  import type { Replace } from '../types/replace.js'
7
8
  import type { UnionToIntersection } from '../types/union-to-intersection.js'
@@ -12,6 +13,7 @@ export const chains = [
12
13
  ...tvmChains,
13
14
  ...kvmChains,
14
15
  ...stellarChains,
16
+ ...svmChains,
15
17
  ] as const
16
18
 
17
19
  // ChainId
@@ -2,6 +2,7 @@ import type { EvmChainType } from '../../evm/chain/define-chain.js'
2
2
  import type { KvmChainType } from '../../kvm/chain/define-chain.js'
3
3
  import type { MvmChainType } from '../../mvm/chain/define-chain.js'
4
4
  import type { StellarChainType } from '../../stellar/chain/define-chain.js'
5
+ import type { SvmChainType } from '../../svm/chain/define-chain.js'
5
6
  import type { TvmChainType } from '../../tvm/chain/define-chain.js'
6
7
  import type { ChainId, ChainKey } from './chains.js'
7
8
 
@@ -11,6 +12,7 @@ export type ChainType =
11
12
  | TvmChainType
12
13
  | KvmChainType
13
14
  | StellarChainType
15
+ | SvmChainType
14
16
 
15
17
  export type NetType = 'mainnet' | 'testnet'
16
18
 
@@ -5,6 +5,7 @@ import type { EvmChainId } from '~/evm/chain/chains.js'
5
5
  import type { EvmCurrency } from '~/evm/currency/currency.js'
6
6
  import type { EvmID } from '~/evm/types/id.js'
7
7
  import { KvmToken } from '~/kvm/index.js'
8
+ import { svmAddress } from '~/svm/currency/token.js'
8
9
  import { EvmNative } from '../../evm/currency/native.js'
9
10
  import {
10
11
  type EvmAddress,
@@ -13,6 +14,12 @@ import {
13
14
  serializedEvmTokenSchema,
14
15
  } from '../../evm/currency/token.js'
15
16
  import { MvmToken } from '../../mvm/currency/token.js'
17
+ import {
18
+ type SvmAddress,
19
+ type SvmChainId,
20
+ SvmNative,
21
+ SvmToken,
22
+ } from '../../svm/index.js'
16
23
  import { TvmNative } from '../../tvm/currency/native.js'
17
24
  import { TvmToken } from '../../tvm/currency/token.js'
18
25
  import { getChainIdAddressFromId } from '../utils/id.js'
@@ -37,6 +44,17 @@ describe('generic/currency/currency.ts types', () => {
37
44
  expectTypeOf(evmMockNative.id).toEqualTypeOf<`${EvmChainId}:NATIVE`>()
38
45
  })
39
46
 
47
+ it('should return the correct id for SvmNative', () => {
48
+ const svmMockNative = new SvmNative({
49
+ chainId: -5,
50
+ symbol: 'SVM',
51
+ name: 'Svm Native',
52
+ decimals: 9,
53
+ })
54
+
55
+ expectTypeOf(svmMockNative.id).toEqualTypeOf<`${SvmChainId}:NATIVE`>()
56
+ })
57
+
40
58
  it('should return the correct id for EvmToken', () => {
41
59
  const evmMockToken = new EvmToken({
42
60
  chainId: 1,
@@ -50,6 +68,20 @@ describe('generic/currency/currency.ts types', () => {
50
68
  evmMockToken.id,
51
69
  ).toEqualTypeOf<`${EvmChainId}:${EvmAddress}`>()
52
70
  })
71
+
72
+ it('should return the correct id for SvmToken', () => {
73
+ const svmMockToken = new SvmToken({
74
+ chainId: -5,
75
+ address: svmAddress('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'),
76
+ symbol: 'USDC',
77
+ name: 'USD Coin',
78
+ decimals: 6,
79
+ })
80
+
81
+ expectTypeOf(
82
+ svmMockToken.id,
83
+ ).toEqualTypeOf<`${SvmChainId}:${SvmAddress}`>()
84
+ })
53
85
  })
54
86
 
55
87
  describe('wrapCurrency', () => {
@@ -100,7 +132,7 @@ describe('generic/currency/currency.ts types', () => {
100
132
  expect(tvmMockToken.address).toBe('t1234567890abcdef1234567890abcdef1')
101
133
  })
102
134
 
103
- it('should not lowercase the address - Kvm', () => {
135
+ it('should not lowercase the address - Kvm / Svm', () => {
104
136
  const kvmMockToken = new KvmToken({
105
137
  chainId: -3,
106
138
  symbol: 'KVM',
@@ -110,6 +142,18 @@ describe('generic/currency/currency.ts types', () => {
110
142
  })
111
143
 
112
144
  expect(kvmMockToken.address).toBe('My-Namespace.My-Token')
145
+
146
+ const svmMockToken = new SvmToken({
147
+ chainId: -5,
148
+ symbol: 'USDC',
149
+ name: 'USD Coin',
150
+ decimals: 6,
151
+ address: svmAddress('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'),
152
+ })
153
+
154
+ expect(svmMockToken.address).toBe(
155
+ 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
156
+ )
113
157
  })
114
158
 
115
159
  it('should return the same chaintype - Mvm', () => {
@@ -135,6 +179,17 @@ describe('generic/currency/currency.ts types', () => {
135
179
  expectTypeOf(tvmMockToken.wrap()).toEqualTypeOf<TvmToken>()
136
180
  })
137
181
 
182
+ it('should return the same chaintype - Svm', () => {
183
+ const svmMockNative = new SvmNative({
184
+ chainId: -5,
185
+ symbol: 'SVM',
186
+ name: 'Svm Native',
187
+ decimals: 9,
188
+ })
189
+
190
+ expectTypeOf(svmMockNative.wrap()).toEqualTypeOf<SvmToken>()
191
+ })
192
+
138
193
  it('should return the same chaintype - Kvm', () => {
139
194
  const kvmMockToken = new KvmToken({
140
195
  chainId: -3,
@@ -4,6 +4,9 @@ import type { serializedEvmNativeSchema } from '../../evm/currency/native.js'
4
4
  import type { serializedEvmTokenSchema } from '../../evm/currency/token.js'
5
5
  import { serializedKvmTokenSchema } from '../../kvm/currency/token.js'
6
6
  import { serializedMvmTokenSchema } from '../../mvm/currency/token.js'
7
+ import { serializedSvmCurrencySchema } from '../../svm/currency/currency.js'
8
+ import type { serializedSvmNativeSchema } from '../../svm/currency/native.js'
9
+ import type { serializedSvmTokenSchema } from '../../svm/index.js'
7
10
  import {
8
11
  serializedTvmCurrencySchema,
9
12
  type serializedTvmNativeSchema,
@@ -23,6 +26,9 @@ export type SerializedCurrencySchema<
23
26
  | typeof serializedTvmCurrencySchema<TMetadata>
24
27
  | typeof serializedCurrencySchema<TMetadata>
25
28
  | typeof serializedKvmTokenSchema<TMetadata>
29
+ | typeof serializedSvmNativeSchema<TMetadata>
30
+ | typeof serializedSvmTokenSchema<TMetadata>
31
+ | typeof serializedSvmCurrencySchema<TMetadata>
26
32
  >
27
33
 
28
34
  export const serializedCurrencySchema = <
@@ -35,6 +41,7 @@ export const serializedCurrencySchema = <
35
41
  serializedMvmTokenSchema(opts),
36
42
  serializedTvmCurrencySchema(opts),
37
43
  serializedKvmTokenSchema(opts),
44
+ serializedSvmCurrencySchema(opts),
38
45
  ])
39
46
 
40
47
  export type SerializedCurrency<
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sushi",
3
3
  "description": "Sushi",
4
- "version": "6.3.0",
4
+ "version": "6.4.0",
5
5
  "type": "module",
6
6
  "main": "./_cjs/generic/index.js",
7
7
  "module": "./_esm/generic/index.js",
@@ -17,6 +17,7 @@
17
17
  "tvm",
18
18
  "kvm",
19
19
  "stellar",
20
+ "svm",
20
21
  "package.json"
21
22
  ],
22
23
  "exports": {
@@ -56,6 +57,12 @@
56
57
  "require": "./_cjs/stellar/index.js",
57
58
  "default": "./_esm/stellar/index.js"
58
59
  },
60
+ "./svm": {
61
+ "types": "./_types/svm/index.d.ts",
62
+ "import": "./_esm/svm/index.js",
63
+ "require": "./_cjs/svm/index.js",
64
+ "default": "./_esm/svm/index.js"
65
+ },
59
66
  "./package.json": "./package.json"
60
67
  },
61
68
  "typesVersions": {
@@ -71,6 +78,12 @@
71
78
  ],
72
79
  "kvm": [
73
80
  "_types/kvm/index.d.ts"
81
+ ],
82
+ "stellar": [
83
+ "_types/stellar/index.d.ts"
84
+ ],
85
+ "svm": [
86
+ "_types/svm/index.d.ts"
74
87
  ]
75
88
  }
76
89
  },
@@ -79,11 +92,15 @@
79
92
  "tiny-invariant": "1.3.3"
80
93
  },
81
94
  "peerDependencies": {
95
+ "@solana/addresses": ">=5",
82
96
  "typescript": ">= 5.8.3 < 6",
83
97
  "viem": "*",
84
98
  "zod": ">=4"
85
99
  },
86
100
  "peerDependenciesMeta": {
101
+ "@solana/addresses": {
102
+ "optional": true
103
+ },
87
104
  "typescript": {
88
105
  "optional": true
89
106
  },
@@ -0,0 +1,93 @@
1
+ import type { Replace } from '../../generic/types/replace.js'
2
+ import type { UnionToIntersection } from '../../generic/types/union-to-intersection.js'
3
+ import { defineSvmChain } from './define-chain.js'
4
+
5
+ const solana = defineSvmChain({
6
+ chainId: -5,
7
+ key: 'solana',
8
+ shortName: 'sol',
9
+ name: 'Solana',
10
+ blockExplorers: {
11
+ default: {
12
+ name: 'Solscan',
13
+ url: 'https://solscan.io',
14
+ },
15
+ },
16
+ netType: 'mainnet',
17
+ nativeCurrency: {
18
+ name: 'Solana',
19
+ symbol: 'SOL',
20
+ decimals: 9,
21
+ },
22
+ })
23
+
24
+ export const svmChains = [solana] as const
25
+
26
+ export const svmChainIds = /* @__PURE__ */ svmChains.map(
27
+ (chain) => chain.chainId,
28
+ )
29
+
30
+ export type SvmChainId = (typeof svmChainIds)[number]
31
+
32
+ type SvmChainIdMap = UnionToIntersection<
33
+ (typeof svmChains)[number] extends infer I
34
+ ? I extends { key: infer K; chainId: infer C }
35
+ ? K extends string
36
+ ? { [key in K as Uppercase<Replace<key, '-', '_'>>]: C }
37
+ : never
38
+ : never
39
+ : never
40
+ >
41
+
42
+ export const SvmChainId = /* @__PURE__ */ new Proxy<SvmChainIdMap>(
43
+ {} as SvmChainIdMap,
44
+ {
45
+ get: (_: unknown, key: keyof SvmChainIdMap) => {
46
+ const _key = key.toLowerCase().replace(/_/g, '-') as SvmChainKey
47
+ const chain = svmChains.find((chain) => chain.key === _key)
48
+
49
+ if (!chain) return undefined
50
+
51
+ return chain.chainId
52
+ },
53
+ },
54
+ )
55
+
56
+ export function isSvmChainId(chainId: number): chainId is SvmChainId {
57
+ return svmChains.some((chain) => chain.chainId === chainId)
58
+ }
59
+
60
+ export function getSvmChainById<C extends SvmChainId>(chainId: C) {
61
+ return svmChains.find((chain) => chain.chainId === chainId)! as Extract<
62
+ (typeof svmChains)[number],
63
+ { chainId: C }
64
+ >
65
+ }
66
+
67
+ // SvmMainnetChainId
68
+ export type SvmMainnetChainId = Extract<
69
+ (typeof svmChains)[number],
70
+ { netType: 'mainnet' }
71
+ >['chainId']
72
+
73
+ export function isSvmMainnetChainId(
74
+ chainId: number,
75
+ ): chainId is SvmMainnetChainId {
76
+ return svmChains.some(
77
+ (chain) => chain.chainId === chainId && chain.netType === 'mainnet',
78
+ )
79
+ }
80
+
81
+ // SvmChainKey
82
+ export type SvmChainKey = (typeof svmChains)[number]['key']
83
+
84
+ export function isSvmChainKey(key: string): key is SvmChainKey {
85
+ return svmChains.some((chain) => chain.key === key)
86
+ }
87
+
88
+ export function getSvmChainByKey<C extends SvmChainKey>(key: C) {
89
+ return svmChains.find((chain) => chain.key === key)! as Extract<
90
+ (typeof svmChains)[number],
91
+ { key: C }
92
+ >
93
+ }
@@ -0,0 +1,50 @@
1
+ import type {
2
+ BlockExplorers,
3
+ Chain,
4
+ NetType,
5
+ } from '../../generic/chain/interface.js'
6
+ import type { SvmAddress } from '../currency/token.js'
7
+ import type { SvmChainId, SvmChainKey } from './chains.js'
8
+
9
+ export type SvmChainType = 'svm'
10
+
11
+ type SvmChainNativeCurrency = {
12
+ name: string
13
+ symbol: string
14
+ decimals: number
15
+ }
16
+
17
+ type SvmChainBase<TChainId extends number, TChainKey extends string> = Chain<
18
+ SvmChainType,
19
+ // @ts-expect-error infinite loop
20
+ TChainId,
21
+ TChainKey,
22
+ Readonly<string>,
23
+ Readonly<string>,
24
+ NetType,
25
+ BlockExplorers,
26
+ SvmAddress,
27
+ string
28
+ > & {
29
+ nativeCurrency: SvmChainNativeCurrency
30
+ }
31
+
32
+ export type SvmChain = SvmChainBase<SvmChainId, SvmChainKey>
33
+
34
+ type SvmChainInput = Omit<
35
+ SvmChainBase<number, string>,
36
+ 'type' | 'getTransactionUrl' | 'getAccountUrl' | 'getTokenUrl'
37
+ >
38
+
39
+ export function defineSvmChain<const T extends SvmChainInput>(chain: T) {
40
+ return {
41
+ ...chain,
42
+ type: 'svm' as const,
43
+ getTransactionUrl: (input: string) =>
44
+ `${chain.blockExplorers.default.url}/tx/${input}`,
45
+ getAccountUrl: (input: string) =>
46
+ `${chain.blockExplorers.default.url}/account/${input}`,
47
+ getTokenUrl: (input: SvmAddress) =>
48
+ `${chain.blockExplorers.default.url}/token/${input}`,
49
+ } as const satisfies SvmChainBase<number, string>
50
+ }
@@ -0,0 +1,2 @@
1
+ export * from './chains.js'
2
+ export * from './define-chain.js'
@@ -0,0 +1,2 @@
1
+ export * from './simple-constants.js'
2
+ export * from './tokens/index.js'
@@ -0,0 +1,3 @@
1
+ import { svmAddress } from '../currency/token.js'
2
+
3
+ export const svmNativeAddress = svmAddress('11111111111111111111111111111111')
@@ -0,0 +1,2 @@
1
+ export * from './tokens/index.js'
2
+ export * from './wrapped-native.js'
@@ -0,0 +1,19 @@
1
+ import { SvmChainId } from '../../../../svm/chain/index.js'
2
+ import type { SvmCurrency } from '../../../../svm/currency/currency.js'
3
+ import { SvmNative } from '../../../../svm/currency/native.js'
4
+ import { SVM_USDC } from '../tokens/USDC.js'
5
+ import { SVM_USDT } from '../tokens/USDT.js'
6
+ import { SVM_WBTC } from '../tokens/WBTC.js'
7
+ import { SVM_WETH } from '../tokens/WETH.js'
8
+ import { WSOL } from '../tokens/WSOL.js'
9
+
10
+ export const SVM_DEFAULT_BASES = {
11
+ [SvmChainId.SOLANA]: [
12
+ SvmNative.fromChainId(SvmChainId.SOLANA),
13
+ WSOL[SvmChainId.SOLANA],
14
+ SVM_USDC[SvmChainId.SOLANA],
15
+ SVM_USDT[SvmChainId.SOLANA],
16
+ SVM_WBTC[SvmChainId.SOLANA],
17
+ SVM_WETH[SvmChainId.SOLANA],
18
+ ],
19
+ } as const satisfies Record<SvmChainId, Readonly<SvmCurrency[]>>
@@ -0,0 +1,14 @@
1
+ import { SvmChainId, svmChainIds } from '../../../../svm/chain/index.js'
2
+ import type { SvmCurrency } from '../../../../svm/currency/currency.js'
3
+ import { SvmNative } from '../../../../svm/currency/native.js'
4
+ import { SVM_USDC } from '../tokens/USDC.js'
5
+
6
+ export const svmDefaultCurrency = {
7
+ ...(Object.fromEntries(
8
+ svmChainIds.map((chainId) => [chainId, SvmNative.fromChainId(chainId)]),
9
+ ) as Record<SvmChainId, SvmCurrency>),
10
+ } as const satisfies Record<SvmChainId, SvmCurrency>
11
+
12
+ export const svmDefaultQuoteCurrency = {
13
+ [SvmChainId.SOLANA]: SVM_USDC[SvmChainId.SOLANA],
14
+ } as const satisfies Record<SvmChainId, SvmCurrency>
@@ -0,0 +1,3 @@
1
+ export * from './default-bases.js'
2
+ export * from './default-quote.js'
3
+ export * from './stables.js'
@@ -0,0 +1,22 @@
1
+ import { SvmChainId } from '../../../../svm/chain/index.js'
2
+ import type { SvmCurrency } from '../../../../svm/currency/currency.js'
3
+ import type { SvmToken } from '../../../../svm/currency/token.js'
4
+ import { SVM_USDC } from '../tokens/USDC.js'
5
+ import { SVM_USDT } from '../tokens/USDT.js'
6
+
7
+ export const SVM_STABLES = {
8
+ [SvmChainId.SOLANA]: [
9
+ SVM_USDC[SvmChainId.SOLANA],
10
+ SVM_USDT[SvmChainId.SOLANA],
11
+ ],
12
+ } as const satisfies Record<SvmChainId, SvmToken[]>
13
+
14
+ export function isSvmStable(currency: SvmCurrency): boolean {
15
+ if (currency.type === 'native') {
16
+ return false
17
+ }
18
+
19
+ return SVM_STABLES[currency.chainId]?.some(
20
+ (stable) => stable.address.toLowerCase() === currency.address.toLowerCase(),
21
+ )
22
+ }
@@ -0,0 +1,18 @@
1
+ import { SvmChainId } from '../../../../svm/chain/index.js'
2
+ import { SvmToken, svmAddress } from '../../../../svm/currency/token.js'
3
+
4
+ export const SVM_USDC_ADDRESS = {
5
+ [SvmChainId.SOLANA]: svmAddress(
6
+ 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
7
+ ),
8
+ } as const
9
+
10
+ export const SVM_USDC = {
11
+ [SvmChainId.SOLANA]: new SvmToken({
12
+ chainId: SvmChainId.SOLANA,
13
+ address: SVM_USDC_ADDRESS[SvmChainId.SOLANA],
14
+ decimals: 6,
15
+ symbol: 'USDC',
16
+ name: 'USD Coin',
17
+ }),
18
+ } as const
@@ -0,0 +1,18 @@
1
+ import { SvmChainId } from '../../../../svm/chain/index.js'
2
+ import { SvmToken, svmAddress } from '../../../../svm/currency/token.js'
3
+
4
+ export const SVM_USDT_ADDRESS = {
5
+ [SvmChainId.SOLANA]: svmAddress(
6
+ 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB',
7
+ ),
8
+ } as const
9
+
10
+ export const SVM_USDT = {
11
+ [SvmChainId.SOLANA]: new SvmToken({
12
+ chainId: SvmChainId.SOLANA,
13
+ address: SVM_USDT_ADDRESS[SvmChainId.SOLANA],
14
+ decimals: 6,
15
+ symbol: 'USDT',
16
+ name: 'Tether USD',
17
+ }),
18
+ } as const
@@ -0,0 +1,18 @@
1
+ import { SvmChainId } from '../../../../svm/chain/index.js'
2
+ import { SvmToken, svmAddress } from '../../../../svm/currency/token.js'
3
+
4
+ export const SVM_WBTC_ADDRESS = {
5
+ [SvmChainId.SOLANA]: svmAddress(
6
+ '3NZ9JMVBmGAqocybic2c7LQCJScmgsAZ6vQqTDzcqmJh',
7
+ ),
8
+ } as const
9
+
10
+ export const SVM_WBTC = {
11
+ [SvmChainId.SOLANA]: new SvmToken({
12
+ chainId: SvmChainId.SOLANA,
13
+ address: SVM_WBTC_ADDRESS[SvmChainId.SOLANA],
14
+ decimals: 8,
15
+ symbol: 'WBTC',
16
+ name: 'Wrapped BTC (Wormhole)',
17
+ }),
18
+ } as const
@@ -0,0 +1,18 @@
1
+ import { SvmChainId } from '../../../../svm/chain/index.js'
2
+ import { SvmToken, svmAddress } from '../../../../svm/currency/token.js'
3
+
4
+ export const SVM_WETH_ADDRESS = {
5
+ [SvmChainId.SOLANA]: svmAddress(
6
+ '7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs',
7
+ ),
8
+ } as const
9
+
10
+ export const SVM_WETH = {
11
+ [SvmChainId.SOLANA]: new SvmToken({
12
+ chainId: SvmChainId.SOLANA,
13
+ address: SVM_WETH_ADDRESS[SvmChainId.SOLANA],
14
+ decimals: 8,
15
+ symbol: 'WETH',
16
+ name: 'Wrapped Ether (Wormhole)',
17
+ }),
18
+ } as const
@@ -0,0 +1,18 @@
1
+ import { SvmChainId } from '../../../../svm/chain/index.js'
2
+ import { SvmToken, svmAddress } from '../../../../svm/currency/token.js'
3
+
4
+ export const WSOL_ADDRESS = {
5
+ [SvmChainId.SOLANA]: svmAddress(
6
+ 'So11111111111111111111111111111111111111112',
7
+ ),
8
+ } as const
9
+
10
+ export const WSOL = {
11
+ [SvmChainId.SOLANA]: new SvmToken({
12
+ chainId: SvmChainId.SOLANA,
13
+ address: WSOL_ADDRESS[SvmChainId.SOLANA],
14
+ decimals: 9,
15
+ symbol: 'WSOL',
16
+ name: 'Wrapped SOL',
17
+ }),
18
+ } as const
@@ -0,0 +1,5 @@
1
+ export * from './USDC.js'
2
+ export * from './USDT.js'
3
+ export * from './WBTC.js'
4
+ export * from './WETH.js'
5
+ export * from './WSOL.js'
@@ -0,0 +1,10 @@
1
+ import { SvmChainId } from '../../../svm/chain/index.js'
2
+ import { WSOL, WSOL_ADDRESS } from './tokens/WSOL.js'
3
+
4
+ export const SVM_WNATIVE_ADDRESS = {
5
+ [SvmChainId.SOLANA]: WSOL_ADDRESS[SvmChainId.SOLANA],
6
+ }
7
+
8
+ export const SVM_WNATIVE = {
9
+ [SvmChainId.SOLANA]: WSOL[SvmChainId.SOLANA],
10
+ }
@@ -0,0 +1,31 @@
1
+ import { z } from 'zod'
2
+ import type { CurrencyMetadata } from '../../generic/currency/currency.js'
3
+ import { svmNativeAddress } from '../config/simple-constants.js'
4
+ import { type SvmNative, serializedSvmNativeSchema } from './native.js'
5
+ import { type SvmToken, serializedSvmTokenSchema } from './token.js'
6
+
7
+ export type SvmCurrency<
8
+ TMetadata extends CurrencyMetadata = Record<string, unknown>,
9
+ > = SvmToken<TMetadata> | SvmNative
10
+
11
+ export const serializedSvmCurrencySchema = <
12
+ TMetadata extends {} = CurrencyMetadata,
13
+ >(
14
+ opts: { metadata?: z.ZodType<TMetadata> } = {},
15
+ ) =>
16
+ z.discriminatedUnion('type', [
17
+ serializedSvmTokenSchema(opts),
18
+ serializedSvmNativeSchema(opts),
19
+ ])
20
+
21
+ /**
22
+ *
23
+ * @returns The address of the currency. If the currency is native, returns the native address constant.
24
+ */
25
+ export function getSvmCurrencyAddress(currency: SvmCurrency) {
26
+ return currency.type === 'native' ? svmNativeAddress : currency.address
27
+ }
28
+
29
+ export type SerializedSvmCurrency<
30
+ TMetadata extends CurrencyMetadata = CurrencyMetadata,
31
+ > = z.infer<ReturnType<typeof serializedSvmCurrencySchema<TMetadata>>>
@@ -0,0 +1,17 @@
1
+ import { type SerializedSvmNative, SvmNative } from './native.js'
2
+ import { type SerializedSvmToken, SvmToken } from './token.js'
3
+
4
+ function deserializeSvmCurrency(data: SerializedSvmToken): SvmToken
5
+ function deserializeSvmCurrency(data: SerializedSvmNative): SvmNative
6
+
7
+ function deserializeSvmCurrency(
8
+ data: SerializedSvmNative | SerializedSvmToken,
9
+ ) {
10
+ if (data.type === 'native') {
11
+ return new SvmNative(data)
12
+ } else {
13
+ return new SvmToken(data)
14
+ }
15
+ }
16
+
17
+ export { deserializeSvmCurrency }
@@ -0,0 +1,5 @@
1
+ export * from './currency.js'
2
+ export * from './deserialize-currency.js'
3
+ export * from './native.js'
4
+ export * from './token.js'
5
+ export * from './unwrap-token.js'