Fix spot order cancellation
This commit is contained in:
parent
3594cc0d8d
commit
14eee32799
|
@ -603,10 +603,11 @@ async function liquidateAccount(
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let r = 0; r < 5 && liqee.hasAnySpotOrders(); r++) {
|
for (let r = 0; r < 5 && liqee.hasAnySpotOrders(); r++) {
|
||||||
for (let i = 0; i < mangoGroup.spotMarkets.length; i++) {
|
for (let i = 0; i < groupIds.spotMarkets.length; i++) {
|
||||||
if (liqee.inMarginBasket[i]) {
|
if (liqee.inMarginBasket[i]) {
|
||||||
const spotMarket = spotMarkets[i];
|
const spotMarketConfig = groupIds.spotMarkets[i];
|
||||||
const baseRootBank = rootBanks[i];
|
const spotMarket = spotMarkets[spotMarketConfig.marketIndex];
|
||||||
|
const baseRootBank = rootBanks[spotMarketConfig.marketIndex];
|
||||||
const quoteRootBank = rootBanks[QUOTE_INDEX];
|
const quoteRootBank = rootBanks[QUOTE_INDEX];
|
||||||
|
|
||||||
if (baseRootBank && quoteRootBank) {
|
if (baseRootBank && quoteRootBank) {
|
||||||
|
@ -1057,6 +1058,7 @@ async function balanceAccount(
|
||||||
spotMarkets: Market[],
|
spotMarkets: Market[],
|
||||||
perpMarkets: PerpMarket[],
|
perpMarkets: PerpMarket[],
|
||||||
) {
|
) {
|
||||||
|
return;
|
||||||
if (Date.now() < lastRebalance + rebalanceInterval) {
|
if (Date.now() < lastRebalance + rebalanceInterval) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,11 +14,7 @@ import {
|
||||||
QUOTE_INDEX,
|
QUOTE_INDEX,
|
||||||
IDS,
|
IDS,
|
||||||
} from '@blockworks-foundation/mango-client';
|
} from '@blockworks-foundation/mango-client';
|
||||||
import {
|
import { Account, Commitment, Connection, Keypair } from '@solana/web3.js';
|
||||||
Account,
|
|
||||||
Commitment,
|
|
||||||
Connection,
|
|
||||||
} from '@solana/web3.js';
|
|
||||||
import { Market } from '@project-serum/serum';
|
import { Market } from '@project-serum/serum';
|
||||||
import { Token, TOKEN_PROGRAM_ID } from '@solana/spl-token';
|
import { Token, TOKEN_PROGRAM_ID } from '@solana/spl-token';
|
||||||
import { spawn } from 'child_process';
|
import { spawn } from 'child_process';
|
||||||
|
@ -28,10 +24,9 @@ async function testPerpLiquidationAndBankruptcy() {
|
||||||
const cluster = (process.env.CLUSTER || 'devnet') as Cluster;
|
const cluster = (process.env.CLUSTER || 'devnet') as Cluster;
|
||||||
const config = new Config(IDS);
|
const config = new Config(IDS);
|
||||||
const keypairPath = os.homedir() + '/.config/solana/devnet.json';
|
const keypairPath = os.homedir() + '/.config/solana/devnet.json';
|
||||||
const payer = new Account(
|
const payer = Keypair.fromSecretKey(
|
||||||
JSON.parse(
|
new Uint8Array(
|
||||||
process.env.KEYPAIR ||
|
JSON.parse(process.env.KEYPAIR || fs.readFileSync(keypairPath, 'utf-8')),
|
||||||
fs.readFileSync(keypairPath, 'utf-8'),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -75,7 +70,7 @@ async function testPerpLiquidationAndBankruptcy() {
|
||||||
env: {
|
env: {
|
||||||
CLUSTER: 'devnet',
|
CLUSTER: 'devnet',
|
||||||
GROUP: 'devnet.3',
|
GROUP: 'devnet.3',
|
||||||
PATH: process.env.PATH
|
PATH: process.env.PATH,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
// keeper.stdout.on('data', (data) => {
|
// keeper.stdout.on('data', (data) => {
|
||||||
|
@ -97,7 +92,7 @@ async function testPerpLiquidationAndBankruptcy() {
|
||||||
env: {
|
env: {
|
||||||
CLUSTER: 'devnet',
|
CLUSTER: 'devnet',
|
||||||
GROUP: 'devnet.3',
|
GROUP: 'devnet.3',
|
||||||
PATH: process.env.PATH
|
PATH: process.env.PATH,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -139,21 +134,21 @@ async function testPerpLiquidationAndBankruptcy() {
|
||||||
payer.publicKey,
|
payer.publicKey,
|
||||||
);
|
);
|
||||||
|
|
||||||
const liqorPk = await client.initMangoAccount(mangoGroup, payer);
|
const liqorPk = (await client.initMangoAccount(mangoGroup, payer))!;
|
||||||
const liqorAccount = await client.getMangoAccount(
|
const liqorAccount = await client.getMangoAccount(
|
||||||
liqorPk,
|
liqorPk,
|
||||||
mangoGroup.dexProgramId,
|
mangoGroup.dexProgramId,
|
||||||
);
|
);
|
||||||
console.log('Created Liqor:', liqorPk.toBase58());
|
console.log('Created Liqor:', liqorPk.toBase58());
|
||||||
|
|
||||||
const liqeePk = await client.initMangoAccount(mangoGroup, payer);
|
const liqeePk = (await client.initMangoAccount(mangoGroup, payer))!;
|
||||||
const liqeeAccount = await client.getMangoAccount(
|
const liqeeAccount = await client.getMangoAccount(
|
||||||
liqeePk,
|
liqeePk,
|
||||||
mangoGroup.dexProgramId,
|
mangoGroup.dexProgramId,
|
||||||
);
|
);
|
||||||
console.log('Created Liqee:', liqeePk.toBase58());
|
console.log('Created Liqee:', liqeePk.toBase58());
|
||||||
|
|
||||||
const makerPk = await client.initMangoAccount(mangoGroup, payer);
|
const makerPk = (await client.initMangoAccount(mangoGroup, payer))!;
|
||||||
const makerAccount = await client.getMangoAccount(
|
const makerAccount = await client.getMangoAccount(
|
||||||
makerPk,
|
makerPk,
|
||||||
mangoGroup.dexProgramId,
|
mangoGroup.dexProgramId,
|
||||||
|
@ -301,7 +296,8 @@ async function testPerpLiquidationAndBankruptcy() {
|
||||||
GROUP: 'devnet.3',
|
GROUP: 'devnet.3',
|
||||||
KEYPAIR: keypairPath,
|
KEYPAIR: keypairPath,
|
||||||
LIQOR_PK: liqorAccount.publicKey.toBase58(),
|
LIQOR_PK: liqorAccount.publicKey.toBase58(),
|
||||||
PATH: process.env.PATH
|
ENDPOINT_URL: config.cluster_urls[cluster],
|
||||||
|
PATH: process.env.PATH,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue