Git Product home page Git Product logo

keeper-bots-v2's Introduction

Keeper Bots for Drift Protocol v2

Docs Discord Chat License

Setting up

This repo has two main branches:

  • master: bleeding edge, may be unstable, currently running on the devnet cluster
  • mainnet-beta: stable, currently running on the mainnet-beta cluster

Setup Environment

yaml Config file:

A .yaml file can be used to configure the bot setup now. See example.config.yaml for a commented example.

Then you can run the bot by loading the config file:

yarn run dev --config-file=example.config.yaml

Here is a table defining the various fields and their usage/defaults:

Field Type Description Default
global object global configs to apply to all running bots -
global.endpoint string RPC endpoint to use -
global.wsEndpoint string (optional) Websocket endpoint to use derived from global.endpoint
global.keeperPrivateKey string (optional) The private key to use to pay/sign transactions KEEPER_PRIVATE_KEY environment variable
global.initUser bool Set true to init a fresh userAccount false
global.websocket bool Set true to run the selected bots in websocket mode if compatible false
global.runOnce bool Set true to run only one iteration of the selected bots false
global.debug bool Set true to enable debug logging false
global.subaccounts list (optional) Which subaccount IDs to load 0
enabledBots list list of bots to enable, matching key must be present under botConfigs -
botConfigs object configs for associated bots -
botConfigs.<bot_type> object config for a specific <bot_type> -

Install dependencies

Run from repo root to install npm dependencies:

yarn

Initialize User

A ClearingHouseUser must be created before interacting with the ClearingHouse program.

yarn run dev --init-user

Alternatively, you can put the private key into a browser wallet and use the UI at https://app.drift.trade to initialize the user.

Collateral

Some bots (i.e. trading, liquidator and JIT makers) require collateral in order to keep positions open, a helper function is included to help with depositing collateral. A user must be initialized first before collateral may be deposited.

# deposit 10,000 USDC
yarn run dev --force-deposit 10000

Alternatively, you can put the private key into a browser wallet and use the UI at https://app.drift.trade to deposit collateral.

Free collateral is what is determines the size of borrows and perp positions that an account can have. Free collateral = total collateral - initial margin requirement. Total collateral is the value of the spot assets in your account + unrealized perp pnl. The initial margin requirement is the total weighted value of the perp positions and spot liabilities in your account. The initial margin requirement weights are determined here. In simple terms, free collateral is essentially the amount of total collateral that is not being used up by borrows and existing perp positions and open orders.

Run Bots

After creating your config.yaml file as above, run with:

yarn run dev --config-file=config.yaml

By default, some Prometheus metrics are exposed on localhost:9464/metrics.

Notes on some bots

Filler Bot

Include filler and/or spotFiller under .enabledBots in config.yaml. For a lightweight version of a filler bot for perp markets, include fillerLite rather than filler in config.yaml. The lighter version of the filler can be run on public RPCs for testing, but is not as stable.

Read the docs: https://docs.drift.trade/keepers-and-decentralised-orderbook

Fills (matches) crossing orders on the exchange for a small cut of the taker fees. Fillers maintain a copy of the DLOB to look for orders that cross. Fillers will also attempt to execute triggerable orders.

Common errors

When running the filler bots, you might see the following error codes in the transaction logs on a failed in pre-flight simulation:

For perps

Error Description
OrderDoesNotExist Outcompeted: Order was already filled by someone else
OrderNotTriggerable Outcompeted: order was already triggered by someone else
RevertFill Outcompeted: order was already filled by someone else

Other messages

Message Description
filler last active slot != current slot You might see this when outcompeted on a fill. The filler last active slot was the last slot that the filler had a successful fill in, so it may diverge current slot if the filler has not placed a successful order.

Liquidator Bot

The liquidator bot monitors spot and perp markets for bankrupt accounts, and attempts to liquidate positions according to the protocol's liquidation process.

Notes on derisking (useJupiter)

This liquidator implementation includes an option to useJupiter to derisk (sell) spot assets into USDC. The derisk loop will use the more favorable of Drift spot or Jupiter before executing. Set useJupiter under the liquidator config to enable this behavior (see below).

You may also set disableAutoDerisking to true, to disable the derisking loop. You may want to do this as part of a larger strategy where you are ok with taking on risk at a favorable to market price (liquidation fee applied).

Notes on configuring subaccount

By default the liquidator will attempt to liqudate (inherit the risk of) endangered positions in all markets. Set botConfigs.liquidator.perpMarketIndicies and/or botConfigs.liquidator.spotMarketIndicies in the config file to restrict which markets you want to liquidate. The account specified in global.subaccounts will be used as the active account.

perpSubaccountConfig and spotSubaccountConfig can be used instead of perpMarketIndicies and spotMarketIndicies to specify a mapping from subaccount to list of market indicies. The value of these 2 fields are json strings:

An example config.yaml

botConfigs:
  ...
  liquidator:
    ...
    useJupiter: true
    perpSubAccountConfig:
      0:
        - 0
        - 1
        - 2
      1:
        - 3
        - 4
        - 5
        - 6
        - 7
        - 8
        - 9
        - 10
        - 11
        - 12
    spotSubAccountConfig:
      0:
        - 0
        - 1
        - 2

Means the liquidator will liquidate perp markets 0-2 using subaccount 0, perp markets 3-12 using subaccount 1, and spot markets 0-2 using subaccount 0. It will also use jupiter to derisk spot assets into USDC. Make sure that for all subaccounts specified in the botConfigs, that they are also listed in the global configs. So for the above example config:

global:
  ...
  subaccounts: [0, 1]

Common errors

When running the liquidator, you might see the following error codes in the transaction logs on a failed in pre-flight simulation:

Error Description
SufficientCollateral The account you're trying to liquidate has sufficient collateral and can't be liquidated
InvalidSpotPosition Outcompeted: the liqudated account's spot position was already liquidated.
InvalidPerpPosition Outcompeted: the liqudated account's perp position was already liquidated.

Jit Maker

The jit maker bot supplies liquidity to the protocol by participating in jit acutions for perp markets. Before running a jit maker bot, be sure to read the documentation below:

Read the docs on jit auctions: https://docs.drift.trade/just-in-time-jit-auctions

Read the docs on the jit proxy client: https://github.com/drift-labs/jit-proxy/blob/master/ts/sdk/Readme.md

Be aware that running a jit maker means taking on positional risk, so be sure to manage your risk properly!

Implementation

This sample jit maker uses the jit proxy client, and updates JitParams for the markets specified in the config. The bot will update its bid and ask to match the current top level market in the DLOB, and specifies its maximum position size to keep leverage at 1. The jit maker will attempt to fill taker orders that cross its market that's specified in the JitParams. If the current auction price does not cross the bid/ask the transaction will fail during pre-flight simulation, because for the purposes of the jit proxy program, the market is considered the market maker's worst acceptable price of execution. For order execution, the jit maker currently uses the JitterSniper -- read more on the jitters and different options in the jit proxy client documentation (link above).

This bot is meant to serve as a starting off point for participating in jit auctions. To increase strategy complexity, consider different strategies for updating your markets. To change the amount of leverage, change the constant TARGET_LEVERAGE_PER_ACCOUNT before running.

Common errors

Error Description
BidNotCrossed/AskNotCrossed The jit proxy program simulation fails if the auction price is not lower than the jit param bid or higher than jit param ask. Bot's market, oracle price, or auction price changed during execution. Can be a latency issue, either slow order submission or slow websocket/polling connection.
OrderNotFound Outcompeted: the taker order was already filled.

Running the bot and notes on configs

jitMaker.config.yaml is supplied as an example, and a jit maker can be run with yarn run dev --config-file=jitMaker.config.yaml. Jit maker bots require colleteral, so make sure to specify depositing collateral in the config file using forceDeposit, or deposit collateral using the app or SDK before running the bot.

To avoid errors being thrown during initialization, remember to enumerate in the global configs the subaccounts being used in the bot configs. An example below in a config.yaml file:

global:
  ...
  subaccounts: [0, 1] <----- bot configs specify subaccounts of [0, 1, 1], so make sure we load in [0, 1] in global configs to properly initialize driftClient!


botConfigs:
  jitMaker:
    botId: "jitMaker"
    dryRun: false
    # below, ordering is important: match the subaccountIds to perpMarketindices.
    # e.g. to MM perp markets 0, 1 both on subaccount 0, then subaccounts=[0,0], perpMarketIndicies=[0,1]
    #      to MM perp market 0 on subaccount 0 and perp market 1 on subaccount 1, then subaccounts=[0, 1], perpMarketIndicies=[0, 1]
    # also, make sure all subaccounts are loaded in the global config subaccounts above to avoid errors
    subaccounts: [0, 1, 1] <--------------- the subaccount set should be specified above too!
    perpMarketIndicies: [0, 1, 2]

keeper-bots-v2's People

Contributors

0xbigz avatar chenwainuo avatar crispheaney avatar github-actions[bot] avatar lowkeynicc avatar nouralharithi avatar partiallysorted avatar ricardojmendez avatar ryumasolooo avatar soundsonacid avatar waggme avatar wphan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

keeper-bots-v2's Issues

Error: 410 Gone: {"jsonrpc":"2.0","error":{"code": 410, "message":"The RPC call or parameters have been disabled."}, "id": "b8c96bb9-ea15-4c14-8e71-a80e1cfe3225" }

Running any of the yarn script fails with a grpc 410 error. For example
yarn run dev --init-user --config-file config.yaml

produces:

yarn run v1.22.21
$ NODE_OPTIONS=--max-old-space-size=8192 ts-node src/index.ts --init-user --config-file config.yaml
[2024-02-19T12:39:31.599Z] info: Loading config from config.yaml
[2024-02-19T12:39:31.609Z] info: Bot config:
{
  "global": {
    "driftEnv": "mainnet-beta",
    "initUser": false,
    "testLiveness": false,
    "cancelOpenOrders": false,
    "closeOpenPositions": false,
    "forceDeposit": null,
    "websocket": true,
    "eventSubscriber": false,
    "runOnce": false,
    "debug": false,
    "subaccounts": [
      0
    ],
    "eventSubscriberPollingInterval": 5000,
    "bulkAccountLoaderPollingInterval": 5000,
    "endpoint": "https://api.mainnet-beta.solana.com",
    "priorityFeeMethod": "solana",
    "maxPriorityFeeMicroLamports": 10000,
    "keeperPrivateKey": "*******************************************************",
    "useJito": false,
    "jitoBlockEngineUrl": "frankfurt.mainnet.block-engine.jito.wtf",
    "jitoAuthPrivateKey": "/path/to/jito/bundle/signing/key/auth.json",
    "txRetryTimeoutMs": 30000
  },
  "enabledBots": [
    "filler",
    "trigger",
    "floatingMaker"
  ],
  "botConfigs": {
    "filler": {
      "botId": "filler",
      "dryRun": true,
      "fillerPollingInterval": 6000,
      "metricsPort": 9464,
      "revertOnFailure": true,
      "simulateTxForCUEstimate": true
    },
    "spotFiller": {
      "botId": "spot-filler",
      "dryRun": false,
      "fillerPollingInterval": 6000,
      "metricsPort": 9464,
      "revertOnFailure": true,
      "simulateTxForCUEstimate": true
    },
    "liquidator": {
      "botId": "liquidator",
      "dryRun": false,
      "metricsPort": 9465,
      "disableAutoDerisking": false,
      "useJupiter": true,
      "perpSubAccountConfig": {
        "0": [
          0,
          1
        ]
      },
      "spotSubAccountConfig": {},
      "maxSlippagePct": 50,
      "maxSlippageBps": 50,
      "deriskAuctionDurationSlots": 100,
      "deriskAlgo": "market",
      "minDepositToLiq": {
        "1": 10,
        "2": 1000
      },
      "excludedAccounts": [
        "9CJLgd5f9nmTp7KRV37RFcQrfEmJn6TU87N7VQAe2Pcq",
        "Edh39zr8GnQFNYwyvxhPngTJHrr29H3vVup8e8ZD4Hwu"
      ],
      "maxPositionTakeoverPctOfCollateral": 0.5,
      "notifyOnLiquidation": true
    },
    "trigger": {
      "botId": "trigger",
      "dryRun": true,
      "metricsPort": 9465
    },
    "markTwapCrank": {
      "botId": "mark-twap-cranker",
      "dryRun": false,
      "metricsPort": 9465,
      "crankIntervalToMarketIndicies": {
        "15000": [
          0,
          1,
          2
        ],
        "60000": [
          3,
          4,
          5,
          6,
          7,
          8,
          9,
          10,
          11,
          12,
          13,
          14,
          15,
          16
        ]
      }
    },
    "floatingMaker": {
      "botId": "floating-maker",
      "dryRun": true,
      "metricsPort": 9467
    }
  }
}
[2024-02-19T12:39:31.610Z] info: RPC endpoint: https://api.mainnet-beta.solana.com
[2024-02-19T12:39:31.610Z] info: WS endpoint:  undefined
[2024-02-19T12:39:31.610Z] info: Helius endpoint:  undefined
[2024-02-19T12:39:31.610Z] info: DriftEnv:     mainnet-beta
[2024-02-19T12:39:31.610Z] info: Commit:       
[2024-02-19T12:39:31.610Z] info: Loading wallet keypair
[2024-02-19T12:39:31.611Z] info: loading private key from /.../keeper-bots-v2/id.json
[2024-02-19T12:39:31.611Z] info: Trying to load private key as numbers array
[2024-02-19T12:39:31.823Z] info: DriftClient ProgramId: dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH
[2024-02-19T12:39:31.823Z] info: Wallet pubkey: ...
[2024-02-19T12:39:31.823Z] info:  . SOL balance: 0.09787275
[2024-02-19T12:39:31.873Z] info:  . USDC balance: 112.712606
[2024-02-19T12:39:31.873Z] info: priorityFeeMethod: solana, maxFeeMicroLamports: 10000
[2024-02-19T12:39:31.878Z] info: filler: revertOnFailure: true, simulateTxForCUEstimate: true
[2024-02-19T12:39:31.878Z] info: filler: jito enabled: false
[2024-02-19T12:39:31.884Z] info: prometheus scrape endpoint started: http://localhost:9464/metrics
[2024-02-19T12:39:31.884Z] info: prometheus scrape endpoint started: http://localhost:9465/metrics
[2024-02-19T12:39:31.884Z] info: prometheus scrape endpoint started: http://localhost:9467/metrics
/home/.../keeper-bots-v2/node_modules/@solana/web3.js/src/connection.ts:1648
        callback(new Error(`${res.status} ${res.statusText}: ${text}`));
                 ^
Error: 410 Gone:  {"jsonrpc":"2.0","error":{"code": 410, "message":"The RPC call or parameters have been disabled."}, "id": "b8c96bb9-ea15-4c14-8e71-a80e1cfe3225" } 

    at ClientBrowser.callServer (/home/.../keeper-bots-v2/node_modules/@solana/web3.js/src/connection.ts:1648:18)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Could you provide launch.json configs for VSCode and I could try debugging further?

isMakerBreachedMaintenanceMarginLog regex is incorrect

wanted to flag an issue with isMakerBreachedMaintenanceMarginLog. below is the format for a failed fill because the maker breached the fill requirements.

'Program ComputeBudget111111111111111111111111111111 invoke [1]',
    'Program ComputeBudget111111111111111111111111111111 success',
    'Program <DRIFT_PID> invoke [1]',
    'Program log: Instruction: FillPerpOrder',
    'Program log: 
    'Program log: ,
    'Program log: maker (<MAKER_USER_ACCOUNT>) breached fill requirements (margin requirement <MR>) (total_collateral <TC>)',
    'Program log: Err filling order id <O_N> for user <TAKER_USER_ACCOUNT> for market index <M_N>',
    'Program log: AnchorError occurred. Error Code: InsufficientCollateral. Error Number: 6003. Error Message: Insufficient collateral.',
    'Program <DRIFT_PID> consumed 284757 of 1400000 compute units',
    'Program <DRIFT_PID> failed: custom program error: 0x1773'

Fillerlite error causing bot to stop

After pulling all the updates, I am still getting an error on fillerlite bot causing the bot to stop

``assoc node (ixIdx: ${ixIdx}): ${filledNode.node.userAccount!.toString()}, ${
^
TypeError: Cannot read properties of undefined (reading 'node')`

add max swap size for liquidator

to prevent unnecessary price impact in illiquid spot markets (i.e. wbtc, weth), add a field to the config to limit the size of individual swaps.

additionally:

  • enable twap for specific markets
  • be 'price impact' or 'slippage from oracle' aware. Currently maxSlippageBps in the config is jupiter slippage

Update cached accounts for wrong account owner errors

Investigate root cause and handle this

[fillerLite]: ❌ error simulating tx:
Program ComputeBudget111111111111111111111111111111 invoke [1]
Program ComputeBudget111111111111111111111111111111 success
Program dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH invoke [1]
Program log: Instruction: FillPerpOrder
Program log: AnchorError caused by account: user. Error Code: AccountOwnedByWrongProgram. Error Number: 3007. Error Message: The given account is owned by a different program than expected.
Program log: Left:
Program log: 11111111111111111111111111111111
Program log: Right:
Program log: dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH
Program dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH consumed 12486 of 1400000 compute units
Program dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH failed: custom program error: 0xbbf
Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 1: custom program error: 0xbbf
    at Connection.sendEncodedTransaction (/app/node_modules/@solana/web3.js/lib/index.cjs.js:9560:13)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Connection.sendRawTransaction (/app/node_modules/@solana/web3.js/lib/index.cjs.js:9526:20)
    at async RetryTxSender.sendRawTransaction (/app/node_modules/@drift-labs/sdk/lib/tx/retryTxSender.js:29:20)

Please update main net branch dependencies

[2024-02-02T15:33:02.976Z] error: User for 85giG7tjhA1LECHPRBEZrHvkGFy39z3YmD9En8AtHmRF does not exist (subAccountId: 0)
[2024-02-02T15:33:02.976Z] info: Creating User for 85giG7tjhA1LECHPRBEZrHvkGFy39z3YmD9En8AtHmRF
SendTransactionError: failed to send transaction: Transaction simulation failed: This transaction has already been processed
at Connection.sendEncodedTransaction (/Users/adamzhong/keeper-bots-v2/node_modules/@solana/web3.js/src/connection.ts:5922:13)
at runMicrotasks ()
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Connection.sendRawTransaction (/Users/adamzhong/keeper-bots-v2/node_modules/@solana/web3.js/src/connection.ts:5881:20) {
logs: []
}
/Users/adamzhong/keeper-bots-v2/node_modules/@drift-labs/sdk/lib/tx/baseTxSender.js:181
throw new Error(Transaction was not confirmed in 30 seconds. It is unknown if it succeeded or failed. Check signature ${signature} using the Solana Explorer or CLI tools.);
^
Error: Transaction was not confirmed in 30 seconds. It is unknown if it succeeded or failed. Check signature ccqYCNpbd4CiYgrQhU5HendCgsugBzWhgJJbd6tKoWdf4jGHsyi1RKHN1JuHe64GEqnm9Sfcp4ihNLYNYguvwdX using the Solana Explorer or CLI tools.
at RetryTxSender.confirmTransactionPolling (/Users/adamzhong/keeper-bots-v2/node_modules/@drift-labs/sdk/lib/tx/baseTxSender.js:181:15)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RetryTxSender.confirmTransaction (/Users/adamzhong/keeper-bots-v2/node_modules/@drift-labs/sdk/lib/tx/baseTxSender.js:189:20)
at async RetryTxSender.sendRawTransaction (/Users/adamzhong/keeper-bots-v2/node_modules/@drift-labs/sdk/lib/tx/retryTxSender.js:64:28)
at async DriftClient.initializeUserAccount (/Users/adamzhong/keeper-bots-v2/node_modules/@drift-labs/sdk/lib/driftClient.js:439:27)
at async checkUserExists (/Users/adamzhong/keeper-bots-v2/src/index.ts:944:20)
at async runBot (/Users/adamzhong/keeper-bots-v2/src/index.ts:781:26)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Not enough SOL to fill

During the process of running the keeper bot, it always reports the following error, But I have SOL in my address.

[2024-05-18T01:17:00.583Z] info: Confirming tx sigs took: 0 ms
[2024-05-18T01:17:05.661Z] info: Not enough SOL to fill, skipping fill
[2024-05-18T01:17:05.661Z] info: Confirming tx sigs: 0
[2024-05-18T01:17:05.661Z] info: Confirming tx sigs took: 0 ms
[2024-05-18T01:17:10.972Z] info: Confirming tx sigs: 0
[2024-05-18T01:17:10.972Z] info: Confirming tx sigs took: 0 ms
[2024-05-18T01:17:11.780Z] info: Not enough SOL to fill, skipping fill
[2024-05-18T01:17:15.972Z] info: Confirming tx sigs: 0
[2024-05-18T01:17:15.972Z] info: Confirming tx sigs took: 0 ms
[2024-05-18T01:17:17.870Z] info: Not enough SOL to fill, skipping fill
[2024-05-18T01:17:22.792Z] info: Confirming tx sigs: 0
[2024-05-18T01:17:22.792Z] info: Confirming tx sigs took: 0 ms
[2024-05-18T01:17:23.894Z] info: Not enough SOL to fill, skipping fill
[2024-05-18T01:17:27.897Z] info: Confirming tx sigs: 0
[2024-05-18T01:17:27.897Z] info: Confirming tx sigs took: 0 ms
[2024-05-18T01:17:30.000Z] info: Not enough SOL to fill, skipping fill
[2024-05-18T01:17:32.998Z] info: Confirming tx sigs: 0
[2024-05-18T01:17:32.998Z] info: Confirming tx sigs took: 0 ms

Filler Bot unable to submit transactions

During the process of running the keeper bot (command: yarn start --filler --trigger --config-file example.config.yaml), it always reports the following error and transactions have not been successfully submitted.
————————————————————————————————————————————————————————
[2024-02-21T02:21:19.474Z] info: slotSubscriber slot: 249460315, userMap slot: 249460344
[2024-02-21T02:21:19.475Z] info: including taker AMDsLg6HPmkQRUBwhYMCpVoNc17tJEJmjgNpa3srWc4d-35534 (fillTxId: 678)
[2024-02-21T02:21:19.475Z] info: Filling perp node 1 (fillTxId: 678)
taker on market 11: AMDsLg6HPmkQRUBwhYMCpVoNc17tJEJmjgNpa3srWc4d-35536 short 0/1067 @ 0 (orderType: oracle)
makers:
vAMM
[2024-02-21T02:21:19.475Z] info: slotSubscriber slot: 249460315, userMap slot: 249460344
[2024-02-21T02:21:19.476Z] info: including taker AMDsLg6HPmkQRUBwhYMCpVoNc17tJEJmjgNpa3srWc4d-35536 (fillTxId: 678)
[2024-02-21T02:21:19.476Z] info: sending tx, 26 unique accounts, total ix: 2, calcd tx size: 1024, took 2ms (fillTxId: 678)
Error loading priority fee solana: Unexpected token 'j', "json metho"... is not valid JSON
SyntaxError: Unexpected token 'j', "json metho"... is not valid JSON
at JSON.parse ()
at ClientBrowser._parseResponse (/Users/yong/Desktop/project/keeper-bots-v2/node_modules/jayson/lib/client/browser/index.js:131:21)
at /Users/yong/Desktop/project/keeper-bots-v2/node_modules/jayson/lib/client/browser/index.js:103:10
at ClientBrowser.callServer (/Users/yong/Desktop/project/keeper-bots-v2/node_modules/@solana/web3.js/lib/index.cjs.js:6472:9)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Simulated tx took: 262ms
[2024-02-21T02:21:20.299Z] info: tryBulkFillPerpNodes estimated CUs: 29922 (fillTxId: 678)
[2024-02-21T02:21:20.299Z] error: simError: {"InstructionError":[4,{"Custom":6239}]} (fillTxId: 678)
[2024-02-21T02:21:20.299Z] info: Processing tx log for assoc node 0
taker on market 11: AMDsLg6HPmkQRUBwhYMCpVoNc17tJEJmjgNpa3srWc4d-35534 short 0/1067 @ 0 (orderType: oracle)
makers:
vAMM
[2024-02-21T02:21:20.299Z] error: assoc node (ixIdx: 0): AMDsLg6HPmkQRUBwhYMCpVoNc17tJEJmjgNpa3srWc4d, 35534; does not exist (filled by someone else); Program log: Order does not exist 35534
[2024-02-21T02:21:20.299Z] info: Processing tx log for assoc node 1
taker on market 11: AMDsLg6HPmkQRUBwhYMCpVoNc17tJEJmjgNpa3srWc4d-35536 short 0/1067 @ 0 (orderType: oracle)
makers:
vAMM
[2024-02-21T02:21:20.299Z] error: assoc node (ixIdx: 1): AMDsLg6HPmkQRUBwhYMCpVoNc17tJEJmjgNpa3srWc4d, 35536; does not exist (filled by someone else); Program log: Order does not exist 35536
——————————————————————————————————————————————————

I increased maxPriorityFeeMicroLamports from 10000 to 20000 or even higher, but still couldn't submit transactions. Is it due to my computing speed, network issues, or low fee configuration?

filler last active slot != current slot

Hi folks,

I've been getting this error from the filler bot: filler last active slot (XXX) != current slot (YYY), where XXX can be 26k slots behind Y. Not entirely clear what it means nor how to address it. It seems to happen only when filling orders, and triggers work fine.

I suspect this might not be a program but RPC-related, however the fact that some instructions do work leaves me wondering.

Any pointers?

floatingMaker order cancelation behavior

On the floatingMaker bot, it looks like the open orders for a given market are canceled only if one has been fully filled.

if (
(openOrders.length > 0 && openOrders.length != 2) ||
marketIndex === 0
) {

This makes sense if the idea is to avoid placing new orders if the market hasn't fully hit one of our ranges. However, it always cancels the orders for SOL-PERP.

What's the rationale?

Rust SDK

Do you also have a Rust SDK for spot swap trading?

USDC token account does not exist for new user.

Calling initUser results in the following error:

SolanaJSONRPCError: failed to get token account balance: Invalid param: could not find account at Connection.getTokenAccountBalance (drift-keeper-bots-v2/node_modules/@solana/web3.js/src/connection.ts:2704:13) at processTicksAndRejections (node:internal/process/task_queues:95:5) at async getTokenAccountBalance (drift-keeper-bots-v2/src/utils.ts:4:18) at async runBot (drift-keeper-bots-v2/src/index.ts:279:22) at async recursiveTryCatch (drift-keeper-bots-v2/src/index.ts:563:3) { code: -32602, data: undefined }

How to make a simple swap on devnet?

On devnet

I need to make a simple swap operation and as one time operation, as a test.

I need it in the form of 3 types: SOL -> token, token -> SOL, token -> token

Initially I have 10 SOL on my dev account. I've tried to eliminate all the stuff from that I may not need from jupiterSpotSwap(....) and then call this function in the end of init(...). I specified subAccountIndex = 0 and marketIndex = 0 too.

It's not worked. But there'll be some or other error at runtime still, for instance:

error: Error trying to long spot position for market 0 on jupiter, subaccount start 0

How will I make a simple swap then? Is there any simple example?

And what preliminary work have I make for this: open a position, set up something.... ? And how?

100% CPU usage running Liquidator Bot

The April 15th release of the Liquidator Bot seems to have an 100% CPU issue when its activated. Tried a few different computers and AWS servers and they all lead to 100% CPU usage on a single core.

Please fix because liquidator is unusable.

Another issue not allowing fillerlite bot to run

keeper-bots-v2/node_modules/ts-node/src/index.ts:859
return new TSError(diagnosticText, diagnosticCodes, diagnostics);
^
TSError: ⨯ Unable to compile TypeScript:
src/bots/uncrossArbBot.ts:211:51 - error TS2339: Property 'arbPerp' does not exist on type 'JitProxyClient'.

211 const txResult = await this.jitProxyClient.arbPerp({

What API endpoints are used?

In the config there's "RPC endpoint" for which a Solana node url can be specified. Some requests go to Jupiter too.

Is this it? Doesn't the Drift SDK library itself use any API of https://drift.trade? Namely, api.drift.trade or something similar.

track tx simulation response time and disable during congested periods.

It might make sense to try to send out txs faster during congested/volatile periods. Add something to track how long simulateTransaction calls take, and track the median/max CUs estimated (check that these values make sense). Use these values when simulateTransaction takes longer than usual (i.e.the P50 has been increasing over the last 5 minutes), and just stop simulating and pre-populate the CU limit

where to get the "keeperPrivateKey"

Hello, I'm new to the project and trying to run the project.
I Met following error while run it:
image

Where or How can I get the keeperPrivateKey pls?

Thanks !

TypeError on Filler bots

Hey, I am still getting the type error on both filler and filler lite bots after pulling the updates with git pull and making sure I ran yarn.

src/utils.ts:129
if (!node.node.userAccount) {
^
TypeError: Cannot read properties of undefined (reading 'node')

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.