sushi 6.5.4 → 6.6.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 (208) hide show
  1. package/_cjs/generic/currency/serialized-currency.js +4 -2
  2. package/_cjs/generic/currency/serialized-currency.js.map +1 -1
  3. package/_cjs/generic/currency/unwrap-token.js +10 -0
  4. package/_cjs/generic/currency/unwrap-token.js.map +1 -1
  5. package/_cjs/stellar/address.js +8 -4
  6. package/_cjs/stellar/address.js.map +1 -1
  7. package/_cjs/stellar/config/index.js +1 -0
  8. package/_cjs/stellar/config/index.js.map +1 -1
  9. package/_cjs/stellar/config/simple-constants.js +5 -5
  10. package/_cjs/stellar/config/simple-constants.js.map +1 -1
  11. package/_cjs/stellar/config/tokens/index.js +19 -0
  12. package/_cjs/stellar/config/tokens/index.js.map +1 -0
  13. package/_cjs/stellar/config/tokens/token-maps/default-bases.js +27 -0
  14. package/_cjs/stellar/config/tokens/token-maps/default-bases.js.map +1 -0
  15. package/_cjs/stellar/config/tokens/token-maps/default-quote.js +13 -0
  16. package/_cjs/stellar/config/tokens/token-maps/default-quote.js.map +1 -0
  17. package/_cjs/stellar/config/tokens/token-maps/index.js +20 -0
  18. package/_cjs/stellar/config/tokens/token-maps/index.js.map +1 -0
  19. package/_cjs/stellar/config/tokens/token-maps/stables.js +15 -0
  20. package/_cjs/stellar/config/tokens/token-maps/stables.js.map +1 -0
  21. package/_cjs/stellar/config/tokens/tokens/CETES.js +23 -0
  22. package/_cjs/stellar/config/tokens/tokens/CETES.js.map +1 -0
  23. package/_cjs/stellar/config/tokens/tokens/EURC.js +23 -0
  24. package/_cjs/stellar/config/tokens/tokens/EURC.js.map +1 -0
  25. package/_cjs/stellar/config/tokens/tokens/PYUSD.js +23 -0
  26. package/_cjs/stellar/config/tokens/tokens/PYUSD.js.map +1 -0
  27. package/_cjs/stellar/config/tokens/tokens/SolvBTC.js +23 -0
  28. package/_cjs/stellar/config/tokens/tokens/SolvBTC.js.map +1 -0
  29. package/_cjs/stellar/config/tokens/tokens/USDC.js +23 -0
  30. package/_cjs/stellar/config/tokens/tokens/USDC.js.map +1 -0
  31. package/_cjs/stellar/config/tokens/tokens/USDY.js +23 -0
  32. package/_cjs/stellar/config/tokens/tokens/USDY.js.map +1 -0
  33. package/_cjs/stellar/config/tokens/tokens/USTRY.js +23 -0
  34. package/_cjs/stellar/config/tokens/tokens/USTRY.js.map +1 -0
  35. package/_cjs/stellar/config/tokens/tokens/XLM.js +23 -0
  36. package/_cjs/stellar/config/tokens/tokens/XLM.js.map +1 -0
  37. package/_cjs/stellar/config/tokens/tokens/index.js +26 -0
  38. package/_cjs/stellar/config/tokens/tokens/index.js.map +1 -0
  39. package/_cjs/stellar/config/tokens/tokens/xSolvBTC.js +23 -0
  40. package/_cjs/stellar/config/tokens/tokens/xSolvBTC.js.map +1 -0
  41. package/_cjs/stellar/currency/currency.js +45 -0
  42. package/_cjs/stellar/currency/currency.js.map +1 -0
  43. package/_cjs/stellar/currency/deserialize-currency.js +8 -0
  44. package/_cjs/stellar/currency/deserialize-currency.js.map +1 -0
  45. package/_cjs/stellar/currency/index.js +21 -0
  46. package/_cjs/stellar/currency/index.js.map +1 -0
  47. package/_cjs/stellar/currency/token.js +94 -0
  48. package/_cjs/stellar/currency/token.js.map +1 -0
  49. package/_cjs/stellar/currency/unwrap-token.js +7 -0
  50. package/_cjs/stellar/currency/unwrap-token.js.map +1 -0
  51. package/_cjs/stellar/index.js +1 -0
  52. package/_cjs/stellar/index.js.map +1 -1
  53. package/_cjs/stellar/types/id.js +3 -0
  54. package/_cjs/stellar/types/id.js.map +1 -0
  55. package/_cjs/stellar/types/index.js +3 -0
  56. package/_cjs/stellar/types/index.js.map +1 -0
  57. package/_cjs/stellar/utils/normalize-address.js.map +1 -1
  58. package/_esm/generic/currency/serialized-currency.js +2 -0
  59. package/_esm/generic/currency/serialized-currency.js.map +1 -1
  60. package/_esm/generic/currency/unwrap-token.js +10 -0
  61. package/_esm/generic/currency/unwrap-token.js.map +1 -1
  62. package/_esm/stellar/address.js +6 -3
  63. package/_esm/stellar/address.js.map +1 -1
  64. package/_esm/stellar/config/index.js +1 -0
  65. package/_esm/stellar/config/index.js.map +1 -1
  66. package/_esm/stellar/config/simple-constants.js +5 -5
  67. package/_esm/stellar/config/simple-constants.js.map +1 -1
  68. package/_esm/stellar/config/tokens/index.js +3 -0
  69. package/_esm/stellar/config/tokens/index.js.map +1 -0
  70. package/_esm/stellar/config/tokens/token-maps/default-bases.js +24 -0
  71. package/_esm/stellar/config/tokens/token-maps/default-bases.js.map +1 -0
  72. package/_esm/stellar/config/tokens/token-maps/default-quote.js +10 -0
  73. package/_esm/stellar/config/tokens/token-maps/default-quote.js.map +1 -0
  74. package/_esm/stellar/config/tokens/token-maps/index.js +4 -0
  75. package/_esm/stellar/config/tokens/token-maps/index.js.map +1 -0
  76. package/_esm/stellar/config/tokens/token-maps/stables.js +11 -0
  77. package/_esm/stellar/config/tokens/token-maps/stables.js.map +1 -0
  78. package/_esm/stellar/config/tokens/tokens/CETES.js +20 -0
  79. package/_esm/stellar/config/tokens/tokens/CETES.js.map +1 -0
  80. package/_esm/stellar/config/tokens/tokens/EURC.js +20 -0
  81. package/_esm/stellar/config/tokens/tokens/EURC.js.map +1 -0
  82. package/_esm/stellar/config/tokens/tokens/PYUSD.js +20 -0
  83. package/_esm/stellar/config/tokens/tokens/PYUSD.js.map +1 -0
  84. package/_esm/stellar/config/tokens/tokens/SolvBTC.js +20 -0
  85. package/_esm/stellar/config/tokens/tokens/SolvBTC.js.map +1 -0
  86. package/_esm/stellar/config/tokens/tokens/USDC.js +20 -0
  87. package/_esm/stellar/config/tokens/tokens/USDC.js.map +1 -0
  88. package/_esm/stellar/config/tokens/tokens/USDY.js +20 -0
  89. package/_esm/stellar/config/tokens/tokens/USDY.js.map +1 -0
  90. package/_esm/stellar/config/tokens/tokens/USTRY.js +20 -0
  91. package/_esm/stellar/config/tokens/tokens/USTRY.js.map +1 -0
  92. package/_esm/stellar/config/tokens/tokens/XLM.js +20 -0
  93. package/_esm/stellar/config/tokens/tokens/XLM.js.map +1 -0
  94. package/_esm/stellar/config/tokens/tokens/index.js +10 -0
  95. package/_esm/stellar/config/tokens/tokens/index.js.map +1 -0
  96. package/_esm/stellar/config/tokens/tokens/xSolvBTC.js +20 -0
  97. package/_esm/stellar/config/tokens/tokens/xSolvBTC.js.map +1 -0
  98. package/_esm/stellar/currency/currency.js +7 -0
  99. package/_esm/stellar/currency/currency.js.map +1 -0
  100. package/_esm/stellar/currency/deserialize-currency.js +6 -0
  101. package/_esm/stellar/currency/deserialize-currency.js.map +1 -0
  102. package/_esm/stellar/currency/index.js +5 -0
  103. package/_esm/stellar/currency/index.js.map +1 -0
  104. package/_esm/stellar/currency/token.js +56 -0
  105. package/_esm/stellar/currency/token.js.map +1 -0
  106. package/_esm/stellar/currency/unwrap-token.js +4 -0
  107. package/_esm/stellar/currency/unwrap-token.js.map +1 -0
  108. package/_esm/stellar/index.js +1 -0
  109. package/_esm/stellar/index.js.map +1 -1
  110. package/_esm/stellar/types/id.js +2 -0
  111. package/_esm/stellar/types/id.js.map +1 -0
  112. package/_esm/stellar/types/index.js +2 -0
  113. package/_esm/stellar/types/index.js.map +1 -0
  114. package/_esm/stellar/utils/normalize-address.js.map +1 -1
  115. package/_types/generic/currency/serialized-currency.d.ts +12 -1
  116. package/_types/generic/currency/serialized-currency.d.ts.map +1 -1
  117. package/_types/generic/currency/unwrap-token.d.ts +1 -1
  118. package/_types/generic/currency/unwrap-token.d.ts.map +1 -1
  119. package/_types/generic/types/for-chain.d.ts +6 -3
  120. package/_types/generic/types/for-chain.d.ts.map +1 -1
  121. package/_types/stellar/address.d.ts +4 -2
  122. package/_types/stellar/address.d.ts.map +1 -1
  123. package/_types/stellar/config/index.d.ts +1 -0
  124. package/_types/stellar/config/index.d.ts.map +1 -1
  125. package/_types/stellar/config/simple-constants.d.ts.map +1 -1
  126. package/_types/stellar/config/tokens/index.d.ts +3 -0
  127. package/_types/stellar/config/tokens/index.d.ts.map +1 -0
  128. package/_types/stellar/config/tokens/token-maps/default-bases.d.ts +4 -0
  129. package/_types/stellar/config/tokens/token-maps/default-bases.d.ts.map +1 -0
  130. package/_types/stellar/config/tokens/token-maps/default-quote.d.ts +7 -0
  131. package/_types/stellar/config/tokens/token-maps/default-quote.d.ts.map +1 -0
  132. package/_types/stellar/config/tokens/token-maps/index.d.ts +4 -0
  133. package/_types/stellar/config/tokens/token-maps/index.d.ts.map +1 -0
  134. package/_types/stellar/config/tokens/token-maps/stables.d.ts +7 -0
  135. package/_types/stellar/config/tokens/token-maps/stables.d.ts.map +1 -0
  136. package/_types/stellar/config/tokens/tokens/CETES.d.ts +7 -0
  137. package/_types/stellar/config/tokens/tokens/CETES.d.ts.map +1 -0
  138. package/_types/stellar/config/tokens/tokens/EURC.d.ts +7 -0
  139. package/_types/stellar/config/tokens/tokens/EURC.d.ts.map +1 -0
  140. package/_types/stellar/config/tokens/tokens/PYUSD.d.ts +7 -0
  141. package/_types/stellar/config/tokens/tokens/PYUSD.d.ts.map +1 -0
  142. package/_types/stellar/config/tokens/tokens/SolvBTC.d.ts +7 -0
  143. package/_types/stellar/config/tokens/tokens/SolvBTC.d.ts.map +1 -0
  144. package/_types/stellar/config/tokens/tokens/USDC.d.ts +7 -0
  145. package/_types/stellar/config/tokens/tokens/USDC.d.ts.map +1 -0
  146. package/_types/stellar/config/tokens/tokens/USDY.d.ts +7 -0
  147. package/_types/stellar/config/tokens/tokens/USDY.d.ts.map +1 -0
  148. package/_types/stellar/config/tokens/tokens/USTRY.d.ts +7 -0
  149. package/_types/stellar/config/tokens/tokens/USTRY.d.ts.map +1 -0
  150. package/_types/stellar/config/tokens/tokens/XLM.d.ts +7 -0
  151. package/_types/stellar/config/tokens/tokens/XLM.d.ts.map +1 -0
  152. package/_types/stellar/config/tokens/tokens/index.d.ts +10 -0
  153. package/_types/stellar/config/tokens/tokens/index.d.ts.map +1 -0
  154. package/_types/stellar/config/tokens/tokens/xSolvBTC.d.ts +7 -0
  155. package/_types/stellar/config/tokens/tokens/xSolvBTC.d.ts.map +1 -0
  156. package/_types/stellar/currency/currency.d.ts +19 -0
  157. package/_types/stellar/currency/currency.d.ts.map +1 -0
  158. package/_types/stellar/currency/deserialize-currency.d.ts +4 -0
  159. package/_types/stellar/currency/deserialize-currency.d.ts.map +1 -0
  160. package/_types/stellar/currency/index.d.ts +5 -0
  161. package/_types/stellar/currency/index.d.ts.map +1 -0
  162. package/_types/stellar/currency/token.d.ts +32 -0
  163. package/_types/stellar/currency/token.d.ts.map +1 -0
  164. package/_types/stellar/currency/unwrap-token.d.ts +3 -0
  165. package/_types/stellar/currency/unwrap-token.d.ts.map +1 -0
  166. package/_types/stellar/index.d.ts +2 -0
  167. package/_types/stellar/index.d.ts.map +1 -1
  168. package/_types/stellar/types/id.d.ts +5 -0
  169. package/_types/stellar/types/id.d.ts.map +1 -0
  170. package/_types/stellar/types/index.d.ts +2 -0
  171. package/_types/stellar/types/index.d.ts.map +1 -0
  172. package/_types/stellar/utils/normalize-address.d.ts +1 -1
  173. package/_types/stellar/utils/normalize-address.d.ts.map +1 -1
  174. package/generic/currency/serialized-currency.ts +5 -0
  175. package/generic/currency/unwrap-token.test.ts +23 -0
  176. package/generic/currency/unwrap-token.ts +12 -0
  177. package/generic/types/for-chain.test-d.ts +30 -0
  178. package/generic/types/for-chain.ts +15 -6
  179. package/package.json +1 -1
  180. package/stellar/address.test.ts +47 -0
  181. package/stellar/address.ts +11 -4
  182. package/stellar/config/index.ts +1 -0
  183. package/stellar/config/simple-constants.ts +10 -7
  184. package/stellar/config/tokens/index.ts +2 -0
  185. package/stellar/config/tokens/token-maps/default-bases.ts +25 -0
  186. package/stellar/config/tokens/token-maps/default-quote.ts +12 -0
  187. package/stellar/config/tokens/token-maps/index.ts +3 -0
  188. package/stellar/config/tokens/token-maps/stables.test.ts +22 -0
  189. package/stellar/config/tokens/token-maps/stables.ts +17 -0
  190. package/stellar/config/tokens/tokens/CETES.ts +22 -0
  191. package/stellar/config/tokens/tokens/EURC.ts +22 -0
  192. package/stellar/config/tokens/tokens/PYUSD.ts +22 -0
  193. package/stellar/config/tokens/tokens/SolvBTC.ts +22 -0
  194. package/stellar/config/tokens/tokens/USDC.ts +22 -0
  195. package/stellar/config/tokens/tokens/USDY.ts +22 -0
  196. package/stellar/config/tokens/tokens/USTRY.ts +22 -0
  197. package/stellar/config/tokens/tokens/XLM.ts +22 -0
  198. package/stellar/config/tokens/tokens/index.ts +9 -0
  199. package/stellar/config/tokens/tokens/xSolvBTC.ts +22 -0
  200. package/stellar/currency/currency.ts +21 -0
  201. package/stellar/currency/deserialize-currency.ts +7 -0
  202. package/stellar/currency/index.ts +4 -0
  203. package/stellar/currency/token.ts +93 -0
  204. package/stellar/currency/unwrap-token.ts +5 -0
  205. package/stellar/index.ts +2 -0
  206. package/stellar/types/id.ts +9 -0
  207. package/stellar/types/index.ts +1 -0
  208. package/stellar/utils/normalize-address.ts +4 -4
@@ -0,0 +1,22 @@
1
+ import { StellarChainId } from '../../../chain/chains.js'
2
+ import { StellarToken } from '../../../currency/token.js'
3
+
4
+ export const STELLAR_XSOLVBTC_ADDRESS = {
5
+ [StellarChainId.STELLAR]:
6
+ 'CAUP7NFABXE5TJRL3FKTPMWRLC7IAXYDCTHQRFSCLR5TMGKHOOQO772J',
7
+ } as const
8
+
9
+ export const STELLAR_XSOLVBTC: Record<StellarChainId, StellarToken> = {
10
+ [StellarChainId.STELLAR]: new StellarToken({
11
+ chainId: StellarChainId.STELLAR,
12
+ address: STELLAR_XSOLVBTC_ADDRESS[StellarChainId.STELLAR],
13
+ issuer: undefined,
14
+ decimals: 8,
15
+ symbol: 'xSolvBTC',
16
+ name: 'xSolvBTC',
17
+ origin: 'solv.finance',
18
+ metadata: {
19
+ icon: 'https://raw.githubusercontent.com/solv-finance/solv-resources/main/xSolvBTC/xSolvBTC.svg',
20
+ },
21
+ }),
22
+ }
@@ -0,0 +1,21 @@
1
+ import * as z from 'zod'
2
+ import type { CurrencyMetadata } from '../../generic/currency/currency.js'
3
+ import { type StellarToken, serializedStellarTokenSchema } from './token.js'
4
+
5
+ export type StellarCurrency<
6
+ TMetadata extends CurrencyMetadata = Record<string, unknown>,
7
+ > = StellarToken<TMetadata>
8
+
9
+ export const serializedStellarCurrencySchema = <
10
+ TMetadata extends {} = CurrencyMetadata,
11
+ >(
12
+ opts: { metadata?: z.ZodType<TMetadata> } = {},
13
+ ) => z.discriminatedUnion('type', [serializedStellarTokenSchema(opts)])
14
+
15
+ export function getStellarCurrencyAddress(currency: StellarCurrency) {
16
+ return currency.address
17
+ }
18
+
19
+ export type SerializedStellarCurrency<
20
+ TMetadata extends CurrencyMetadata = CurrencyMetadata,
21
+ > = z.infer<ReturnType<typeof serializedStellarCurrencySchema<TMetadata>>>
@@ -0,0 +1,7 @@
1
+ import { type SerializedStellarToken, StellarToken } from './token.js'
2
+
3
+ function deserializeStellarCurrency(data: SerializedStellarToken) {
4
+ return new StellarToken(data)
5
+ }
6
+
7
+ export { deserializeStellarCurrency }
@@ -0,0 +1,4 @@
1
+ export * from './currency.js'
2
+ export * from './deserialize-currency.js'
3
+ export * from './token.js'
4
+ export * from './unwrap-token.js'
@@ -0,0 +1,93 @@
1
+ import * as z from 'zod'
2
+ import type { CurrencyMetadata } from '../../generic/currency/currency.js'
3
+ import { Token } from '../../generic/currency/token.js'
4
+ import { isStellarAddress, type StellarAddress } from '../address.js'
5
+ import { isStellarChainId, type StellarChainId } from '../chain/chains.js'
6
+ import { normalizeStellarAddress } from '../utils/normalize-address.js'
7
+
8
+ export class StellarToken<
9
+ TMetadata extends CurrencyMetadata = Record<string, unknown>,
10
+ > extends Token<StellarChainId, StellarAddress, TMetadata> {
11
+ public readonly origin: string | undefined
12
+ public readonly issuer: StellarAddress | undefined
13
+
14
+ constructor({
15
+ issuer,
16
+ origin,
17
+ address,
18
+ ...rest
19
+ }: {
20
+ issuer?: StellarAddress | undefined
21
+ origin?: string
22
+ } & ConstructorParameters<
23
+ typeof Token<StellarChainId, StellarAddress, TMetadata>
24
+ >[0]) {
25
+ super({ address: normalizeStellarAddress(address), ...rest })
26
+ this.issuer = issuer ? normalizeStellarAddress(issuer) : issuer
27
+ this.origin = origin
28
+ }
29
+
30
+ public override wrap(): StellarToken<TMetadata> {
31
+ return this
32
+ }
33
+
34
+ public override toJSON(): SerializedStellarToken<TMetadata> {
35
+ return {
36
+ chainId: this.chainId,
37
+ address: this.address,
38
+ issuer: this.issuer,
39
+ symbol: this.symbol,
40
+ name: this.name,
41
+ decimals: this.decimals,
42
+ type: this.type,
43
+
44
+ metadata: this.metadata,
45
+ } as const
46
+ }
47
+
48
+ static fromJSON<TMetadata extends CurrencyMetadata>(
49
+ data: Omit<SerializedStellarToken<TMetadata>, 'metadata'> & {
50
+ metadata?: TMetadata
51
+ },
52
+ ): StellarToken<TMetadata> {
53
+ return new this(data)
54
+ }
55
+ }
56
+
57
+ export const serializedStellarTokenSchema = <
58
+ TMetadata extends {} = CurrencyMetadata,
59
+ >({
60
+ metadata,
61
+ }: {
62
+ metadata?: z.ZodType<TMetadata>
63
+ } = {}) =>
64
+ z.object({
65
+ chainId: z
66
+ .number()
67
+ .int()
68
+ .refine(isStellarChainId)
69
+ .transform((chainId) => chainId as StellarChainId),
70
+ address: z
71
+ .string()
72
+ .refine(isStellarAddress)
73
+ .transform((address) => address as StellarAddress),
74
+ issuer: z
75
+ .string()
76
+ .refine(isStellarAddress)
77
+ .transform((address) => address as StellarAddress)
78
+ .optional(),
79
+ symbol: z.string(),
80
+ name: z.string(),
81
+ decimals: z.number().int().nonnegative(),
82
+ type: z.literal('token'),
83
+
84
+ metadata: (metadata ||
85
+ z
86
+ .record(z.string(), z.unknown())
87
+ .optional()
88
+ .default({})) as z.ZodType<TMetadata>,
89
+ })
90
+
91
+ export type SerializedStellarToken<
92
+ TMetadata extends CurrencyMetadata = CurrencyMetadata,
93
+ > = z.infer<ReturnType<typeof serializedStellarTokenSchema<TMetadata>>>
@@ -0,0 +1,5 @@
1
+ import type { StellarCurrency } from './currency.js'
2
+
3
+ export function unwrapStellarToken(currency: StellarCurrency): StellarCurrency {
4
+ return currency
5
+ }
package/stellar/index.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  export * from './address.js'
2
2
  export * from './chain/index.js'
3
3
  export * from './config/index.js'
4
+ export * from './currency/index.js'
5
+ export type * from './types/index.js'
4
6
  export * from './utils/index.js'
@@ -0,0 +1,9 @@
1
+ import type { ID } from '../../generic/types/id.js'
2
+ import type { StellarAddress } from '../address.js'
3
+ import type { StellarChainId } from '../chain/chains.js'
4
+
5
+ export type StellarID<TIncludeNative extends boolean = false> = ID<
6
+ StellarChainId,
7
+ StellarAddress,
8
+ TIncludeNative
9
+ >
@@ -0,0 +1 @@
1
+ export type * from './id.js'
@@ -1,7 +1,7 @@
1
1
  import type { StellarAddress } from '../address.js'
2
2
 
3
- export function normalizeStellarAddress(
4
- address: StellarAddress,
5
- ): StellarAddress {
6
- return address.toUpperCase() as StellarAddress
3
+ export function normalizeStellarAddress<TAddress extends StellarAddress>(
4
+ address: TAddress,
5
+ ): TAddress {
6
+ return address.toUpperCase() as TAddress
7
7
  }