wasabi-solana-ts 1.2.3 → 1.2.4
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/base/base.d.ts +2 -2
- package/dist/cache/BaseAccountCache.d.ts +44 -0
- package/dist/cache/BaseAccountCache.js +80 -0
- package/dist/cache/TokenMintCache.d.ts +14 -0
- package/dist/cache/TokenMintCache.js +25 -0
- package/dist/index.d.ts +3 -3
- package/dist/instructions/closeLongPosition.d.ts +3 -3
- package/dist/instructions/closePosition.d.ts +2 -2
- package/dist/instructions/closePositionV2.d.ts +2 -2
- package/dist/instructions/closeShortPosition.d.ts +3 -3
- package/dist/instructions/donate.d.ts +2 -2
- package/dist/instructions/increaseLongPositionSetup.d.ts +2 -2
- package/dist/instructions/increaseShortPositionSetup.d.ts +2 -2
- package/dist/instructions/initPool.d.ts +2 -2
- package/dist/instructions/liquidatePosition.d.ts +3 -3
- package/dist/instructions/liquidatePositionV2.d.ts +2 -2
- package/dist/instructions/openLongPosition.d.ts +3 -3
- package/dist/instructions/openLongPosition.js +1 -1
- package/dist/instructions/openShortPosition.d.ts +3 -3
- package/dist/instructions/openShortPosition.js +1 -1
- package/dist/instructions/stopLoss.d.ts +3 -3
- package/dist/instructions/stopLossV2.d.ts +2 -2
- package/dist/instructions/takeProfit.d.ts +3 -3
- package/dist/instructions/takeProfitV2.d.ts +2 -2
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.js +0 -1
- package/dist/utils/utils.d.ts +10 -11
- package/dist/utils/utils.js +36 -64
- package/package.json +5 -3
- package/dist/instructions/closeWallet.d.ts +0 -20
- package/dist/instructions/closeWallet.js +0 -34
- package/dist/instructions/collectFees.d.ts +0 -22
- package/dist/instructions/collectFees.js +0 -40
- package/dist/instructions/generateWallet.d.ts +0 -22
- package/dist/instructions/generateWallet.js +0 -36
- package/dist/instructions/increaseShortPosition.d.ts +0 -6
- package/dist/instructions/increaseShortPosition.js +0 -70
- package/dist/instructions/initDebtController.d.ts +0 -24
- package/dist/instructions/initDebtController.js +0 -37
- package/dist/instructions/initGlobalSettings.d.ts +0 -9
- package/dist/instructions/initGlobalSettings.js +0 -32
- package/dist/instructions/initOrUpdatePermission.d.ts +0 -22
- package/dist/instructions/initOrUpdatePermission.js +0 -48
- package/dist/instructions/initStopLossOrder.d.ts +0 -12
- package/dist/instructions/initStopLossOrder.js +0 -40
- package/dist/instructions/initTakeProfitOrder.d.ts +0 -12
- package/dist/instructions/initTakeProfitOrder.js +0 -40
- package/dist/instructions/mint.d.ts +0 -8
- package/dist/instructions/mint.js +0 -35
- package/dist/instructions/removePermission.d.ts +0 -16
- package/dist/instructions/removePermission.js +0 -25
- package/dist/instructions/repay.d.ts +0 -11
- package/dist/instructions/repay.js +0 -44
- package/dist/instructions/setLpState.d.ts +0 -11
- package/dist/instructions/setLpState.js +0 -28
- package/dist/instructions/setMaxApy.d.ts +0 -11
- package/dist/instructions/setMaxApy.js +0 -31
- package/dist/instructions/setMaxLeverage.d.ts +0 -11
- package/dist/instructions/setMaxLeverage.js +0 -31
- package/dist/instructions/setSuperAdmin.d.ts +0 -11
- package/dist/instructions/setSuperAdmin.js +0 -27
- package/dist/instructions/setTradeState.d.ts +0 -11
- package/dist/instructions/setTradeState.js +0 -28
- package/dist/instructions/swap.d.ts +0 -30
- package/dist/instructions/swap.js +0 -91
- package/dist/instructions/swapJupiter.d.ts +0 -90
- package/dist/instructions/swapJupiter.js +0 -61
- package/dist/instructions/swapRaydium.d.ts +0 -38
- package/dist/instructions/swapRaydium.js +0 -170
- package/dist/instructions/updateLongPosition.d.ts +0 -6
- package/dist/instructions/updateLongPosition.js +0 -69
- package/dist/instructions/updateLpVaultMaxBorrow.d.ts +0 -12
- package/dist/instructions/updateLpVaultMaxBorrow.js +0 -35
- package/dist/sender-provider/baseSenderProvider.d.ts +0 -42
- package/dist/sender-provider/baseSenderProvider.js +0 -178
- package/dist/sender-provider/index.d.ts +0 -5
- package/dist/sender-provider/index.js +0 -21
- package/dist/sender-provider/jitoBrowser.d.ts +0 -2
- package/dist/sender-provider/jitoBrowser.js +0 -32
- package/dist/sender-provider/jitoSenderProvider.d.ts +0 -5
- package/dist/sender-provider/jitoSenderProvider.js +0 -69
- package/dist/sender-provider/jitoServer.d.ts +0 -2
- package/dist/sender-provider/jitoServer.js +0 -67
- package/dist/sender-provider/jitoTips.d.ts +0 -17
- package/dist/sender-provider/jitoTips.js +0 -75
- package/dist/sender-provider/jitoTypes.d.ts +0 -12
- package/dist/sender-provider/jitoTypes.js +0 -6
- package/dist/utils/mintCache.d.ts +0 -10
- package/dist/utils/mintCache.js +0 -39
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ProviderBuilder = exports.baseSender = void 0;
|
|
4
|
-
const web3_js_1 = require("@solana/web3.js");
|
|
5
|
-
const jitoSenderProvider_1 = require("./jitoSenderProvider");
|
|
6
|
-
const jitoTips_1 = require("./jitoTips");
|
|
7
|
-
const transaction_builder_1 = require("../transaction-builder");
|
|
8
|
-
const baseSender = (connection, confirm = false) => async (transactions) => {
|
|
9
|
-
const sendTx = async (transactions) => {
|
|
10
|
-
if (transactions.length > 1) {
|
|
11
|
-
throw new Error('Base sender only supports one transaction');
|
|
12
|
-
}
|
|
13
|
-
const signature = await connection.sendTransaction(transactions[0], { skipPreflight: true });
|
|
14
|
-
if (confirm) {
|
|
15
|
-
const confirmStrategy = {
|
|
16
|
-
signature,
|
|
17
|
-
blockhash: transactions[0].message.recentBlockhash,
|
|
18
|
-
lastValidBlockHeight: await connection.getBlockHeight()
|
|
19
|
-
};
|
|
20
|
-
const status = await connection.confirmTransaction(confirmStrategy);
|
|
21
|
-
if (status.value.err) {
|
|
22
|
-
throw new Error('Transaction failed: ' + status.value.err.toString());
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return signature;
|
|
26
|
-
};
|
|
27
|
-
return {
|
|
28
|
-
transactions,
|
|
29
|
-
send: async () => {
|
|
30
|
-
return await sendTx(transactions);
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
exports.baseSender = baseSender;
|
|
35
|
-
class ProviderBuilder {
|
|
36
|
-
connection;
|
|
37
|
-
payer;
|
|
38
|
-
simulateTransaction;
|
|
39
|
-
confirmTransaction;
|
|
40
|
-
providerClient;
|
|
41
|
-
options;
|
|
42
|
-
transactions = [];
|
|
43
|
-
setConnection(connection) {
|
|
44
|
-
this.connection = connection;
|
|
45
|
-
return this;
|
|
46
|
-
}
|
|
47
|
-
setPayer(payer) {
|
|
48
|
-
this.payer = payer;
|
|
49
|
-
return this;
|
|
50
|
-
}
|
|
51
|
-
setSimulateTransaction(simulateTransaction) {
|
|
52
|
-
this.simulateTransaction = simulateTransaction;
|
|
53
|
-
return this;
|
|
54
|
-
}
|
|
55
|
-
setConfirmTransaction(confirmTransaction) {
|
|
56
|
-
this.confirmTransaction = confirmTransaction;
|
|
57
|
-
return this;
|
|
58
|
-
}
|
|
59
|
-
setProviderClient(providerClient) {
|
|
60
|
-
this.providerClient = providerClient;
|
|
61
|
-
return this;
|
|
62
|
-
}
|
|
63
|
-
setOptions(options) {
|
|
64
|
-
this.options = options;
|
|
65
|
-
return this;
|
|
66
|
-
}
|
|
67
|
-
addTransactions(...transactions) {
|
|
68
|
-
this.transactions.push(...transactions);
|
|
69
|
-
return this;
|
|
70
|
-
}
|
|
71
|
-
setTransactions(transactions) {
|
|
72
|
-
this.transactions = transactions;
|
|
73
|
-
return this;
|
|
74
|
-
}
|
|
75
|
-
addSerializedTransactions(...transaction) {
|
|
76
|
-
this.transactions.push(...transaction.map((tx) => web3_js_1.VersionedTransaction.deserialize(Buffer.from(tx, 'base64'))));
|
|
77
|
-
return this;
|
|
78
|
-
}
|
|
79
|
-
setSerializedTransactions(transactions) {
|
|
80
|
-
this.transactions = transactions.map((tx) => web3_js_1.VersionedTransaction.deserialize(Buffer.from(tx, 'base64')));
|
|
81
|
-
return this;
|
|
82
|
-
}
|
|
83
|
-
setProviderOptions(options) {
|
|
84
|
-
this.options = options;
|
|
85
|
-
return this;
|
|
86
|
-
}
|
|
87
|
-
getTransactions() {
|
|
88
|
-
return this.transactions;
|
|
89
|
-
}
|
|
90
|
-
async getSender() {
|
|
91
|
-
if (this.providerClient) {
|
|
92
|
-
return (0, jitoSenderProvider_1.jitoSender)(this.connection, this.providerClient, this.confirmTransaction)(this.transactions);
|
|
93
|
-
}
|
|
94
|
-
return (0, exports.baseSender)(this.connection, this.confirmTransaction)(this.transactions);
|
|
95
|
-
}
|
|
96
|
-
async sign(transactions, signer) {
|
|
97
|
-
console.log('signer', signer);
|
|
98
|
-
if ('signAllTransactions' in signer && signer.signAllTransactions) {
|
|
99
|
-
this.transactions = await signer.signAllTransactions(transactions);
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
for (const transaction of transactions) {
|
|
103
|
-
if ('signTransaction' in signer && signer.signTransaction) {
|
|
104
|
-
const txPromises = transactions.map(tx => signer.signTransaction(tx));
|
|
105
|
-
this.transactions = await Promise.all([...txPromises]);
|
|
106
|
-
}
|
|
107
|
-
else if (signer instanceof web3_js_1.Keypair) {
|
|
108
|
-
transaction.sign([signer]);
|
|
109
|
-
}
|
|
110
|
-
else if ('secretKey' in signer) {
|
|
111
|
-
const keypair = web3_js_1.Keypair.fromSecretKey(signer.secretKey);
|
|
112
|
-
transaction.sign([keypair]);
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
throw new Error('Invalid signer');
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
return this;
|
|
120
|
-
}
|
|
121
|
-
async simulate(transactions) {
|
|
122
|
-
const simPromises = transactions.map((tx) => {
|
|
123
|
-
return this.connection.simulateTransaction(tx, { commitment: 'confirmed' });
|
|
124
|
-
});
|
|
125
|
-
const simResults = await Promise.all([...simPromises]);
|
|
126
|
-
for (const simResult of simResults) {
|
|
127
|
-
if (simResult.value.err) {
|
|
128
|
-
throw new Error('Failed to simulate transaction: ' + simResult.value.err.toString() + '');
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
validateSignatures() {
|
|
134
|
-
for (const transaction of this.transactions) {
|
|
135
|
-
if (!transaction.signatures.length) {
|
|
136
|
-
throw new Error('Transaction has no signatures');
|
|
137
|
-
}
|
|
138
|
-
const message = transaction.message;
|
|
139
|
-
const feePayerPubkey = message.staticAccountKeys[0];
|
|
140
|
-
if (!feePayerPubkey.equals(this.payer)) {
|
|
141
|
-
throw new Error('Fee payer public key mismatch');
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
validateSignedTransactions() {
|
|
147
|
-
for (const transaction of this.transactions) {
|
|
148
|
-
const message = transaction.message;
|
|
149
|
-
if (transaction.signatures.length < message.header.numRequiredSignatures) {
|
|
150
|
-
throw new Error(`Transaction requires ${message.header.numRequiredSignatures} signatures but only has ${transaction.signatures.length}`);
|
|
151
|
-
}
|
|
152
|
-
if (!transaction.signatures[0]) {
|
|
153
|
-
throw new Error('Fee payer is missing');
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
async build(signer) {
|
|
159
|
-
// Validate signature length
|
|
160
|
-
this.validateSignatures();
|
|
161
|
-
// Simulate
|
|
162
|
-
this.simulateTransaction && (await this.simulate(this.transactions));
|
|
163
|
-
// Add the tip instruction
|
|
164
|
-
if (this.providerClient && this.options?.tipAmount) {
|
|
165
|
-
const tipIx = (0, jitoTips_1.createTipInstruction)(this.payer, this.options.tipAmount);
|
|
166
|
-
const builder = new transaction_builder_1.TransactionBuilder()
|
|
167
|
-
.setPayer(this.payer)
|
|
168
|
-
.setConnection(this.connection)
|
|
169
|
-
.addInstructions(tipIx);
|
|
170
|
-
const tx = await builder.build();
|
|
171
|
-
this.transactions.push(tx);
|
|
172
|
-
}
|
|
173
|
-
await this.sign(this.transactions, signer);
|
|
174
|
-
this.validateSignedTransactions();
|
|
175
|
-
return this.getSender();
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
exports.ProviderBuilder = ProviderBuilder;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./baseSenderProvider.js"), exports);
|
|
18
|
-
__exportStar(require("./jitoSenderProvider.js"), exports);
|
|
19
|
-
__exportStar(require("./baseSenderProvider.js"), exports);
|
|
20
|
-
__exportStar(require("./jitoTips.js"), exports);
|
|
21
|
-
__exportStar(require("./jitoTypes.js"), exports);
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createBrowserClient = void 0;
|
|
4
|
-
const jito_js_rpc_1 = require("jito-js-rpc");
|
|
5
|
-
const jitoTypes_1 = require("./jitoTypes");
|
|
6
|
-
const createBrowserClient = async (url) => {
|
|
7
|
-
const client = new jito_js_rpc_1.JitoJsonRpcClient(url, jitoTypes_1.UUID);
|
|
8
|
-
return {
|
|
9
|
-
sendBundle: async (transactions) => {
|
|
10
|
-
try {
|
|
11
|
-
const base64Txs = [
|
|
12
|
-
...new Set(transactions.map((tx) => {
|
|
13
|
-
return Buffer.from(tx.serialize()).toString('base64');
|
|
14
|
-
}))
|
|
15
|
-
];
|
|
16
|
-
const response = await client.sendBundle([base64Txs, { encoding: 'base64' }]);
|
|
17
|
-
return response.result;
|
|
18
|
-
}
|
|
19
|
-
catch (e) {
|
|
20
|
-
throw e;
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
confirmBundle: async (bundleId) => {
|
|
24
|
-
const result = await client.confirmInflightBundle(bundleId);
|
|
25
|
-
if (result.err) {
|
|
26
|
-
throw new Error(result.err);
|
|
27
|
-
}
|
|
28
|
-
return;
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
exports.createBrowserClient = createBrowserClient;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { VersionedTransaction, Connection } from '@solana/web3.js';
|
|
2
|
-
import { Sender } from '../index';
|
|
3
|
-
import { JitoClient } from './jitoTypes';
|
|
4
|
-
export declare const createJitoClient: (url?: string, uuid?: string) => Promise<JitoClient>;
|
|
5
|
-
export declare const jitoSender: (_connection: Connection, providerClient: JitoClient, confirm?: boolean) => (transactions: VersionedTransaction[]) => Promise<Sender>;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.jitoSender = exports.createJitoClient = void 0;
|
|
27
|
-
const jitoTypes_1 = require("./jitoTypes");
|
|
28
|
-
const createJitoClient = async (url, uuid) => {
|
|
29
|
-
if (typeof window === 'undefined') {
|
|
30
|
-
const { createServerClient } = await Promise.resolve().then(() => __importStar(require('./jitoServer')));
|
|
31
|
-
return createServerClient(url || jitoTypes_1.JITO_BASE_URL);
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
const { createBrowserClient } = await Promise.resolve().then(() => __importStar(require('./jitoBrowser')));
|
|
35
|
-
return createBrowserClient(url || jitoTypes_1.JITO_RPC_URL);
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
exports.createJitoClient = createJitoClient;
|
|
39
|
-
const jitoSender = (_connection, providerClient, confirm = false) => async (transactions) => {
|
|
40
|
-
// To send transactions only to the Jito block-engine
|
|
41
|
-
//const sendTx = async (): Promise<string> => {
|
|
42
|
-
// return connection.sendTransaction(transactions[0], { skipPreflight: true });
|
|
43
|
-
//};
|
|
44
|
-
const sendBundle = async () => {
|
|
45
|
-
try {
|
|
46
|
-
const response = await providerClient.sendBundle(transactions);
|
|
47
|
-
if (confirm) {
|
|
48
|
-
await providerClient.confirmBundle(response);
|
|
49
|
-
}
|
|
50
|
-
return response;
|
|
51
|
-
}
|
|
52
|
-
catch (e) {
|
|
53
|
-
throw e;
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
return {
|
|
57
|
-
transactions,
|
|
58
|
-
send: async () => {
|
|
59
|
-
try {
|
|
60
|
-
return sendBundle();
|
|
61
|
-
// return sendTx();
|
|
62
|
-
}
|
|
63
|
-
catch (e) {
|
|
64
|
-
throw new Error('Failed to send transaction(s)');
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
exports.jitoSender = jitoSender;
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.createServerClient = void 0;
|
|
27
|
-
const createServerClient = async (url) => {
|
|
28
|
-
const { searcher } = await Promise.resolve().then(() => __importStar(require('jito-ts')));
|
|
29
|
-
const { Bundle } = await Promise.resolve().then(() => __importStar(require('jito-ts/dist/sdk/block-engine/types')));
|
|
30
|
-
const client = searcher.searcherClient(url);
|
|
31
|
-
return {
|
|
32
|
-
sendBundle: async (transactions) => {
|
|
33
|
-
try {
|
|
34
|
-
const response = await client.sendBundle(new Bundle(transactions, transactions.length));
|
|
35
|
-
console.log(response);
|
|
36
|
-
if (response.ok) {
|
|
37
|
-
return response.value;
|
|
38
|
-
}
|
|
39
|
-
throw new Error('Failed to send bundle');
|
|
40
|
-
}
|
|
41
|
-
catch (e) {
|
|
42
|
-
throw e;
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
// Not really used in the backend - blocking
|
|
46
|
-
confirmBundle: async (bundleId) => {
|
|
47
|
-
return new Promise((resolve, reject) => {
|
|
48
|
-
const cancelStream = client.onBundleResult((result) => {
|
|
49
|
-
if (result.bundleId === bundleId) {
|
|
50
|
-
console.log('Bundle :', result);
|
|
51
|
-
cancelStream();
|
|
52
|
-
resolve();
|
|
53
|
-
}
|
|
54
|
-
}, (error) => {
|
|
55
|
-
cancelStream();
|
|
56
|
-
reject(error);
|
|
57
|
-
});
|
|
58
|
-
// Timeout after 30 seconds
|
|
59
|
-
setTimeout(() => {
|
|
60
|
-
cancelStream();
|
|
61
|
-
reject(new Error('Bundle confirmation timed out'));
|
|
62
|
-
}, 30000);
|
|
63
|
-
});
|
|
64
|
-
},
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
exports.createServerClient = createServerClient;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { VersionedTransaction, TransactionInstruction, PublicKey } from '@solana/web3.js';
|
|
2
|
-
export declare const getRandomTipAccount: () => PublicKey;
|
|
3
|
-
export type Percentile = 25 | 50 | 75 | 95 | 99;
|
|
4
|
-
export interface LatestTips {
|
|
5
|
-
time: string;
|
|
6
|
-
landedTips25thPercentile: number;
|
|
7
|
-
landedTips50thPercentile: number;
|
|
8
|
-
landedTips75thPercentile: number;
|
|
9
|
-
landedTips95thPercentile: number;
|
|
10
|
-
landedTips99thPercentile: number;
|
|
11
|
-
emaLandedTips50thPercentile: number;
|
|
12
|
-
}
|
|
13
|
-
export declare const getTipAmountFromPriorityFee: (transaction: VersionedTransaction) => number;
|
|
14
|
-
export declare const getTipWithPercentile: (percentile: Percentile) => Promise<number>;
|
|
15
|
-
export declare const getLatestTipsFromRpc: () => Promise<LatestTips>;
|
|
16
|
-
export declare const needBundle: (transaction: VersionedTransaction) => boolean;
|
|
17
|
-
export declare const createTipInstruction: (payer: PublicKey, tipAmount: number) => TransactionInstruction;
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createTipInstruction = exports.needBundle = exports.getLatestTipsFromRpc = exports.getTipWithPercentile = exports.getTipAmountFromPriorityFee = exports.getRandomTipAccount = void 0;
|
|
7
|
-
const web3_js_1 = require("@solana/web3.js");
|
|
8
|
-
const axios_1 = __importDefault(require("axios"));
|
|
9
|
-
// NOTE: These remain fairly constant
|
|
10
|
-
const JITO_TIP_ACCOUNTS = [
|
|
11
|
-
'96gYZGLnJYVFmbjzopPSU6QiEV5fGqZNyN9nmNhvrZU5',
|
|
12
|
-
'HFqU5x63VTqvQss8hp11i4wVV8bD44PvwucfZ2bU7gRe',
|
|
13
|
-
'Cw8CFyM9FkoMi7K7Crf6HNQqf4uEMzpKw6QNghXLvLkY',
|
|
14
|
-
'ADaUMid9yfUytqMBgopwjb2DTLSokTSzL1zt6iGPaS49',
|
|
15
|
-
'DfXygSm4jCyNCybVYYK6DwvWqjKee8pbDmJGcLWNDXjh',
|
|
16
|
-
'ADuUkR4vqLUMWXxW9gh6D6L8pMSawimctcNZ5pGwDcEt',
|
|
17
|
-
'DttWaMuVvTiduZRnguLF7jNxTgiMBZ1hyAumKUiL2KRL',
|
|
18
|
-
'3AVi9Tg9Uo68tJfuvoKvqKNWKkC5wPdSSdeBnizKZ6jT'
|
|
19
|
-
];
|
|
20
|
-
const getRandomTipAccount = () => {
|
|
21
|
-
return new web3_js_1.PublicKey(JITO_TIP_ACCOUNTS[Math.floor(Math.random() * JITO_TIP_ACCOUNTS.length)]);
|
|
22
|
-
};
|
|
23
|
-
exports.getRandomTipAccount = getRandomTipAccount;
|
|
24
|
-
const V0_TX_LIMIT = 1644;
|
|
25
|
-
// 30% of the total priority fee - intended to be used in addition to the priority fee for the `/transaction`
|
|
26
|
-
// endpoint
|
|
27
|
-
const getTipAmountFromPriorityFee = (transaction) => {
|
|
28
|
-
const instructions = transaction.message.compiledInstructions;
|
|
29
|
-
const computeLimit = new DataView(instructions[0].data.buffer).getUint32(1, true);
|
|
30
|
-
const computePrice = new DataView(instructions[1].data.buffer).getBigUint64(1, true);
|
|
31
|
-
return Number((BigInt(computeLimit) * computePrice) / BigInt(3000000));
|
|
32
|
-
};
|
|
33
|
-
exports.getTipAmountFromPriorityFee = getTipAmountFromPriorityFee;
|
|
34
|
-
const getTipWithPercentile = async (percentile) => {
|
|
35
|
-
const latestTips = await (0, exports.getLatestTipsFromRpc)();
|
|
36
|
-
switch (percentile) {
|
|
37
|
-
case 25:
|
|
38
|
-
return latestTips.landedTips25thPercentile;
|
|
39
|
-
case 50:
|
|
40
|
-
return latestTips.landedTips50thPercentile;
|
|
41
|
-
case 75:
|
|
42
|
-
return latestTips.landedTips75thPercentile;
|
|
43
|
-
case 95:
|
|
44
|
-
return latestTips.landedTips95thPercentile;
|
|
45
|
-
case 99:
|
|
46
|
-
return latestTips.landedTips99thPercentile;
|
|
47
|
-
default:
|
|
48
|
-
return latestTips.landedTips75thPercentile;
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
exports.getTipWithPercentile = getTipWithPercentile;
|
|
52
|
-
const getLatestTipsFromRpc = async () => {
|
|
53
|
-
const client = axios_1.default.create({
|
|
54
|
-
headers: {
|
|
55
|
-
'Content-Type': 'application/json'
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
const response = await client.get('https://bundles.jito.wtf/api/v1/bundles/tip_floor');
|
|
59
|
-
return response.data;
|
|
60
|
-
};
|
|
61
|
-
exports.getLatestTipsFromRpc = getLatestTipsFromRpc;
|
|
62
|
-
const needBundle = (transaction) => {
|
|
63
|
-
return (transaction.message.serialize().length + transaction.signatures.length * 64) > V0_TX_LIMIT;
|
|
64
|
-
};
|
|
65
|
-
exports.needBundle = needBundle;
|
|
66
|
-
// A tip transaction is ~220 bytes (rough estimation 64 bytes for signature + 1 for length prefix)
|
|
67
|
-
// A tip instruction is ~150 bytes (exactly 152 bytes)
|
|
68
|
-
const createTipInstruction = (payer, tipAmount) => {
|
|
69
|
-
return web3_js_1.SystemProgram.transfer({
|
|
70
|
-
fromPubkey: payer,
|
|
71
|
-
toPubkey: (0, exports.getRandomTipAccount)(),
|
|
72
|
-
lamports: tipAmount
|
|
73
|
-
});
|
|
74
|
-
};
|
|
75
|
-
exports.createTipInstruction = createTipInstruction;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { VersionedTransaction } from '@solana/web3.js';
|
|
2
|
-
export declare const JITO_BASE_URL = "mainnet.block-engine.jito.wtf";
|
|
3
|
-
export declare const JITO_RPC_URL: string;
|
|
4
|
-
export declare const UUID: string;
|
|
5
|
-
export interface Bundle {
|
|
6
|
-
transactions: Uint8Array[];
|
|
7
|
-
maxTransactionCount: number;
|
|
8
|
-
}
|
|
9
|
-
export interface JitoClient {
|
|
10
|
-
sendBundle(transactions: VersionedTransaction[]): Promise<string>;
|
|
11
|
-
confirmBundle(bundleId: string): Promise<void>;
|
|
12
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UUID = exports.JITO_RPC_URL = exports.JITO_BASE_URL = void 0;
|
|
4
|
-
exports.JITO_BASE_URL = 'mainnet.block-engine.jito.wtf';
|
|
5
|
-
exports.JITO_RPC_URL = 'https://' + exports.JITO_BASE_URL + '/api/v1';
|
|
6
|
-
exports.UUID = process.env.JITO_UUID;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { PublicKey, AccountInfo, Connection } from "@solana/web3.js";
|
|
2
|
-
/**
|
|
3
|
-
* A class that caches mint account data
|
|
4
|
-
*/
|
|
5
|
-
export declare class MintCache {
|
|
6
|
-
private cache;
|
|
7
|
-
private connection;
|
|
8
|
-
constructor(connection: Connection);
|
|
9
|
-
getMintInfos(mints: PublicKey[]): Promise<Map<PublicKey, AccountInfo<Buffer>>>;
|
|
10
|
-
}
|
package/dist/utils/mintCache.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MintCache = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* A class that caches mint account data
|
|
6
|
-
*/
|
|
7
|
-
class MintCache {
|
|
8
|
-
cache = new Map();
|
|
9
|
-
connection;
|
|
10
|
-
constructor(connection) {
|
|
11
|
-
this.connection = connection;
|
|
12
|
-
}
|
|
13
|
-
async getMintInfos(mints) {
|
|
14
|
-
const missingMints = [];
|
|
15
|
-
const results = new Map();
|
|
16
|
-
mints.forEach((mint) => {
|
|
17
|
-
const key = mint.toBase58();
|
|
18
|
-
if (this.cache.has(key)) {
|
|
19
|
-
results.set(mint, this.cache.get(key));
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
missingMints.push(mint);
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
if (missingMints.length > 0) {
|
|
26
|
-
const fetchedInfos = await this.connection.getMultipleAccountsInfo(missingMints);
|
|
27
|
-
missingMints.forEach((mint, idx) => {
|
|
28
|
-
const info = fetchedInfos[idx] || null;
|
|
29
|
-
if (info) {
|
|
30
|
-
const key = mint.toBase58();
|
|
31
|
-
this.cache.set(key, info);
|
|
32
|
-
results.set(mint, info);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
return results;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
exports.MintCache = MintCache;
|