Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

Latest commit

 

History

History
122 lines (80 loc) · 5.83 KB

CONTRIBUTING.md

File metadata and controls

122 lines (80 loc) · 5.83 KB

Contribution Guidelines

The Issues section of this repository can be sorted by items with the Help Wanted label.

Not a developer? Feel free to reach out to us on Discord with feedback, suggestions, or make a donation to help fund development!

Suggesting Support for New Dapp

Want a new dapp to be supported by WeaverFi? Feel free to create a new issue here by going to Issues, New Issue and selecting the New Project template to make it easier for all involved to see what you are suggesting.

Reporting Bugs

Found a bug? You can either choose to report it in our Discord server in the #bug-reports channel, or by creating an issue in this repository. To do so, go to Issues, New Issue, and you'll see a Bug Report template you can use to facilitate your report.

Donations

Support us on GitCoin here!

Donations can also be made to support the development of WeaverFi through the following wallet addresses:

Ethereum: ncookie.eth

BSC/Polygon/Fantom/Avalanche/Cronos/Optimism/Arbitrum: 0xbE4FeAE32210f682A41e1C41e3eaF4f8204cD29E

We plan to soon change our donation structure to allocate some of the funds towards hosting costs, and the rest distributed among contributors.

Adding Support for New Dapp Yourself

Doing so was made as easy and straightforward as possible. Simply fork this repository and submit a pull request with the following changes:

  • Any new relevant tracked tokens listed in /src/tokens.ts.
  • Any new relevant new ABIs updated in /src/ABIs.ts.
  • A file in /src/projects/ with the functionality of querying the new dapp in the appropriate chain folder, as a .ts file.

The basic structure of any project's integration is an exported get() function that returns token balances. Here's a simple example from PoolTogether's Ethereum integration:

export const get = async (wallet: Address) => {
  let balance: Token[] = [];
  balance.push(...(await getPoolBalanceV4(wallet).catch((err) => { throw new WeaverError(chain, project, 'getPoolBalanceV4()', err) })));
  return balance;
}

The getPoolBalanceV4() function in this case is a function that would check a user's PoolTogether V4 balance on-chain, and return some Token objects. You can have many different functions to query many different aspects of any project! Keep in mind there are other ready objects for other token types such as NativeToken, LPToken, DebtToken or XToken.

Here's the aforementioned example function:

export const getPoolBalanceV4 = async (wallet: Address) => {
  let balance = parseInt(await query(chain, poolTicketV4, minABI, 'balanceOf', [wallet]));
  if(balance > 0) {
    let newToken = await addToken(chain, project, 'staked', usdc, balance, wallet, poolDepositV4);
    return [newToken];
  } else {
    return [];
  }
}

As this integration is quite simple, the query() function was used to make on-chain queries. If there are multiple on-chain queries to make, consider using multicallQuery(), multicallOneMethodQuery() or multicallOneContractQuery() to greatly speed up the efficiency of your integration.

The addToken() function was then used to create a Token object suitable to return as a result. Appropriately named methods are also available for other token types, such as addNativeToken(), addLPToken(), addDebtToken() and addXToken().

You can also add any extra info you'd like to your token balances, since all token types have an optional info attribute to indicate values like apr, apy, unlock, deprecated, or any others you may think of.

There are tons of already present implementations of dapps in /src/projects/, use any relevant ones as a template for your new integration!

You can test your implementation through npm run test, and a lot of tests are already setup and available in /src/tests.ts. Make sure you run npm run build at least once to add your integration to the projects list!

If your PR isn't reviewed right away, reach out in our Discord server!

Tracking New Token

In order to track a new token, first ensure it has a price feed available either through CoinGecko, ParaSwap or 1Inch (not necessary for NFTs).

Simply add the token's information to /src/tokens.ts under its appropriate chain! Each addition follows the following structure:

{
  address: Address,
  symbol: string,
  logo: URL,
  decimals: number
}

Here's the USDC token on Ethereum, as an example:

{ address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', symbol: 'USDC', logo: 'https://etherscan.io/token/images/centre-usdc_28.png', decimals: 6 }

Tracking New NFT

In order to track a new NFT, simply add its information to /src/tokens.ts under its appropriate chain, with the following structure:

{
  address: Address,
  dataQuery: 'indexed' | 'listed' | 'none',
  name: string
}

The dataQuery value lets the SDK know how to fetch data from any given NFT. These are the currently available query types:

  • indexed: The NFT has a tokenOfOwnerByIndex method.
  • listed: The NFT has a tokensOfOwner method.
  • none: The NFT does not allow for ownership search, and thus no data is displayed.

Here's the Pfer NFT on Ethereum, for example:

{ address: '0xBCC664B1E6848caba2Eb2f3dE6e21F81b9276dD8', dataQuery: 'none', name: 'Pfers' }

Other Contributions

If you have in mind any other type of contribution, please reach out in our Discord server!