-
Notifications
You must be signed in to change notification settings - Fork 9
/
types.ts
101 lines (87 loc) · 2.68 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import { TokenAmount } from '../tokenAmount';
import { Slippage } from '../slippage';
import { PoolState } from '../types';
import { Address, Hex, InputAmount } from '../../types';
import {
AddLiquidityV2BuildCallInput,
AddLiquidityV2QueryOutput,
} from './addLiquidityV2/types';
import { Permit2 } from '../permit2Helper';
export enum AddLiquidityKind {
Unbalanced = 'Unbalanced',
SingleToken = 'SingleToken',
Proportional = 'Proportional',
}
// This will be extended for each pools specific input requirements
export type AddLiquidityBaseInput = {
chainId: number;
rpcUrl: string;
sender?: Address;
userData?: Hex;
};
export type AddLiquidityUnbalancedInput = AddLiquidityBaseInput & {
amountsIn: InputAmount[];
kind: AddLiquidityKind.Unbalanced;
};
export type AddLiquiditySingleTokenInput = AddLiquidityBaseInput & {
bptOut: InputAmount;
tokenIn: Address;
kind: AddLiquidityKind.SingleToken;
};
export type AddLiquidityProportionalInput = AddLiquidityBaseInput & {
referenceAmount: InputAmount;
kind: AddLiquidityKind.Proportional;
};
export type AddLiquidityInput =
| AddLiquidityUnbalancedInput
| AddLiquiditySingleTokenInput
| AddLiquidityProportionalInput;
export type AddLiquidityBaseQueryOutput = {
poolType: string;
poolId: Hex;
addLiquidityKind: AddLiquidityKind;
bptOut: TokenAmount;
amountsIn: TokenAmount[];
chainId: number;
tokenInIndex?: number;
protocolVersion: 1 | 2 | 3;
to: Address;
};
export type AddLiquidityQueryOutput =
| AddLiquidityBaseQueryOutput
| AddLiquidityV2QueryOutput;
export type AddLiquidityBaseBuildCallInput = {
slippage: Slippage;
wethIsEth?: boolean;
} & AddLiquidityBaseQueryOutput;
export type AddLiquidityBuildCallInput =
| AddLiquidityBaseBuildCallInput
| AddLiquidityV2BuildCallInput;
export interface AddLiquidityBase {
query(
input: AddLiquidityInput,
poolState: PoolState,
): Promise<AddLiquidityQueryOutput>;
buildCall(input: AddLiquidityBuildCallInput): AddLiquidityBuildCallOutput;
buildCallWithPermit2(
input: AddLiquidityBuildCallInput,
permit2: Permit2,
): AddLiquidityBuildCallOutput;
}
export type AddLiquidityBuildCallOutput = {
callData: Hex;
to: Address;
value: bigint;
minBptOut: TokenAmount;
maxAmountsIn: TokenAmount[];
};
export type AddLiquidityConfig = {
customAddLiquidityTypes: Record<string, AddLiquidityBase>;
};
// type exposed because FE team uses it for batching add liquidity and stake operations
export type JoinPoolRequest = {
assets: Address[];
maxAmountsIn: readonly bigint[];
userData: Hex;
fromInternalBalance: boolean;
};