@clonegod/ttd-sol-common 2.0.70 → 2.0.72
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/appconfig/SolanaTradeAppConfig.js +1 -1
- package/dist/common/subscribe_account_update.js +1 -1
- package/dist/trade/tx_builder.js +2 -2
- package/package.json +2 -2
- package/src/appconfig/SolanaTradeAppConfig.ts +2 -1
- package/src/common/subscribe_account_update.ts +2 -2
- package/src/quote/chain_ops.ts +1 -1
- package/src/trade/tx_builder.ts +3 -3
|
@@ -60,7 +60,7 @@ class SolanaTradeAppConfig extends dist_1.AbstractTradeAppConfig {
|
|
|
60
60
|
(0, dist_1.log_info)(`Received transaction result via WebSocket: ${tx_id}`);
|
|
61
61
|
this.emit(dist_1.LOCAL_EVENT_NAME.EVENT_WALLET_TRANSACTION + '#' + tx_id, messageObj);
|
|
62
62
|
};
|
|
63
|
-
const ws_port =
|
|
63
|
+
const ws_port = dist_1.SERVICE_PORT.STREAM_TRADE_WS;
|
|
64
64
|
const ws_url = `ws://127.0.0.1:${ws_port}`;
|
|
65
65
|
this.ws_client = new dist_1.WebSocketClient(ws_url);
|
|
66
66
|
this.ws_client.onMessage(transactionHandler);
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.subscribe_pool_account_update = subscribe_pool_account_update;
|
|
4
4
|
const dist_1 = require("@clonegod/ttd-core/dist");
|
|
5
5
|
function subscribe_pool_account_update(dex_id, pool_list, callback) {
|
|
6
|
-
const port =
|
|
6
|
+
const port = dist_1.SERVICE_PORT.STREAM_QUOTE_WS;
|
|
7
7
|
const ws_url = `ws://127.0.0.1:${port}`;
|
|
8
8
|
const ws_client = new dist_1.WebSocketClient(ws_url);
|
|
9
9
|
ws_client.onOpen(() => {
|
package/dist/trade/tx_builder.js
CHANGED
|
@@ -101,8 +101,8 @@ class SolTransactionBuilder {
|
|
|
101
101
|
if (tip_lamports < 5000) {
|
|
102
102
|
tip_lamports = 5000;
|
|
103
103
|
}
|
|
104
|
-
if (tip_lamports >
|
|
105
|
-
tip_lamports =
|
|
104
|
+
if (tip_lamports > 1000000) {
|
|
105
|
+
tip_lamports = 1000000;
|
|
106
106
|
}
|
|
107
107
|
let tip_instruction = web3_js_1.SystemProgram.transfer({
|
|
108
108
|
fromPubkey: this.keypair.publicKey,
|
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.72",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"push": "npm run build && npm publish"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@clonegod/ttd-core": "3.1.
|
|
16
|
+
"@clonegod/ttd-core": "3.1.86",
|
|
17
17
|
"@solana/web3.js": "1.91.6",
|
|
18
18
|
"rpc-websockets": "7.10.0",
|
|
19
19
|
"axios": "^1.2.3",
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
LOCAL_EVENT_NAME,
|
|
17
17
|
log_error,
|
|
18
18
|
log_info,
|
|
19
|
+
SERVICE_PORT,
|
|
19
20
|
sleep,
|
|
20
21
|
WebSocketClient,
|
|
21
22
|
} from '@clonegod/ttd-core/dist'
|
|
@@ -106,7 +107,7 @@ export class SolanaTradeAppConfig extends AbstractTradeAppConfig {
|
|
|
106
107
|
this.emit(LOCAL_EVENT_NAME.EVENT_WALLET_TRANSACTION + '#' + tx_id, messageObj)
|
|
107
108
|
}
|
|
108
109
|
|
|
109
|
-
const ws_port =
|
|
110
|
+
const ws_port = SERVICE_PORT.STREAM_TRADE_WS
|
|
110
111
|
const ws_url = `ws://127.0.0.1:${ws_port}`
|
|
111
112
|
this.ws_client = new WebSocketClient(ws_url)
|
|
112
113
|
this.ws_client.onMessage(transactionHandler)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StandardPoolInfoType } from "@clonegod/ttd-core";
|
|
2
|
-
import { DEX_ID, log_warn, WebSocketClient } from "@clonegod/ttd-core/dist";
|
|
2
|
+
import { DEX_ID, log_warn, SERVICE_PORT, WebSocketClient } from "@clonegod/ttd-core/dist";
|
|
3
3
|
import { SolanaPoolAccountUpdateEventData } from "../types";
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -8,7 +8,7 @@ import { SolanaPoolAccountUpdateEventData } from "../types";
|
|
|
8
8
|
* - 交易使用:交易中需要池子的最新状态
|
|
9
9
|
*/
|
|
10
10
|
export function subscribe_pool_account_update(dex_id: DEX_ID, pool_list: StandardPoolInfoType[], callback: (eventData: SolanaPoolAccountUpdateEventData) => void) {
|
|
11
|
-
const port =
|
|
11
|
+
const port = SERVICE_PORT.STREAM_QUOTE_WS;
|
|
12
12
|
const ws_url = `ws://127.0.0.1:${port}`;
|
|
13
13
|
const ws_client = new WebSocketClient(ws_url)
|
|
14
14
|
ws_client.onOpen(() => {
|
package/src/quote/chain_ops.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { TokenPriceCache } from './pricing/token_price_cache'
|
|
|
9
9
|
*
|
|
10
10
|
* 把「询价流程不变、链能力可换」收成一个对象:同一套 AbstractDexQuote 模板,Solana 注入 SolanaChainOps。
|
|
11
11
|
* 与 SUI 的差异:
|
|
12
|
-
* - 池事件源是 stream-quote 的 **WS 通道**(subscribe_pool_account_update,port
|
|
12
|
+
* - 池事件源是 stream-quote 的 **WS 通道**(subscribe_pool_account_update,port SERVICE_PORT.STREAM_QUOTE_WS),
|
|
13
13
|
* 推送的是**账户原始快照**(base64),非结构化 swap 事件(详见 pool_event.ts)。
|
|
14
14
|
* - assertProgramDeployed 用 connection.getAccountInfo + executable 校验(Solana 无 eth_getCode)。
|
|
15
15
|
* - Solana 地址是 base58 **大小写敏感**,loadTokenPrices 用原地址作 key(不可 lowercase)。
|
package/src/trade/tx_builder.ts
CHANGED
|
@@ -178,10 +178,10 @@ export class SolTransactionBuilder {
|
|
|
178
178
|
// 2、swqos + jito: 至少 0.0002 SOL 小费 -> lamports = 0.0002 * LAMPORTS_PER_SOL
|
|
179
179
|
let tip_lamports = sol_tip_fee
|
|
180
180
|
if (tip_lamports < 5000) {
|
|
181
|
-
tip_lamports = 5000
|
|
181
|
+
tip_lamports = 5000 // 下限:Helius swqos 协议硬要求
|
|
182
182
|
}
|
|
183
|
-
if (tip_lamports >
|
|
184
|
-
tip_lamports =
|
|
183
|
+
if (tip_lamports > 1000000) {
|
|
184
|
+
tip_lamports = 1000000 // 上限:0.001 SOL
|
|
185
185
|
}
|
|
186
186
|
let tip_instruction = SystemProgram.transfer({
|
|
187
187
|
fromPubkey: this.keypair.publicKey,
|