@clonegod/ttd-sol-common 2.0.53 → 2.0.55
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/trade/send/jito.d.ts +1 -0
- package/dist/trade/send/jito.js +7 -2
- package/docs/clmm.md +10 -0
- package/package.json +2 -2
- package/src/trade/send/jito.ts +7 -2
package/dist/trade/send/jito.js
CHANGED
|
@@ -52,11 +52,15 @@ class JitoUtils {
|
|
|
52
52
|
return JitoUtils.fetchJitoTipAccounts().then((accounts) => {
|
|
53
53
|
JitoUtils.jitoTipAccounts = accounts;
|
|
54
54
|
console.log(`fetchJitoTipAccounts success: ${accounts.length} accounts`, accounts);
|
|
55
|
+
}).catch((error) => {
|
|
56
|
+
(0, dist_1.log_warn)(`fetchJitoTipAccounts failed!`, {
|
|
57
|
+
url: JitoUtils.jitoTipAccountUrl,
|
|
58
|
+
error: error.message
|
|
59
|
+
});
|
|
55
60
|
});
|
|
56
61
|
}
|
|
57
62
|
static async fetchJitoTipAccounts() {
|
|
58
|
-
const
|
|
59
|
-
const response = await axios_1.default.post(url, {
|
|
63
|
+
const response = await axios_1.default.post(JitoUtils.jitoTipAccountUrl, {
|
|
60
64
|
jsonrpc: '2.0',
|
|
61
65
|
id: 1,
|
|
62
66
|
method: 'getTipAccounts',
|
|
@@ -67,6 +71,7 @@ class JitoUtils {
|
|
|
67
71
|
}
|
|
68
72
|
exports.JitoUtils = JitoUtils;
|
|
69
73
|
JitoUtils.jitoTipAccounts = [];
|
|
74
|
+
JitoUtils.jitoTipAccountUrl = 'https://mainnet.block-engine.jito.wtf/api/v1/getTipAccounts';
|
|
70
75
|
const getJitoTipAccount = () => {
|
|
71
76
|
let jito_tip_accounts = JitoUtils.jitoTipAccounts;
|
|
72
77
|
if (jito_tip_accounts.length === 0) {
|
package/docs/clmm.md
CHANGED
|
@@ -104,5 +104,15 @@ sqrtPriceX64
|
|
|
104
104
|
输入 amountIn → 扣费 → 逐 tick 吃(跨 tick 更新 L,跨 array 加载下一个)→ 输出 amountOut + 最终价格
|
|
105
105
|
|
|
106
106
|
|
|
107
|
+
-------------------
|
|
108
|
+
CLMM 里 price 的定义:
|
|
109
|
+
- 核心状态是 `sqrtPriceX64`(Q64.64 定点)。
|
|
110
|
+
- 价格默认方向是 **tokenB per tokenA**,即「1 个 tokenA 要多少 tokenB」(quote/base)。
|
|
111
|
+
计算公式:`price = (sqrtPriceX64^2) / 2^128`。
|
|
112
|
+
- 对应 tick:`sqrtPriceX64 = 1.0001^(tick/2) * 2^64`,因此
|
|
113
|
+
`tick = floor(log(price) / log(1.0001))`(按 tokenB/tokenA 方向)。
|
|
114
|
+
- 如果需要 **tokenA per tokenB**(倒数价格),取 `1 / price`。
|
|
115
|
+
简化理解:CLMM 把价格存成 `sqrtPriceX64`,平方后除以 `2^128` 得到 tokenB/tokenA 的现价;tick 是以 1.0001 为底的价格刻度。
|
|
116
|
+
|
|
107
117
|
|
|
108
118
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clonegod/ttd-sol-common",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.55",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"push": "npm run build && npm publish"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@clonegod/ttd-core": "2.1.
|
|
16
|
+
"@clonegod/ttd-core": "2.1.15",
|
|
17
17
|
"@solana/web3.js": "1.91.6",
|
|
18
18
|
"rpc-websockets": "7.10.0",
|
|
19
19
|
"axios": "^1.2.3",
|
package/src/trade/send/jito.ts
CHANGED
|
@@ -15,17 +15,22 @@ export const JITO_TIP_ACCOUNTS = [
|
|
|
15
15
|
|
|
16
16
|
export class JitoUtils {
|
|
17
17
|
static jitoTipAccounts: string[] = []
|
|
18
|
+
static jitoTipAccountUrl = 'https://mainnet.block-engine.jito.wtf/api/v1/getTipAccounts'
|
|
18
19
|
|
|
19
20
|
static async init(): Promise<void> {
|
|
20
21
|
return JitoUtils.fetchJitoTipAccounts().then((accounts) => {
|
|
21
22
|
JitoUtils.jitoTipAccounts = accounts;
|
|
22
23
|
console.log(`fetchJitoTipAccounts success: ${accounts.length} accounts`, accounts)
|
|
24
|
+
}).catch((error) => {
|
|
25
|
+
log_warn(`fetchJitoTipAccounts failed!`, {
|
|
26
|
+
url: JitoUtils.jitoTipAccountUrl,
|
|
27
|
+
error: error.message
|
|
28
|
+
});
|
|
23
29
|
});
|
|
24
30
|
}
|
|
25
31
|
|
|
26
32
|
static async fetchJitoTipAccounts(): Promise<string[]> {
|
|
27
|
-
const
|
|
28
|
-
const response = await axios.post<{ result: string[] }>(url, {
|
|
33
|
+
const response = await axios.post<{ result: string[] }>(JitoUtils.jitoTipAccountUrl, {
|
|
29
34
|
jsonrpc: '2.0',
|
|
30
35
|
id: 1,
|
|
31
36
|
method: 'getTipAccounts',
|