mango-v4/ts/client/scripts/liqtest
Serge Farny f54bb6f0b0
Serge/liquidator split tcs and liquidation (#914)
liquidator: split TCS triggering and liquidation job

Concurrent execution of candidate lookup and tx building/sending
- Also added an health assertion IX to protect liqor in multi liquidation scenario
- And a timeout for jupiter v6 queries (avoid blocking liquidation because of slow TCS)
2024-03-20 15:25:52 +01:00
..
README.md Serge/liquidator split tcs and liquidation (#914) 2024-03-20 15:25:52 +01:00
liqtest-check-tcs.ts Token conditional swaps (#604) 2023-07-03 14:09:11 +02:00
liqtest-close-group.ts Fix logging in liqtest scripts 2024-03-14 08:58:04 +01:00
liqtest-create-group.ts Merge remote-tracking branch 'origin/deploy' into dev 2024-03-14 11:26:33 +01:00
liqtest-create-tokens-and-markets.ts liquidator: batch serum-cancel step (#861) 2024-01-29 15:07:24 +01:00
liqtest-make-candidates.ts liquidator: batch serum-cancel step (#861) 2024-01-29 15:07:24 +01:00
liqtest-make-tcs-candidates-perf.ts liquidator: parallel tcs execution (#679) 2023-08-18 15:36:02 +02:00
liqtest-make-tcs-candidates.ts Merge branch 'main' into deploy 2024-03-10 14:26:29 +01:00
liqtest-settle-and-close-all.ts liquidator: batch serum-cancel step (#861) 2024-01-29 15:07:24 +01:00

README.md

Set environment variables

CLUSTER=devnet
CLUSTER_URL=https://mango.devnet.rpcpool.com/<token>
PAYER_KEYPAIR=~/.config/solana/mb-liqtest.json
# Adjust this to a free group
GROUP_NUM=200

Get devnet SOL

The scripts need a lot of SOL for mint, market, group and account creation. There's ample available, best to ask around.

Create tokens and markets

This is one-time setup:

yarn ts-node ts/client/scripts/liqtest/liqtest-create-tokens-and-markets.ts

It'll emit some MINTS=... and SERUM_MARKETS=.. env vars, set those, all further commands will use them.

Make a group

yarn ts-node ts/client/scripts/liqtest/liqtest-create-group.ts

Groups can be reused a lot, but sometimes closing them may be necessary

yarn ts-node ts/client/scripts/liqtest/liqtest-close-group.ts

Preferably close all mango accounts first.

Create candidate mango accounts

yarn ts-node ts/client/scripts/liqtest/liqtest-make-candidates.ts

This creates a bunch of to-be-liquidated accounts as well as a LIQOR account.

Liquidate

Run the liquidator on the group with the liqor account.

Since devnet doesn't have any jupiter, run with

JUPITER_VERSION=mock
TCS_MODE=borrow-buy
REBALANCE=false

Settle and close all open mango accounts

At any point, to reset by closing all accounts:

yarn ts-node ts/client/scripts/liqtest/liqtest-settle-and-close-all.ts