punkkit-sdk 1.0.27 → 1.0.29
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/index.js +41 -13
- package/dist/index.mjs +41 -13
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -31487,6 +31487,30 @@ var init_lib49 = __esm({
|
|
|
31487
31487
|
}
|
|
31488
31488
|
});
|
|
31489
31489
|
|
|
31490
|
+
// config/addresses.json
|
|
31491
|
+
var addresses_default;
|
|
31492
|
+
var init_addresses3 = __esm({
|
|
31493
|
+
"config/addresses.json"() {
|
|
31494
|
+
addresses_default = {
|
|
31495
|
+
mutiVoucher: "0x0000000000000000000000000000000000000044",
|
|
31496
|
+
auction: {
|
|
31497
|
+
chainYVaultV2: "0xAa9e62EB6d74d66Ff6720D1A8143c8237067Ff58",
|
|
31498
|
+
chainXAuctionV2: "0x88566F811b751Fa527A0816d99d6968E00f2eBef",
|
|
31499
|
+
coinbase: "0xAa9e62EB6d74d66Ff6720D1A8143c8237067Ff58"
|
|
31500
|
+
},
|
|
31501
|
+
uniswap: {
|
|
31502
|
+
create2: "0xc5a5C42992dECbae36851359345FE25997F5C42d",
|
|
31503
|
+
token0: "0x18c714d6cc9A38DBb369a8c47A8744016F8D7055",
|
|
31504
|
+
token1: "0x8B4eEeBE05048C084AB739deB29d94E8E0d07A6E",
|
|
31505
|
+
poolManager: "0x4cb143D21145BcAf06D2c5557927E2939Aa0FAfe",
|
|
31506
|
+
liquidPool: "0xB3AEA00D39f4dEE364D767Cd0fb7B437d415Fb9C",
|
|
31507
|
+
limitOrder: "0xE8feDC742EDE9852c7F3E2c3793a2A98C1c7D040",
|
|
31508
|
+
dynamicFee: "0xA0C0C10e144D34EB501A42Df0EdB5C45D40Ad040"
|
|
31509
|
+
}
|
|
31510
|
+
};
|
|
31511
|
+
}
|
|
31512
|
+
});
|
|
31513
|
+
|
|
31490
31514
|
// config/env.config.ts
|
|
31491
31515
|
function getEnvValue(key3, defaultValue) {
|
|
31492
31516
|
const value = process.env[key3];
|
|
@@ -31534,20 +31558,20 @@ function loadConfig() {
|
|
|
31534
31558
|
)
|
|
31535
31559
|
},
|
|
31536
31560
|
contracts: {
|
|
31537
|
-
mutiVoucher:
|
|
31561
|
+
mutiVoucher: addresses_default.mutiVoucher,
|
|
31538
31562
|
auction: {
|
|
31539
|
-
chainYVaultV2:
|
|
31540
|
-
chainXAuctionV2:
|
|
31541
|
-
coinbase:
|
|
31563
|
+
chainYVaultV2: addresses_default.auction.chainYVaultV2,
|
|
31564
|
+
chainXAuctionV2: addresses_default.auction.chainXAuctionV2,
|
|
31565
|
+
coinbase: addresses_default.auction.coinbase
|
|
31542
31566
|
},
|
|
31543
31567
|
uniswap: {
|
|
31544
|
-
create2:
|
|
31545
|
-
token0:
|
|
31546
|
-
token1:
|
|
31547
|
-
poolManager:
|
|
31548
|
-
liquidPool:
|
|
31549
|
-
limitOrder:
|
|
31550
|
-
dynamicFee:
|
|
31568
|
+
create2: addresses_default.uniswap.create2,
|
|
31569
|
+
token0: addresses_default.uniswap.token0,
|
|
31570
|
+
token1: addresses_default.uniswap.token1,
|
|
31571
|
+
poolManager: addresses_default.uniswap.poolManager,
|
|
31572
|
+
liquidPool: addresses_default.uniswap.liquidPool,
|
|
31573
|
+
limitOrder: addresses_default.uniswap.limitOrder,
|
|
31574
|
+
dynamicFee: addresses_default.uniswap.dynamicFee
|
|
31551
31575
|
}
|
|
31552
31576
|
},
|
|
31553
31577
|
abiPaths: {
|
|
@@ -31586,6 +31610,7 @@ var init_env_config = __esm({
|
|
|
31586
31610
|
"config/env.config.ts"() {
|
|
31587
31611
|
"use strict";
|
|
31588
31612
|
init_lib49();
|
|
31613
|
+
init_addresses3();
|
|
31589
31614
|
config = loadConfig();
|
|
31590
31615
|
RPC_URL = config.rpc.url;
|
|
31591
31616
|
PRIVATE_KEY = config.wallet.privateKey;
|
|
@@ -38653,6 +38678,9 @@ init_contract();
|
|
|
38653
38678
|
async function removeLiqByPosition(wallet2, tickLower, tickUpper, liquidityToRemove) {
|
|
38654
38679
|
const liqPool = await getContract(wallet2, "LiquidPool");
|
|
38655
38680
|
let liqDelta = BigInt(liquidityToRemove.toString());
|
|
38681
|
+
if (liqDelta === 0n) {
|
|
38682
|
+
throw new Error("[SDK] Error: Cannot remove 0 liquidity. Action aborted.");
|
|
38683
|
+
}
|
|
38656
38684
|
if (liqDelta > 0n) {
|
|
38657
38685
|
liqDelta = liqDelta * -1n;
|
|
38658
38686
|
}
|
|
@@ -38729,8 +38757,8 @@ async function getUserPositions(wallet2, userAddress) {
|
|
|
38729
38757
|
// liquidity is int256, keep as string to prevent JS precision loss
|
|
38730
38758
|
liquidity: pos.liquidity.toString()
|
|
38731
38759
|
};
|
|
38732
|
-
});
|
|
38733
|
-
console.log(`[SDK] Found ${formattedPositions.length} position(s).`);
|
|
38760
|
+
}).filter((pos) => pos.liquidity !== "0");
|
|
38761
|
+
console.log(`[SDK] Found ${formattedPositions.length} active position(s).`);
|
|
38734
38762
|
return formattedPositions;
|
|
38735
38763
|
} catch (error) {
|
|
38736
38764
|
console.error(`[SDK] Failed to fetch user positions: `, error);
|
package/dist/index.mjs
CHANGED
|
@@ -31491,6 +31491,30 @@ var init_lib49 = __esm({
|
|
|
31491
31491
|
}
|
|
31492
31492
|
});
|
|
31493
31493
|
|
|
31494
|
+
// config/addresses.json
|
|
31495
|
+
var addresses_default;
|
|
31496
|
+
var init_addresses3 = __esm({
|
|
31497
|
+
"config/addresses.json"() {
|
|
31498
|
+
addresses_default = {
|
|
31499
|
+
mutiVoucher: "0x0000000000000000000000000000000000000044",
|
|
31500
|
+
auction: {
|
|
31501
|
+
chainYVaultV2: "0xAa9e62EB6d74d66Ff6720D1A8143c8237067Ff58",
|
|
31502
|
+
chainXAuctionV2: "0x88566F811b751Fa527A0816d99d6968E00f2eBef",
|
|
31503
|
+
coinbase: "0xAa9e62EB6d74d66Ff6720D1A8143c8237067Ff58"
|
|
31504
|
+
},
|
|
31505
|
+
uniswap: {
|
|
31506
|
+
create2: "0xc5a5C42992dECbae36851359345FE25997F5C42d",
|
|
31507
|
+
token0: "0x18c714d6cc9A38DBb369a8c47A8744016F8D7055",
|
|
31508
|
+
token1: "0x8B4eEeBE05048C084AB739deB29d94E8E0d07A6E",
|
|
31509
|
+
poolManager: "0x4cb143D21145BcAf06D2c5557927E2939Aa0FAfe",
|
|
31510
|
+
liquidPool: "0xB3AEA00D39f4dEE364D767Cd0fb7B437d415Fb9C",
|
|
31511
|
+
limitOrder: "0xE8feDC742EDE9852c7F3E2c3793a2A98C1c7D040",
|
|
31512
|
+
dynamicFee: "0xA0C0C10e144D34EB501A42Df0EdB5C45D40Ad040"
|
|
31513
|
+
}
|
|
31514
|
+
};
|
|
31515
|
+
}
|
|
31516
|
+
});
|
|
31517
|
+
|
|
31494
31518
|
// config/env.config.ts
|
|
31495
31519
|
function getEnvValue(key3, defaultValue) {
|
|
31496
31520
|
const value = process.env[key3];
|
|
@@ -31538,20 +31562,20 @@ function loadConfig() {
|
|
|
31538
31562
|
)
|
|
31539
31563
|
},
|
|
31540
31564
|
contracts: {
|
|
31541
|
-
mutiVoucher:
|
|
31565
|
+
mutiVoucher: addresses_default.mutiVoucher,
|
|
31542
31566
|
auction: {
|
|
31543
|
-
chainYVaultV2:
|
|
31544
|
-
chainXAuctionV2:
|
|
31545
|
-
coinbase:
|
|
31567
|
+
chainYVaultV2: addresses_default.auction.chainYVaultV2,
|
|
31568
|
+
chainXAuctionV2: addresses_default.auction.chainXAuctionV2,
|
|
31569
|
+
coinbase: addresses_default.auction.coinbase
|
|
31546
31570
|
},
|
|
31547
31571
|
uniswap: {
|
|
31548
|
-
create2:
|
|
31549
|
-
token0:
|
|
31550
|
-
token1:
|
|
31551
|
-
poolManager:
|
|
31552
|
-
liquidPool:
|
|
31553
|
-
limitOrder:
|
|
31554
|
-
dynamicFee:
|
|
31572
|
+
create2: addresses_default.uniswap.create2,
|
|
31573
|
+
token0: addresses_default.uniswap.token0,
|
|
31574
|
+
token1: addresses_default.uniswap.token1,
|
|
31575
|
+
poolManager: addresses_default.uniswap.poolManager,
|
|
31576
|
+
liquidPool: addresses_default.uniswap.liquidPool,
|
|
31577
|
+
limitOrder: addresses_default.uniswap.limitOrder,
|
|
31578
|
+
dynamicFee: addresses_default.uniswap.dynamicFee
|
|
31555
31579
|
}
|
|
31556
31580
|
},
|
|
31557
31581
|
abiPaths: {
|
|
@@ -31590,6 +31614,7 @@ var init_env_config = __esm({
|
|
|
31590
31614
|
"config/env.config.ts"() {
|
|
31591
31615
|
"use strict";
|
|
31592
31616
|
init_lib49();
|
|
31617
|
+
init_addresses3();
|
|
31593
31618
|
config = loadConfig();
|
|
31594
31619
|
RPC_URL = config.rpc.url;
|
|
31595
31620
|
PRIVATE_KEY = config.wallet.privateKey;
|
|
@@ -38656,6 +38681,9 @@ init_contract();
|
|
|
38656
38681
|
async function removeLiqByPosition(wallet2, tickLower, tickUpper, liquidityToRemove) {
|
|
38657
38682
|
const liqPool = await getContract(wallet2, "LiquidPool");
|
|
38658
38683
|
let liqDelta = BigInt(liquidityToRemove.toString());
|
|
38684
|
+
if (liqDelta === 0n) {
|
|
38685
|
+
throw new Error("[SDK] Error: Cannot remove 0 liquidity. Action aborted.");
|
|
38686
|
+
}
|
|
38659
38687
|
if (liqDelta > 0n) {
|
|
38660
38688
|
liqDelta = liqDelta * -1n;
|
|
38661
38689
|
}
|
|
@@ -38732,8 +38760,8 @@ async function getUserPositions(wallet2, userAddress) {
|
|
|
38732
38760
|
// liquidity is int256, keep as string to prevent JS precision loss
|
|
38733
38761
|
liquidity: pos.liquidity.toString()
|
|
38734
38762
|
};
|
|
38735
|
-
});
|
|
38736
|
-
console.log(`[SDK] Found ${formattedPositions.length} position(s).`);
|
|
38763
|
+
}).filter((pos) => pos.liquidity !== "0");
|
|
38764
|
+
console.log(`[SDK] Found ${formattedPositions.length} active position(s).`);
|
|
38737
38765
|
return formattedPositions;
|
|
38738
38766
|
} catch (error) {
|
|
38739
38767
|
console.error(`[SDK] Failed to fetch user positions: `, error);
|