Merge pull request #20 from ricardojmendez/commitment-level
Optional commitment level
This commit is contained in:
commit
5c2f027a7a
|
@ -66,6 +66,7 @@ This mode never triggers advanced orders.
|
||||||
| `LIAB_LIMIT` | `0.9` | Percentage of your available margin to use when taking on liabilities |
|
| `LIAB_LIMIT` | `0.9` | Percentage of your available margin to use when taking on liabilities |
|
||||||
| `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 |
|
||||||
|
|
||||||
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
|
||||||
|
|
|
@ -67,6 +67,11 @@ 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
|
||||||
|
// to avoid BlockhashNotFound errors. Adding a parameter.
|
||||||
|
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:
|
||||||
//
|
//
|
||||||
|
@ -98,9 +103,11 @@ const payer = Keypair.fromSecretKey(
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
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, 'processed' as Commitment);
|
const connection = new Connection(rpcEndpoint, commitmentLevel as Commitment);
|
||||||
const client = new MangoClient(connection, mangoProgramId);
|
const client = new MangoClient(connection, mangoProgramId);
|
||||||
|
|
||||||
let mangoSubscriptionId = -1;
|
let mangoSubscriptionId = -1;
|
||||||
|
|
Loading…
Reference in New Issue