@1inch/swap-vm-sdk 0.1.0 → 0.1.1
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 +1 -1
- package/dist/index.js +38 -39
- package/dist/index.mjs +38 -39
- package/package.json +18 -18
- package/dist/swap-vm/types.d.mts +0 -22
- package/dist/swap-vm/types.d.ts +0 -22
package/README.md
CHANGED
|
@@ -236,7 +236,7 @@ Available instruction categories in the full Swap VM instruction set include:
|
|
|
236
236
|
### Trading instructions
|
|
237
237
|
- `XYC_SWAP_XD` - XYC swap for multi-dimensional pools
|
|
238
238
|
- `CONCENTRATE_GROW_LIQUIDITY_XD` - Concentrate liquidity in multi-dimensional pools
|
|
239
|
-
- `CONCENTRATE_GROW_LIQUIDITY_2D` - Concentrate liquidity in
|
|
239
|
+
- `CONCENTRATE_GROW_LIQUIDITY_2D` - Concentrate liquidity in 2 tokens pools
|
|
240
240
|
- `DECAY_XD` - Apply decay calculation
|
|
241
241
|
- `LIMIT_SWAP_1D` - Execute limit order swap
|
|
242
242
|
- `LIMIT_SWAP_ONLY_FULL_1D` - Execute limit order only if fully fillable
|
package/dist/index.js
CHANGED
|
@@ -31,7 +31,6 @@ const viem = __toESM(require("viem"));
|
|
|
31
31
|
const __1inch_sdk_core = __toESM(require("@1inch/sdk-core"));
|
|
32
32
|
const __1inch_byte_utils = __toESM(require("@1inch/byte-utils"));
|
|
33
33
|
const assert = __toESM(require("assert"));
|
|
34
|
-
const node_assert = __toESM(require("node:assert"));
|
|
35
34
|
|
|
36
35
|
//#region src/abi/SwapVM.abi.ts
|
|
37
36
|
const SWAP_VM_ABI = [
|
|
@@ -861,7 +860,7 @@ var MakerTraits = class MakerTraits {
|
|
|
861
860
|
traits = traits.setMask(MakerTraits.CUSTOM_RECEIVER_MASK, BigInt(this.customReceiver?.toString() || 0n));
|
|
862
861
|
const { data, offsets } = MakerTraits.HOOKS.reduce((acc, hookName, i) => {
|
|
863
862
|
const hook = this[hookName];
|
|
864
|
-
const hasTarget = this.hasTargetForHook(hookName);
|
|
863
|
+
const hasTarget = this.hasTargetForHook(hookName, maker);
|
|
865
864
|
const encoded = hook && hasTarget ? hook.encode() : hook?.data || __1inch_sdk_core.HexString.EMPTY;
|
|
866
865
|
acc.sum += BigInt(encoded.bytesCount());
|
|
867
866
|
acc.offsets += acc.sum << 16n * BigInt(i);
|
|
@@ -1291,7 +1290,7 @@ var JumpArgs = class JumpArgs {
|
|
|
1291
1290
|
static CODER = new JumpArgsCoder();
|
|
1292
1291
|
constructor(nextPC) {
|
|
1293
1292
|
this.nextPC = nextPC;
|
|
1294
|
-
(0,
|
|
1293
|
+
(0, assert.default)(nextPC <= UINT_16_MAX$3 && nextPC >= 0n, `Invalid nextPC value: ${nextPC}. Must be between 0 and 65535`);
|
|
1295
1294
|
}
|
|
1296
1295
|
/**
|
|
1297
1296
|
* Decodes hex data into JumpArgs instance
|
|
@@ -1436,7 +1435,7 @@ var OnlyTakerTokenBalanceGteArgs = class OnlyTakerTokenBalanceGteArgs {
|
|
|
1436
1435
|
constructor(token, minAmount) {
|
|
1437
1436
|
this.token = token;
|
|
1438
1437
|
this.minAmount = minAmount;
|
|
1439
|
-
(0,
|
|
1438
|
+
(0, assert.default)(minAmount >= 0n, "minAmount must be non-negative");
|
|
1440
1439
|
}
|
|
1441
1440
|
/**
|
|
1442
1441
|
* Decodes hex data into OnlyTakerTokenBalanceGteArgs instance
|
|
@@ -1482,7 +1481,7 @@ var OnlyTakerTokenSupplyShareGteArgs = class OnlyTakerTokenSupplyShareGteArgs {
|
|
|
1482
1481
|
constructor(token, minShareE18) {
|
|
1483
1482
|
this.token = token;
|
|
1484
1483
|
this.minShareE18 = minShareE18;
|
|
1485
|
-
(0,
|
|
1484
|
+
(0, assert.default)(minShareE18 >= 0n && minShareE18 <= UINT_64_MAX$4, `Invalid minShareE18 value: ${minShareE18}. Must be a valid uint64`);
|
|
1486
1485
|
}
|
|
1487
1486
|
/**
|
|
1488
1487
|
* Decodes hex data into OnlyTakerTokenSupplyShareGteArgs instance
|
|
@@ -1523,7 +1522,7 @@ var SaltArgs = class SaltArgs {
|
|
|
1523
1522
|
static CODER = new SaltArgsCoder();
|
|
1524
1523
|
constructor(salt$1) {
|
|
1525
1524
|
this.salt = salt$1;
|
|
1526
|
-
(0,
|
|
1525
|
+
(0, assert.default)(salt$1 >= 0n && salt$1 <= __1inch_byte_utils.UINT_64_MAX, `Invalid salt value: ${salt$1}. Must be a valid uint64`);
|
|
1527
1526
|
}
|
|
1528
1527
|
/**
|
|
1529
1528
|
* Decodes hex data into SaltArgs instance
|
|
@@ -1613,7 +1612,7 @@ var InvalidateBit1DArgs = class InvalidateBit1DArgs {
|
|
|
1613
1612
|
static CODER = new InvalidateBit1DArgsCoder();
|
|
1614
1613
|
constructor(bitIndex) {
|
|
1615
1614
|
this.bitIndex = bitIndex;
|
|
1616
|
-
(0,
|
|
1615
|
+
(0, assert.default)(bitIndex >= 0n && bitIndex <= __1inch_byte_utils.UINT_32_MAX, `Invalid bitIndex value: ${bitIndex}. Must be a valid uint32`);
|
|
1617
1616
|
}
|
|
1618
1617
|
/**
|
|
1619
1618
|
* Decodes hex data into InvalidateBit1DArgs instance
|
|
@@ -1789,7 +1788,7 @@ var ConcentrateGrowLiquidityXDArgs = class ConcentrateGrowLiquidityXDArgs {
|
|
|
1789
1788
|
constructor(tokenDeltas) {
|
|
1790
1789
|
this.tokenDeltas = tokenDeltas;
|
|
1791
1790
|
tokenDeltas.forEach((td, index) => {
|
|
1792
|
-
(0,
|
|
1791
|
+
(0, assert.default)(td.delta >= 0n && td.delta <= __1inch_byte_utils.UINT_256_MAX, `Invalid delta at index ${index}: ${td.delta}. Must be >= 0 and <= UINT_256_MAX`);
|
|
1793
1792
|
});
|
|
1794
1793
|
}
|
|
1795
1794
|
/**
|
|
@@ -1834,8 +1833,8 @@ var ConcentrateGrowLiquidity2DArgs = class ConcentrateGrowLiquidity2DArgs {
|
|
|
1834
1833
|
constructor(deltaLt, deltaGt) {
|
|
1835
1834
|
this.deltaLt = deltaLt;
|
|
1836
1835
|
this.deltaGt = deltaGt;
|
|
1837
|
-
(0,
|
|
1838
|
-
(0,
|
|
1836
|
+
(0, assert.default)(deltaLt >= 0n && deltaLt <= __1inch_byte_utils.UINT_256_MAX, `Invalid deltaLt: ${deltaLt}. Must be >= 0 and <= UINT_256_MAX`);
|
|
1837
|
+
(0, assert.default)(deltaGt >= 0n && deltaGt <= __1inch_byte_utils.UINT_256_MAX, `Invalid deltaGt: ${deltaGt}. Must be >= 0 and <= UINT_256_MAX`);
|
|
1839
1838
|
}
|
|
1840
1839
|
/**
|
|
1841
1840
|
* Helper to create args from token addresses and deltas (handles ordering)
|
|
@@ -1931,7 +1930,7 @@ var DecayXDArgs = class DecayXDArgs {
|
|
|
1931
1930
|
static CODER = new DecayXDArgsCoder();
|
|
1932
1931
|
constructor(decayPeriod) {
|
|
1933
1932
|
this.decayPeriod = decayPeriod;
|
|
1934
|
-
(0,
|
|
1933
|
+
(0, assert.default)(decayPeriod >= 0n && decayPeriod <= __1inch_byte_utils.UINT_16_MAX, `Invalid decayPeriod value: ${decayPeriod}. Must be a valid uint16`);
|
|
1935
1934
|
}
|
|
1936
1935
|
/**
|
|
1937
1936
|
* Decodes hex data into DecayXDArgs instance
|
|
@@ -2054,8 +2053,8 @@ var MinRateArgs = class MinRateArgs {
|
|
|
2054
2053
|
constructor(rateLt, rateGt) {
|
|
2055
2054
|
this.rateLt = rateLt;
|
|
2056
2055
|
this.rateGt = rateGt;
|
|
2057
|
-
(0,
|
|
2058
|
-
(0,
|
|
2056
|
+
(0, assert.default)(rateLt >= 0n && rateLt <= __1inch_byte_utils.UINT_64_MAX, `Invalid rateLt: ${rateLt}. Must be a valid uint64`);
|
|
2057
|
+
(0, assert.default)(rateGt >= 0n && rateGt <= __1inch_byte_utils.UINT_64_MAX, `Invalid rateGt: ${rateGt}. Must be a valid uint64`);
|
|
2059
2058
|
}
|
|
2060
2059
|
static fromTokens(tokenA, tokenB, rateA, rateB) {
|
|
2061
2060
|
if (BigInt(tokenA.toString()) < BigInt(tokenB.toString())) return new MinRateArgs(rateA, rateB);
|
|
@@ -2154,10 +2153,10 @@ var DutchAuctionArgs = class DutchAuctionArgs {
|
|
|
2154
2153
|
this.startTime = startTime;
|
|
2155
2154
|
this.duration = duration;
|
|
2156
2155
|
this.decayFactor = decayFactor;
|
|
2157
|
-
(0,
|
|
2158
|
-
(0,
|
|
2159
|
-
(0,
|
|
2160
|
-
(0,
|
|
2156
|
+
(0, assert.default)(startTime >= 0n && startTime <= __1inch_byte_utils.UINT_40_MAX, `Invalid startTime: ${startTime}. Must be a valid uint40`);
|
|
2157
|
+
(0, assert.default)(duration >= 0n && duration <= __1inch_byte_utils.UINT_16_MAX, `Invalid duration: ${duration}. Must be a valid uint16`);
|
|
2158
|
+
(0, assert.default)(decayFactor >= 0n && decayFactor <= __1inch_byte_utils.UINT_32_MAX, `Invalid decayFactor: ${decayFactor}. Must be a valid uint32`);
|
|
2159
|
+
(0, assert.default)(decayFactor < 1e18, `Decay factor should be less than 1e18: ${decayFactor}`);
|
|
2161
2160
|
}
|
|
2162
2161
|
/**
|
|
2163
2162
|
* Decodes hex data into DutchAuctionArgs instance
|
|
@@ -2252,10 +2251,10 @@ var OraclePriceAdjusterArgs = class OraclePriceAdjusterArgs {
|
|
|
2252
2251
|
this.maxStaleness = maxStaleness;
|
|
2253
2252
|
this.oracleDecimals = oracleDecimals;
|
|
2254
2253
|
this.oracleAddress = oracleAddress;
|
|
2255
|
-
(0,
|
|
2256
|
-
(0,
|
|
2257
|
-
(0,
|
|
2258
|
-
(0,
|
|
2254
|
+
(0, assert.default)(maxPriceDecay >= 0n && maxPriceDecay <= __1inch_byte_utils.UINT_64_MAX, `Invalid maxPriceDecay: ${maxPriceDecay}. Must be a valid uint64`);
|
|
2255
|
+
(0, assert.default)(maxPriceDecay < 1e18, `Max price decay should be less than 1e18: ${maxPriceDecay}`);
|
|
2256
|
+
(0, assert.default)(maxStaleness >= 0n && maxStaleness <= __1inch_byte_utils.UINT_16_MAX, `Invalid maxStaleness: ${maxStaleness}. Must be a valid uint16`);
|
|
2257
|
+
(0, assert.default)(oracleDecimals >= 0n && oracleDecimals <= __1inch_byte_utils.UINT_8_MAX, `Invalid oracleDecimals: ${oracleDecimals}. Must be a valid uint8`);
|
|
2259
2258
|
}
|
|
2260
2259
|
/**
|
|
2261
2260
|
* Decodes hex data into OraclePriceAdjusterArgs instance
|
|
@@ -2344,10 +2343,10 @@ var BaseFeeAdjusterArgs = class BaseFeeAdjusterArgs {
|
|
|
2344
2343
|
this.ethToToken1Price = ethToToken1Price;
|
|
2345
2344
|
this.gasAmount = gasAmount;
|
|
2346
2345
|
this.maxPriceDecay = maxPriceDecay;
|
|
2347
|
-
(0,
|
|
2348
|
-
(0,
|
|
2349
|
-
(0,
|
|
2350
|
-
(0,
|
|
2346
|
+
(0, assert.default)(baseGasPrice >= 0n && baseGasPrice <= __1inch_byte_utils.UINT_64_MAX, `Invalid baseGasPrice: ${baseGasPrice}. Must be a valid uint64`);
|
|
2347
|
+
(0, assert.default)(ethToToken1Price >= 0n && ethToToken1Price <= __1inch_byte_utils.UINT_96_MAX, `Invalid ethToToken1Price: ${ethToToken1Price}. Must be a valid uint96`);
|
|
2348
|
+
(0, assert.default)(gasAmount >= 0n && gasAmount <= __1inch_byte_utils.UINT_24_MAX, `Invalid gasAmount: ${gasAmount}. Must be a valid uint24`);
|
|
2349
|
+
(0, assert.default)(maxPriceDecay >= 0n && maxPriceDecay <= __1inch_byte_utils.UINT_64_MAX, `Invalid maxPriceDecay: ${maxPriceDecay}. Must be a valid uint64`);
|
|
2351
2350
|
}
|
|
2352
2351
|
/**
|
|
2353
2352
|
* Decodes hex data into BaseFeeAdjusterArgs instance
|
|
@@ -2471,12 +2470,12 @@ var TWAPSwapArgs = class TWAPSwapArgs {
|
|
|
2471
2470
|
this.duration = duration;
|
|
2472
2471
|
this.priceBumpAfterIlliquidity = priceBumpAfterIlliquidity;
|
|
2473
2472
|
this.minTradeAmountOut = minTradeAmountOut;
|
|
2474
|
-
(0,
|
|
2475
|
-
(0,
|
|
2476
|
-
(0,
|
|
2477
|
-
(0,
|
|
2478
|
-
(0,
|
|
2479
|
-
(0,
|
|
2473
|
+
(0, assert.default)(balanceIn >= 0n && balanceIn <= __1inch_byte_utils.UINT_256_MAX, `Invalid balanceIn: ${balanceIn}. Must be >= 0 and <= UINT_256_MAX`);
|
|
2474
|
+
(0, assert.default)(balanceOut >= 0n && balanceOut <= __1inch_byte_utils.UINT_256_MAX, `Invalid balanceOut: ${balanceOut}. Must be >= 0 and <= UINT_256_MAX`);
|
|
2475
|
+
(0, assert.default)(startTime >= 0n && startTime <= __1inch_byte_utils.UINT_256_MAX, `Invalid startTime: ${startTime}. Must be >= 0 and <= UINT_256_MAX`);
|
|
2476
|
+
(0, assert.default)(duration >= 0n && duration <= __1inch_byte_utils.UINT_256_MAX, `Invalid duration: ${duration}. Must be >= 0 and <= UINT_256_MAX`);
|
|
2477
|
+
(0, assert.default)(priceBumpAfterIlliquidity >= 0n && priceBumpAfterIlliquidity <= __1inch_byte_utils.UINT_256_MAX, `Invalid priceBumpAfterIlliquidity: ${priceBumpAfterIlliquidity}. Must be >= 0 and <= UINT_256_MAX`);
|
|
2478
|
+
(0, assert.default)(minTradeAmountOut >= 0n && minTradeAmountOut <= __1inch_byte_utils.UINT_256_MAX, `Invalid minTradeAmountOut: ${minTradeAmountOut}. Must be >= 0 and <= UINT_256_MAX`);
|
|
2480
2479
|
}
|
|
2481
2480
|
/**
|
|
2482
2481
|
* Decodes hex data into TWAPSwapArgs instance
|
|
@@ -2538,8 +2537,8 @@ var FlatFeeArgs = class FlatFeeArgs {
|
|
|
2538
2537
|
static CODER = new FlatFeeArgsCoder();
|
|
2539
2538
|
constructor(fee) {
|
|
2540
2539
|
this.fee = fee;
|
|
2541
|
-
(0,
|
|
2542
|
-
(0,
|
|
2540
|
+
(0, assert.default)(fee >= 0n && fee <= __1inch_byte_utils.UINT_32_MAX, `Invalid fee: ${fee}. Must be a valid uint32`);
|
|
2541
|
+
(0, assert.default)(fee <= BigInt(FEE_100_PERCENT$1), `Fee out of range: ${fee}. Must be <= ${FEE_100_PERCENT$1}`);
|
|
2543
2542
|
}
|
|
2544
2543
|
/**
|
|
2545
2544
|
* Decodes hex data into FlatFeeArgs instance
|
|
@@ -2602,8 +2601,8 @@ var ProtocolFeeArgs = class ProtocolFeeArgs {
|
|
|
2602
2601
|
constructor(fee, to) {
|
|
2603
2602
|
this.fee = fee;
|
|
2604
2603
|
this.to = to;
|
|
2605
|
-
(0,
|
|
2606
|
-
(0,
|
|
2604
|
+
(0, assert.default)(fee >= 0n && fee <= __1inch_byte_utils.UINT_32_MAX, `Invalid fee: ${fee}. Must be a valid uint32`);
|
|
2605
|
+
(0, assert.default)(fee <= BigInt(FEE_100_PERCENT), `Fee out of range: ${fee}. Must be <= ${FEE_100_PERCENT}`);
|
|
2607
2606
|
}
|
|
2608
2607
|
/**
|
|
2609
2608
|
* Decodes hex data into ProtocolFeeArgs instance
|
|
@@ -2787,10 +2786,10 @@ var StableSwap2DArgs = class StableSwap2DArgs {
|
|
|
2787
2786
|
this.A = A;
|
|
2788
2787
|
this.rateLt = rateLt;
|
|
2789
2788
|
this.rateGt = rateGt;
|
|
2790
|
-
(0,
|
|
2791
|
-
(0,
|
|
2792
|
-
(0,
|
|
2793
|
-
(0,
|
|
2789
|
+
(0, assert.default)(fee >= 0n && fee <= __1inch_byte_utils.UINT_32_MAX, `Invalid fee: ${fee}`);
|
|
2790
|
+
(0, assert.default)(A >= 0n && A <= __1inch_byte_utils.UINT_32_MAX, `Invalid A: ${A}`);
|
|
2791
|
+
(0, assert.default)(rateLt > 0n && rateLt <= __1inch_byte_utils.UINT_256_MAX, `Invalid rateLt: ${rateLt}. Must be positive and <= UINT_256_MAX`);
|
|
2792
|
+
(0, assert.default)(rateGt > 0n && rateGt <= __1inch_byte_utils.UINT_256_MAX, `Invalid rateGt: ${rateGt}. Must be positive and <= UINT_256_MAX`);
|
|
2794
2793
|
}
|
|
2795
2794
|
static fromTokens(fee, a, tokenA, tokenB, rateA, rateB) {
|
|
2796
2795
|
if (BigInt(tokenA.toString()) < BigInt(tokenB.toString())) return new StableSwap2DArgs(fee, a, rateA, rateB);
|
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,6 @@ import { decodeAbiParameters, decodeEventLog, encodeAbiParameters, encodeFunctio
|
|
|
2
2
|
import { Address, Address as Address$1, AddressHalf, CallInfo, HexString, HexString as HexString$1, Interaction, NetworkEnum, NetworkEnum as NetworkEnum$1 } from "@1inch/sdk-core";
|
|
3
3
|
import { BN, BitMask, BytesBuilder, BytesIter, UINT_16_MAX, UINT_24_MAX, UINT_256_MAX, UINT_32_MAX, UINT_40_MAX, UINT_64_MAX, UINT_8_MAX, UINT_96_MAX, add0x, trim0x } from "@1inch/byte-utils";
|
|
4
4
|
import assert from "assert";
|
|
5
|
-
import assert$1 from "node:assert";
|
|
6
5
|
|
|
7
6
|
//#region rolldown:runtime
|
|
8
7
|
var __defProp = Object.defineProperty;
|
|
@@ -842,7 +841,7 @@ var MakerTraits = class MakerTraits {
|
|
|
842
841
|
traits = traits.setMask(MakerTraits.CUSTOM_RECEIVER_MASK, BigInt(this.customReceiver?.toString() || 0n));
|
|
843
842
|
const { data, offsets } = MakerTraits.HOOKS.reduce((acc, hookName, i) => {
|
|
844
843
|
const hook = this[hookName];
|
|
845
|
-
const hasTarget = this.hasTargetForHook(hookName);
|
|
844
|
+
const hasTarget = this.hasTargetForHook(hookName, maker);
|
|
846
845
|
const encoded = hook && hasTarget ? hook.encode() : hook?.data || HexString$1.EMPTY;
|
|
847
846
|
acc.sum += BigInt(encoded.bytesCount());
|
|
848
847
|
acc.offsets += acc.sum << 16n * BigInt(i);
|
|
@@ -1272,7 +1271,7 @@ var JumpArgs = class JumpArgs {
|
|
|
1272
1271
|
static CODER = new JumpArgsCoder();
|
|
1273
1272
|
constructor(nextPC) {
|
|
1274
1273
|
this.nextPC = nextPC;
|
|
1275
|
-
assert
|
|
1274
|
+
assert(nextPC <= UINT_16_MAX$1 && nextPC >= 0n, `Invalid nextPC value: ${nextPC}. Must be between 0 and 65535`);
|
|
1276
1275
|
}
|
|
1277
1276
|
/**
|
|
1278
1277
|
* Decodes hex data into JumpArgs instance
|
|
@@ -1417,7 +1416,7 @@ var OnlyTakerTokenBalanceGteArgs = class OnlyTakerTokenBalanceGteArgs {
|
|
|
1417
1416
|
constructor(token, minAmount) {
|
|
1418
1417
|
this.token = token;
|
|
1419
1418
|
this.minAmount = minAmount;
|
|
1420
|
-
assert
|
|
1419
|
+
assert(minAmount >= 0n, "minAmount must be non-negative");
|
|
1421
1420
|
}
|
|
1422
1421
|
/**
|
|
1423
1422
|
* Decodes hex data into OnlyTakerTokenBalanceGteArgs instance
|
|
@@ -1463,7 +1462,7 @@ var OnlyTakerTokenSupplyShareGteArgs = class OnlyTakerTokenSupplyShareGteArgs {
|
|
|
1463
1462
|
constructor(token, minShareE18) {
|
|
1464
1463
|
this.token = token;
|
|
1465
1464
|
this.minShareE18 = minShareE18;
|
|
1466
|
-
assert
|
|
1465
|
+
assert(minShareE18 >= 0n && minShareE18 <= UINT_64_MAX$1, `Invalid minShareE18 value: ${minShareE18}. Must be a valid uint64`);
|
|
1467
1466
|
}
|
|
1468
1467
|
/**
|
|
1469
1468
|
* Decodes hex data into OnlyTakerTokenSupplyShareGteArgs instance
|
|
@@ -1504,7 +1503,7 @@ var SaltArgs = class SaltArgs {
|
|
|
1504
1503
|
static CODER = new SaltArgsCoder();
|
|
1505
1504
|
constructor(salt$1) {
|
|
1506
1505
|
this.salt = salt$1;
|
|
1507
|
-
assert
|
|
1506
|
+
assert(salt$1 >= 0n && salt$1 <= UINT_64_MAX, `Invalid salt value: ${salt$1}. Must be a valid uint64`);
|
|
1508
1507
|
}
|
|
1509
1508
|
/**
|
|
1510
1509
|
* Decodes hex data into SaltArgs instance
|
|
@@ -1594,7 +1593,7 @@ var InvalidateBit1DArgs = class InvalidateBit1DArgs {
|
|
|
1594
1593
|
static CODER = new InvalidateBit1DArgsCoder();
|
|
1595
1594
|
constructor(bitIndex) {
|
|
1596
1595
|
this.bitIndex = bitIndex;
|
|
1597
|
-
assert
|
|
1596
|
+
assert(bitIndex >= 0n && bitIndex <= UINT_32_MAX, `Invalid bitIndex value: ${bitIndex}. Must be a valid uint32`);
|
|
1598
1597
|
}
|
|
1599
1598
|
/**
|
|
1600
1599
|
* Decodes hex data into InvalidateBit1DArgs instance
|
|
@@ -1770,7 +1769,7 @@ var ConcentrateGrowLiquidityXDArgs = class ConcentrateGrowLiquidityXDArgs {
|
|
|
1770
1769
|
constructor(tokenDeltas) {
|
|
1771
1770
|
this.tokenDeltas = tokenDeltas;
|
|
1772
1771
|
tokenDeltas.forEach((td, index) => {
|
|
1773
|
-
assert
|
|
1772
|
+
assert(td.delta >= 0n && td.delta <= UINT_256_MAX, `Invalid delta at index ${index}: ${td.delta}. Must be >= 0 and <= UINT_256_MAX`);
|
|
1774
1773
|
});
|
|
1775
1774
|
}
|
|
1776
1775
|
/**
|
|
@@ -1815,8 +1814,8 @@ var ConcentrateGrowLiquidity2DArgs = class ConcentrateGrowLiquidity2DArgs {
|
|
|
1815
1814
|
constructor(deltaLt, deltaGt) {
|
|
1816
1815
|
this.deltaLt = deltaLt;
|
|
1817
1816
|
this.deltaGt = deltaGt;
|
|
1818
|
-
assert
|
|
1819
|
-
assert
|
|
1817
|
+
assert(deltaLt >= 0n && deltaLt <= UINT_256_MAX, `Invalid deltaLt: ${deltaLt}. Must be >= 0 and <= UINT_256_MAX`);
|
|
1818
|
+
assert(deltaGt >= 0n && deltaGt <= UINT_256_MAX, `Invalid deltaGt: ${deltaGt}. Must be >= 0 and <= UINT_256_MAX`);
|
|
1820
1819
|
}
|
|
1821
1820
|
/**
|
|
1822
1821
|
* Helper to create args from token addresses and deltas (handles ordering)
|
|
@@ -1912,7 +1911,7 @@ var DecayXDArgs = class DecayXDArgs {
|
|
|
1912
1911
|
static CODER = new DecayXDArgsCoder();
|
|
1913
1912
|
constructor(decayPeriod) {
|
|
1914
1913
|
this.decayPeriod = decayPeriod;
|
|
1915
|
-
assert
|
|
1914
|
+
assert(decayPeriod >= 0n && decayPeriod <= UINT_16_MAX, `Invalid decayPeriod value: ${decayPeriod}. Must be a valid uint16`);
|
|
1916
1915
|
}
|
|
1917
1916
|
/**
|
|
1918
1917
|
* Decodes hex data into DecayXDArgs instance
|
|
@@ -2035,8 +2034,8 @@ var MinRateArgs = class MinRateArgs {
|
|
|
2035
2034
|
constructor(rateLt, rateGt) {
|
|
2036
2035
|
this.rateLt = rateLt;
|
|
2037
2036
|
this.rateGt = rateGt;
|
|
2038
|
-
assert
|
|
2039
|
-
assert
|
|
2037
|
+
assert(rateLt >= 0n && rateLt <= UINT_64_MAX, `Invalid rateLt: ${rateLt}. Must be a valid uint64`);
|
|
2038
|
+
assert(rateGt >= 0n && rateGt <= UINT_64_MAX, `Invalid rateGt: ${rateGt}. Must be a valid uint64`);
|
|
2040
2039
|
}
|
|
2041
2040
|
static fromTokens(tokenA, tokenB, rateA, rateB) {
|
|
2042
2041
|
if (BigInt(tokenA.toString()) < BigInt(tokenB.toString())) return new MinRateArgs(rateA, rateB);
|
|
@@ -2135,10 +2134,10 @@ var DutchAuctionArgs = class DutchAuctionArgs {
|
|
|
2135
2134
|
this.startTime = startTime;
|
|
2136
2135
|
this.duration = duration;
|
|
2137
2136
|
this.decayFactor = decayFactor;
|
|
2138
|
-
assert
|
|
2139
|
-
assert
|
|
2140
|
-
assert
|
|
2141
|
-
assert
|
|
2137
|
+
assert(startTime >= 0n && startTime <= UINT_40_MAX, `Invalid startTime: ${startTime}. Must be a valid uint40`);
|
|
2138
|
+
assert(duration >= 0n && duration <= UINT_16_MAX, `Invalid duration: ${duration}. Must be a valid uint16`);
|
|
2139
|
+
assert(decayFactor >= 0n && decayFactor <= UINT_32_MAX, `Invalid decayFactor: ${decayFactor}. Must be a valid uint32`);
|
|
2140
|
+
assert(decayFactor < 1e18, `Decay factor should be less than 1e18: ${decayFactor}`);
|
|
2142
2141
|
}
|
|
2143
2142
|
/**
|
|
2144
2143
|
* Decodes hex data into DutchAuctionArgs instance
|
|
@@ -2233,10 +2232,10 @@ var OraclePriceAdjusterArgs = class OraclePriceAdjusterArgs {
|
|
|
2233
2232
|
this.maxStaleness = maxStaleness;
|
|
2234
2233
|
this.oracleDecimals = oracleDecimals;
|
|
2235
2234
|
this.oracleAddress = oracleAddress;
|
|
2236
|
-
assert
|
|
2237
|
-
assert
|
|
2238
|
-
assert
|
|
2239
|
-
assert
|
|
2235
|
+
assert(maxPriceDecay >= 0n && maxPriceDecay <= UINT_64_MAX, `Invalid maxPriceDecay: ${maxPriceDecay}. Must be a valid uint64`);
|
|
2236
|
+
assert(maxPriceDecay < 1e18, `Max price decay should be less than 1e18: ${maxPriceDecay}`);
|
|
2237
|
+
assert(maxStaleness >= 0n && maxStaleness <= UINT_16_MAX, `Invalid maxStaleness: ${maxStaleness}. Must be a valid uint16`);
|
|
2238
|
+
assert(oracleDecimals >= 0n && oracleDecimals <= UINT_8_MAX, `Invalid oracleDecimals: ${oracleDecimals}. Must be a valid uint8`);
|
|
2240
2239
|
}
|
|
2241
2240
|
/**
|
|
2242
2241
|
* Decodes hex data into OraclePriceAdjusterArgs instance
|
|
@@ -2325,10 +2324,10 @@ var BaseFeeAdjusterArgs = class BaseFeeAdjusterArgs {
|
|
|
2325
2324
|
this.ethToToken1Price = ethToToken1Price;
|
|
2326
2325
|
this.gasAmount = gasAmount;
|
|
2327
2326
|
this.maxPriceDecay = maxPriceDecay;
|
|
2328
|
-
assert
|
|
2329
|
-
assert
|
|
2330
|
-
assert
|
|
2331
|
-
assert
|
|
2327
|
+
assert(baseGasPrice >= 0n && baseGasPrice <= UINT_64_MAX, `Invalid baseGasPrice: ${baseGasPrice}. Must be a valid uint64`);
|
|
2328
|
+
assert(ethToToken1Price >= 0n && ethToToken1Price <= UINT_96_MAX, `Invalid ethToToken1Price: ${ethToToken1Price}. Must be a valid uint96`);
|
|
2329
|
+
assert(gasAmount >= 0n && gasAmount <= UINT_24_MAX, `Invalid gasAmount: ${gasAmount}. Must be a valid uint24`);
|
|
2330
|
+
assert(maxPriceDecay >= 0n && maxPriceDecay <= UINT_64_MAX, `Invalid maxPriceDecay: ${maxPriceDecay}. Must be a valid uint64`);
|
|
2332
2331
|
}
|
|
2333
2332
|
/**
|
|
2334
2333
|
* Decodes hex data into BaseFeeAdjusterArgs instance
|
|
@@ -2452,12 +2451,12 @@ var TWAPSwapArgs = class TWAPSwapArgs {
|
|
|
2452
2451
|
this.duration = duration;
|
|
2453
2452
|
this.priceBumpAfterIlliquidity = priceBumpAfterIlliquidity;
|
|
2454
2453
|
this.minTradeAmountOut = minTradeAmountOut;
|
|
2455
|
-
assert
|
|
2456
|
-
assert
|
|
2457
|
-
assert
|
|
2458
|
-
assert
|
|
2459
|
-
assert
|
|
2460
|
-
assert
|
|
2454
|
+
assert(balanceIn >= 0n && balanceIn <= UINT_256_MAX, `Invalid balanceIn: ${balanceIn}. Must be >= 0 and <= UINT_256_MAX`);
|
|
2455
|
+
assert(balanceOut >= 0n && balanceOut <= UINT_256_MAX, `Invalid balanceOut: ${balanceOut}. Must be >= 0 and <= UINT_256_MAX`);
|
|
2456
|
+
assert(startTime >= 0n && startTime <= UINT_256_MAX, `Invalid startTime: ${startTime}. Must be >= 0 and <= UINT_256_MAX`);
|
|
2457
|
+
assert(duration >= 0n && duration <= UINT_256_MAX, `Invalid duration: ${duration}. Must be >= 0 and <= UINT_256_MAX`);
|
|
2458
|
+
assert(priceBumpAfterIlliquidity >= 0n && priceBumpAfterIlliquidity <= UINT_256_MAX, `Invalid priceBumpAfterIlliquidity: ${priceBumpAfterIlliquidity}. Must be >= 0 and <= UINT_256_MAX`);
|
|
2459
|
+
assert(minTradeAmountOut >= 0n && minTradeAmountOut <= UINT_256_MAX, `Invalid minTradeAmountOut: ${minTradeAmountOut}. Must be >= 0 and <= UINT_256_MAX`);
|
|
2461
2460
|
}
|
|
2462
2461
|
/**
|
|
2463
2462
|
* Decodes hex data into TWAPSwapArgs instance
|
|
@@ -2519,8 +2518,8 @@ var FlatFeeArgs = class FlatFeeArgs {
|
|
|
2519
2518
|
static CODER = new FlatFeeArgsCoder();
|
|
2520
2519
|
constructor(fee) {
|
|
2521
2520
|
this.fee = fee;
|
|
2522
|
-
assert
|
|
2523
|
-
assert
|
|
2521
|
+
assert(fee >= 0n && fee <= UINT_32_MAX, `Invalid fee: ${fee}. Must be a valid uint32`);
|
|
2522
|
+
assert(fee <= BigInt(FEE_100_PERCENT$1), `Fee out of range: ${fee}. Must be <= ${FEE_100_PERCENT$1}`);
|
|
2524
2523
|
}
|
|
2525
2524
|
/**
|
|
2526
2525
|
* Decodes hex data into FlatFeeArgs instance
|
|
@@ -2583,8 +2582,8 @@ var ProtocolFeeArgs = class ProtocolFeeArgs {
|
|
|
2583
2582
|
constructor(fee, to) {
|
|
2584
2583
|
this.fee = fee;
|
|
2585
2584
|
this.to = to;
|
|
2586
|
-
assert
|
|
2587
|
-
assert
|
|
2585
|
+
assert(fee >= 0n && fee <= UINT_32_MAX, `Invalid fee: ${fee}. Must be a valid uint32`);
|
|
2586
|
+
assert(fee <= BigInt(FEE_100_PERCENT), `Fee out of range: ${fee}. Must be <= ${FEE_100_PERCENT}`);
|
|
2588
2587
|
}
|
|
2589
2588
|
/**
|
|
2590
2589
|
* Decodes hex data into ProtocolFeeArgs instance
|
|
@@ -2768,10 +2767,10 @@ var StableSwap2DArgs = class StableSwap2DArgs {
|
|
|
2768
2767
|
this.A = A;
|
|
2769
2768
|
this.rateLt = rateLt;
|
|
2770
2769
|
this.rateGt = rateGt;
|
|
2771
|
-
assert
|
|
2772
|
-
assert
|
|
2773
|
-
assert
|
|
2774
|
-
assert
|
|
2770
|
+
assert(fee >= 0n && fee <= UINT_32_MAX, `Invalid fee: ${fee}`);
|
|
2771
|
+
assert(A >= 0n && A <= UINT_32_MAX, `Invalid A: ${A}`);
|
|
2772
|
+
assert(rateLt > 0n && rateLt <= UINT_256_MAX, `Invalid rateLt: ${rateLt}. Must be positive and <= UINT_256_MAX`);
|
|
2773
|
+
assert(rateGt > 0n && rateGt <= UINT_256_MAX, `Invalid rateGt: ${rateGt}. Must be positive and <= UINT_256_MAX`);
|
|
2775
2774
|
}
|
|
2776
2775
|
static fromTokens(fee, a, tokenA, tokenB, rateA, rateB) {
|
|
2777
2776
|
if (BigInt(tokenA.toString()) < BigInt(tokenB.toString())) return new StableSwap2DArgs(fee, a, rateA, rateB);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1inch/swap-vm-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "1inch Swap VM SDK",
|
|
5
5
|
"author": "@1inch",
|
|
6
6
|
"license": "LicenseRef-Degensoft-SwapVM-1.1",
|
|
@@ -25,6 +25,20 @@
|
|
|
25
25
|
"README.md",
|
|
26
26
|
"package.json"
|
|
27
27
|
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "rm -rf dist && tsdown",
|
|
30
|
+
"test": "vitest run",
|
|
31
|
+
"test:e2e": "vitest run --config vitest.e2e.config.mts",
|
|
32
|
+
"test:watch": "vitest watch",
|
|
33
|
+
"test:coverage": "vitest run --coverage",
|
|
34
|
+
"lint": "eslint .",
|
|
35
|
+
"lint:fix": "eslint . --fix",
|
|
36
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
37
|
+
"format:check": "prettier --check \"src/**/*.ts\"",
|
|
38
|
+
"type-check": "tsc --noEmit",
|
|
39
|
+
"clean": "rimraf dist node_modules",
|
|
40
|
+
"changelog:generate": "changelog generate -a"
|
|
41
|
+
},
|
|
28
42
|
"keywords": [
|
|
29
43
|
"1inch",
|
|
30
44
|
"swap-vm",
|
|
@@ -38,8 +52,8 @@
|
|
|
38
52
|
},
|
|
39
53
|
"dependencies": {
|
|
40
54
|
"@1inch/byte-utils": "^3.1.7",
|
|
41
|
-
"
|
|
42
|
-
"
|
|
55
|
+
"@1inch/sdk-core": "workspace:*",
|
|
56
|
+
"tslib": "^2.8.1"
|
|
43
57
|
},
|
|
44
58
|
"devDependencies": {
|
|
45
59
|
"@types/node": "^22.13.0",
|
|
@@ -54,19 +68,5 @@
|
|
|
54
68
|
},
|
|
55
69
|
"publishConfig": {
|
|
56
70
|
"access": "public"
|
|
57
|
-
},
|
|
58
|
-
"scripts": {
|
|
59
|
-
"build": "rm -rf dist && tsdown",
|
|
60
|
-
"test": "vitest run",
|
|
61
|
-
"test:e2e": "vitest run --config vitest.e2e.config.mts",
|
|
62
|
-
"test:watch": "vitest watch",
|
|
63
|
-
"test:coverage": "vitest run --coverage",
|
|
64
|
-
"lint": "eslint .",
|
|
65
|
-
"lint:fix": "eslint . --fix",
|
|
66
|
-
"format": "prettier --write \"src/**/*.ts\"",
|
|
67
|
-
"format:check": "prettier --check \"src/**/*.ts\"",
|
|
68
|
-
"type-check": "tsc --noEmit",
|
|
69
|
-
"clean": "rimraf dist node_modules",
|
|
70
|
-
"changelog:generate": "changelog generate -a"
|
|
71
71
|
}
|
|
72
|
-
}
|
|
72
|
+
}
|
package/dist/swap-vm/types.d.mts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Address } from '@1inch/sdk-core';
|
|
2
|
-
export type MakerTraitsBuildArgs = {
|
|
3
|
-
shouldUnwrapWeth?: boolean;
|
|
4
|
-
hasPreTransferOutHook?: boolean;
|
|
5
|
-
hasPostTransferInHook?: boolean;
|
|
6
|
-
useAquaInsteadOfSignature?: boolean;
|
|
7
|
-
ignoreAquaForTransferIn?: boolean;
|
|
8
|
-
expiration?: bigint;
|
|
9
|
-
receiver?: Address;
|
|
10
|
-
preTransferOutDataLength?: bigint;
|
|
11
|
-
postTransferInDataLength?: bigint;
|
|
12
|
-
};
|
|
13
|
-
export type TakerTraitsBuildArgs = {
|
|
14
|
-
isExactIn?: boolean;
|
|
15
|
-
shouldUnwrapWeth?: boolean;
|
|
16
|
-
hasPreTransferInHook?: boolean;
|
|
17
|
-
isStrictThresholdAmount?: boolean;
|
|
18
|
-
isFirstTransferFromTaker?: boolean;
|
|
19
|
-
useTransferFromAndAquaPush?: boolean;
|
|
20
|
-
threshold?: bigint;
|
|
21
|
-
customReceiver?: Address;
|
|
22
|
-
};
|
package/dist/swap-vm/types.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Address } from '@1inch/sdk-core';
|
|
2
|
-
export type MakerTraitsBuildArgs = {
|
|
3
|
-
shouldUnwrapWeth?: boolean;
|
|
4
|
-
hasPreTransferOutHook?: boolean;
|
|
5
|
-
hasPostTransferInHook?: boolean;
|
|
6
|
-
useAquaInsteadOfSignature?: boolean;
|
|
7
|
-
ignoreAquaForTransferIn?: boolean;
|
|
8
|
-
expiration?: bigint;
|
|
9
|
-
receiver?: Address;
|
|
10
|
-
preTransferOutDataLength?: bigint;
|
|
11
|
-
postTransferInDataLength?: bigint;
|
|
12
|
-
};
|
|
13
|
-
export type TakerTraitsBuildArgs = {
|
|
14
|
-
isExactIn?: boolean;
|
|
15
|
-
shouldUnwrapWeth?: boolean;
|
|
16
|
-
hasPreTransferInHook?: boolean;
|
|
17
|
-
isStrictThresholdAmount?: boolean;
|
|
18
|
-
isFirstTransferFromTaker?: boolean;
|
|
19
|
-
useTransferFromAndAquaPush?: boolean;
|
|
20
|
-
threshold?: bigint;
|
|
21
|
-
customReceiver?: Address;
|
|
22
|
-
};
|