-
Notifications
You must be signed in to change notification settings - Fork 11
/
types.ts
127 lines (111 loc) · 3.82 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import { TokenAmount } from '../tokenAmount';
import { Slippage } from '../slippage';
import { Address, InputAmount } from '../../types';
import { PoolState } from '../types';
import {
RemoveLiquidityV2BuildCallInput,
RemoveLiquidityV2QueryOutput,
} from './removeLiquidityV2/types';
import { Permit } from '../permitHelper';
import { RemoveLiquidityBoostedBuildCallInput } from '../removeLiquidityBoosted/types';
import { Hex } from 'viem';
export enum RemoveLiquidityKind {
Unbalanced = 'Unbalanced', // exact out
SingleTokenExactOut = 'SingleTokenExactOut', // exact out (single token out)
SingleTokenExactIn = 'SingleTokenExactIn', // exact in (single token out)
Proportional = 'Proportional', // exact in (all tokens out)
Recovery = 'Recovery', // exact in (all tokens out) - Pool in recovery mode
}
// This will be extended for each pools specific output requirements
export type RemoveLiquidityBaseInput = {
chainId: number;
rpcUrl: string;
sender?: Address;
userData?: Hex;
};
export type RemoveLiquidityUnbalancedInput = RemoveLiquidityBaseInput & {
amountsOut: InputAmount[];
kind: RemoveLiquidityKind.Unbalanced;
};
export type RemoveLiquiditySingleTokenExactOutInput =
RemoveLiquidityBaseInput & {
amountOut: InputAmount;
kind: RemoveLiquidityKind.SingleTokenExactOut;
};
export type RemoveLiquiditySingleTokenExactInInput =
RemoveLiquidityBaseInput & {
bptIn: InputAmount;
tokenOut: Address;
kind: RemoveLiquidityKind.SingleTokenExactIn;
};
export type RemoveLiquidityProportionalInput = RemoveLiquidityBaseInput & {
bptIn: InputAmount;
kind: RemoveLiquidityKind.Proportional;
};
export type RemoveLiquidityRecoveryInput = RemoveLiquidityBaseInput & {
bptIn: InputAmount;
kind: RemoveLiquidityKind.Recovery;
};
export type RemoveLiquidityInput =
| RemoveLiquidityUnbalancedInput
| RemoveLiquiditySingleTokenExactOutInput
| RemoveLiquiditySingleTokenExactInInput
| RemoveLiquidityProportionalInput
| RemoveLiquidityRecoveryInput;
// Returned from a remove liquidity query
export type RemoveLiquidityBaseQueryOutput = {
poolType: string;
poolId: Address;
removeLiquidityKind: RemoveLiquidityKind;
bptIn: TokenAmount;
amountsOut: TokenAmount[];
tokenOutIndex?: number;
protocolVersion: 1 | 2 | 3;
chainId: number;
to: Address;
};
export type RemoveLiquidityQueryOutput =
| RemoveLiquidityBaseQueryOutput
| RemoveLiquidityV2QueryOutput;
export type RemoveLiquidityBaseBuildCallInput = {
slippage: Slippage;
wethIsEth?: boolean;
} & RemoveLiquidityBaseQueryOutput;
export type RemoveLiquidityBuildCallInput =
| RemoveLiquidityBaseBuildCallInput
| RemoveLiquidityV2BuildCallInput
| RemoveLiquidityBoostedBuildCallInput;
export type RemoveLiquidityBuildCallOutput = {
callData: Address;
to: Address;
value: bigint;
maxBptIn: TokenAmount;
minAmountsOut: TokenAmount[];
};
export interface RemoveLiquidityBase {
query(
input: RemoveLiquidityInput,
poolState: PoolState,
): Promise<RemoveLiquidityQueryOutput>;
queryRemoveLiquidityRecovery(
input: RemoveLiquidityRecoveryInput,
poolState: PoolState,
): Promise<RemoveLiquidityQueryOutput>;
buildCall(
input: RemoveLiquidityBuildCallInput,
): RemoveLiquidityBuildCallOutput;
buildCallWithPermit(
input: RemoveLiquidityBuildCallInput,
permit: Permit,
): RemoveLiquidityBuildCallOutput;
}
export type RemoveLiquidityConfig = {
customRemoveLiquidityTypes: Record<string, RemoveLiquidityBase>;
};
// type exposed because FE team uses it for batching unstake and remove liquidity operations
export type ExitPoolRequest = {
assets: Address[];
minAmountsOut: bigint[];
userData: Address;
toInternalBalance: boolean;
};