From 9b4b153629bf3c8ef9b0694c0bd0cf9bfd6d5d16 Mon Sep 17 00:00:00 2001 From: xavikh Date: Wed, 18 Dec 2024 11:05:27 +0000 Subject: [PATCH] Test LP --- test/fork/e2eV2.t.sol | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/test/fork/e2eV2.t.sol b/test/fork/e2eV2.t.sol index 1fb80bf..47ae63a 100644 --- a/test/fork/e2eV2.t.sol +++ b/test/fork/e2eV2.t.sol @@ -5,6 +5,7 @@ import {console2 as console} from "forge-std/console2.sol"; import {IDAO} from "@aragon/osx/core/dao/IDAO.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import {DAO} from "@aragon/osx/core/dao/DAO.sol"; import {Multisig, MultisigSetup} from "@aragon/multisig/MultisigSetup.sol"; import {UUPSUpgradeable as UUPS} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; @@ -26,6 +27,14 @@ interface IERC20Mint is IERC20 { function updateTransferWhitelist(address _account, bool _add) external; } +interface NFT721Position is IERC721 { + function withdrawFromPosition(uint256 _tokenId, uint256 amountToWithdraw) external; + + function createPosition(uint256 _amount, uint256 _lockDuration) external; + + function lastTokenId() external view returns (uint256); +} + contract GhettoMultisig { function approveCallerToSpendTokenWithID(address _token, uint256 _id) external { _token.call(abi.encodeWithSignature("approve(address,uint256)", msg.sender, _id)); @@ -1437,14 +1446,29 @@ contract TestE2EV2 is Test, IWithdrawalQueueErrors, IGaugeVote, IEscrowCurveToke return false; } - address xKIMOwner = address(0x6f1130E4b96C681e2721667DDfFcA99dD6824a2d); + // NFT token 0x2548255dcedFA9C1cB87ca2a645A1CB88FB66ac0 + NFT721Position nftPosition = NFT721Position(0x2548255dcedFA9C1cB87ca2a645A1CB88FB66ac0); + + uint256 lpAmount = 3_000 ether; + uint256 lpTokenId = 86; - vm.startPrank(xKIMOwner); + vm.startPrank(whale); { - token.updateTransferWhitelist(whale, true); - token.updateTransferWhitelist(distributor, true); - token.updateTransferWhitelist(address(escrow), true); - token.updateTransferWhitelist(address(queue), true); + // Carlos is poor + assertEq(token.balanceOf(whale), 0); + nftPosition.withdrawFromPosition(lpTokenId, lpAmount); + + // Carlos is rich but he hates money + assertEq(token.balanceOf(whale), lpAmount); + token.approve(address(nftPosition), lpAmount); + nftPosition.createPosition(lpAmount, 0); + // Carlos is poor again + assertEq(token.balanceOf(whale), 0); + + // Just kidding, Carlos wants a Lambo and a Fiat500 + uint256 lastTokenId = nftPosition.lastTokenId(); + nftPosition.withdrawFromPosition(lastTokenId, lpAmount); + assertEq(token.balanceOf(whale), lpAmount); } vm.stopPrank();