Skip to content

feat(Lighter): auto-fetch account index by address if subaccount not used#34

Open
SoYuCry wants to merge 1 commit intoyour-quantguy:mainfrom
SoYuCry:main
Open

feat(Lighter): auto-fetch account index by address if subaccount not used#34
SoYuCry wants to merge 1 commit intoyour-quantguy:mainfrom
SoYuCry:main

Conversation

@SoYuCry
Copy link
Copy Markdown

@SoYuCry SoYuCry commented Nov 5, 2025

🧠 背景

许多用户在运行 Lighter 策略时,会被环境变量配置中的
LIGHTER_ACCOUNT_INDEX 搞懵。

实际上,大部分用户并没有创建子账户,只是使用主账户进行交易。
在这种情况下,强制要求他们手动去网页查找 account_index 既繁琐又容易出错。


🚀 改动内容

  • 当未设置 LIGHTER_ACCOUNT_INDEX 时,自动通过 LIGHTER_ADDRESS 获取主账户的 account_index
  • 只要求设置 API_KEY_PRIVATE_KEY
  • LIGHTER_ACCOUNT_INDEXLIGHTER_ADDRESS 二选一。
  • 若缺失二者,明确抛出错误提示。
  • 更新日志输出,打印获取到的 account_index,使调试信息更直观。
  • 更新环境变量说明与示例文件。

✅ 测试结果

已通过单测。
验证了以下场景:

  • 不提供 account_index 时自动根据钱包获取;
  • 提供无效地址时抛出明确错误;
  • 仅设置 LIGHTER_ACCOUNT_INDEX 时逻辑不受影响;
  • 环境变量缺失时报错提示完整。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant