SDK用于从块链获取DeFi Saver策略数据.
从块链中获取策略数据,并将其分析成可读格式. 使用以下一个类获取策略数据: Ethereum Strategies, Optimism Strategies, Arbitrium Strategies 或 BaseStrategies. 使用以下一个类来获取遗留自动化的数据: LegacyMakerAutomation,LegacyAaveAutomation,或LegacyCompoundAutomation. 还有各种服务和常数可供使用.
使用量
const ethereumStrategies = new EthereumStrategies({
provider: WEB3_PROVIDER_HERE,
});
const subscriptions = await ethereumStrategies.getSubscriptionsFor(
// Pass one or multiple owner addresses, or use getSubscriptions method to fetch all subscriptions
['0x000000000000000000000000000000000000dEaD'],
{
fromBlock: 0,
toBlock: 'latest',
mergeSubs: true, // Used for merging subscriptions with same strategy ID (e.g. boost and repay)
enabledOnly: true,
unexpiredOnly: true, // Referring to exchange subscriptions
}
);
// Do what you would like with subscriptions
发展----如何增加新战略?
- 添加策略/捆绑ID到
./src/types/enums.ts创建Identifiers必要时 - 添加战略/散装信息到
./src/constants/index.ts - 为以下文件添加编码/解码:
./src/services/strategySubService.ts./src/services/subDataService.ts./src/services/triggerService.ts
- 写入策略解析
./src/services/strategeiesService.ts并添加到const parsingMethodsMapping - 每种方法的写测试
- 运行测试
yarn test或者说yarn test fileName对于特定文件(例如:.yarn test utils(中文(简体) ) - 恭喜你们
测试
npm run test - 进行所有测试
npm run test-single --name=your_test_name - 运行指定名称的单一测试,例如 My Test. test.ts测试名称为 My Test