-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: initial integration structure * feat(ui): add supplied and borrowed assets lists * feat(ui): initial components * feat(abi): update to v3 abi * feat(ui): improve ui * fix: atoken and debttoken balances * feat(aave-integration): add apy data * feat(aave-integration): add modals * feat(aave-integration): health factor calculation * feat(aave-integration): apy calculation * feat(aave-integration): add contract writes * refactor(aave-integration): improve useAave hook code * feat(aave-integration): responsive lists * feat(aave-integration): repay with aTokens * feat(aave-integration): switch borrow rate * docs(aave-integration): Create README.md * docs(aave-integration): Update README.md * fix(aave-integration): build failing because of isolated module * fix(aave-integration): build failing because of isolated module * fix: format errors * fix: config networks * chore: hide supply/borrow select on bigger screens * chore: hide supply/borrow select on bigger screens * feat: handle unsupported chains * feat: add checkbox to hide assets with 0 balance * chore(ui): align cards on left side of the dashboard * refactor: use single state as an object in useAave * fix: useAave broken * feat: use ContractWriteButton for write operations * feat: add max button to inputs * fix: minor UI improvements * feat(ui): hide ~0 balances on user supplies and borrows * fix: margin cards UI con smaller screens * refactor: remove useAave unused code * fix: call revert on stable rate borrow * feat: toast after supply/borrow/withdraw/repay success * fix: negative big int if decimals < 5 * fix: remove console logs * fix: format errors * fix: add removed files * fix: add removed files * fix: format errors * fix: minor UI improvements * fix: small layout updates * fix: usage as collateral always seems to be enabled * fix: usage as collateral always seems to be enabled --------- Co-authored-by: AlanRacciatti <[email protected]> Co-authored-by: Chiin <[email protected]> Co-authored-by: Kames <[email protected]>
- Loading branch information
1 parent
1b1e190
commit 893bd18
Showing
48 changed files
with
9,940 additions
and
3,552 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
'use client' | ||
import { ReactNode } from 'react' | ||
|
||
import { motion } from 'framer-motion' | ||
import Image from 'next/image' | ||
import Balancer from 'react-wrap-balancer' | ||
|
||
import { WalletConnect } from '@/components/blockchain/wallet-connect' | ||
import { IsWalletConnected } from '@/components/shared/is-wallet-connected' | ||
import { IsWalletDisconnected } from '@/components/shared/is-wallet-disconnected' | ||
import { LinkComponent } from '@/components/shared/link-component' | ||
import { FADE_DOWN_ANIMATION_VARIANTS } from '@/config/design' | ||
import { turboIntegrations } from '@/data/turbo-integrations' | ||
|
||
export default function AaveLayout({ children }: { children: ReactNode }) { | ||
return ( | ||
<> | ||
<div className="flex w-full flex-col pb-10 lg:pb-12"> | ||
<div className="relative flex flex-1"> | ||
<div className="flex-center flex h-full flex-1 flex-col items-center justify-center text-center"> | ||
<motion.div | ||
animate="show" | ||
className="w-full max-w-3xl px-5 xl:px-0" | ||
initial="hidden" | ||
viewport={{ once: true }} | ||
whileInView="show" | ||
variants={{ | ||
hidden: {}, | ||
show: { | ||
transition: { | ||
staggerChildren: 0.15, | ||
}, | ||
}, | ||
}}> | ||
<Image alt="Aave Icon" className="mx-auto mb-5" height={100} src={turboIntegrations.aave.imgDark} width={100} /> | ||
<motion.h1 | ||
className="pb-5 text-center text-2xl font-bold tracking-[-0.02em] drop-shadow-sm md:text-8xl md:leading-[6rem]" | ||
variants={FADE_DOWN_ANIMATION_VARIANTS}> | ||
Aave | ||
</motion.h1> | ||
<motion.p className=" mb-8 text-center text-gray-500 dark:text-gray-200 md:text-xl" variants={FADE_DOWN_ANIMATION_VARIANTS}> | ||
<Balancer className="w-full text-xl font-semibold">Borrow and lend assets seamlessly</Balancer> | ||
</motion.p> | ||
<motion.div className="my-4 text-xl" variants={FADE_DOWN_ANIMATION_VARIANTS}> | ||
<LinkComponent isExternal href={turboIntegrations.aave.url}> | ||
<button className="btn btn-primary">Documentation</button> | ||
</LinkComponent> | ||
</motion.div> | ||
</motion.div> | ||
</div> | ||
</div> | ||
</div> | ||
<main className="w-full"> | ||
<IsWalletDisconnected> | ||
<div className="mx-auto mt-10 w-fit"> | ||
<WalletConnect /> | ||
</div> | ||
</IsWalletDisconnected> | ||
<IsWalletConnected>{children}</IsWalletConnected> | ||
</main> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { IntegrationOgImage } from '@/components/ui/social/og-image-integrations' | ||
|
||
export const runtime = 'edge' | ||
export const size = { | ||
width: 1200, | ||
height: 630, | ||
} | ||
|
||
export default IntegrationOgImage('aave') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
'use client' | ||
|
||
import { useState } from 'react' | ||
|
||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select' | ||
import { GeneralInfo } from '@/integrations/aave/components/general-info' | ||
import { ListAssetsToBorrow } from '@/integrations/aave/components/list-assets-to-borrow' | ||
import { ListAssetsToSupply } from '@/integrations/aave/components/list-assets-to-supply' | ||
import { ListBorrowedAssets } from '@/integrations/aave/components/list-borrowed-assets' | ||
import { ListSuppliedAssets } from '@/integrations/aave/components/list-supplied-assets' | ||
import { useAave } from '@/integrations/aave/hooks/use-aave' | ||
|
||
export default function AaveHome() { | ||
const [actionSelected, setActionSelected] = useState('supply') | ||
const { chainSupported } = useAave() | ||
|
||
return chainSupported ? ( | ||
<section className="w-full lg:mt-10"> | ||
<div className="mx-auto max-w-screen-xl"> | ||
<GeneralInfo /> | ||
<div className="m-2 mb-5 w-40 xl:hidden"> | ||
<Select value={actionSelected} onValueChange={(action) => setActionSelected(action)}> | ||
<SelectTrigger className="input mt-2 bg-white text-gray-600 placeholder:text-neutral-400 dark:bg-gray-700 dark:text-slate-300 dark:placeholder:text-neutral-400"> | ||
<SelectValue placeholder="Select market" /> | ||
</SelectTrigger> | ||
<SelectContent className="w-56 bg-white dark:bg-gray-700"> | ||
<SelectItem value="supply"> | ||
<div className="flex items-center justify-between">Supply</div> | ||
</SelectItem> | ||
<SelectItem value="borrow"> | ||
<div className="flex items-center justify-between">Borrow</div> | ||
</SelectItem> | ||
</SelectContent> | ||
</Select> | ||
</div> | ||
|
||
<div className="mb-4 flex justify-between dark:text-white"> | ||
<div className={`${actionSelected === 'supply' ? '' : 'hidden'} m-2 w-full xl:block`}> | ||
<ListSuppliedAssets /> | ||
</div> | ||
<div className={`${actionSelected === 'borrow' ? '' : 'hidden'} m-2 w-full xl:block`}> | ||
<ListBorrowedAssets /> | ||
</div> | ||
</div> | ||
|
||
<div className="flex justify-between dark:text-white "> | ||
<div className={`${actionSelected === 'supply' ? '' : 'hidden'} m-2 w-full xl:block`}> | ||
<ListAssetsToSupply /> | ||
</div> | ||
<div className={`${actionSelected === 'borrow' ? '' : 'hidden'} m-2 w-full xl:block`}> | ||
<ListAssetsToBorrow /> | ||
</div> | ||
</div> | ||
</div> | ||
</section> | ||
) : ( | ||
<section className="w-full lg:mt-10"> | ||
<div className="mx-auto max-w-screen-xl"> | ||
<h1 className=" mt-5 text-center text-2xl">Chain not supported</h1> | ||
<GeneralInfo /> | ||
</div> | ||
</section> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Image from './opengraph-image' | ||
|
||
export const runtime = 'edge' | ||
export const size = { | ||
width: 1200, | ||
height: 630, | ||
} | ||
|
||
export default Image |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# Aave - TurboETH Integration | ||
|
||
This React Hook integrates with [Aave](https://aave.com/), enabling users to supply and borrow assets. The integration is built using [Wagmi CLI](https://wagmi.sh/cli/commands/generate), interacting with the Aave [UiPoolDataProvider](https://docs.aave.com/developers/periphery-contracts/uipooldataproviderv3) and [Pool](https://docs.aave.com/developers/core-contracts/pool) contracts. | ||
|
||
## Features | ||
|
||
- Get pools and users data on Aave with the `useAave` hook | ||
- Interact with the pool contract using Wagmi's generated hooks | ||
|
||
## Hooks | ||
|
||
### `useAave()` | ||
|
||
The `useAave()` hook retrieves and computes various data related to the user's activities on the Aave lending protocol. | ||
|
||
**Parameters:** | ||
|
||
The hook doesn't take any parameters. | ||
|
||
**Returns:** | ||
|
||
The hook returns an object `data` with the following properties: | ||
|
||
- `reservesData`: An array of data on the reserves fetched from the Aave protocol, with information about each asset in the pool, such as total liquidity, total borrowings, liquidity rate, variable borrow rate, and more. | ||
|
||
- `userReservesData`: An array of data about the user's reserves in the Aave protocol. This data includes information about each asset the user has in the pool. | ||
|
||
- `usdData`: An array derived from `userReservesData`, where each element is enriched with additional data like `reserveData`, `tokenPriceInUsd`, `amountInUsd`, and `debtInUsd`. | ||
|
||
- `balanceInUsd`: The user's total balance in USD, as calculated based on the user's reserves data. | ||
|
||
- `totalDebtInUsd`: The user's total debt in USD, as calculated based on the user's reserves data. | ||
|
||
- `collateralInUsd`: The total collateral in USD, as calculated based on the user's reserves data. | ||
|
||
- `maxBorrowableInUsd`: The maximum amount the user can borrow in USD, calculated based on the user's reserves data. | ||
|
||
- `healthFactor`: A metric calculated based on the user's collateral and debt that indicates the health of the user's position in the protocol. | ||
|
||
- `averageSupplyApy`: The average annual percentage yield (APY) for supplying assets, calculated based on the user's reserves data. | ||
|
||
- `averageBorrowApy`: The average APY for borrowing assets, calculated based on the user's reserves data. | ||
|
||
- `averageNetApy`: The average net APY, calculated based on the user's reserves data. | ||
|
||
- `poolAddress`: The address of the Aave lending pool. | ||
|
||
**Behavior:** | ||
|
||
- On initial render, and whenever there's a change in the user's reserves data, reserves data, market, or user, the hook calculates and updates multiple financial parameters. | ||
|
||
**Example:** | ||
|
||
```javascript | ||
const { data } = useAave() | ||
``` | ||
|
||
Also check the hooks generated at `integrations/aave/generated/aave-wagmi.ts` | ||
|
||
## File Structure | ||
|
||
``` | ||
integrations/aave | ||
├── abis | ||
│ ├── pool-abi.ts | ||
│ └── ui-pool-data-provider-abi.ts | ||
├── components | ||
│ ├── asset-to-borrow-item.tsx | ||
│ ├── asset-to-supply-item.tsx | ||
│ ├── borrowed-assets-item.tsx | ||
│ ├── general-info.tsx | ||
│ ├── health-factor.tsx | ||
│ ├── list-assets-to-borrow.tsx | ||
│ ├── list-assets-to-supply.tsx | ||
│ ├── list-borrowed-assets.tsx | ||
│ ├── list-supplied-assets.tsx | ||
│ ├── spinner.tsx | ||
│ └── supplied-assets-item.tsx | ||
├── generated | ||
│ └── aave-wagmi.ts | ||
├── hooks | ||
│ └── use-aave.ts | ||
├── utils | ||
│ ├── index.ts | ||
│ ├── market-config.ts | ||
│ └── types.ts | ||
│── wagmi.config.ts | ||
└── README.md | ||
``` |
Oops, something went wrong.
893bd18
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
turbo-eth – ./
turboeth.vercel.app
turbo-eth-district-labs.vercel.app
turbo-eth-git-integrations-district-labs.vercel.app
turboeth.dev
www.turboeth.dev
www.turboeth.xyz
turboeth.xyz
turbo.district.dev