-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
111 additions
and
7 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
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,45 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.25; | ||
|
||
import { MockAccountantWithRateProviders } from "../src/mocks/MockAccountantWithRateProviders.sol"; | ||
import { MockERC20 } from "../src/mocks/MockERC20.sol"; | ||
import { MockUSDC } from "../src/mocks/MockUSDC.sol"; | ||
import { MockVault } from "../src/mocks/MockVault.sol"; | ||
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | ||
import { Test } from "forge-std/Test.sol"; | ||
|
||
abstract contract NestBoringVaultModuleTest is Test { | ||
|
||
MockUSDC public asset; | ||
MockVault public vault; | ||
MockAccountantWithRateProviders public accountant; | ||
|
||
address public owner; | ||
address public user; | ||
|
||
function setUp() public virtual { | ||
owner = address(this); | ||
user = makeAddr("user"); | ||
|
||
// Deploy mocks | ||
asset = new MockUSDC(); | ||
vault = new MockVault( | ||
owner, // _owner | ||
"Mock Vault", // _name | ||
"MVLT", // _symbol | ||
address(asset) // _usdc | ||
); | ||
|
||
accountant = new MockAccountantWithRateProviders( | ||
address(vault), // _vault | ||
address(asset), // _base | ||
1e18 // startingExchangeRate (1:1 ratio) | ||
); | ||
} | ||
|
||
// Common tests that apply to all NestBoringVaultModule implementations | ||
function testInitialization() public virtual; | ||
//function testOwnershipAndAuth() public virtual; | ||
//function testAssetHandling() public virtual; | ||
|
||
} |
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 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.25; | ||
|
||
import { NestTeller } from "../src/vault/NestTeller.sol"; | ||
import { NestBoringVaultModuleTest } from "./NestBoringVaultModuleTest.t.sol"; | ||
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | ||
|
||
contract NestTellerTest is NestBoringVaultModuleTest { | ||
|
||
NestTeller public teller; | ||
address public endpoint; | ||
uint256 public constant MINIMUM_MINT_PERCENTAGE = 9900; // 99% | ||
|
||
function setUp() public override { | ||
super.setUp(); | ||
endpoint = makeAddr("endpoint"); | ||
|
||
// Deal some tokens to the vault for initial liquidity | ||
deal(address(asset), address(vault), 1_000_000e6); | ||
|
||
// Setup initial rates in accountant | ||
accountant.setRateInQuote(1e18); // 1:1 ratio | ||
|
||
teller = new NestTeller( | ||
owner, address(vault), address(accountant), endpoint, address(asset), MINIMUM_MINT_PERCENTAGE | ||
); | ||
|
||
// Approve teller to spend vault's tokens | ||
vm.prank(address(vault)); | ||
IERC20(address(asset)).approve(address(teller), type(uint256).max); | ||
} | ||
|
||
function testInitialization() public override { | ||
assertEq(teller.owner(), owner); | ||
assertEq(address(teller.vaultContract()), address(vault)); | ||
assertEq(address(teller.accountantContract()), address(accountant)); | ||
assertEq(teller.asset(), address(asset)); | ||
assertEq(teller.minimumMintPercentage(), MINIMUM_MINT_PERCENTAGE); | ||
} | ||
|
||
function testDeposit( | ||
uint256 amount | ||
) public { | ||
// Bound the amount to reasonable values | ||
amount = bound(amount, 1e6, 1_000_000e6); | ||
|
||
// Give user some tokens | ||
deal(address(asset), user, amount); | ||
|
||
// Approve teller | ||
vm.startPrank(user); | ||
IERC20(address(asset)).approve(address(teller), amount); | ||
|
||
// Deposit | ||
uint256 shares = teller.deposit(amount, user, user); | ||
|
||
// Verify | ||
assertGt(shares, 0, "Should have received shares"); | ||
assertEq(IERC20(address(asset)).balanceOf(address(vault)), amount, "Vault should have received tokens"); | ||
vm.stopPrank(); | ||
} | ||
|
||
} |