badger-finance / badger-sdk Goto Github PK
View Code? Open in Web Editor NEWBadger Protocol Typescript SDK
License: MIT License
Badger Protocol Typescript SDK
License: MIT License
All sdk services extends from Service
base class, which could and actually has it's own methods. In mocks.generator we are scanning services prototype
which gave us only mehtods from current class. It would be nice to have all methods for this scan.
in places like https://github.com/Badger-Finance/badger-sdk/blob/main/src/vaults/vaults.service.ts#L286 and https://github.com/Badger-Finance/badger-sdk/blob/main/src/vaults/vaults.service.ts#L281 we are sure we have available the transactions info so there's no need to use the default params type where it is optional
Allow inspection of treasury multi-sigs positions over time and the yield they had generated. Should contain:
Convex position info breakdown and yield generated
Aave position info collateral breakdown and yield generated
Uniswap v3 NFTs position, holdings on each NFT and fees generated over time
Claimable amounts in the tree from dogfooding, such as the dog food in this sett
Check if Citadel contracts have some data to give on key methods. If so, add service to generator.
Current realisation of mocks.processor taking only one variant of args taken from config to load method and save it .json file. Would be nice to have possibility of adding different variants of args to receive more mocks for the end user.
Here is code placing, that can help:
https://github.com/Badger-Finance/badger-sdk/tree/main/mocks.pkg/src/config
https://github.com/Badger-Finance/badger-sdk/blob/main/mocks.pkg/src/processor/mocks.processor.ts
In order to complete Badger-Finance/v2-ui#2423. Provide interface for interaction with TimelockController contract and further utilisation in api.
The SDK / API implementations currently support a subset of the queries possible to the Badger API. Implement the missing API queries.
API documentation in full is found here.
The full list of implemented endpoints is found here.
To provide convenient unit testing with our sdk, gather responses from onchain and offchain data in separate deployed mocks lib.
As sdk goals to become main fetching point of badger data, it would be easy to mock this resp and use such tools as snapshot testing, to keep ur services coverage at high lvl.
semantic-release-bot
(should be synced with main lib)if a contract call fails before the user signs the transaction it is recognized as a transaction rejected because the status flag that is initially UserConfirmation
is never updated. Example:
let result = TransactionStatus.UserConfirmation;
try {
tx = await contract.call(param, { ...overrides });
} catch (error) {
// at this point result will always be user confirmation if contract.call threw an error
if (result === ransactionStatus.UserConfirmation) {
onRejection()
...
}
}
For now mocks.pkg generates only .json's for eth and polygon networks. Need to enable all other networks, note that not methods would work properly and not all contract are propagated on all networks, so u would need to change args from base config or ignore method, if it`s not possible to make it work.
List of chains that processor is scanning:
https://github.com/Badger-Finance/badger-sdk/blob/main/mocks.pkg/src/constants.ts#L16
Config files with methods args for chains:
https://github.com/Badger-Finance/badger-sdk/tree/main/mocks.pkg/src/config
We already have .json files with responses from all sdk services. But mocks.pkg naturally packed as npm lib. We have clients, which is written in python, so would be gr8 if they could reuse mocks in their test flow.
My variants:
there are multiple zap options to mint ibbtc, all with a different input asset. This is currently handled in the UI with a factory but can be abstracted in the sdk
Badger-Finance/v2-ui#2098 (comment)
The Badger DAO needs to provide access to data pertaining to the Citadel DAO. The following are key components in the Citadel ecosystem that need to be supported:
Citadel Minter
https://github.com/Citadel-DAO/citadel-contracts/blob/main/src/CitadelMinter.sol
Supply Schedule
https://github.com/Citadel-DAO/citadel-contracts/blob/main/src/interfaces/citadel/ISupplySchedule.sol
Staked Citadel Locker
https://github.com/Citadel-DAO/staked-citadel-locker/blob/main/src/StakedCitadelLocker.sol
Citadel Minter
supplySchedule
callslastMintTimestamp
CitadelDistributionToStaking
historic queries, these should be formatted similarly to VaultPerformanceEvent
if possibleStaked Citadel Locker
rewardDistributors
rewardData
queryTokens services loadBalances
only allows looking up the user balance who created the SDK provider.
Add LoadBalancesOptions
to include
{
tokens: string[],
address?: string,
}
The default address looked up is the signer of the SDK provider if one exists, or else throws.
loadVaults
and loadVault
with API v3 variants of request / responsesloadVaultsV2
and loadVaultV2
naming on the latter requirement is potentially suspect, and option to alternative naming conventions - not loving the clash with 'vault version' ideas
Add sdk.api in generation process of mocks. Should be added here,
https://github.com/Badger-Finance/badger-sdk/blob/main/mocks.pkg/src/enums/sdk.services.enum.ts as new val.
And args.cfg for chains should be filled this appropriate values. U can find them right here
https://github.com/Badger-Finance/badger-sdk/tree/main/mocks.pkg/src/config
Sometimes it's needed to regen some specific mock only for one method. It would be convenient to do with method name as cli args to mocks:gen command
Allow easy access to Harvest and TreeDistribution event data for all vaults.
A claim of rewards by a vault may trigger multiple of the same event types.
Support the following:
All requests should group these events by timestamp when counting the number of requested items.
Example:
badger-sdk/src/vaults/vaults.service.ts
Lines 180 to 242 in dc29ab9
Allow the SDK to enable one liner deposits into a Badger vault. Vaults require approvals for depositing. A vault deposit should:
Methods are discovered from service's prototypes, load responses and save them to .json files. The problem is, that .json files from deleted methods are not removing automatically and will trash library with unnecessary Kbyts.
Add cleaner, and then we can call it on husky
hook along with guard
.
Implement the following interface on the base sdk
object.
async function getGasPrices(): Record<GasSpeed, BigNumber>;
https://github.com/Badger-Finance/badger-api/blob/main/src/chains/config/chain.config.ts#L110-L150
Allow the SDK to enable one liner withdraws from a Badger vault. Vaults require approvals on receipt tokens for withdrawing. A vault withdraw should:
the current setup of the sdk does not allow for a good testing experience for third party integrations (api, ui, etc.)
https://github.com/Badger-Finance/badger-sdk/blob/main/src/vaults/vaults.service.ts#L300
vaults service, and rewards service both wait on the registry to be ready when they are created. this call cannot be mocked by outside users easily (or stopped)
The SDK is meant to be used in web apps and should be performant. Optimize our package for the best in browser experience.
Similar to the way the SDK implements the API interface for easily querying data from our implementation, the SDK should also support querying directly the subgraphs that Badger maintains to do whatever data analysis they wish. The GraphQL support should follow the same pattern as the API support. It should be able to be a stand alone usage while also available within the SDK itself.
The SDK is a general purpose tool that will implement all methods of data retrieval for information Badger offers as well as implement a select set of user functionality. The easy of querying the Badger subgraph fits into this goal.
The ideal example of how to integrate this is available in the API GraphQL Configuration.
It seems like now after mocks:gen command, changed are not commited to master on CI, this cause cache missmatch to grow proportionally to new changes.
Guarded and experimental vaults (status 1 and 2) may have guest lists associated with them. These guest lists enforce who may or may not deposit as well as have metadata information regarding individual and total vault caps.
Enable utility methods to allow for exposing these limits with optional functionality to get user specific caps it an address is provided.
The SDK has minimal examples, and README documentation is not sufficient to show the support the Badger SDK has and the ease of development it enables. A docusaurus app should be created to better document in a nice way the SDK, its services, and at a granular level provide information on the action / data provided by a given method within a service.
Sdk method ListHarvests during processor work failing with err. For now it`s ignored.
Find out the reason, fix it, and rm method from ignore list.
we have both of the available, they can be used for notifications
https://github.com/Badger-Finance/badger-sdk/blob/main/src/tokens/tokens.service.ts#L72-L78
Vault v1 and v1.5 have different strategy ABI. This means that using a typed contract for them is not compatible.
https://github.com/Badger-Finance/badger-sdk/blob/main/src/vaults/vaults.service.ts#L139-L155
The getVaultStrategy
implementation returns a v1 strategy for every request. Instead, we should just return the address for the strategy and require the user to instantiate (trivially) the version they are expecting as it is anyway a required input.
getVaultStrategy
to return the strategy addressgetVaultStrategy
Currently @badger-dao/sdk
is currently being deployed manually by myself with manual versioning. Investigate options for automated versioning and releases
A target replacement for this look up information would be code like this
https://github.com/Badger-Finance/badger-api/blob/main/src/vaults/vaults.utils.ts#L139-L194
In order to stabilize and make refactoring easy, we need to cover all modules with units
Add some reasonable filter params on getProductionVaults
which does not otherwise have filter options.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.