-
Notifications
You must be signed in to change notification settings - Fork 7
Test: supply with native and erc20 #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
9e9cdef
fix: update snapshots
juangm b1b2b4e
test: add supply test in stage
juangm 3a04e15
fix: lint
juangm af5890f
fix: remove examples from packages
juangm a9f1706
fix: update lockfile
juangm 20d9af0
fix: refactor
juangm 716eb05
Merge branch 'main' into juan/supply-tests
juangm a4117d4
fix: problem with lock file
juangm 79149f6
fix: set bigger timeout
juangm 0d52fea
Merge branch 'main' into juan/supply-tests
juangm e84b55f
fix: refactor scenario
juangm 108379f
temp: possible to run tests locally
juangm 4286072
fix: use expect instead of error
juangm b874ec7
fix: not run tests if lint fail
juangm d5f5ea6
fix: refactor scenario
juangm e4fe694
fix: add custom matcher and refactor
juangm b28aaa8
test: fetch specific market data
juangm 47eefd6
Merge branch 'main' into juan/supply-tests
juangm c137bf0
core: update schema and fixes
juangm 67c2c1f
test: add fetch vaults and market state
juangm e32d741
fix: rename file
juangm 69ee083
chore: scaffold aave market test scenarios
cesarenaldi e1b0441
chore: temp tweak to CI workflows
cesarenaldi 43c2fe2
Merge branch 'main' into juan/supply-tests
juangm 16d7556
test: separate tests in supply and withdraw
juangm ce91256
Merge branch 'main' into juan/supply-tests
juangm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,13 @@ | ||
| import { describe, expect, it } from 'vitest'; | ||
|
|
||
| // THIS IS A VERY WIP | ||
|
|
||
| describe('Given an Aave Market', () => { | ||
| describe('And a user with a supply position', () => { | ||
| describe('When the user enables e-mode for that market', () => { | ||
| it('Then it should be possible to borrow from the reserve', () => { | ||
| expect(true).toBe(true); | ||
| }); | ||
| }); | ||
| }); | ||
| }); |
Empty file.
This file contains hidden or 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 hidden or 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,19 @@ | ||
| import { describe, expect, it } from 'vitest'; | ||
|
|
||
| describe('Given an Aave Market', () => { | ||
| describe('And a user with a borrow position', () => { | ||
| describe('When the user repays their loan', () => { | ||
| it('Then it should be reflected in the user borrow positions', () => { | ||
| expect(true).toBe(true); | ||
| }); | ||
| }); | ||
|
|
||
| describe('And the reserve allows repaying in native tokens', () => { | ||
| describe('When the user repays their loan in native tokens', () => { | ||
| it('Then it should be reflected in the user borrow positions', () => { | ||
| expect(true).toBe(true); | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
| }); |
cesarenaldi marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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,129 @@ | ||
| import type { Reserve } from '@aave/graphql'; | ||
| import { assertOk, bigDecimal, evmAddress } from '@aave/types'; | ||
| import { beforeAll, describe, expect, it } from 'vitest'; | ||
| import { | ||
| client, | ||
| createNewWallet, | ||
| fetchReserve, | ||
| fundErc20Address, | ||
| fundNativeAddress, | ||
| WETH_ADDRESS, | ||
| } from '../test-utils'; | ||
| import { sendWith } from '../viem'; | ||
| import { supply } from './transactions'; | ||
| import { userSupplies } from './user'; | ||
|
|
||
| describe('Given an Aave Market', () => { | ||
| describe('When the user supplies tokens to a Reserve', () => { | ||
| const wallet = createNewWallet(); | ||
| const amountToSupply = '0.01'; | ||
| let reserveInfo: Reserve; | ||
|
|
||
| beforeAll(async () => { | ||
| await fundErc20Address( | ||
| WETH_ADDRESS, | ||
| evmAddress(wallet.account!.address), | ||
| bigDecimal('0.02'), | ||
| ); | ||
|
|
||
| reserveInfo = await fetchReserve(WETH_ADDRESS); | ||
| // Check if the reserve is not frozen or paused | ||
| expect(reserveInfo.isFrozen).toBe(false); | ||
| expect(reserveInfo.isPaused).toBe(false); | ||
| }); | ||
|
|
||
| it(`Then it should be available in the user's supply positions`, async () => { | ||
| const result = await supply(client, { | ||
| market: reserveInfo.market.address, | ||
| supplier: evmAddress(wallet.account!.address), | ||
| amount: { | ||
| erc20: { | ||
| value: amountToSupply, | ||
| currency: WETH_ADDRESS, | ||
| }, | ||
| }, | ||
| chainId: reserveInfo.market.chain.chainId, | ||
| }) | ||
| .andThen(sendWith(wallet)) | ||
| .andThen(() => | ||
| userSupplies(client, { | ||
| markets: [ | ||
| { | ||
| address: reserveInfo.market.address, | ||
| chainId: reserveInfo.market.chain.chainId, | ||
| }, | ||
| ], | ||
| user: evmAddress(wallet.account!.address), | ||
| }), | ||
| ); | ||
| assertOk(result); | ||
| expect(result.value).toEqual([ | ||
| expect.objectContaining({ | ||
| balance: expect.objectContaining({ | ||
| amount: expect.objectContaining({ | ||
| value: expect.toBeBigDecimalCloseTo(amountToSupply), | ||
| }), | ||
| }), | ||
| }), | ||
| ]); | ||
| }, 25_000); | ||
| }); | ||
|
|
||
| describe('And the Reserve allows to supply in native tokens', () => { | ||
| let reserveInfo: Reserve; | ||
|
|
||
| beforeAll(async () => { | ||
| reserveInfo = await fetchReserve(WETH_ADDRESS); | ||
| // Check if the reserve is not frozen or paused | ||
| expect(reserveInfo.isFrozen).toBe(false); | ||
| expect(reserveInfo.isPaused).toBe(false); | ||
| // And accepts native tokens | ||
| expect(reserveInfo.acceptsNative?.symbol).toEqual('ETH'); | ||
| }); | ||
|
|
||
| describe('When the user supplies to the reserve in native tokens', () => { | ||
| const wallet = createNewWallet(); | ||
| const amountToSupply = '0.01'; | ||
|
|
||
| beforeAll(async () => { | ||
| await fundNativeAddress( | ||
| evmAddress(wallet.account!.address), | ||
| bigDecimal('0.02'), | ||
| ); | ||
| }); | ||
|
|
||
| it(`Then it should be available in the user's supply positions`, async () => { | ||
| const result = await supply(client, { | ||
| market: reserveInfo.market.address, | ||
| supplier: evmAddress(wallet.account!.address), | ||
| amount: { | ||
| native: amountToSupply, | ||
| }, | ||
| chainId: reserveInfo.market.chain.chainId, | ||
| }) | ||
| .andThen(sendWith(wallet)) | ||
| .andThen(() => | ||
| userSupplies(client, { | ||
| markets: [ | ||
| { | ||
| address: reserveInfo.market.address, | ||
| chainId: reserveInfo.market.chain.chainId, | ||
| }, | ||
| ], | ||
| user: evmAddress(wallet.account!.address), | ||
| }), | ||
| ); | ||
| assertOk(result); | ||
| expect(result.value).toEqual([ | ||
| expect.objectContaining({ | ||
| balance: expect.objectContaining({ | ||
| amount: expect.objectContaining({ | ||
| value: expect.toBeBigDecimalCloseTo(amountToSupply), | ||
| }), | ||
| }), | ||
| }), | ||
| ]); | ||
| }, 25_000); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or 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 hidden or 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,22 @@ | ||
| import { assertOk, evmAddress } from '@aave/types'; | ||
| import { describe, expect, it } from 'vitest'; | ||
| import { client, wallet } from '../test-utils'; | ||
| import { vaults } from './vaults'; | ||
|
|
||
| describe('Given the Aave Protocol v3', () => { | ||
| describe('When fetching vaults data', () => { | ||
| it('Then it should be possible to fetch vaults owned by a given user', async () => { | ||
| const result = await vaults(client, { | ||
| criteria: { | ||
| ownedBy: [evmAddress(wallet.account!.address)], | ||
| }, | ||
| }); | ||
|
|
||
| assertOk(result); | ||
|
|
||
| result.value.items.forEach((vault) => { | ||
| expect(vault).toMatchSnapshot(); | ||
| }); | ||
| }); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is doable with a simple
ENVIRONMENT=localin front of any of the commands. I am not sure if we should have these scripts proliferating.