blockhash
This commit is contained in:
parent
788850c311
commit
40742594b2
|
@ -30,7 +30,8 @@
|
|||
"@solana/spl-token": "^0.1.6",
|
||||
"@solana/web3.js": "^1.43.5",
|
||||
"bn.js": "^5.1.0",
|
||||
"dotenv": "^10.0.0"
|
||||
"dotenv": "^10.0.0",
|
||||
"tslog": "^3.3.4"
|
||||
},
|
||||
"resolutions": {
|
||||
"bn.js": "5.1.3",
|
||||
|
|
|
@ -10,7 +10,7 @@ import {
|
|||
Connection,
|
||||
PublicKey,
|
||||
Transaction,
|
||||
ComputeBudgetProgram,
|
||||
ComputeBudgetProgram, BlockhashWithExpiryBlockHeight,
|
||||
} from '@solana/web3.js';
|
||||
import { getMultipleAccounts, sleep } from '../utils/utils';
|
||||
import BN from 'bn.js';
|
||||
|
@ -20,6 +20,7 @@ import {
|
|||
Market,
|
||||
} from '@project-serum/serum';
|
||||
import { Token, TOKEN_PROGRAM_ID } from '@solana/spl-token';
|
||||
import { Logger } from 'tslog';
|
||||
|
||||
const {
|
||||
ENDPOINT_URL,
|
||||
|
@ -59,10 +60,26 @@ const payer = Keypair.fromSecretKey(
|
|||
),
|
||||
);
|
||||
|
||||
console.log('openbook-cranker', payer.publicKey.toString());
|
||||
const log: Logger = new Logger({name: "openbook-cranker", displayFunctionName: false, displayFilePath: "hidden", minLevel: "info"});
|
||||
|
||||
log.info(payer.publicKey.toString());
|
||||
|
||||
const connection = new Connection(ENDPOINT_URL!, 'processed' as Commitment);
|
||||
|
||||
let recentBlockhash: BlockhashWithExpiryBlockHeight;
|
||||
connection.getLatestBlockhash(
|
||||
"finalized"
|
||||
).then((blockhash) => {recentBlockhash = blockhash;});
|
||||
|
||||
setInterval(
|
||||
async () =>
|
||||
(recentBlockhash = await connection.getLatestBlockhash(
|
||||
"finalized"
|
||||
)),
|
||||
20 * 1000,
|
||||
);
|
||||
|
||||
|
||||
async function run() {
|
||||
const spotMarkets = await Promise.all(
|
||||
markets[cluster].map((m) => {
|
||||
|
@ -146,7 +163,9 @@ async function run() {
|
|||
limit: consumeEventsLimit,
|
||||
programId: serumProgramId,
|
||||
});
|
||||
const transaction = new Transaction();
|
||||
const transaction = new Transaction({
|
||||
...recentBlockhash,
|
||||
});
|
||||
transaction.add(
|
||||
ComputeBudgetProgram.setComputeUnitLimit({
|
||||
units: CuLimit,
|
||||
|
@ -162,21 +181,17 @@ async function run() {
|
|||
}
|
||||
transaction.add(instr);
|
||||
|
||||
console.log(
|
||||
'market',
|
||||
i,
|
||||
'sending consume events for',
|
||||
events.length,
|
||||
'events',
|
||||
);
|
||||
console.log(await connection.sendTransaction(transaction, [payer], {
|
||||
log.info(`market ${i} sending consume events for ${events.length} events`);
|
||||
|
||||
transaction.sign(payer);
|
||||
connection.sendRawTransaction(transaction.serialize(), {
|
||||
skipPreflight: true,
|
||||
maxRetries: 2,
|
||||
}));
|
||||
}).then(x => log.info(`Cranked market ${i}: ${x}`));
|
||||
}
|
||||
await sleep(interval);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
log.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
25
yarn.lock
25
yarn.lock
|
@ -353,6 +353,11 @@ bs58@^4.0.0, bs58@^4.0.1:
|
|||
dependencies:
|
||||
base-x "^3.0.2"
|
||||
|
||||
buffer-from@^1.0.0:
|
||||
version "1.1.2"
|
||||
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5"
|
||||
integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==
|
||||
|
||||
buffer-layout@^1.2.0:
|
||||
version "1.2.2"
|
||||
resolved "https://registry.yarnpkg.com/buffer-layout/-/buffer-layout-1.2.2.tgz#b9814e7c7235783085f9ca4966a0cfff112259d5"
|
||||
|
@ -773,6 +778,19 @@ snake-case@^3.0.4:
|
|||
dot-case "^3.0.4"
|
||||
tslib "^2.0.3"
|
||||
|
||||
source-map-support@^0.5.21:
|
||||
version "0.5.21"
|
||||
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f"
|
||||
integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==
|
||||
dependencies:
|
||||
buffer-from "^1.0.0"
|
||||
source-map "^0.6.0"
|
||||
|
||||
source-map@^0.6.0:
|
||||
version "0.6.1"
|
||||
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
|
||||
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==
|
||||
|
||||
superstruct@^0.14.2:
|
||||
version "0.14.2"
|
||||
resolved "https://registry.yarnpkg.com/superstruct/-/superstruct-0.14.2.tgz#0dbcdf3d83676588828f1cf5ed35cda02f59025b"
|
||||
|
@ -827,6 +845,13 @@ tslib@^2.0.3:
|
|||
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.5.0.tgz#42bfed86f5787aeb41d031866c8f402429e0fddf"
|
||||
integrity sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==
|
||||
|
||||
tslog@^3.3.4:
|
||||
version "3.3.4"
|
||||
resolved "https://registry.yarnpkg.com/tslog/-/tslog-3.3.4.tgz#083197a908c97b3b714a0576b9dac293f223f368"
|
||||
integrity sha512-N0HHuHE0e/o75ALfkioFObknHR5dVchUad4F0XyFf3gXJYB++DewEzwGI/uIOM216E5a43ovnRNEeQIq9qgm4Q==
|
||||
dependencies:
|
||||
source-map-support "^0.5.21"
|
||||
|
||||
tweetnacl@^1.0.0:
|
||||
version "1.0.3"
|
||||
resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-1.0.3.tgz#ac0af71680458d8a6378d0d0d050ab1407d35596"
|
||||
|
|
Loading…
Reference in New Issue