npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

aave-v3-react

v1.1.0

Published

A collection of React hooks to interact with the Aave V3 pools and smart contracts.

Downloads

11

Readme

Aave V3 React

banner

npm npm bundle size npm

Overview

aave-v3-react is a React SDK that makes creating a dApp on top of the Aave Protocol V3 feeling like a breeze. We offer a full suite of hooks and providers integrated with wagmi and viem to make devs life easier.

Features

  • (Almost) full integration with the Aave Protocol V3
    • Check the opened issues for the missing methods. 100% integration coming soon;
  • Wagmi integration
  • Simple hooks for reading and writing from/to the Aave V3 pools
  • Comprehensive TypeScript support
  • Next.js and Vite example apps

Installation

After having setting up a react project with vite or next.js

install the required packages using your favourite package manager:

npm install aave-v3-react @tanstack/react-query wagmi [email protected] connectkit @tanstack/react-query-devtools

or

yarn add aave-v3-react @tanstack/react-query wagmi [email protected] connectkit @tanstack/react-query-devtools

Note on the additional packages

aave-v3-react depends on @tanstack/react-query, wagmi and viem. If any of those packages is missing or installed with an unsupported version, it's possible you experience errors like:

  • useQuery must be used with QueryClientProvider;
  • useChain must be used with Wagmiprovider;

If this is the case, please double check the version of the packages before opening an issue.

Quick start

if you have installed all the packages above, you can spin up your project quickly with the following structure:

my-project/
│
├── src/
│ ├── App.tsx
| |── wagmiConfig.ts
│ └── main.tsx
│
└── package.json

wagmiConfig.ts

import { supportedNetworks } from "aave-v3-react";
import { getDefaultConfig } from "connectkit";
import { createConfig, http } from "wagmi";
import { Chain } from "wagmi/chains";

/**
 * his config allows wagmi to support all the networks supported by aave-v3-react, feel free to
 * change it according to your needs
 */
export const config = createConfig(
  getDefaultConfig({
    appName: "Vite/AAVE react sdk sample app",
    walletConnectProjectId: "PROJECT_ID",
    // TODO: IS there a better type for this?
    chains: supportedNetworks as unknown as readonly [Chain, ...Chain[]],
    transports: supportedNetworks.reduce(
      (acc, network) => {
        acc[network.id] = http();
        return acc;
      },
      {} as Record<number, ReturnType<typeof http>>,
    ),
  }),
);

main.tsx

import React from "react";
import ReactDOM from "react-dom/client";
import { WagmiProvider } from "wagmi";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
import { ConnectKitProvider } from "connectkit";
import { AaveContractsProvider  } from "aave-v3-react";
import { config } from "./config";
import { App } from "./App";

/**
* To be configured based on your needs. All the aave-v3-react hooks will store data here
*/
const queryClient = new QueryClient();

ReactDOM.createRoot(document.getElementById("root")!).render(
  <React.StrictMode>
    <WagmiProvider config={config}>
        <QueryClientProvider client={queryClient}>
            <ReactQueryDevtools initialIsOpen={false} />
            <ConnectKitProvider>
                <AaveContractsProvider>
                    <App />
                </AaveContractsProvider>
            </ConnectKitProvider>
        </QueryClientProvider>
    </WagmiProvider>
  </React.StrictMode>
);

App.tsx

import { formatBalance, useReserves  } from "aave-v3-react";
export const App = () => {

    const { data, isLoading, error } = useReserves()

    console.log({data, isLoading, error})


    return (
        <div>
            <h1> Total liquidity </h1>
            <b>{formatBalance(
                    userReserves?.formattedReserves.totalLiquidityUSD,
                    "USD",
                )}
            </b>
        </div>
    )
}

About Next.js

aave-v3-react is fully complatible with next.js, but you may experience some issues with wagmi and connectkit in some cases. Make sure to add the "use client"; directive where needed, and eventually check their docs to tackle such errors.

React native

React native support is still unexplored but should work out of the box. In case you managed to integrate the library there correctly, please open a PR documenting that and possibly providing an example app.

API Reference

Full API reference is coming soon. For the moment you can refer to aave-utilities. Most of the V3 methods available there have been integrated, and we aim to full support.

Also, a few methods like

  • useReserves

  • useUserReserves

  • useSupply

  • useWithdraw

    have been fully integrated in the example apps.

Future of the project

aave-v3-react is a reactive wrapper on top of aave-utilities, in the short/mid term we aim to:

  • Implement all the V3 methods available there
  • Fix some type errors and liting issues
  • Keep the library up-to-date with the latest releases
  • 100% coverage with unit/e2e
  • Investigate react-native support
  • Add more examples

Contributing

Contributing guidlines are coming soon. If you want to contribute to this project, open an issue, PR or write me on X (@ErikNucibella)

Acknowledgments