added shuffling of margin accounts
This commit is contained in:
parent
a3fabb5814
commit
60ab5d1b03
|
@ -179,6 +179,13 @@ async function balanceWallets(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function shuffleArray(array) {
|
||||||
|
for (let i = array.length - 1; i > 0; i--) {
|
||||||
|
const j = Math.floor(Math.random() * (i + 1));
|
||||||
|
[array[i], array[j]] = [array[j], array[i]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function runPartialLiquidator() {
|
async function runPartialLiquidator() {
|
||||||
const client = new MangoClient();
|
const client = new MangoClient();
|
||||||
const cluster = process.env.CLUSTER || 'mainnet-beta';
|
const cluster = process.env.CLUSTER || 'mainnet-beta';
|
||||||
|
@ -265,6 +272,7 @@ async function runPartialLiquidator() {
|
||||||
)
|
)
|
||||||
: await client.getAllMarginAccounts(connection, programId, mangoGroup);
|
: await client.getAllMarginAccounts(connection, programId, mangoGroup);
|
||||||
|
|
||||||
|
shuffleArray(marginAccounts);
|
||||||
let [prices, vaultAccs, liqorAccs] = await Promise.all([
|
let [prices, vaultAccs, liqorAccs] = await Promise.all([
|
||||||
mangoGroup.getPrices(connection),
|
mangoGroup.getPrices(connection),
|
||||||
getMultipleAccounts(connection, mangoGroup.vaults),
|
getMultipleAccounts(connection, mangoGroup.vaults),
|
||||||
|
@ -305,6 +313,7 @@ async function runPartialLiquidator() {
|
||||||
let maxBorrVal = 0;
|
let maxBorrVal = 0;
|
||||||
let minCollAcc: MarginAccount | undefined = undefined;
|
let minCollAcc: MarginAccount | undefined = undefined;
|
||||||
let minCollVal = 99999;
|
let minCollVal = 99999;
|
||||||
|
|
||||||
for (let ma of marginAccounts) {
|
for (let ma of marginAccounts) {
|
||||||
// parallelize this if possible
|
// parallelize this if possible
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue