Skip to content
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

Update submodules and minor formatting #65

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
12 changes: 12 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,15 @@
[submodule "lib/solidity-stringutils"]
path = lib/solidity-stringutils
url = https://github.com/Arachnid/solidity-stringutils
[submodule "lib/axelar-gmp-sdk-solidity"]
path = lib/axelar-gmp-sdk-solidity
url = https://github.com/axelarnetwork/axelar-gmp-sdk-solidity
[submodule "lib/axelar-cgp-solidity"]
path = lib/axelar-cgp-solidity
url = https://github.com/axelarnetwork/axelar-cgp-solidity
[submodule "lib/axelar-its"]
path = lib/axelar-its
url = https://github.com/axelarnetwork/interchain-token-service
[submodule "lib/openzeppelin-contracts-4-8-3"]
path = lib/openzeppelin-contracts-4-8-3
url = https://github.com/OpenZeppelin/openzeppelin-contracts
6 changes: 6 additions & 0 deletions remappings.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
oz/=lib/openzeppelin-contracts/contracts/
oz-4-8-3/=lib/openzeppelin-contracts-4-8-3/contracts/
oz-4-5-0/=lib/openzeppelin-contracts-4-5-0/contracts/
ozu/=lib/openzeppelin-contracts-upgradeable/contracts
ozu-4-5-1/=lib/openzeppelin-contracts-upgradeable-4-5-1/contracts
@axelar-network/axelar-gmp-sdk-solidity=lib/axelar-gmp-sdk-solidity/
@axelar-network/axelar-cgp-solidity=lib/axelar-cgp-solidity/
axelar-gmp=lib/axelar-gmp-sdk-solidity/contracts
axelar-cgp=lib/axelar-cgp-solidity/contracts
axelar-its=lib/axelar-its/contracts
4 changes: 2 additions & 2 deletions script/deployRetirementV1.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ pragma solidity ^0.8.0;

import "forge-std/Script.sol";

import "oz/proxy/transparent/TransparentUpgradeableProxy.sol";
import "oz/proxy/transparent/ProxyAdmin.sol";
import "oz-4-8-3/proxy/transparent/TransparentUpgradeableProxy.sol";
import "oz-4-8-3/proxy/transparent/ProxyAdmin.sol";

import {KlimaCarbonRetirements} from "../src/retirement_v1/KlimaCarbonRetirements.sol";
import {KlimaRetirementAggregator} from "../src/retirement_v1/KlimaRetirementAggregator.sol";
Expand Down
3 changes: 1 addition & 2 deletions src/infinity/AppStorage.sol
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "oz/token/ERC20/IERC20.sol";
import "oz-4-8-3/token/ERC20/IERC20.sol";
import "./libraries/LibRetire.sol";

/**
* @author Cujo
* @title App Storage defines the state object for Klima Infinity
*/

contract Account {
struct Retirement {
address poolTokenAddress; // Pool token used
Expand Down
14 changes: 7 additions & 7 deletions src/infinity/interfaces/ITrident.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pragma solidity ^0.8.16;

import "oz/token/ERC20/IERC20.sol";
import "oz-4-8-3/token/ERC20/IERC20.sol";

interface IBentoBoxMinimal {
/// @dev Approves users' BentoBox assets to a "master" contract.
Expand All @@ -15,14 +15,14 @@ interface IBentoBoxMinimal {
bytes32 s
) external;

function toAmount(IERC20 token, uint share, bool roundUp) external view returns (uint amount);
function toAmount(IERC20 token, uint256 share, bool roundUp) external view returns (uint256 amount);
}

/// @notice Trident pool router interface.
interface ITridentRouter {
struct ExactInputSingleParams {
uint amountIn;
uint amountOutMinimum;
uint256 amountIn;
uint256 amountOutMinimum;
address pool;
address tokenIn;
bytes data;
Expand All @@ -31,7 +31,7 @@ interface ITridentRouter {
function exactInputSingleWithNativeToken(ExactInputSingleParams calldata params)
external
payable
returns (uint amountOut);
returns (uint256 amountOut);
}

/// @notice Trident pool interface.
Expand All @@ -40,11 +40,11 @@ interface ITridentPool {
/// @dev The pool does not need to include a trade simulator directly in itself - it can use a library.
/// @param data ABI-encoded params that the pool requires.
/// @return finalAmountOut The amount of output tokens that will be sent to the user if the trade is executed.
function getAmountOut(bytes calldata data) external view returns (uint finalAmountOut);
function getAmountOut(bytes calldata data) external view returns (uint256 finalAmountOut);

/// @notice Simulates a trade and returns the expected output.
/// @dev The pool does not need to include a trade simulator directly in itself - it can use a library.
/// @param data ABI-encoded params that the pool requires.
/// @return finalAmountIn The amount of input tokens that are required from the user if the trade is executed.
function getAmountIn(bytes calldata data) external view returns (uint finalAmountIn);
function getAmountIn(bytes calldata data) external view returns (uint256 finalAmountIn);
}
4 changes: 2 additions & 2 deletions src/infinity/interfaces/IWMATIC.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pragma solidity ^0.8.16;

import "oz/token/ERC20/IERC20.sol";
import "oz-4-8-3/token/ERC20/IERC20.sol";

/**
* @author Cujo
Expand All @@ -12,5 +12,5 @@ import "oz/token/ERC20/IERC20.sol";
interface IWMATIC is IERC20 {
function deposit() external payable;

function withdraw(uint) external;
function withdraw(uint256) external;
}
2 changes: 1 addition & 1 deletion src/infinity/libraries/Bridges/LibToucanCarbon.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity ^0.8.16;

import "../../C.sol";
import "oz/token/ERC721/IERC721.sol";
import "oz-4-8-3/token/ERC721/IERC721.sol";
import "../../interfaces/IToucan.sol";
import "../LibAppStorage.sol";
import "../LibRetire.sol";
Expand Down
7 changes: 3 additions & 4 deletions src/infinity/libraries/Token/LibApprove.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@

pragma solidity ^0.8.16;

import "oz/token/ERC20/utils/SafeERC20.sol";
import "oz-4-8-3/token/ERC20/utils/SafeERC20.sol";

/**
* @author publius
* @title LibApproval handles approval other ERC-20 tokens.
*
*/

library LibApprove {
using SafeERC20 for IERC20;

function approveToken(IERC20 token, address spender, uint amount) internal {
if (token.allowance(address(this), spender) == type(uint).max) return;
function approveToken(IERC20 token, address spender, uint256 amount) internal {
if (token.allowance(address(this), spender) == type(uint256).max) return;
token.safeIncreaseAllowance(spender, amount);
}
}
31 changes: 15 additions & 16 deletions src/infinity/libraries/Token/LibBalance.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

pragma solidity ^0.8.16;

import "oz/token/ERC20/utils/SafeERC20.sol";
import "oz/utils/math/Math.sol";
import {SafeCast} from "oz/utils/math/SafeCast.sol";
import "oz-4-8-3/token/ERC20/utils/SafeERC20.sol";
import "oz-4-8-3/utils/math/Math.sol";
import {SafeCast} from "oz-4-8-3/utils/math/SafeCast.sol";
import "../LibAppStorage.sol";

/**
Expand All @@ -14,28 +14,27 @@ import "../LibAppStorage.sol";
* Largely inspired by Balancer's Vault
*
*/

library LibBalance {
using SafeERC20 for IERC20;
using SafeCast for uint;
using SafeCast for uint256;

/**
* @dev Emitted when a account's Internal Balance changes, through interacting using Internal Balance.
*
*/
event InternalBalanceChanged(address indexed account, IERC20 indexed token, int delta);
event InternalBalanceChanged(address indexed account, IERC20 indexed token, int256 delta);

function getBalance(address account, IERC20 token) internal view returns (uint combined_balance) {
function getBalance(address account, IERC20 token) internal view returns (uint256 combined_balance) {
combined_balance = token.balanceOf(account) + getInternalBalance(account, token);
return combined_balance;
}

/**
* @dev Increases `account`'s Internal Balance for `token` by `amount`.
*/
function increaseInternalBalance(address account, IERC20 token, uint amount) internal {
uint currentBalance = getInternalBalance(account, token);
uint newBalance = currentBalance + amount;
function increaseInternalBalance(address account, IERC20 token, uint256 amount) internal {
uint256 currentBalance = getInternalBalance(account, token);
uint256 newBalance = currentBalance + amount;
setInternalBalance(account, token, newBalance, amount.toInt256());
}

Expand All @@ -44,17 +43,17 @@ library LibBalance {
* doesn't revert if `account` doesn't have enough balance, and sets it to zero and returns the deducted amount
* instead.
*/
function decreaseInternalBalance(address account, IERC20 token, uint amount, bool allowPartial)
function decreaseInternalBalance(address account, IERC20 token, uint256 amount, bool allowPartial)
internal
returns (uint deducted)
returns (uint256 deducted)
{
uint currentBalance = getInternalBalance(account, token);
uint256 currentBalance = getInternalBalance(account, token);
require(allowPartial || (currentBalance >= amount), "Balance: Insufficient internal balance");

deducted = Math.min(currentBalance, amount);
// By construction, `deducted` is lower or equal to `currentBalance`, so we don't need to use checked
// arithmetic.
uint newBalance = currentBalance - deducted;
uint256 newBalance = currentBalance - deducted;
setInternalBalance(account, token, newBalance, -(deducted.toInt256()));
}

Expand All @@ -65,7 +64,7 @@ library LibBalance {
* (if positive) or decreased (if negative). To avoid reading the current balance in order to compute the delta,
* this function relies on the caller providing it directly.
*/
function setInternalBalance(address account, IERC20 token, uint newBalance, int delta) private {
function setInternalBalance(address account, IERC20 token, uint256 newBalance, int256 delta) private {
AppStorage storage s = LibAppStorage.diamondStorage();
s.internalTokenBalance[account][token] = newBalance;
emit InternalBalanceChanged(account, token, delta);
Expand All @@ -74,7 +73,7 @@ library LibBalance {
/**
* @dev Returns `account`'s Internal Balance for `token`.
*/
function getInternalBalance(address account, IERC20 token) internal view returns (uint) {
function getInternalBalance(address account, IERC20 token) internal view returns (uint256) {
AppStorage storage s = LibAppStorage.diamondStorage();
return s.internalTokenBalance[account][token];
}
Expand Down
4 changes: 2 additions & 2 deletions src/infinity/libraries/Token/LibTransfer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
*/
pragma solidity ^0.8.16;

import "oz/token/ERC20/utils/SafeERC20.sol";
import "oz/token/ERC1155/IERC1155.sol";
import "oz-4-8-3/token/ERC20/utils/SafeERC20.sol";
import "oz-4-8-3/token/ERC1155/IERC1155.sol";
import "./LibBalance.sol";

library LibTransfer {
Expand Down
7 changes: 2 additions & 5 deletions src/protocol/allocators/RetirementBondAllocator.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity =0.8.19;

import "oz/access/Ownable2Step.sol";
import "oz/token/ERC20/utils/SafeERC20.sol";
import "oz-4-8-3/access/Ownable2Step.sol";
import "oz-4-8-3/token/ERC20/utils/SafeERC20.sol";

import {IKlima, IKlimaTreasury, IKlimaRetirementBond} from "../interfaces/IKLIMA.sol";

Expand All @@ -11,7 +11,6 @@ import {IKlima, IKlimaTreasury, IKlimaRetirementBond} from "../interfaces/IKLIMA
* @author Cujo
* @notice A contract for allocating retirement bonds using excess reserves from the Klima Treasury.
*/

contract RetirementBondAllocator is Ownable2Step {
using SafeERC20 for IKlima;

Expand Down Expand Up @@ -89,11 +88,9 @@ contract RetirementBondAllocator is Ownable2Step {
* @param _maxReservePercent The new maximum reserve percentage allowed. 500 = 5%.
*/
function updateMaxReservePercent(uint256 _maxReservePercent) external onlyDAO {

uint256 oldMax = maxReservePercent;
maxReservePercent = _maxReservePercent;

emit MaxPercentUpdated(oldMax, maxReservePercent);
}

}
Loading