GithubHelp home page GithubHelp logo

badger-sdk's People

Contributors

0xikalgo avatar btcookies avatar darruma avatar dependabot[bot] avatar eliobricenov avatar gallodasballo avatar mitche50 avatar mranilrai avatar mrbasado avatar namelsking avatar okjintao avatar semantic-release-bot avatar shakotn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

badger-sdk's Issues

[feat](Mocks.pkg): Check methods from parent class for Services

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.

Treasury positions history and their yield

Background

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

[feat](Mocks.pkg): Args map for services methods args config

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

feat(sdk): Governance service

Background

In order to complete Badger-Finance/v2-ui#2423. Provide interface for interaction with TimelockController contract and further utilisation in api.

Tasks

  • Governance service, with abis and interfaces for contract above
  • Cover base service and methods
  • Dogfood api endpoints in api service
    • Provide data for mocks of endpoints above
  • Fetch TimelockController from registry
  • Improve deloyedAt script for events in dynamic addresses
  • Generate mocks for new service

feat: complete support for badger-api-v2

Background

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.

Tasks

  • Add missing API endpoints with proper query params
  • Add tests where possible / applicable

[feat]: @badger-dao/sdk-mocks lib for testing

Background

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.

Tasks

  • Write mocks processor, that will cover all sdk methods.
  • Save responses to .json files, for easy imports
  • Export .json files in one entry, pack as a lib
  • Deploy with semantic-release-bot (should be synced with main lib)

bug: contract errors are treated as transactions rejected

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()
    ...
  }
}

[feat](Mocks.pkg): Fill methods args configs for all chains

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

[feat](Mocks.pkg): Mocks for python clients

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:

  • pack as pypi library and add to deploy github.flow (the best i guess)
  • .py script which will load this mocks into project (quick variant)

feat(citadel): citadel service

Summary

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

Requirements

Citadel Minter

  • support proxied supplySchedule calls
  • support lastMintTimestamp
  • support CitadelDistributionToStaking historic queries, these should be formatted similarly to VaultPerformanceEvent if possible

Staked Citadel Locker

  • support rewardDistributors
  • support rewardData query
  • support supply, and epochs queries
  • support balances, userLocks queries
  • getRewardTokens
  • claimableRewards
  • rewardWeightOf
  • lockedBalanceOf
  • balanceOf
  • balanceAtEpochOf
  • etc... (note: we may just skip some of them possible not needed)

feat(tokens): allow tokens service to look up other users balances

Summary

Tokens 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.

feat: utilize API v3 for `/vaults` and `/vault?address=x`

Summary

  • replace loadVaults and loadVault with API v3 variants of request / responses
  • as an option for temporarily backwards compatibility or optionality expose loadVaultsV2 and loadVaultV2

naming on the latter requirement is potentially suspect, and option to alternative naming conventions - not loving the clash with 'vault version' ideas

feat: harvest + tree distribution retrieval

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:

  • query last x harvests
  • query harvests in specific time ranges (before x, after x, in range x-y)

All requests should group these events by timestamp when counting the number of requested items.

Example:

// query previous harvest events to aggregate data
const harvestFilter = vault.filters.Harvested();
const harvestEvents = await vault.queryFilter(harvestFilter);
// collect all the harvest timestamps
const eventTimestamps = new Set<BigNumber>();
harvestEvents.forEach((e) => {
const timestamp = e.args[3];
if (!eventTimestamps.has(timestamp)) {
eventTimestamps.add(timestamp);
}
});
/**
* sort by most recent harvests, and remove all but the most recent 4 harvests
* we use 4 so we can have 3 harvest cycles, the 4th harvest is used as the
* start of the first cycle
*/
const recentTimestamps = [...eventTimestamps]
.sort((a, b) => b.sub(a).toNumber())
.slice(0, 3);
// previous harvest start is the timestamp of the second most recent harvest
const previousHarvestTimestamp = recentTimestamps[1];
const firstHarvestTimestamp = recentTimestamps[recentTimestamps.length - 1];
const recentHarvestEvents = harvestEvents.filter((h) =>
h.args[3].gte(firstHarvestTimestamp),
);
const harvests = await Promise.all(
recentHarvestEvents.map(async (d): Promise<TokenBalance> => {
const { name, decimals, symbol } = await this.sdk.tokens.loadToken(
d.args[0],
);
return {
address: d.args[0],
balance: formatBalance(d.args[1], decimals),
name,
decimals,
symbol,
value: 0,
};
}),
);
const treeDistributionFilter = vault.filters.TreeDistribution();
const treeDistributionEvents = (
await vault.queryFilter(treeDistributionFilter)
).filter((e) => e.args[3].gte(firstHarvestTimestamp));
const treeDistributions = await Promise.all(
treeDistributionEvents.map(async (d): Promise<TokenBalance> => {
const { name, decimals, symbol } = await this.sdk.tokens.loadToken(
d.args[0],
);
return {
address: d.args[0],
balance: formatBalance(d.args[1], decimals),
name,
decimals,
symbol,
value: 0,
};
}),
);

feat: enable vault deposits

Background

Allow the SDK to enable one liner deposits into a Badger vault. Vaults require approvals for depositing. A vault deposit should:

  • verify adequate token deposit allowances for the deposit contract
  • increase allowances for deposit contract as required
  • deposit the underlying token into the vault
  • add tests where possible / applicable

[chore](Mocks.pkg): RM cleaner for .json

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.

feat: enable vault withdraws

Background

Allow the SDK to enable one liner withdraws from a Badger vault. Vaults require approvals on receipt tokens for withdrawing. A vault withdraw should:

  • #109
  • increase allowances for vault contract as required
  • withdraw the underlying token from the vault
  • add tests where possible / applicable

feat: badger subgraph support via graphql library

Background

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.

Tasks

  • Add GraphQL, queries, fragments, and configuration
  • Add BadgerGraph support as stand alone and sdk offering
  • Add test coverage where possible / applicable

feat: enable vault guest list look up

Background

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.

Key Data

  • Total Vault Cap
  • Total User Cap
  • Remaining Vault Cap
  • Remaining User Cap (if applicable)

docs: docusaurus support

Summary

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.

bug(vaults): getVaultStrategy is not v1.5 compatible

Summary

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.

Tasks

  • Update getVaultStrategy to return the strategy address
  • Test coverage for getVaultStrategy

feat: automated package version release

Summary

Currently @badger-dao/sdk is currently being deployed manually by myself with manual versioning. Investigate options for automated versioning and releases

Tasks

  • Investigate publishing options
  • Select + implement publishing solution

feat: support vault fee data fetching + influence vault fee handling

Summary

  • support fetching vault fees for any vaults
  • we should consider implications / performance impacts of adding this information to base vault data returned
  • influence vaults have specific not on chain fees (or breakdowns) that don't reflect always on strategies - ensure we have a robust way to handle multiple influence strategy fee set ups for any future considerations

Example

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

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.