Add CONFIRMATION_TIMEOUT env variable
This commit is contained in:
parent
c81f6afce3
commit
3594cc0d8d
|
@ -67,6 +67,7 @@ This mode never triggers advanced orders.
|
||||||
| `MIN_EQUITY` | `0` | Minimum account equity required to liquidate |
|
| `MIN_EQUITY` | `0` | Minimum account equity required to liquidate |
|
||||||
| `LIQUIDATABLE_FEED_WEBSOCKET_ADDRESS` | N/A | Websocket URL of the liquidatable-accounts-feed service, see above |
|
| `LIQUIDATABLE_FEED_WEBSOCKET_ADDRESS` | N/A | Websocket URL of the liquidatable-accounts-feed service, see above |
|
||||||
| `COMMITMENT_LEVEL` | `processed` | Commitment level for the connection |
|
| `COMMITMENT_LEVEL` | `processed` | Commitment level for the connection |
|
||||||
|
| `CONFIRMATION_TIMEOUT` | `30000` | Milliseconds to wait for transaction confirmation |
|
||||||
|
|
||||||
You can add these variables to a `.env` file in the project root to load automatically on liquidator startup. For example:
|
You can add these variables to a `.env` file in the project root to load automatically on liquidator startup. For example:
|
||||||
```bash
|
```bash
|
||||||
|
|
|
@ -22,12 +22,7 @@ import {
|
||||||
sleep,
|
sleep,
|
||||||
ZERO_I80F48,
|
ZERO_I80F48,
|
||||||
} from '@blockworks-foundation/mango-client';
|
} from '@blockworks-foundation/mango-client';
|
||||||
import {
|
import { Commitment, Connection, Keypair, PublicKey } from '@solana/web3.js';
|
||||||
Commitment,
|
|
||||||
Connection,
|
|
||||||
Keypair,
|
|
||||||
PublicKey,
|
|
||||||
} from '@solana/web3.js';
|
|
||||||
import { Market, OpenOrders } from '@project-serum/serum';
|
import { Market, OpenOrders } from '@project-serum/serum';
|
||||||
import BN from 'bn.js';
|
import BN from 'bn.js';
|
||||||
import { Orderbook } from '@project-serum/serum/lib/market';
|
import { Orderbook } from '@project-serum/serum/lib/market';
|
||||||
|
@ -67,10 +62,9 @@ const groupIds =
|
||||||
throw new Error(`Group ${groupName} not found`);
|
throw new Error(`Group ${groupName} not found`);
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
||||||
// The Triton team recommends using the commitment level `confirmed` in order
|
// The Triton team recommends using the commitment level `confirmed` in order
|
||||||
// to avoid BlockhashNotFound errors. Adding a parameter.
|
// to avoid BlockhashNotFound errors. Adding a parameter.
|
||||||
const commitmentLevel = process.env.COMMITMENT_LEVEL || 'processed'
|
const commitmentLevel = process.env.COMMITMENT_LEVEL || 'processed';
|
||||||
|
|
||||||
// Target values to keep in spot, ordered the same as in mango client's ids.json
|
// Target values to keep in spot, ordered the same as in mango client's ids.json
|
||||||
// Example:
|
// Example:
|
||||||
|
@ -108,7 +102,9 @@ console.log(`Commitment level: ${commitmentLevel}`);
|
||||||
console.log(`Payer: ${payer.publicKey.toBase58()}`);
|
console.log(`Payer: ${payer.publicKey.toBase58()}`);
|
||||||
const rpcEndpoint = process.env.ENDPOINT_URL || config.cluster_urls[cluster];
|
const rpcEndpoint = process.env.ENDPOINT_URL || config.cluster_urls[cluster];
|
||||||
const connection = new Connection(rpcEndpoint, commitmentLevel as Commitment);
|
const connection = new Connection(rpcEndpoint, commitmentLevel as Commitment);
|
||||||
const client = new MangoClient(connection, mangoProgramId);
|
const client = new MangoClient(connection, mangoProgramId, {
|
||||||
|
timeout: parseInt(process.env.CONFIRMATION_TIMEOUT || '30000'),
|
||||||
|
});
|
||||||
|
|
||||||
let mangoSubscriptionId = -1;
|
let mangoSubscriptionId = -1;
|
||||||
let dexSubscriptionId = -1;
|
let dexSubscriptionId = -1;
|
||||||
|
@ -334,9 +330,7 @@ async function maybeLiquidateAccount(
|
||||||
console.log('Liquidated account', mangoAccountKeyString);
|
console.log('Liquidated account', mangoAccountKeyString);
|
||||||
notify(`Liquidated account ${mangoAccountKeyString}`);
|
notify(`Liquidated account ${mangoAccountKeyString}`);
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
console.error(
|
console.error(`Failed to liquidate account ${mangoAccountKeyString}:`, err);
|
||||||
`Failed to liquidate account ${mangoAccountKeyString}:`, err
|
|
||||||
);
|
|
||||||
notify(`Failed to liquidate account ${mangoAccountKeyString}: ${err}`);
|
notify(`Failed to liquidate account ${mangoAccountKeyString}: ${err}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue