@steerprotocol/sdk 1.19.14 → 1.19.16
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/README.md +281 -11
- package/dist/cjs/base/VaultClient.js +95 -1
- package/dist/cjs/base/VaultClient.js.map +1 -1
- package/dist/cjs/base/vault/single-asset/calculateLimitPrice.js +231 -0
- package/dist/cjs/base/vault/single-asset/calculateLimitPrice.js.map +1 -0
- package/dist/cjs/base/vault/single-asset/calculateSwapAmount.js +68 -0
- package/dist/cjs/base/vault/single-asset/calculateSwapAmount.js.map +1 -0
- package/dist/cjs/base/vault/single-asset/estimateLpTokens.js +355 -0
- package/dist/cjs/base/vault/single-asset/estimateLpTokens.js.map +1 -0
- package/dist/cjs/base/vault/single-asset/index.js +109 -0
- package/dist/cjs/base/vault/single-asset/index.js.map +1 -0
- package/dist/cjs/base/vault/single-asset/simulateSwap.js +291 -0
- package/dist/cjs/base/vault/single-asset/simulateSwap.js.map +1 -0
- package/dist/cjs/base/vault/single-asset/singleAssetDeposit.js +324 -0
- package/dist/cjs/base/vault/single-asset/singleAssetDeposit.js.map +1 -0
- package/dist/cjs/base/vault/single-asset/types.js +15 -0
- package/dist/cjs/base/vault/single-asset/types.js.map +1 -0
- package/dist/cjs/base/vault/utils.js +229 -18
- package/dist/cjs/base/vault/utils.js.map +1 -1
- package/dist/cjs/const/abis/index.js +3 -0
- package/dist/cjs/const/abis/index.js.map +1 -1
- package/dist/cjs/const/abis/quoter.js +248 -0
- package/dist/cjs/const/abis/quoter.js.map +1 -0
- package/dist/cjs/const/abis/singleTokenDeposit.js +925 -0
- package/dist/cjs/const/abis/singleTokenDeposit.js.map +1 -0
- package/dist/cjs/const/amm/configs/protocols/quickswap-integral.js +3 -0
- package/dist/cjs/const/amm/configs/protocols/quickswap-integral.js.map +1 -1
- package/dist/cjs/const/amm/configs/protocols/uniswap.js +15 -0
- package/dist/cjs/const/amm/configs/protocols/uniswap.js.map +1 -1
- package/dist/cjs/const/deployments/abis.js +277 -0
- package/dist/cjs/const/deployments/abis.js.map +1 -1
- package/dist/cjs/const/deployments/polygon.js +8 -0
- package/dist/cjs/const/deployments/polygon.js.map +1 -1
- package/dist/cjs/const/index.js +6 -5
- package/dist/cjs/const/index.js.map +1 -1
- package/dist/cjs/const/network.js.map +1 -1
- package/dist/cjs/const/quoter.js +38 -0
- package/dist/cjs/const/quoter.js.map +1 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/base/VaultClient.js +81 -1
- package/dist/esm/base/VaultClient.js.map +1 -1
- package/dist/esm/base/vault/single-asset/calculateLimitPrice.js +224 -0
- package/dist/esm/base/vault/single-asset/calculateLimitPrice.js.map +1 -0
- package/dist/esm/base/vault/single-asset/calculateSwapAmount.js +65 -0
- package/dist/esm/base/vault/single-asset/calculateSwapAmount.js.map +1 -0
- package/dist/esm/base/vault/single-asset/estimateLpTokens.js +350 -0
- package/dist/esm/base/vault/single-asset/estimateLpTokens.js.map +1 -0
- package/dist/esm/base/vault/single-asset/index.js +83 -0
- package/dist/esm/base/vault/single-asset/index.js.map +1 -0
- package/dist/esm/base/vault/single-asset/simulateSwap.js +285 -0
- package/dist/esm/base/vault/single-asset/simulateSwap.js.map +1 -0
- package/dist/esm/base/vault/single-asset/singleAssetDeposit.js +320 -0
- package/dist/esm/base/vault/single-asset/singleAssetDeposit.js.map +1 -0
- package/dist/esm/base/vault/single-asset/types.js +12 -0
- package/dist/esm/base/vault/single-asset/types.js.map +1 -0
- package/dist/esm/base/vault/utils.js +226 -18
- package/dist/esm/base/vault/utils.js.map +1 -1
- package/dist/esm/const/abis/index.js +3 -0
- package/dist/esm/const/abis/index.js.map +1 -1
- package/dist/esm/const/abis/quoter.js +245 -0
- package/dist/esm/const/abis/quoter.js.map +1 -0
- package/dist/esm/const/abis/singleTokenDeposit.js +922 -0
- package/dist/esm/const/abis/singleTokenDeposit.js.map +1 -0
- package/dist/esm/const/amm/configs/protocols/quickswap-integral.js +3 -0
- package/dist/esm/const/amm/configs/protocols/quickswap-integral.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/uniswap.js +15 -0
- package/dist/esm/const/amm/configs/protocols/uniswap.js.map +1 -1
- package/dist/esm/const/deployments/abis.js +277 -0
- package/dist/esm/const/deployments/abis.js.map +1 -1
- package/dist/esm/const/deployments/polygon.js +8 -0
- package/dist/esm/const/deployments/polygon.js.map +1 -1
- package/dist/esm/const/index.js +6 -5
- package/dist/esm/const/index.js.map +1 -1
- package/dist/esm/const/network.js.map +1 -1
- package/dist/esm/const/quoter.js +34 -0
- package/dist/esm/const/quoter.js.map +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/types/base/VaultClient.d.ts +136 -4
- package/dist/types/base/VaultClient.d.ts.map +1 -1
- package/dist/types/base/vault/single-asset/calculateLimitPrice.d.ts +59 -0
- package/dist/types/base/vault/single-asset/calculateLimitPrice.d.ts.map +1 -0
- package/dist/types/base/vault/single-asset/calculateSwapAmount.d.ts +30 -0
- package/dist/types/base/vault/single-asset/calculateSwapAmount.d.ts.map +1 -0
- package/dist/types/base/vault/single-asset/estimateLpTokens.d.ts +61 -0
- package/dist/types/base/vault/single-asset/estimateLpTokens.d.ts.map +1 -0
- package/dist/types/base/vault/single-asset/index.d.ts +80 -0
- package/dist/types/base/vault/single-asset/index.d.ts.map +1 -0
- package/dist/types/base/vault/single-asset/simulateSwap.d.ts +119 -0
- package/dist/types/base/vault/single-asset/simulateSwap.d.ts.map +1 -0
- package/dist/types/base/vault/single-asset/singleAssetDeposit.d.ts +141 -0
- package/dist/types/base/vault/single-asset/singleAssetDeposit.d.ts.map +1 -0
- package/dist/types/base/vault/single-asset/types.d.ts +167 -0
- package/dist/types/base/vault/single-asset/types.d.ts.map +1 -0
- package/dist/types/base/vault/utils.d.ts +95 -0
- package/dist/types/base/vault/utils.d.ts.map +1 -1
- package/dist/types/const/abis/index.d.ts +3 -0
- package/dist/types/const/abis/index.d.ts.map +1 -1
- package/dist/types/const/abis/quoter.d.ts +206 -0
- package/dist/types/const/abis/quoter.d.ts.map +1 -0
- package/dist/types/const/abis/singleTokenDeposit.d.ts +47 -0
- package/dist/types/const/abis/singleTokenDeposit.d.ts.map +1 -0
- package/dist/types/const/amm/configs/protocols/quickswap-integral.d.ts.map +1 -1
- package/dist/types/const/amm/configs/protocols/uniswap.d.ts.map +1 -1
- package/dist/types/const/deployments/abis.d.ts +215 -0
- package/dist/types/const/deployments/abis.d.ts.map +1 -1
- package/dist/types/const/deployments/polygon.d.ts.map +1 -1
- package/dist/types/const/index.d.ts +6 -5
- package/dist/types/const/index.d.ts.map +1 -1
- package/dist/types/const/network.d.ts +2 -0
- package/dist/types/const/network.d.ts.map +1 -1
- package/dist/types/const/quoter.d.ts +17 -0
- package/dist/types/const/quoter.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types.d.ts +3 -0
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import { decodeFunctionResult, encodeFunctionData } from 'viem';
|
|
2
|
+
import { UniswapV3QuoterABI } from '../../../const/abis/quoter';
|
|
3
|
+
import { getQuoterAddressByChainId } from '../../../const/quoter';
|
|
4
|
+
import { getPoolPrice } from '../utils';
|
|
5
|
+
import { bigintToDecimal, decimalToBigint, getPoolSlot0, getQuoteFromSqrtRatioX96 } from './calculateLimitPrice';
|
|
6
|
+
import { AMMType } from './types';
|
|
7
|
+
/**
|
|
8
|
+
* Simulates a swap to get the expected output amounts without executing the swap
|
|
9
|
+
* Uses Uniswap V3 Quoter contract for accurate simulation
|
|
10
|
+
*
|
|
11
|
+
* @param publicClient - Viem public client for blockchain reads
|
|
12
|
+
* @param params - Parameters for swap simulation
|
|
13
|
+
* @param chainId - Chain ID to get the appropriate Quoter address
|
|
14
|
+
* @returns Promise resolving to the simulated swap results
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const result = await simulateSwap(publicClient, {
|
|
19
|
+
* pool: '0x...',
|
|
20
|
+
* recipient: '0x...',
|
|
21
|
+
* zeroForOne: true,
|
|
22
|
+
* amountSpecified: parseEther('10'),
|
|
23
|
+
* sqrtPriceLimitX96: limitPrice,
|
|
24
|
+
* ammType: AMMType.UniswapV3,
|
|
25
|
+
* tokenIn: '0x...',
|
|
26
|
+
* tokenOut: '0x...',
|
|
27
|
+
* fee: 3000
|
|
28
|
+
* }, 137); // Polygon chain ID
|
|
29
|
+
*
|
|
30
|
+
* if (result.success) {
|
|
31
|
+
* console.log('Amount out:', result.data.amountOut);
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export async function simulateSwap(publicClient, params, chainId) {
|
|
36
|
+
try {
|
|
37
|
+
// For now, only handle UniswapV3 - other AMMs can be added later
|
|
38
|
+
if (params.ammType !== AMMType.UniswapV3) {
|
|
39
|
+
throw new Error(`AMM type ${params.ammType} not yet supported. Use UniswapV3 for now.`);
|
|
40
|
+
}
|
|
41
|
+
// Get the appropriate Quoter contract address
|
|
42
|
+
const quoterAddress = params.quoterAddress || getQuoterAddressByChainId(chainId);
|
|
43
|
+
// Use Quoter's quoteExactInputSingle for simulation
|
|
44
|
+
const result = await publicClient.call({
|
|
45
|
+
to: quoterAddress,
|
|
46
|
+
data: encodeFunctionData({
|
|
47
|
+
abi: UniswapV3QuoterABI,
|
|
48
|
+
functionName: 'quoteExactInputSingle',
|
|
49
|
+
args: [
|
|
50
|
+
{
|
|
51
|
+
tokenIn: params.tokenIn,
|
|
52
|
+
tokenOut: params.tokenOut,
|
|
53
|
+
amountIn: params.amountSpecified,
|
|
54
|
+
fee: params.fee,
|
|
55
|
+
sqrtPriceLimitX96: params.sqrtPriceLimitX96
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
})
|
|
59
|
+
});
|
|
60
|
+
if (!result.data) {
|
|
61
|
+
throw new Error('No data returned from quoter simulation');
|
|
62
|
+
}
|
|
63
|
+
// Decode the result - Quoter returns a tuple: [amountOut, sqrtPriceX96After, initializedTicksCrossed, gasEstimate]
|
|
64
|
+
const [amountOut, sqrtPriceX96After] = decodeFunctionResult({
|
|
65
|
+
abi: UniswapV3QuoterABI,
|
|
66
|
+
functionName: 'quoteExactInputSingle',
|
|
67
|
+
data: result.data
|
|
68
|
+
});
|
|
69
|
+
// Convert to the expected SwapSimulationResponse format
|
|
70
|
+
// For exact input swaps, we know the input amount and get the output amount
|
|
71
|
+
let amount0, amount1;
|
|
72
|
+
if (params.zeroForOne) {
|
|
73
|
+
// Swapping token0 for token1
|
|
74
|
+
amount0 = -params.amountSpecified; // negative because we're giving token0
|
|
75
|
+
amount1 = amountOut; // positive because we're receiving token1
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
// Swapping token1 for token0
|
|
79
|
+
amount0 = amountOut; // positive because we're receiving token0
|
|
80
|
+
amount1 = -params.amountSpecified; // negative because we're giving token1
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
data: {
|
|
84
|
+
amount0,
|
|
85
|
+
amount1,
|
|
86
|
+
sqrtPriceX96After
|
|
87
|
+
},
|
|
88
|
+
status: 200,
|
|
89
|
+
success: true
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
return {
|
|
94
|
+
data: null,
|
|
95
|
+
status: 500,
|
|
96
|
+
success: false,
|
|
97
|
+
error: error instanceof Error ? error.message : 'Failed to simulate swap'
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Determines the swap direction based on the token being deposited
|
|
103
|
+
*
|
|
104
|
+
* @param isToken0 - true if depositing token0, false if token1
|
|
105
|
+
* @returns true if swapping token0 → token1, false otherwise
|
|
106
|
+
*/
|
|
107
|
+
export function determineSwapDirection(isToken0) {
|
|
108
|
+
// If depositing token0, we need to swap some token0 to token1
|
|
109
|
+
// If depositing token1, we need to swap some token1 to token0
|
|
110
|
+
return isToken0;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Validates swap simulation parameters
|
|
114
|
+
*
|
|
115
|
+
* @param params - Parameters to validate
|
|
116
|
+
* @throws Error if parameters are invalid
|
|
117
|
+
*/
|
|
118
|
+
export function validateSwapParams(params) {
|
|
119
|
+
if (!params.pool || params.pool === '0x0000000000000000000000000000000000000000') {
|
|
120
|
+
throw new Error('Invalid pool address');
|
|
121
|
+
}
|
|
122
|
+
if (!params.recipient || params.recipient === '0x0000000000000000000000000000000000000000') {
|
|
123
|
+
throw new Error('Invalid recipient address');
|
|
124
|
+
}
|
|
125
|
+
if (params.amountSpecified <= 0n) {
|
|
126
|
+
throw new Error('Amount specified must be greater than 0');
|
|
127
|
+
}
|
|
128
|
+
if (params.sqrtPriceLimitX96 <= 0n) {
|
|
129
|
+
throw new Error('Sqrt price limit must be greater than 0');
|
|
130
|
+
}
|
|
131
|
+
if (!params.tokenIn || params.tokenIn === '0x0000000000000000000000000000000000000000') {
|
|
132
|
+
throw new Error('Invalid tokenIn address');
|
|
133
|
+
}
|
|
134
|
+
if (!params.tokenOut || params.tokenOut === '0x0000000000000000000000000000000000000000') {
|
|
135
|
+
throw new Error('Invalid tokenOut address');
|
|
136
|
+
}
|
|
137
|
+
if (params.fee <= 0) {
|
|
138
|
+
throw new Error('Pool fee must be greater than 0');
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Simulates a swap with slippage analysis by first getting current pool state,
|
|
143
|
+
* then simulating the swap and calculating price impact
|
|
144
|
+
*
|
|
145
|
+
* @param publicClient - Viem public client for blockchain reads
|
|
146
|
+
* @param params - Parameters for swap simulation with slippage analysis
|
|
147
|
+
* @param chainId - Chain ID to get the appropriate Quoter address
|
|
148
|
+
* @returns Promise resolving to swap results with slippage analysis
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```typescript
|
|
152
|
+
* const result = await simulateSwapWithSlippage(publicClient, {
|
|
153
|
+
* poolAddress: '0x...',
|
|
154
|
+
* recipient: '0x...',
|
|
155
|
+
* zeroForOne: true,
|
|
156
|
+
* amountSpecified: parseEther('10'),
|
|
157
|
+
* sqrtPriceLimitX96: limitPrice,
|
|
158
|
+
* ammType: AMMType.UniswapV3,
|
|
159
|
+
* tokenIn: '0x...',
|
|
160
|
+
* tokenOut: '0x...',
|
|
161
|
+
* fee: 3000
|
|
162
|
+
* }, 137); // Polygon chain ID
|
|
163
|
+
*
|
|
164
|
+
* if (result.success) {
|
|
165
|
+
* console.log('Price slippage:', result.data.priceSlippagePercent, '%');
|
|
166
|
+
* console.log('Current price:', result.data.currentPrice);
|
|
167
|
+
* console.log('Price after swap:', result.data.priceAfter);
|
|
168
|
+
* }
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
export async function simulateSwapWithSlippage(publicClient, params, chainId) {
|
|
172
|
+
try {
|
|
173
|
+
// Validate params
|
|
174
|
+
validateSwapWithSlippageParams(params);
|
|
175
|
+
// Step 1: Get current pool state from slot0
|
|
176
|
+
const slot0Result = await getPoolSlot0(publicClient, params.poolAddress, params.ammType);
|
|
177
|
+
if (!slot0Result.data) {
|
|
178
|
+
throw new Error('Failed to get pool slot0 data');
|
|
179
|
+
}
|
|
180
|
+
// Decode slot0 result
|
|
181
|
+
const currentSlot0 = {
|
|
182
|
+
sqrtPriceX96: getPoolPrice(slot0Result.data, {
|
|
183
|
+
isAlgebraPool: params.ammType === AMMType.Algebra,
|
|
184
|
+
isAlgebraIntegralPool: params.ammType === AMMType.AlgebraIntegral,
|
|
185
|
+
isPoolSharkPool: false // PoolShark not defined in AMMType enum
|
|
186
|
+
}) || BigInt(0),
|
|
187
|
+
tick: slot0Result.data.tick,
|
|
188
|
+
observationIndex: slot0Result.data.observationIndex,
|
|
189
|
+
observationCardinality: slot0Result.data.observationCardinality,
|
|
190
|
+
observationCardinalityNext: slot0Result.data.observationCardinalityNext,
|
|
191
|
+
feeProtocol: slot0Result.data.feeProtocol,
|
|
192
|
+
unlocked: slot0Result.data.unlocked
|
|
193
|
+
};
|
|
194
|
+
// Step 2: Simulate the swap using existing function
|
|
195
|
+
const swapParams = {
|
|
196
|
+
pool: params.poolAddress,
|
|
197
|
+
recipient: params.recipient,
|
|
198
|
+
zeroForOne: params.zeroForOne,
|
|
199
|
+
amountSpecified: params.amountSpecified,
|
|
200
|
+
sqrtPriceLimitX96: params.sqrtPriceLimitX96,
|
|
201
|
+
ammType: params.ammType,
|
|
202
|
+
tokenIn: params.tokenIn,
|
|
203
|
+
tokenOut: params.tokenOut,
|
|
204
|
+
fee: params.fee,
|
|
205
|
+
quoterAddress: params.quoterAddress
|
|
206
|
+
};
|
|
207
|
+
const swapResult = await simulateSwap(publicClient, swapParams, chainId);
|
|
208
|
+
if (!swapResult.success || !swapResult.data) {
|
|
209
|
+
throw new Error(swapResult.error || 'Swap simulation failed');
|
|
210
|
+
}
|
|
211
|
+
// Step 3: Calculate price slippage
|
|
212
|
+
const currentPrice = getQuoteFromSqrtRatioX96(bigintToDecimal(currentSlot0.sqrtPriceX96), bigintToDecimal(10n ** 18n), params.tokenIn, params.tokenOut);
|
|
213
|
+
const priceAfter = getQuoteFromSqrtRatioX96(bigintToDecimal(swapResult.data.sqrtPriceX96After), bigintToDecimal(10n ** 18n), params.tokenIn, params.tokenOut);
|
|
214
|
+
// Calculate slippage percentage
|
|
215
|
+
// Positive slippage means unfavorable price movement
|
|
216
|
+
const priceSlippagePercent = calculatePriceSlippage(currentPrice, priceAfter, params.zeroForOne);
|
|
217
|
+
return {
|
|
218
|
+
data: {
|
|
219
|
+
currentSlot0,
|
|
220
|
+
swapSimulation: swapResult.data,
|
|
221
|
+
priceSlippagePercent: priceSlippagePercent.toFixed(5),
|
|
222
|
+
currentPrice: decimalToBigint(currentPrice),
|
|
223
|
+
priceAfter: decimalToBigint(priceAfter)
|
|
224
|
+
},
|
|
225
|
+
status: 200,
|
|
226
|
+
success: true
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
catch (error) {
|
|
230
|
+
return {
|
|
231
|
+
data: null,
|
|
232
|
+
status: 500,
|
|
233
|
+
success: false,
|
|
234
|
+
error: error instanceof Error ? error.message : 'Failed to simulate swap with slippage'
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Calculates price slippage percentage using Decimal.js
|
|
240
|
+
*
|
|
241
|
+
* @param priceBefore - Price before the swap (Decimal)
|
|
242
|
+
* @param priceAfter - Price after the swap (Decimal)
|
|
243
|
+
* @param zeroForOne - Swap direction (true if token0 → token1)
|
|
244
|
+
* @returns Slippage percentage (positive means unfavorable movement)
|
|
245
|
+
*/
|
|
246
|
+
function calculatePriceSlippage(priceBefore, priceAfter, zeroForOne) {
|
|
247
|
+
if (priceBefore.isZero()) {
|
|
248
|
+
throw new Error('Price before cannot be zero');
|
|
249
|
+
}
|
|
250
|
+
const priceChange = priceAfter.minus(priceBefore).dividedBy(priceBefore).times(100);
|
|
251
|
+
// For zeroForOne swaps (selling token0), favorable movement is price going down
|
|
252
|
+
// For oneForZero swaps (selling token1), favorable movement is price going up
|
|
253
|
+
// We return positive values for unfavorable movement (slippage)
|
|
254
|
+
return zeroForOne ? priceChange : priceChange.negated();
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Validates swap with slippage parameters
|
|
258
|
+
*
|
|
259
|
+
* @param params - Parameters to validate
|
|
260
|
+
* @throws Error if parameters are invalid
|
|
261
|
+
*/
|
|
262
|
+
function validateSwapWithSlippageParams(params) {
|
|
263
|
+
if (!params.poolAddress || params.poolAddress === '0x0000000000000000000000000000000000000000') {
|
|
264
|
+
throw new Error('Invalid pool address');
|
|
265
|
+
}
|
|
266
|
+
if (!params.recipient || params.recipient === '0x0000000000000000000000000000000000000000') {
|
|
267
|
+
throw new Error('Invalid recipient address');
|
|
268
|
+
}
|
|
269
|
+
if (params.amountSpecified <= 0n) {
|
|
270
|
+
throw new Error('Amount specified must be greater than 0');
|
|
271
|
+
}
|
|
272
|
+
if (params.sqrtPriceLimitX96 <= 0n) {
|
|
273
|
+
throw new Error('Sqrt price limit must be greater than 0');
|
|
274
|
+
}
|
|
275
|
+
if (!params.tokenIn || params.tokenIn === '0x0000000000000000000000000000000000000000') {
|
|
276
|
+
throw new Error('Invalid tokenIn address');
|
|
277
|
+
}
|
|
278
|
+
if (!params.tokenOut || params.tokenOut === '0x0000000000000000000000000000000000000000') {
|
|
279
|
+
throw new Error('Invalid tokenOut address');
|
|
280
|
+
}
|
|
281
|
+
if (params.fee <= 0) {
|
|
282
|
+
throw new Error('Pool fee must be greater than 0');
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
//# sourceMappingURL=simulateSwap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simulateSwap.js","sourceRoot":"","sources":["../../../../../src/base/vault/single-asset/simulateSwap.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAElE,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAEjH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,YAA0B,EAC1B,MAA0B,EAC1B,OAAe;IAEf,IAAI,CAAC;QACH,iEAAiE;QACjE,IAAI,MAAM,CAAC,OAAO,KAAK,OAAO,CAAC,SAAS,EAAE,CAAC;YACzC,MAAM,IAAI,KAAK,CAAC,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AAM,CAAC,WAAW,KAAK,4CAA4C,EAAE,CAAC;QAC/F,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC1C,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,SAAS,KAAK,4CAA4C,EAAE,CAAC;QAC3F,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAC/C,CAAC;IAED,IAAI,MAAM,CAAC,eAAe,IAAI,EAAE,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC7D,CAAC;IAED,IAAI,MAAM,CAAC,iBAAiB,IAAI,EAAE,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC7D,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,KAAK,4CAA4C,EAAE,CAAC;QACvF,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,KAAK,4CAA4C,EAAE,CAAC;QACzF,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAC9C,CAAC;IAED,IAAI,MAAM,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
import { getContractAddressByChainIdAndContractName } from '../../../const';
|
|
2
|
+
import { singleTokenDepositAbi } from '../../../const/abis/singleTokenDeposit';
|
|
3
|
+
import { UniswapV3PoolABI } from '../../../const/abis/UniswapPool';
|
|
4
|
+
import { calculateLimitPrice } from './calculateLimitPrice';
|
|
5
|
+
import { calculateSwapAmount } from './calculateSwapAmount';
|
|
6
|
+
import { estimateLpTokens } from './estimateLpTokens';
|
|
7
|
+
import { determineSwapDirection, simulateSwapWithSlippage } from './simulateSwap';
|
|
8
|
+
import { AMMType } from './types';
|
|
9
|
+
/**
|
|
10
|
+
* Main single-asset deposit client that orchestrates all the steps
|
|
11
|
+
*/
|
|
12
|
+
export class SingleAssetDepositClient {
|
|
13
|
+
constructor(publicClient, walletClient) {
|
|
14
|
+
this.publicClient = publicClient;
|
|
15
|
+
this.walletClient = walletClient;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Previews a single-asset deposit by running all simulation steps
|
|
19
|
+
* This allows users to see the expected outcome before executing the transaction
|
|
20
|
+
*
|
|
21
|
+
* @param params - Single-asset deposit parameters
|
|
22
|
+
* @param poolAddress - Address of the pool (must be provided separately)
|
|
23
|
+
* @returns Promise resolving to the complete deposit preview
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* const preview = await client.previewDeposit({
|
|
28
|
+
* assets: parseEther('100'),
|
|
29
|
+
* receiver: userAddress,
|
|
30
|
+
* vault: vaultAddress,
|
|
31
|
+
* isToken0: true,
|
|
32
|
+
* depositSlippagePercent: 5n,
|
|
33
|
+
* swapSlippageBP: 500,
|
|
34
|
+
* ammType: AMMType.UniswapV3,
|
|
35
|
+
* singleAssetDepositContract: contractAddress
|
|
36
|
+
* }, poolAddress);
|
|
37
|
+
*
|
|
38
|
+
* if (preview.success) {
|
|
39
|
+
* console.log('Expected LP tokens:', preview.data.lpEstimation.lpTokens);
|
|
40
|
+
* console.log('Swap amount:', preview.data.swapAmount);
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
async previewDeposit(params, poolAddress) {
|
|
45
|
+
try {
|
|
46
|
+
const chainId = await this.publicClient.getChainId();
|
|
47
|
+
const singleAssentDeposit = params.singleAssetDepositContract || getContractAddressByChainIdAndContractName(chainId, 'SingleAssetDeposit');
|
|
48
|
+
// Step 1: Calculate swap amount
|
|
49
|
+
const swapAmountParams = {
|
|
50
|
+
depositAmount: params.assets,
|
|
51
|
+
isToken0: params.isToken0,
|
|
52
|
+
vault: params.vault,
|
|
53
|
+
pool: poolAddress,
|
|
54
|
+
ammType: params.ammType,
|
|
55
|
+
singleAssetDepositContract: singleAssentDeposit
|
|
56
|
+
};
|
|
57
|
+
const swapAmountResult = await calculateSwapAmount(this.publicClient, swapAmountParams);
|
|
58
|
+
if (!swapAmountResult.success || !swapAmountResult.data) {
|
|
59
|
+
return {
|
|
60
|
+
data: null,
|
|
61
|
+
status: swapAmountResult.status,
|
|
62
|
+
success: false,
|
|
63
|
+
error: swapAmountResult.error || 'Failed to calculate swap amount'
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
const { swapAmount, sqrtPrice } = swapAmountResult.data;
|
|
67
|
+
const zeroForOne = determineSwapDirection(params.isToken0);
|
|
68
|
+
// Get token addresses from the pool contract
|
|
69
|
+
const [token0, token1] = await Promise.all([
|
|
70
|
+
this.publicClient.readContract({
|
|
71
|
+
address: poolAddress,
|
|
72
|
+
abi: UniswapV3PoolABI,
|
|
73
|
+
functionName: 'token0'
|
|
74
|
+
}),
|
|
75
|
+
this.publicClient.readContract({
|
|
76
|
+
address: poolAddress,
|
|
77
|
+
abi: UniswapV3PoolABI,
|
|
78
|
+
functionName: 'token1'
|
|
79
|
+
})
|
|
80
|
+
]);
|
|
81
|
+
// Step 2: Calculate limit price
|
|
82
|
+
const limitPriceParams = {
|
|
83
|
+
pool: poolAddress,
|
|
84
|
+
slippageBP: params.swapSlippageBP,
|
|
85
|
+
zeroForOne,
|
|
86
|
+
ammType: params.ammType,
|
|
87
|
+
token0,
|
|
88
|
+
token1
|
|
89
|
+
};
|
|
90
|
+
const limitPriceResult = await calculateLimitPrice(this.publicClient, limitPriceParams);
|
|
91
|
+
if (!limitPriceResult.success || limitPriceResult.data === null) {
|
|
92
|
+
return {
|
|
93
|
+
data: null,
|
|
94
|
+
status: limitPriceResult.status,
|
|
95
|
+
success: false,
|
|
96
|
+
error: limitPriceResult.error || 'Failed to calculate limit price'
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
const sqrtPriceLimitX96 = limitPriceResult.data;
|
|
100
|
+
// Get pool fee from the contract
|
|
101
|
+
const fee = await this.publicClient.readContract({
|
|
102
|
+
address: poolAddress,
|
|
103
|
+
abi: UniswapV3PoolABI,
|
|
104
|
+
functionName: 'fee'
|
|
105
|
+
});
|
|
106
|
+
// Step 3: Simulate swap
|
|
107
|
+
const simulateSwapParams = {
|
|
108
|
+
poolAddress: poolAddress,
|
|
109
|
+
recipient: params.receiver, // For simulation, use receiver address
|
|
110
|
+
zeroForOne,
|
|
111
|
+
amountSpecified: swapAmount,
|
|
112
|
+
sqrtPriceLimitX96,
|
|
113
|
+
ammType: params.ammType,
|
|
114
|
+
tokenIn: zeroForOne ? token0 : token1,
|
|
115
|
+
tokenOut: zeroForOne ? token1 : token0,
|
|
116
|
+
fee
|
|
117
|
+
};
|
|
118
|
+
const swapSimulationResult = await simulateSwapWithSlippage(this.publicClient, simulateSwapParams, this.publicClient.chain?.id || 1 // Use chain ID from public client, fallback to mainnet
|
|
119
|
+
);
|
|
120
|
+
if (!swapSimulationResult.success || !swapSimulationResult.data) {
|
|
121
|
+
return {
|
|
122
|
+
data: null,
|
|
123
|
+
status: swapSimulationResult.status,
|
|
124
|
+
success: false,
|
|
125
|
+
error: swapSimulationResult.error || 'Failed to simulate swap'
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
const swapSimulation = swapSimulationResult.data;
|
|
129
|
+
// Step 4: Estimate LP tokens
|
|
130
|
+
const lpEstimationResult = await estimateLpTokens(this.publicClient, {
|
|
131
|
+
vault: params.vault,
|
|
132
|
+
originalAssets: params.assets,
|
|
133
|
+
swapAmount,
|
|
134
|
+
swapResult: swapSimulation.swapSimulation,
|
|
135
|
+
isToken0: params.isToken0
|
|
136
|
+
});
|
|
137
|
+
if (!lpEstimationResult.success || !lpEstimationResult.data) {
|
|
138
|
+
return {
|
|
139
|
+
data: null,
|
|
140
|
+
status: lpEstimationResult.status,
|
|
141
|
+
success: false,
|
|
142
|
+
error: lpEstimationResult.error || 'Failed to estimate LP tokens'
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
const lpEstimation = lpEstimationResult.data;
|
|
146
|
+
return {
|
|
147
|
+
data: {
|
|
148
|
+
swapAmount,
|
|
149
|
+
currentSqrtPrice: sqrtPrice,
|
|
150
|
+
sqrtPriceLimitX96,
|
|
151
|
+
swapSimulation,
|
|
152
|
+
lpEstimation,
|
|
153
|
+
zeroForOne
|
|
154
|
+
},
|
|
155
|
+
status: 200,
|
|
156
|
+
success: true
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
return {
|
|
161
|
+
data: null,
|
|
162
|
+
status: 500,
|
|
163
|
+
success: false,
|
|
164
|
+
error: error instanceof Error ? error.message : 'Failed to preview single-asset deposit'
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Executes a single-asset deposit transaction
|
|
170
|
+
*
|
|
171
|
+
* @param params - Single-asset deposit parameters
|
|
172
|
+
* @returns Promise resolving to the transaction hash
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```typescript
|
|
176
|
+
* const result = await client.deposit({
|
|
177
|
+
* assets: parseEther('100'),
|
|
178
|
+
* receiver: userAddress,
|
|
179
|
+
* vault: vaultAddress,
|
|
180
|
+
* isToken0: true,
|
|
181
|
+
* depositSlippagePercent: 5n,
|
|
182
|
+
* swapSlippageBP: 500,
|
|
183
|
+
* ammType: AMMType.UniswapV3,
|
|
184
|
+
* singleAssetDepositContract: contractAddress
|
|
185
|
+
* });
|
|
186
|
+
*
|
|
187
|
+
* if (result.success) {
|
|
188
|
+
* console.log('Transaction hash:', result.data);
|
|
189
|
+
* }
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
async deposit(params) {
|
|
193
|
+
try {
|
|
194
|
+
const account = await this.walletClient.getAddresses();
|
|
195
|
+
if (!account[0]) {
|
|
196
|
+
throw new Error('No account found');
|
|
197
|
+
}
|
|
198
|
+
const singleAssentDeposit = params.singleAssetDepositContract || getContractAddressByChainIdAndContractName(this.publicClient.chain?.id || 1, 'SingleAssetDeposit');
|
|
199
|
+
// Prepare the transaction
|
|
200
|
+
const { request } = await this.publicClient.simulateContract({
|
|
201
|
+
address: singleAssentDeposit,
|
|
202
|
+
abi: singleTokenDepositAbi,
|
|
203
|
+
functionName: 'deposit',
|
|
204
|
+
args: [
|
|
205
|
+
params.assets,
|
|
206
|
+
params.receiver,
|
|
207
|
+
params.vault,
|
|
208
|
+
params.isToken0,
|
|
209
|
+
params.depositSlippagePercent,
|
|
210
|
+
params.swapSlippageBP,
|
|
211
|
+
params.ammType
|
|
212
|
+
],
|
|
213
|
+
account: account[0]
|
|
214
|
+
});
|
|
215
|
+
// Execute the transaction
|
|
216
|
+
const hash = await this.walletClient.writeContract(request);
|
|
217
|
+
return {
|
|
218
|
+
data: hash,
|
|
219
|
+
status: 200,
|
|
220
|
+
success: true
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
catch (error) {
|
|
224
|
+
return {
|
|
225
|
+
data: null,
|
|
226
|
+
status: 500,
|
|
227
|
+
success: false,
|
|
228
|
+
error: error instanceof Error ? error.message : 'Failed to execute single-asset deposit'
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Prepares a single-asset deposit transaction without executing it
|
|
234
|
+
* Useful for batching transactions or custom execution logic
|
|
235
|
+
*
|
|
236
|
+
* @param params - Single-asset deposit parameters
|
|
237
|
+
* @returns Promise resolving to the prepared transaction data
|
|
238
|
+
*/
|
|
239
|
+
async prepareDepositTx(params) {
|
|
240
|
+
try {
|
|
241
|
+
const account = await this.walletClient.getAddresses();
|
|
242
|
+
if (!account[0]) {
|
|
243
|
+
throw new Error('No account found');
|
|
244
|
+
}
|
|
245
|
+
const chainId = await this.publicClient.getChainId();
|
|
246
|
+
const singleAssentDeposit = params.singleAssetDepositContract || getContractAddressByChainIdAndContractName(chainId, 'SingleAssetDeposit');
|
|
247
|
+
await this.publicClient.simulateContract({
|
|
248
|
+
address: singleAssentDeposit,
|
|
249
|
+
abi: singleTokenDepositAbi,
|
|
250
|
+
functionName: 'deposit',
|
|
251
|
+
args: [
|
|
252
|
+
params.assets,
|
|
253
|
+
params.receiver,
|
|
254
|
+
params.vault,
|
|
255
|
+
params.isToken0,
|
|
256
|
+
params.depositSlippagePercent,
|
|
257
|
+
params.swapSlippageBP,
|
|
258
|
+
params.ammType
|
|
259
|
+
],
|
|
260
|
+
account: account[0]
|
|
261
|
+
});
|
|
262
|
+
return {
|
|
263
|
+
data: {
|
|
264
|
+
address: params.singleAssetDepositContract,
|
|
265
|
+
abi: singleTokenDepositAbi,
|
|
266
|
+
functionName: 'deposit',
|
|
267
|
+
args: [
|
|
268
|
+
params.assets,
|
|
269
|
+
params.receiver,
|
|
270
|
+
params.vault,
|
|
271
|
+
params.isToken0,
|
|
272
|
+
params.depositSlippagePercent,
|
|
273
|
+
params.swapSlippageBP,
|
|
274
|
+
params.ammType
|
|
275
|
+
]
|
|
276
|
+
},
|
|
277
|
+
status: 200,
|
|
278
|
+
success: true
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
catch (error) {
|
|
282
|
+
return {
|
|
283
|
+
data: null,
|
|
284
|
+
status: 500,
|
|
285
|
+
success: false,
|
|
286
|
+
error: error instanceof Error ? error.message : 'Failed to prepare single-asset deposit transaction'
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Validates single-asset deposit parameters
|
|
292
|
+
*
|
|
293
|
+
* @param params - Parameters to validate
|
|
294
|
+
* @throws Error if parameters are invalid
|
|
295
|
+
*/
|
|
296
|
+
validateDepositParams(params) {
|
|
297
|
+
if (params.assets <= 0n) {
|
|
298
|
+
throw new Error('Assets amount must be greater than 0');
|
|
299
|
+
}
|
|
300
|
+
if (!params.vault || params.vault === '0x0000000000000000000000000000000000000000') {
|
|
301
|
+
throw new Error('Invalid vault address');
|
|
302
|
+
}
|
|
303
|
+
if (!params.receiver || params.receiver === '0x0000000000000000000000000000000000000000') {
|
|
304
|
+
throw new Error('Invalid receiver address');
|
|
305
|
+
}
|
|
306
|
+
if (!params.singleAssetDepositContract || params.singleAssetDepositContract === '0x0000000000000000000000000000000000000000') {
|
|
307
|
+
throw new Error('Invalid single-asset deposit contract address');
|
|
308
|
+
}
|
|
309
|
+
if (params.depositSlippagePercent > 100n) {
|
|
310
|
+
throw new Error('Deposit slippage percent cannot exceed 100%');
|
|
311
|
+
}
|
|
312
|
+
if (params.swapSlippageBP > 10000) {
|
|
313
|
+
throw new Error('Swap slippage BP cannot exceed 10000 (100%)');
|
|
314
|
+
}
|
|
315
|
+
if (!Object.values(AMMType).includes(params.ammType)) {
|
|
316
|
+
throw new Error('Invalid AMM type');
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
//# sourceMappingURL=singleAssetDeposit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"singleAssetDeposit.js","sourceRoot":"","sources":["../../../../../src/base/vault/single-asset/singleAssetDeposit.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0CAA0C,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,wBAAwB,EAA0B,MAAM,gBAAgB,CAAC;AAO1G,OAAO,EAAE,OAA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,CAAC,CAAC;QAC3C,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,KAAK,4CAA4C,EAAE,CAAC;YACzF,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAC9C,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,0BAA0B,IAAI,MAAM,CAAC,0BAA0B,KAAK,4CAA4C,EAAE,CAAC;YAC7H,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;QACnE,CAAC;QAED,IAAI,MAAM,CAAC,sBAAsB,GAAG,IAAI,EAAE,CAAC;YACzC,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;QACjE,CAAC;QAED,IAAI,MAAM,CAAC,cAAc,GAAG,KAAK,EAAE,CAAC;YAClC,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;QACjE,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;YACrD,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AMM Types supported by single-asset deposits
|
|
3
|
+
*/
|
|
4
|
+
export var AMMType;
|
|
5
|
+
(function (AMMType) {
|
|
6
|
+
AMMType[AMMType["UniswapV3"] = 0] = "UniswapV3";
|
|
7
|
+
AMMType[AMMType["Algebra"] = 1] = "Algebra";
|
|
8
|
+
AMMType[AMMType["AlgebraDirectional"] = 2] = "AlgebraDirectional";
|
|
9
|
+
AMMType[AMMType["AlgebraVE33"] = 3] = "AlgebraVE33";
|
|
10
|
+
AMMType[AMMType["AlgebraIntegral"] = 4] = "AlgebraIntegral";
|
|
11
|
+
})(AMMType || (AMMType = {}));
|
|
12
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/base/vault/single-asset/types.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,CAAN,IAAY,OAMX;AAND,WAAY,OAAO;IACjB,+CAAa,CAAA;IACb,2CAAW,CAAA;IACX,iEAAsB,CAAA;IACtB,mDAAe,CAAA;IACf,2DAAmB,CAAA;AACrB,CAAC,EANW,OAAO,KAAP,OAAO,QAMlB"}
|