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.
- package/_cjs/generic/currency/serialized-currency.js +4 -2
- package/_cjs/generic/currency/serialized-currency.js.map +1 -1
- package/_cjs/generic/currency/unwrap-token.js +10 -0
- package/_cjs/generic/currency/unwrap-token.js.map +1 -1
- package/_cjs/stellar/address.js +8 -4
- package/_cjs/stellar/address.js.map +1 -1
- package/_cjs/stellar/config/index.js +1 -0
- package/_cjs/stellar/config/index.js.map +1 -1
- package/_cjs/stellar/config/simple-constants.js +5 -5
- package/_cjs/stellar/config/simple-constants.js.map +1 -1
- package/_cjs/stellar/config/tokens/index.js +19 -0
- package/_cjs/stellar/config/tokens/index.js.map +1 -0
- package/_cjs/stellar/config/tokens/token-maps/default-bases.js +27 -0
- package/_cjs/stellar/config/tokens/token-maps/default-bases.js.map +1 -0
- package/_cjs/stellar/config/tokens/token-maps/default-quote.js +13 -0
- package/_cjs/stellar/config/tokens/token-maps/default-quote.js.map +1 -0
- package/_cjs/stellar/config/tokens/token-maps/index.js +20 -0
- package/_cjs/stellar/config/tokens/token-maps/index.js.map +1 -0
- package/_cjs/stellar/config/tokens/token-maps/stables.js +15 -0
- package/_cjs/stellar/config/tokens/token-maps/stables.js.map +1 -0
- package/_cjs/stellar/config/tokens/tokens/CETES.js +23 -0
- package/_cjs/stellar/config/tokens/tokens/CETES.js.map +1 -0
- package/_cjs/stellar/config/tokens/tokens/EURC.js +23 -0
- package/_cjs/stellar/config/tokens/tokens/EURC.js.map +1 -0
- package/_cjs/stellar/config/tokens/tokens/PYUSD.js +23 -0
- package/_cjs/stellar/config/tokens/tokens/PYUSD.js.map +1 -0
- package/_cjs/stellar/config/tokens/tokens/SolvBTC.js +23 -0
- package/_cjs/stellar/config/tokens/tokens/SolvBTC.js.map +1 -0
- package/_cjs/stellar/config/tokens/tokens/USDC.js +23 -0
- package/_cjs/stellar/config/tokens/tokens/USDC.js.map +1 -0
- package/_cjs/stellar/config/tokens/tokens/USDY.js +23 -0
- package/_cjs/stellar/config/tokens/tokens/USDY.js.map +1 -0
- package/_cjs/stellar/config/tokens/tokens/USTRY.js +23 -0
- package/_cjs/stellar/config/tokens/tokens/USTRY.js.map +1 -0
- package/_cjs/stellar/config/tokens/tokens/XLM.js +23 -0
- package/_cjs/stellar/config/tokens/tokens/XLM.js.map +1 -0
- package/_cjs/stellar/config/tokens/tokens/index.js +26 -0
- package/_cjs/stellar/config/tokens/tokens/index.js.map +1 -0
- package/_cjs/stellar/config/tokens/tokens/xSolvBTC.js +23 -0
- package/_cjs/stellar/config/tokens/tokens/xSolvBTC.js.map +1 -0
- package/_cjs/stellar/currency/currency.js +45 -0
- package/_cjs/stellar/currency/currency.js.map +1 -0
- package/_cjs/stellar/currency/deserialize-currency.js +8 -0
- package/_cjs/stellar/currency/deserialize-currency.js.map +1 -0
- package/_cjs/stellar/currency/index.js +21 -0
- package/_cjs/stellar/currency/index.js.map +1 -0
- package/_cjs/stellar/currency/token.js +94 -0
- package/_cjs/stellar/currency/token.js.map +1 -0
- package/_cjs/stellar/currency/unwrap-token.js +7 -0
- package/_cjs/stellar/currency/unwrap-token.js.map +1 -0
- package/_cjs/stellar/index.js +1 -0
- package/_cjs/stellar/index.js.map +1 -1
- package/_cjs/stellar/types/id.js +3 -0
- package/_cjs/stellar/types/id.js.map +1 -0
- package/_cjs/stellar/types/index.js +3 -0
- package/_cjs/stellar/types/index.js.map +1 -0
- package/_cjs/stellar/utils/normalize-address.js.map +1 -1
- package/_esm/generic/currency/serialized-currency.js +2 -0
- package/_esm/generic/currency/serialized-currency.js.map +1 -1
- package/_esm/generic/currency/unwrap-token.js +10 -0
- package/_esm/generic/currency/unwrap-token.js.map +1 -1
- package/_esm/stellar/address.js +6 -3
- package/_esm/stellar/address.js.map +1 -1
- package/_esm/stellar/config/index.js +1 -0
- package/_esm/stellar/config/index.js.map +1 -1
- package/_esm/stellar/config/simple-constants.js +5 -5
- package/_esm/stellar/config/simple-constants.js.map +1 -1
- package/_esm/stellar/config/tokens/index.js +3 -0
- package/_esm/stellar/config/tokens/index.js.map +1 -0
- package/_esm/stellar/config/tokens/token-maps/default-bases.js +24 -0
- package/_esm/stellar/config/tokens/token-maps/default-bases.js.map +1 -0
- package/_esm/stellar/config/tokens/token-maps/default-quote.js +10 -0
- package/_esm/stellar/config/tokens/token-maps/default-quote.js.map +1 -0
- package/_esm/stellar/config/tokens/token-maps/index.js +4 -0
- package/_esm/stellar/config/tokens/token-maps/index.js.map +1 -0
- package/_esm/stellar/config/tokens/token-maps/stables.js +11 -0
- package/_esm/stellar/config/tokens/token-maps/stables.js.map +1 -0
- package/_esm/stellar/config/tokens/tokens/CETES.js +20 -0
- package/_esm/stellar/config/tokens/tokens/CETES.js.map +1 -0
- package/_esm/stellar/config/tokens/tokens/EURC.js +20 -0
- package/_esm/stellar/config/tokens/tokens/EURC.js.map +1 -0
- package/_esm/stellar/config/tokens/tokens/PYUSD.js +20 -0
- package/_esm/stellar/config/tokens/tokens/PYUSD.js.map +1 -0
- package/_esm/stellar/config/tokens/tokens/SolvBTC.js +20 -0
- package/_esm/stellar/config/tokens/tokens/SolvBTC.js.map +1 -0
- package/_esm/stellar/config/tokens/tokens/USDC.js +20 -0
- package/_esm/stellar/config/tokens/tokens/USDC.js.map +1 -0
- package/_esm/stellar/config/tokens/tokens/USDY.js +20 -0
- package/_esm/stellar/config/tokens/tokens/USDY.js.map +1 -0
- package/_esm/stellar/config/tokens/tokens/USTRY.js +20 -0
- package/_esm/stellar/config/tokens/tokens/USTRY.js.map +1 -0
- package/_esm/stellar/config/tokens/tokens/XLM.js +20 -0
- package/_esm/stellar/config/tokens/tokens/XLM.js.map +1 -0
- package/_esm/stellar/config/tokens/tokens/index.js +10 -0
- package/_esm/stellar/config/tokens/tokens/index.js.map +1 -0
- package/_esm/stellar/config/tokens/tokens/xSolvBTC.js +20 -0
- package/_esm/stellar/config/tokens/tokens/xSolvBTC.js.map +1 -0
- package/_esm/stellar/currency/currency.js +7 -0
- package/_esm/stellar/currency/currency.js.map +1 -0
- package/_esm/stellar/currency/deserialize-currency.js +6 -0
- package/_esm/stellar/currency/deserialize-currency.js.map +1 -0
- package/_esm/stellar/currency/index.js +5 -0
- package/_esm/stellar/currency/index.js.map +1 -0
- package/_esm/stellar/currency/token.js +56 -0
- package/_esm/stellar/currency/token.js.map +1 -0
- package/_esm/stellar/currency/unwrap-token.js +4 -0
- package/_esm/stellar/currency/unwrap-token.js.map +1 -0
- package/_esm/stellar/index.js +1 -0
- package/_esm/stellar/index.js.map +1 -1
- package/_esm/stellar/types/id.js +2 -0
- package/_esm/stellar/types/id.js.map +1 -0
- package/_esm/stellar/types/index.js +2 -0
- package/_esm/stellar/types/index.js.map +1 -0
- package/_esm/stellar/utils/normalize-address.js.map +1 -1
- package/_types/generic/currency/serialized-currency.d.ts +12 -1
- package/_types/generic/currency/serialized-currency.d.ts.map +1 -1
- package/_types/generic/currency/unwrap-token.d.ts +1 -1
- package/_types/generic/currency/unwrap-token.d.ts.map +1 -1
- package/_types/generic/types/for-chain.d.ts +6 -3
- package/_types/generic/types/for-chain.d.ts.map +1 -1
- package/_types/stellar/address.d.ts +4 -2
- package/_types/stellar/address.d.ts.map +1 -1
- package/_types/stellar/config/index.d.ts +1 -0
- package/_types/stellar/config/index.d.ts.map +1 -1
- package/_types/stellar/config/simple-constants.d.ts.map +1 -1
- package/_types/stellar/config/tokens/index.d.ts +3 -0
- package/_types/stellar/config/tokens/index.d.ts.map +1 -0
- package/_types/stellar/config/tokens/token-maps/default-bases.d.ts +4 -0
- package/_types/stellar/config/tokens/token-maps/default-bases.d.ts.map +1 -0
- package/_types/stellar/config/tokens/token-maps/default-quote.d.ts +7 -0
- package/_types/stellar/config/tokens/token-maps/default-quote.d.ts.map +1 -0
- package/_types/stellar/config/tokens/token-maps/index.d.ts +4 -0
- package/_types/stellar/config/tokens/token-maps/index.d.ts.map +1 -0
- package/_types/stellar/config/tokens/token-maps/stables.d.ts +7 -0
- package/_types/stellar/config/tokens/token-maps/stables.d.ts.map +1 -0
- package/_types/stellar/config/tokens/tokens/CETES.d.ts +7 -0
- package/_types/stellar/config/tokens/tokens/CETES.d.ts.map +1 -0
- package/_types/stellar/config/tokens/tokens/EURC.d.ts +7 -0
- package/_types/stellar/config/tokens/tokens/EURC.d.ts.map +1 -0
- package/_types/stellar/config/tokens/tokens/PYUSD.d.ts +7 -0
- package/_types/stellar/config/tokens/tokens/PYUSD.d.ts.map +1 -0
- package/_types/stellar/config/tokens/tokens/SolvBTC.d.ts +7 -0
- package/_types/stellar/config/tokens/tokens/SolvBTC.d.ts.map +1 -0
- package/_types/stellar/config/tokens/tokens/USDC.d.ts +7 -0
- package/_types/stellar/config/tokens/tokens/USDC.d.ts.map +1 -0
- package/_types/stellar/config/tokens/tokens/USDY.d.ts +7 -0
- package/_types/stellar/config/tokens/tokens/USDY.d.ts.map +1 -0
- package/_types/stellar/config/tokens/tokens/USTRY.d.ts +7 -0
- package/_types/stellar/config/tokens/tokens/USTRY.d.ts.map +1 -0
- package/_types/stellar/config/tokens/tokens/XLM.d.ts +7 -0
- package/_types/stellar/config/tokens/tokens/XLM.d.ts.map +1 -0
- package/_types/stellar/config/tokens/tokens/index.d.ts +10 -0
- package/_types/stellar/config/tokens/tokens/index.d.ts.map +1 -0
- package/_types/stellar/config/tokens/tokens/xSolvBTC.d.ts +7 -0
- package/_types/stellar/config/tokens/tokens/xSolvBTC.d.ts.map +1 -0
- package/_types/stellar/currency/currency.d.ts +19 -0
- package/_types/stellar/currency/currency.d.ts.map +1 -0
- package/_types/stellar/currency/deserialize-currency.d.ts +4 -0
- package/_types/stellar/currency/deserialize-currency.d.ts.map +1 -0
- package/_types/stellar/currency/index.d.ts +5 -0
- package/_types/stellar/currency/index.d.ts.map +1 -0
- package/_types/stellar/currency/token.d.ts +32 -0
- package/_types/stellar/currency/token.d.ts.map +1 -0
- package/_types/stellar/currency/unwrap-token.d.ts +3 -0
- package/_types/stellar/currency/unwrap-token.d.ts.map +1 -0
- package/_types/stellar/index.d.ts +2 -0
- package/_types/stellar/index.d.ts.map +1 -1
- package/_types/stellar/types/id.d.ts +5 -0
- package/_types/stellar/types/id.d.ts.map +1 -0
- package/_types/stellar/types/index.d.ts +2 -0
- package/_types/stellar/types/index.d.ts.map +1 -0
- package/_types/stellar/utils/normalize-address.d.ts +1 -1
- package/_types/stellar/utils/normalize-address.d.ts.map +1 -1
- package/generic/currency/serialized-currency.ts +5 -0
- package/generic/currency/unwrap-token.test.ts +23 -0
- package/generic/currency/unwrap-token.ts +12 -0
- package/generic/types/for-chain.test-d.ts +30 -0
- package/generic/types/for-chain.ts +15 -6
- package/package.json +1 -1
- package/stellar/address.test.ts +47 -0
- package/stellar/address.ts +11 -4
- package/stellar/config/index.ts +1 -0
- package/stellar/config/simple-constants.ts +10 -7
- package/stellar/config/tokens/index.ts +2 -0
- package/stellar/config/tokens/token-maps/default-bases.ts +25 -0
- package/stellar/config/tokens/token-maps/default-quote.ts +12 -0
- package/stellar/config/tokens/token-maps/index.ts +3 -0
- package/stellar/config/tokens/token-maps/stables.test.ts +22 -0
- package/stellar/config/tokens/token-maps/stables.ts +17 -0
- package/stellar/config/tokens/tokens/CETES.ts +22 -0
- package/stellar/config/tokens/tokens/EURC.ts +22 -0
- package/stellar/config/tokens/tokens/PYUSD.ts +22 -0
- package/stellar/config/tokens/tokens/SolvBTC.ts +22 -0
- package/stellar/config/tokens/tokens/USDC.ts +22 -0
- package/stellar/config/tokens/tokens/USDY.ts +22 -0
- package/stellar/config/tokens/tokens/USTRY.ts +22 -0
- package/stellar/config/tokens/tokens/XLM.ts +22 -0
- package/stellar/config/tokens/tokens/index.ts +9 -0
- package/stellar/config/tokens/tokens/xSolvBTC.ts +22 -0
- package/stellar/currency/currency.ts +21 -0
- package/stellar/currency/deserialize-currency.ts +7 -0
- package/stellar/currency/index.ts +4 -0
- package/stellar/currency/token.ts +93 -0
- package/stellar/currency/unwrap-token.ts +5 -0
- package/stellar/index.ts +2 -0
- package/stellar/types/id.ts +9 -0
- package/stellar/types/index.ts +1 -0
- 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,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>>>
|
package/stellar/index.ts
CHANGED
|
@@ -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:
|
|
5
|
-
):
|
|
6
|
-
return address.toUpperCase() as
|
|
3
|
+
export function normalizeStellarAddress<TAddress extends StellarAddress>(
|
|
4
|
+
address: TAddress,
|
|
5
|
+
): TAddress {
|
|
6
|
+
return address.toUpperCase() as TAddress
|
|
7
7
|
}
|