-
Notifications
You must be signed in to change notification settings - Fork 21
/
types.ts
74 lines (64 loc) · 2.56 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { MonetaryAmount } from "@interlay/monetary-js";
import { CurrencyExt } from "../../../types";
import { StandardLiquidityPool } from "../liquidity-pool";
import { StableLiquidityPool } from "../liquidity-pool/stable";
interface TradingPair {
token0: CurrencyExt;
token1: CurrencyExt;
reserve0: MonetaryAmount<CurrencyExt>;
reserve1: MonetaryAmount<CurrencyExt>;
getOutputAmount: (inputAmount: MonetaryAmount<CurrencyExt>) => MonetaryAmount<CurrencyExt>;
pathOf: (inputCurrency: CurrencyExt) => MultiPathElement;
}
interface MultiPathElementBase {
type: MultiPathElementType;
input: CurrencyExt;
output: CurrencyExt;
}
enum MultiPathElementType {
STANDARD = "STANDARD",
STABLE_PLAIN = "STABLE_PLAIN",
STABLE_META = "STABLE_META",
}
interface MultiPathElementStandard extends MultiPathElementBase {
type: MultiPathElementType.STANDARD;
pair: TradingPair;
pool: StandardLiquidityPool;
}
interface MultiPathElementStablePlain extends MultiPathElementBase {
type: MultiPathElementType.STABLE_PLAIN;
pool: StableLiquidityPool;
}
interface MultiPathElementStableMeta extends MultiPathElementBase {
type: MultiPathElementType.STABLE_META;
pool: StableLiquidityPool;
basePool: StableLiquidityPool;
fromBase: boolean;
}
type MultiPathElementStable = MultiPathElementStablePlain | MultiPathElementStableMeta;
type MultiPathElement = MultiPathElementStandard | MultiPathElementStable;
const isStandardMultiPathElement = (pathElement: MultiPathElement): pathElement is MultiPathElementStandard =>
pathElement.type === MultiPathElementType.STANDARD;
const isStableMultiPathElement = (pathElement: MultiPathElement): pathElement is MultiPathElementStable =>
pathElement.type === MultiPathElementType.STABLE_META || pathElement.type === MultiPathElementType.STABLE_PLAIN;
const isStableMetaMultiPathElement = (pathElement: MultiPathElement): pathElement is MultiPathElementStableMeta =>
pathElement.type === MultiPathElementType.STABLE_META;
const isStablePlainMultiPathElement = (pathElement: MultiPathElement): pathElement is MultiPathElementStablePlain =>
pathElement.type === MultiPathElementType.STABLE_PLAIN;
type MultiPath = Array<MultiPathElement>;
export {
isStableMetaMultiPathElement,
isStableMultiPathElement,
isStablePlainMultiPathElement,
isStandardMultiPathElement,
MultiPathElementType,
};
export type {
MultiPath,
MultiPathElement,
MultiPathElementStable,
MultiPathElementStableMeta,
MultiPathElementStablePlain,
MultiPathElementStandard,
TradingPair,
};