Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/forge-std
Submodule forge-std updated 1 files
+1 −1 src/StdUtils.sol
2 changes: 1 addition & 1 deletion lib/v4-core
Submodule v4-core updated 54 files
+1 −1 .forge-snapshots/SwapMath_oneForZero_exactInCapped.snap
+1 −1 .forge-snapshots/SwapMath_oneForZero_exactInPartial.snap
+1 −1 .forge-snapshots/SwapMath_oneForZero_exactOutCapped.snap
+1 −1 .forge-snapshots/SwapMath_oneForZero_exactOutPartial.snap
+1 −1 .forge-snapshots/SwapMath_zeroForOne_exactInCapped.snap
+1 −1 .forge-snapshots/SwapMath_zeroForOne_exactInPartial.snap
+1 −1 .forge-snapshots/SwapMath_zeroForOne_exactOutCapped.snap
+1 −1 .forge-snapshots/SwapMath_zeroForOne_exactOutPartial.snap
+1 −1 .forge-snapshots/addLiquidity with empty hook.snap
+1 −1 .forge-snapshots/addLiquidity with native token.snap
+1 −1 .forge-snapshots/addLiquidity.snap
+1 −1 .forge-snapshots/donate gas with 1 token.snap
+1 −1 .forge-snapshots/donate gas with 2 tokens.snap
+1 −1 .forge-snapshots/erc20 collect protocol fees.snap
+1 −1 .forge-snapshots/initialize.snap
+1 −1 .forge-snapshots/native collect protocol fees.snap
+1 −1 .forge-snapshots/poolManager bytecode size.snap
+1 −1 .forge-snapshots/simple swap with native.snap
+1 −1 .forge-snapshots/simple swap.snap
+1 −1 .forge-snapshots/swap against liquidity with native token.snap
+1 −1 .forge-snapshots/swap against liquidity.snap
+1 −1 .forge-snapshots/swap burn 6909 for input.snap
+1 −1 .forge-snapshots/swap burn native 6909 for input.snap
+1 −1 .forge-snapshots/swap mint native output as 6909.snap
+1 −1 .forge-snapshots/swap mint output as 6909.snap
+1 −1 .forge-snapshots/swap skips hook call if hook is caller.snap
+1 −1 .forge-snapshots/swap with dynamic fee.snap
+1 −1 .forge-snapshots/swap with hooks.snap
+1 −0 .forge-snapshots/swap with lp fee and protocol fee.snap
+1 −1 .forge-snapshots/update dynamic fee in before swap.snap
+2 −2 .github/workflows/coverage.yml
+10 −10 src/PoolManager.sol
+6 −5 src/interfaces/IPoolManager.sol
+2 −2 src/libraries/Hooks.sol
+8 −8 src/libraries/LPFeeLibrary.sol
+37 −19 src/libraries/Pool.sol
+17 −5 src/libraries/ProtocolFeeLibrary.sol
+1 −1 src/libraries/SwapMath.sol
+3 −3 src/test/DynamicFeesTestHook.sol
+3 −3 src/test/MockHooks.sol
+2 −2 src/test/PoolModifyLiquidityTest.sol
+10 −10 src/test/PoolSwapTest.sol
+2 −2 src/test/ProtocolFeeControllerTest.sol
+192 −23 test/DynamicFees.t.sol
+56 −33 test/PoolManager.t.sol
+5 −5 test/PoolManagerInitialize.t.sol
+0 −1 test/SkipCallsTestHook.t.sol
+3 −5 test/libraries/Hooks.t.sol
+30 −5 test/libraries/Pool.t.sol
+73 −0 test/libraries/ProtocolFeeLibrary.t.sol
+25 −25 test/libraries/SwapFeeLibrary.t.sol
+16 −16 test/libraries/SwapMath.t.sol
+2 −2 test/utils/Deployers.sol
+0 −1 test/utils/SwapHelper.t.sol
601 changes: 601 additions & 0 deletions src/TtcLogic.sol

Large diffs are not rendered by default.

596 changes: 38 additions & 558 deletions src/TtcVault.sol

Large diffs are not rendered by default.

43 changes: 43 additions & 0 deletions src/interfaces/ITtcLogic.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.20;

import {Route, Token} from "../types/types.sol";

interface ITtcLogic {
// Errors
error InvalidTokenList();
error MinimumAmountToMint();
error EmptyVault();
error InvalidRedemptionAmount();
error RedemptionTransferFailed();
error TreasuryTransferFailed();
error NoReentrancy();
error OnlyTreasury();
error RocketSwapMaxSlippageExceeded();
error InvalidWeights();
error PoolDoesNotExist();
error NegativePrice();
error NegativeTick();
error InvalidRoute();

// Events
/// @notice event for minting
event Minted(address indexed sender, uint256 ethAmount, uint256 ttcAmount);

/// @notice event for redeeming
event Redeemed(address indexed sender, uint256 ttcAmount);

/// @notice event for rebalancing
event Rebalanced(Token[10] _newTokens);

// Methods
/// @notice mint tokens for msg.value to msg.sender
function mint() external payable;

/// @notice Return constituents to msg.sender and burn
function redeem(uint256 _ttcAmount) external;

/// @notice Rebalance the vault
function rebalance(Token[10] calldata _newTokens, Route[10][] calldata routes) external payable;
}
49 changes: 10 additions & 39 deletions src/interfaces/ITtcVault.sol
Original file line number Diff line number Diff line change
@@ -1,43 +1,14 @@
// SPDX-License-Identifier: GPL-3.0

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.20;

import {Route, Token} from "../types/types.sol";

import {Token} from "../types/types.sol";
interface ITtcVault {
// Errors
error InvalidTokenList();
error MinimumAmountToMint();
error EmptyVault();
error InvalidRedemptionAmount();
error RedemptionTransferFailed();
error TreasuryTransferFailed();
error NoReentrancy();
error OnlyTreasury();
error RocketSwapMaxSlippageExceeded();
error InvalidWeights();
error PoolDoesNotExist();
error NegativePrice();
error NegativeTick();
error InvalidRoute();

// Events
/// @notice event for minting
event Minted(address indexed sender, uint256 ethAmount, uint256 ttcAmount);

/// @notice event for redeeming
event Redeemed(address indexed sender, uint256 ttcAmount);

/// @notice event for rebalancing
event Rebalanced(Token[10] _newTokens);

// Methods
/// @notice mint tokens for msg.value to msg.sender
function mint() external payable;

/// @notice Return constituents to msg.sender and burn
function redeem(uint256 _ttcAmount) external;

/// @notice Rebalance the vault
function rebalance(Token[10] calldata _newTokens, Route[10][] calldata routes) external payable;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
event TtcLogicContractSet(address indexed ttcLogicContract);
event SpendApproved(address indexed token, address indexed spender, uint256 amount);
event Approval(address indexed owner, address indexed spender, uint256 value);

function transferOwnership(address _newOwner) external;
function setTtcLogicContract(address _ttcLogicContract) external;
function approveSpendToLogicContract(Token[10] calldata tokens) external;
}
16 changes: 8 additions & 8 deletions test/TtcTestContext.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pragma solidity 0.8.20;

import "forge-std/Test.sol";
import "../src/TtcVault.sol";
import "../src/TtcLogic.sol";
import "../src/types/types.sol";

contract TtcTestContext is Test {
Expand Down Expand Up @@ -39,7 +39,7 @@ contract TtcTestContext is Test {
address constant RENDER_ADDRESS = address(0x6De037ef9aD2725EB40118Bb1702EBb27e4Aeb24);
address constant AAVE_ADDRESS = address(0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9);

TtcVault public vault;
TtcLogic public logic;
Token[10] public tokens;

function calculateOptimalREthRoute(uint256 _amountIn) public returns (uint[2] memory portions, uint amountOut) {
Expand All @@ -59,23 +59,23 @@ contract TtcTestContext is Test {
}


function getVaultBalances() public view returns (TokenBalance[10] memory) {
function getlogicBalances() public view returns (TokenBalance[10] memory) {
TokenBalance[10] memory balances;
for (uint8 i; i < 10; i++) {
(, address tokenAddress) = vault.constituentTokens(i);
(, address tokenAddress) = logic.constituentTokens(i);
uint256 balance = IERC20(tokenAddress).balanceOf(
address(vault)
address(logic)
);
balances[i] = TokenBalance(tokenAddress, balance);
}
return balances;
}

function printVaultBalances() public view {
console.log("Vault Balances:");
function printlogicBalances() public view {
console.log("logic Balances:");
for (uint8 i; i < 10; i++) {
uint256 balance = IERC20(tokens[i].tokenAddress).balanceOf(
address(vault)
address(logic)
);
console.log(tokens[i].tokenAddress, "-", balance);
}
Expand Down
Loading