@t2000/sdk 0.16.19 → 0.16.20
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/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.js.map +1 -1
- package/dist/index.cjs +15 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +15 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -182,10 +182,17 @@ function parseMoveAbortMessage(msg) {
|
|
|
182
182
|
const abortMatch = msg.match(/abort code:\s*(\d+)/i) ?? msg.match(/MoveAbort[^,]*,\s*(\d+)/);
|
|
183
183
|
if (abortMatch) {
|
|
184
184
|
const code = parseInt(abortMatch[1], 10);
|
|
185
|
-
const mapped = mapMoveAbortCode(code);
|
|
186
185
|
const moduleMatch = msg.match(/Identifier\("([^"]+)"\)/) ?? msg.match(/in '([^']+)'/);
|
|
187
186
|
const fnMatch = msg.match(/function_name:\s*Some\("([^"]+)"\)/);
|
|
187
|
+
const context = `${moduleMatch?.[1] ?? ""}${fnMatch ? `::${fnMatch[1]}` : ""}`.toLowerCase();
|
|
188
188
|
const suffix = moduleMatch ? ` [${moduleMatch[1]}${fnMatch ? `::${fnMatch[1]}` : ""}]` : "";
|
|
189
|
+
if (context.includes("slippage")) {
|
|
190
|
+
return `Swap slippage too high \u2014 price moved during execution${suffix}`;
|
|
191
|
+
}
|
|
192
|
+
if (context.includes("balance::split") || context.includes("balance::ENotEnough")) {
|
|
193
|
+
return `Insufficient on-chain balance${suffix}`;
|
|
194
|
+
}
|
|
195
|
+
const mapped = mapMoveAbortCode(code);
|
|
189
196
|
return `${mapped}${suffix}`;
|
|
190
197
|
}
|
|
191
198
|
return msg;
|
|
@@ -3038,6 +3045,11 @@ var PortfolioManager = class {
|
|
|
3038
3045
|
this.load();
|
|
3039
3046
|
return Object.keys(this.data.strategies);
|
|
3040
3047
|
}
|
|
3048
|
+
clearStrategy(strategyKey) {
|
|
3049
|
+
this.load();
|
|
3050
|
+
delete this.data.strategies[strategyKey];
|
|
3051
|
+
this.save();
|
|
3052
|
+
}
|
|
3041
3053
|
hasStrategyPositions(strategyKey) {
|
|
3042
3054
|
this.load();
|
|
3043
3055
|
const bucket = this.data.strategies[strategyKey];
|
|
@@ -4432,8 +4444,9 @@ To sell investment: t2000 invest sell ${params.amount} ${fromAsset}`,
|
|
|
4432
4444
|
if (!swapAdapter?.addSwapToTx) {
|
|
4433
4445
|
throw new T2000Error("PROTOCOL_UNAVAILABLE", "Swap adapter does not support composable PTB");
|
|
4434
4446
|
}
|
|
4435
|
-
|
|
4447
|
+
let swapMetas = [];
|
|
4436
4448
|
const gasResult = await executeWithGas(this.client, this.keypair, async () => {
|
|
4449
|
+
swapMetas = [];
|
|
4437
4450
|
const tx = new Transaction();
|
|
4438
4451
|
tx.setSender(this._address);
|
|
4439
4452
|
const usdcCoins = await this._fetchCoins(SUPPORTED_ASSETS.USDC.type);
|