sushi 7.1.0 → 7.2.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/evm/config/subgraphs/get-subgraph-url.js +13 -1
- package/_cjs/evm/config/subgraphs/get-subgraph-url.js.map +1 -1
- package/_cjs/evm/config/subgraphs/index.js.map +1 -1
- package/_cjs/generic/currency/amount.js.map +1 -1
- package/_cjs/generic/currency/currency.js +1 -0
- package/_cjs/generic/currency/currency.js.map +1 -1
- package/_cjs/generic/currency/price.js.map +1 -1
- package/_cjs/generic/currency/token.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/evm/config/subgraphs/get-subgraph-url.js +13 -1
- package/_esm/evm/config/subgraphs/get-subgraph-url.js.map +1 -1
- package/_esm/evm/config/subgraphs/index.js.map +1 -1
- package/_esm/generic/currency/amount.js.map +1 -1
- package/_esm/generic/currency/currency.js +1 -0
- package/_esm/generic/currency/currency.js.map +1 -1
- package/_esm/generic/currency/price.js.map +1 -1
- package/_esm/generic/currency/token.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_types/evm/config/subgraphs/get-subgraph-url.d.ts +7 -1
- package/_types/evm/config/subgraphs/get-subgraph-url.d.ts.map +1 -1
- package/_types/evm/config/subgraphs/index.d.ts +1 -0
- package/_types/evm/config/subgraphs/index.d.ts.map +1 -1
- package/_types/evm/config/subgraphs/subgraphs/blade.d.ts +5 -2
- package/_types/evm/config/subgraphs/subgraphs/blade.d.ts.map +1 -1
- package/_types/evm/config/subgraphs/subgraphs/blocks.d.ts +5 -2
- package/_types/evm/config/subgraphs/subgraphs/blocks.d.ts.map +1 -1
- package/_types/evm/config/subgraphs/subgraphs/master-chef-v1.d.ts +5 -2
- package/_types/evm/config/subgraphs/subgraphs/master-chef-v1.d.ts.map +1 -1
- package/_types/evm/config/subgraphs/subgraphs/master-chef-v2.d.ts +5 -2
- package/_types/evm/config/subgraphs/subgraphs/master-chef-v2.d.ts.map +1 -1
- package/_types/evm/config/subgraphs/subgraphs/mini-chef.d.ts +5 -2
- package/_types/evm/config/subgraphs/subgraphs/mini-chef.d.ts.map +1 -1
- package/_types/evm/config/subgraphs/subgraphs/sushi-bar.d.ts +5 -2
- package/_types/evm/config/subgraphs/subgraphs/sushi-bar.d.ts.map +1 -1
- package/_types/evm/config/subgraphs/subgraphs/sushiswap-v2.d.ts +5 -2
- package/_types/evm/config/subgraphs/subgraphs/sushiswap-v2.d.ts.map +1 -1
- package/_types/evm/config/subgraphs/subgraphs/sushiswap-v3.d.ts +5 -2
- package/_types/evm/config/subgraphs/subgraphs/sushiswap-v3.d.ts.map +1 -1
- package/_types/generic/currency/amount.d.ts +17 -17
- package/_types/generic/currency/amount.d.ts.map +1 -1
- package/_types/generic/currency/currency.d.ts +4 -2
- package/_types/generic/currency/currency.d.ts.map +1 -1
- package/_types/generic/currency/price.d.ts +4 -4
- package/_types/generic/currency/price.d.ts.map +1 -1
- package/_types/generic/currency/token.d.ts +1 -1
- package/_types/generic/currency/token.d.ts.map +1 -1
- package/_types/generic/types/id.d.ts +1 -1
- package/_types/generic/types/id.d.ts.map +1 -1
- package/_types/generic/utils/subtract-slippage.d.ts +2 -2
- package/_types/generic/utils/subtract-slippage.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/evm/config/subgraphs/get-subgraph-url.ts +31 -1
- package/evm/config/subgraphs/index.ts +1 -0
- package/evm/config/subgraphs/subgraph-url.test-d.ts +51 -0
- package/evm/config/subgraphs/subgraph-url.test.ts +28 -0
- package/generic/currency/amount.ts +30 -25
- package/generic/currency/currency.ts +11 -2
- package/generic/currency/extensible-currency.test-d.ts +51 -0
- package/generic/currency/extensible-currency.test.ts +83 -0
- package/generic/currency/price.ts +11 -9
- package/generic/currency/token.ts +1 -1
- package/generic/types/id.ts +1 -1
- package/generic/utils/subtract-slippage.ts +2 -2
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Fraction } from '../math/fraction.js'
|
|
2
2
|
import type { BigintIsh } from '../types/bigintish.js'
|
|
3
3
|
import { Amount } from './amount.js'
|
|
4
|
-
import type {
|
|
4
|
+
import type { AnyCurrency } from './currency.js'
|
|
5
5
|
|
|
6
6
|
export class Price<
|
|
7
|
-
TBase extends
|
|
8
|
-
TQuote extends
|
|
7
|
+
TBase extends AnyCurrency,
|
|
8
|
+
TQuote extends AnyCurrency,
|
|
9
9
|
> extends Fraction {
|
|
10
10
|
public readonly base: TBase
|
|
11
11
|
public readonly quote: TQuote
|
|
@@ -13,11 +13,10 @@ export class Price<
|
|
|
13
13
|
/**
|
|
14
14
|
* Creates a Price from a human-readable quote-per-base value, e.g. "1.5".
|
|
15
15
|
*/
|
|
16
|
-
public static fromHuman<
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
): Price<TBase, TQuote> {
|
|
16
|
+
public static fromHuman<
|
|
17
|
+
TBase extends AnyCurrency,
|
|
18
|
+
TQuote extends AnyCurrency,
|
|
19
|
+
>(base: TBase, quote: TQuote, value: string): Price<TBase, TQuote> {
|
|
21
20
|
if (!value.match(/^\d*\.?\d+$/)) {
|
|
22
21
|
throw new Error(`Invalid price: ${value}`)
|
|
23
22
|
}
|
|
@@ -37,7 +36,10 @@ export class Price<
|
|
|
37
36
|
/**
|
|
38
37
|
* Tries to create a Price from a human-readable quote-per-base value.
|
|
39
38
|
*/
|
|
40
|
-
public static tryFromHuman<
|
|
39
|
+
public static tryFromHuman<
|
|
40
|
+
TBase extends AnyCurrency,
|
|
41
|
+
TQuote extends AnyCurrency,
|
|
42
|
+
>(
|
|
41
43
|
base: TBase,
|
|
42
44
|
quote: TQuote,
|
|
43
45
|
value: string,
|
package/generic/types/id.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Amount } from '../currency/amount.js'
|
|
2
|
-
import type {
|
|
2
|
+
import type { AnyCurrency } from '../currency/currency.js'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
*
|
|
@@ -8,7 +8,7 @@ import type { Currency } from '../currency/currency.js'
|
|
|
8
8
|
*
|
|
9
9
|
* @returns The amount after subtracting the slippage, eg. amount * 0.9 if slippage is 10% (0.1).
|
|
10
10
|
*/
|
|
11
|
-
export function subtractSlippage<TCurrency extends
|
|
11
|
+
export function subtractSlippage<TCurrency extends AnyCurrency>(
|
|
12
12
|
amount: Amount<TCurrency>,
|
|
13
13
|
slippage: number,
|
|
14
14
|
) {
|