clanker-sdk 3.1.11 → 3.1.12
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.d.mts +0 -16
- package/dist/index.d.ts +0 -16
- package/dist/index.js +9 -54
- package/dist/index.mjs +9 -56
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -101,23 +101,7 @@ declare class Clanker {
|
|
|
101
101
|
private readonly wallet;
|
|
102
102
|
private readonly factoryAddress;
|
|
103
103
|
private readonly publicClient;
|
|
104
|
-
private readonly Q96;
|
|
105
|
-
private readonly TICK_BASE;
|
|
106
|
-
private readonly TICK_SPACING;
|
|
107
|
-
private readonly MAX_TICK;
|
|
108
104
|
constructor(config: ClankerConfig);
|
|
109
|
-
/**
|
|
110
|
-
* Helper function to calculate sqrt using binary search with BigInt
|
|
111
|
-
* @param value - The value to calculate sqrt of (scaled by 2^96)
|
|
112
|
-
* @returns The sqrt of the value (scaled by 2^48)
|
|
113
|
-
*/
|
|
114
|
-
private sqrt96;
|
|
115
|
-
/**
|
|
116
|
-
* Helper function to calculate log base 1.0001 using binary search
|
|
117
|
-
* @param value - The value to calculate log of (scaled by 2^96)
|
|
118
|
-
* @returns The log base 1.0001 of the value
|
|
119
|
-
*/
|
|
120
|
-
private log1000196;
|
|
121
105
|
private calculateTick;
|
|
122
106
|
private handleError;
|
|
123
107
|
deploy(config: DeploymentConfig): Promise<Address>;
|
package/dist/index.d.ts
CHANGED
|
@@ -101,23 +101,7 @@ declare class Clanker {
|
|
|
101
101
|
private readonly wallet;
|
|
102
102
|
private readonly factoryAddress;
|
|
103
103
|
private readonly publicClient;
|
|
104
|
-
private readonly Q96;
|
|
105
|
-
private readonly TICK_BASE;
|
|
106
|
-
private readonly TICK_SPACING;
|
|
107
|
-
private readonly MAX_TICK;
|
|
108
104
|
constructor(config: ClankerConfig);
|
|
109
|
-
/**
|
|
110
|
-
* Helper function to calculate sqrt using binary search with BigInt
|
|
111
|
-
* @param value - The value to calculate sqrt of (scaled by 2^96)
|
|
112
|
-
* @returns The sqrt of the value (scaled by 2^48)
|
|
113
|
-
*/
|
|
114
|
-
private sqrt96;
|
|
115
|
-
/**
|
|
116
|
-
* Helper function to calculate log base 1.0001 using binary search
|
|
117
|
-
* @param value - The value to calculate log of (scaled by 2^96)
|
|
118
|
-
* @returns The log base 1.0001 of the value
|
|
119
|
-
*/
|
|
120
|
-
private log1000196;
|
|
121
105
|
private calculateTick;
|
|
122
106
|
private handleError;
|
|
123
107
|
deploy(config: DeploymentConfig): Promise<Address>;
|
package/dist/index.js
CHANGED
|
@@ -528,61 +528,19 @@ var Clanker = class {
|
|
|
528
528
|
wallet;
|
|
529
529
|
factoryAddress;
|
|
530
530
|
publicClient;
|
|
531
|
-
Q96 = BigInt("79228162514264337593543950336");
|
|
532
|
-
// 2^96
|
|
533
|
-
TICK_BASE = 1.0001;
|
|
534
|
-
TICK_SPACING = 200;
|
|
535
|
-
MAX_TICK = 887200;
|
|
536
531
|
constructor(config) {
|
|
537
532
|
this.wallet = config.wallet;
|
|
538
533
|
this.publicClient = config.publicClient;
|
|
539
534
|
this.factoryAddress = config.factoryAddress ?? CLANKER_FACTORY_V3_1;
|
|
540
535
|
}
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
}
|
|
550
|
-
let z = value;
|
|
551
|
-
let x = value / BigInt(2) + BigInt(1);
|
|
552
|
-
while (x < z) {
|
|
553
|
-
z = x;
|
|
554
|
-
x = (value / x + x) / BigInt(2);
|
|
555
|
-
}
|
|
556
|
-
return z;
|
|
557
|
-
}
|
|
558
|
-
/**
|
|
559
|
-
* Helper function to calculate log base 1.0001 using binary search
|
|
560
|
-
* @param value - The value to calculate log of (scaled by 2^96)
|
|
561
|
-
* @returns The log base 1.0001 of the value
|
|
562
|
-
*/
|
|
563
|
-
log1000196(value) {
|
|
564
|
-
const valueNum = Number(value) / Number(this.Q96);
|
|
565
|
-
return Math.floor(Math.log(valueNum) / Math.log(this.TICK_BASE));
|
|
566
|
-
}
|
|
567
|
-
async calculateTick(pairedToken, initialMarketCapInPairedToken) {
|
|
568
|
-
try {
|
|
569
|
-
const tokenContract = (0, import_viem.getContract)({
|
|
570
|
-
address: pairedToken,
|
|
571
|
-
abi: import_viem.erc20Abi,
|
|
572
|
-
client: this.publicClient
|
|
573
|
-
});
|
|
574
|
-
const decimals = await tokenContract.read.decimals();
|
|
575
|
-
const TOTAL_SUPPLY = BigInt("100000000000000000000000000000");
|
|
576
|
-
const priceInPairedToken = TOTAL_SUPPLY * this.Q96 / (initialMarketCapInPairedToken * BigInt(10) ** BigInt(decimals));
|
|
577
|
-
const sqrtPriceX96 = this.sqrt96(priceInPairedToken);
|
|
578
|
-
const rawTick = this.log1000196(sqrtPriceX96);
|
|
579
|
-
const tick = Math.round(rawTick / this.TICK_SPACING) * this.TICK_SPACING;
|
|
580
|
-
return Math.min(Math.max(tick, -this.MAX_TICK), this.MAX_TICK);
|
|
581
|
-
} catch (error) {
|
|
582
|
-
throw new Error(
|
|
583
|
-
`Failed to calculate tick: ${error instanceof Error ? error.message : String(error)}`
|
|
584
|
-
);
|
|
585
|
-
}
|
|
536
|
+
// Get paired token decimals
|
|
537
|
+
calculateTick() {
|
|
538
|
+
let desiredPrice = 1e-10;
|
|
539
|
+
const logBase = 1.0001;
|
|
540
|
+
const tickSpacing = 200;
|
|
541
|
+
const rawTick = Math.log(desiredPrice) / Math.log(logBase);
|
|
542
|
+
const initialTick = Math.floor(rawTick / tickSpacing) * tickSpacing;
|
|
543
|
+
return initialTick;
|
|
586
544
|
}
|
|
587
545
|
handleError(error) {
|
|
588
546
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -610,10 +568,7 @@ var Clanker = class {
|
|
|
610
568
|
},
|
|
611
569
|
poolConfig: {
|
|
612
570
|
pairedToken: config.poolConfig.pairedToken,
|
|
613
|
-
tickIfToken0IsNewToken:
|
|
614
|
-
config.poolConfig.pairedToken,
|
|
615
|
-
config.poolConfig.initialMarketCapInPairedToken
|
|
616
|
-
)
|
|
571
|
+
tickIfToken0IsNewToken: this.calculateTick()
|
|
617
572
|
},
|
|
618
573
|
initialBuyConfig: {
|
|
619
574
|
pairedTokenPoolFee: config.initialBuyConfig?.pairedTokenPoolFee ?? 1e4,
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import {
|
|
3
|
-
getContract,
|
|
4
3
|
parseEther,
|
|
5
4
|
stringify,
|
|
6
|
-
erc20Abi,
|
|
7
5
|
parseEventLogs
|
|
8
6
|
} from "viem";
|
|
9
7
|
import { simulateContract, writeContract } from "viem/actions";
|
|
@@ -510,61 +508,19 @@ var Clanker = class {
|
|
|
510
508
|
wallet;
|
|
511
509
|
factoryAddress;
|
|
512
510
|
publicClient;
|
|
513
|
-
Q96 = BigInt("79228162514264337593543950336");
|
|
514
|
-
// 2^96
|
|
515
|
-
TICK_BASE = 1.0001;
|
|
516
|
-
TICK_SPACING = 200;
|
|
517
|
-
MAX_TICK = 887200;
|
|
518
511
|
constructor(config) {
|
|
519
512
|
this.wallet = config.wallet;
|
|
520
513
|
this.publicClient = config.publicClient;
|
|
521
514
|
this.factoryAddress = config.factoryAddress ?? CLANKER_FACTORY_V3_1;
|
|
522
515
|
}
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
}
|
|
532
|
-
let z = value;
|
|
533
|
-
let x = value / BigInt(2) + BigInt(1);
|
|
534
|
-
while (x < z) {
|
|
535
|
-
z = x;
|
|
536
|
-
x = (value / x + x) / BigInt(2);
|
|
537
|
-
}
|
|
538
|
-
return z;
|
|
539
|
-
}
|
|
540
|
-
/**
|
|
541
|
-
* Helper function to calculate log base 1.0001 using binary search
|
|
542
|
-
* @param value - The value to calculate log of (scaled by 2^96)
|
|
543
|
-
* @returns The log base 1.0001 of the value
|
|
544
|
-
*/
|
|
545
|
-
log1000196(value) {
|
|
546
|
-
const valueNum = Number(value) / Number(this.Q96);
|
|
547
|
-
return Math.floor(Math.log(valueNum) / Math.log(this.TICK_BASE));
|
|
548
|
-
}
|
|
549
|
-
async calculateTick(pairedToken, initialMarketCapInPairedToken) {
|
|
550
|
-
try {
|
|
551
|
-
const tokenContract = getContract({
|
|
552
|
-
address: pairedToken,
|
|
553
|
-
abi: erc20Abi,
|
|
554
|
-
client: this.publicClient
|
|
555
|
-
});
|
|
556
|
-
const decimals = await tokenContract.read.decimals();
|
|
557
|
-
const TOTAL_SUPPLY = BigInt("100000000000000000000000000000");
|
|
558
|
-
const priceInPairedToken = TOTAL_SUPPLY * this.Q96 / (initialMarketCapInPairedToken * BigInt(10) ** BigInt(decimals));
|
|
559
|
-
const sqrtPriceX96 = this.sqrt96(priceInPairedToken);
|
|
560
|
-
const rawTick = this.log1000196(sqrtPriceX96);
|
|
561
|
-
const tick = Math.round(rawTick / this.TICK_SPACING) * this.TICK_SPACING;
|
|
562
|
-
return Math.min(Math.max(tick, -this.MAX_TICK), this.MAX_TICK);
|
|
563
|
-
} catch (error) {
|
|
564
|
-
throw new Error(
|
|
565
|
-
`Failed to calculate tick: ${error instanceof Error ? error.message : String(error)}`
|
|
566
|
-
);
|
|
567
|
-
}
|
|
516
|
+
// Get paired token decimals
|
|
517
|
+
calculateTick() {
|
|
518
|
+
let desiredPrice = 1e-10;
|
|
519
|
+
const logBase = 1.0001;
|
|
520
|
+
const tickSpacing = 200;
|
|
521
|
+
const rawTick = Math.log(desiredPrice) / Math.log(logBase);
|
|
522
|
+
const initialTick = Math.floor(rawTick / tickSpacing) * tickSpacing;
|
|
523
|
+
return initialTick;
|
|
568
524
|
}
|
|
569
525
|
handleError(error) {
|
|
570
526
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -592,10 +548,7 @@ var Clanker = class {
|
|
|
592
548
|
},
|
|
593
549
|
poolConfig: {
|
|
594
550
|
pairedToken: config.poolConfig.pairedToken,
|
|
595
|
-
tickIfToken0IsNewToken:
|
|
596
|
-
config.poolConfig.pairedToken,
|
|
597
|
-
config.poolConfig.initialMarketCapInPairedToken
|
|
598
|
-
)
|
|
551
|
+
tickIfToken0IsNewToken: this.calculateTick()
|
|
599
552
|
},
|
|
600
553
|
initialBuyConfig: {
|
|
601
554
|
pairedTokenPoolFee: config.initialBuyConfig?.pairedTokenPoolFee ?? 1e4,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clanker-sdk",
|
|
3
|
-
"version": "3.1.
|
|
4
|
-
"description": "SDK for deploying tokens using Clanker",
|
|
3
|
+
"version": "3.1.12",
|
|
4
|
+
"description": "SDK for deploying tokens using Clanker v3.1.9",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
7
7
|
"types": "dist/index.d.ts",
|