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