Skip to content

Commit

Permalink
feat: replace solmate by solady
Browse files Browse the repository at this point in the history
  • Loading branch information
reednaa committed Feb 12, 2024
1 parent e470047 commit 1972c8d
Show file tree
Hide file tree
Showing 56 changed files with 401 additions and 180 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
[submodule "evm/lib/openzeppelin-contracts"]
path = evm/lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
[submodule "evm/lib/solmate"]
path = evm/lib/solmate
url = https://github.com/transmissions11/solmate
[submodule "evm/lib/solady"]
path = evm/lib/solady
url = https://github.com/Vectorized/solady
216 changes: 216 additions & 0 deletions evm/.gas-snapshot

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion evm/lib/solmate
Submodule solmate deleted from e8f96f
10 changes: 5 additions & 5 deletions evm/script/config/config_contracts.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"contracts": {
"amplified_mathlib": "0x34dEE2Efda1F1279CD03F4068781515DB0A2f463",
"amplified_template": "0xF036724587501706ceE8C9528f1f95aB22128EBE",
"factory": "0x4aBA671b496F03B717fe838881DfA0B936A52f34",
"volatile_mathlib": "0x53189B47eF7A0837f20767564D1D35874d8D7BEc",
"volatile_template": "0xD923EC07E256F80ACE11502ECE0E237CD0cb4500"
"amplified_mathlib": "0x713Ed46B555CdDa17b08F32EE2d5BdceEE333c19",
"amplified_template": "0x4754a274288a2b5D688EFdC091D6CaaE37108023",
"factory": "0x717923a6886e8906063C7a01ec8C9b539801D02B",
"volatile_mathlib": "0x4CA5a524c2D26F597486c1000492Dc225C76f623",
"volatile_template": "0x29412DA1823Ff84162A9fBE24Ef532fce7b4032d"
},
"registry": {
"describer": "0x02a52682aa3634734535bf761800492C9b05A6B0",
Expand Down
16 changes: 8 additions & 8 deletions evm/src/CatalystChainInterface.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.19;

import {ERC20} from 'solmate/tokens/ERC20.sol';
import {SafeTransferLib} from 'solmate/utils/SafeTransferLib.sol';
import {ERC20} from 'solady/tokens/ERC20.sol';
import {SafeTransferLib} from 'solady/utils/SafeTransferLib.sol';
import { IMessageEscrowStructs } from "GeneralisedIncentives/src/interfaces/IMessageEscrowStructs.sol";
import { IIncentivizedMessageEscrow } from "GeneralisedIncentives/src/interfaces/IIncentivizedMessageEscrow.sol";
import { ICatalystReceiver } from "./interfaces/IOnCatalyst.sol";
Expand All @@ -26,7 +26,6 @@ import { ICatalystChainInterface } from "./interfaces/ICatalystChainInterface.so
* message routers with more flexibility.
*/
contract CatalystChainInterface is ICatalystChainInterface, Ownable, Bytes65 {
using SafeTransferLib for ERC20;

//--- ERRORS ---//
// Only the message router should be able to deliver messages.
Expand Down Expand Up @@ -787,7 +786,8 @@ contract CatalystChainInterface is ICatalystChainInterface, Ownable, Bytes65 {
// Collect tokens and collateral from underwriter.
// We still collect the tokens used to incentivise the underwriter as otherwise they could freely reserve liquidity
// in the vaults. Vaults would essentially be a free source of short term options which isn't wanted.
ERC20(toAsset).safeTransferFrom(
SafeTransferLib.safeTransferFrom(
toAsset,
msg.sender,
address(this),
purchasedTokens * (
Expand All @@ -803,7 +803,7 @@ contract CatalystChainInterface is ICatalystChainInterface, Ownable, Bytes65 {
}

// Send the assets to the user.
ERC20(toAsset).safeTransfer(toAccount, purchasedTokens);
SafeTransferLib.safeTransfer(toAsset,toAccount, purchasedTokens);

// Figure out if the user wants to execute additional logic.
// Note that this logic is not contained within a try catch. It could fail.
Expand Down Expand Up @@ -887,10 +887,10 @@ contract CatalystChainInterface is ICatalystChainInterface, Ownable, Bytes65 {
// This following logic might overflow but we would rather have it overflow (which reduces expireShare)
// than to never be able to expire an underwrite.
uint256 expireShare = refundAmount * EXPIRE_CALLER_REWARD / EXPIRE_CALLER_REWARD_DENOMINATOR;
ERC20(toAsset).safeTransfer(msg.sender, expireShare);
SafeTransferLib.safeTransfer(toAsset, msg.sender, expireShare);
// refundAmount > expireShare, and specially when expireShare overflows.
uint256 vaultShare = refundAmount - expireShare;
ERC20(toAsset).safeTransfer(targetVault, vaultShare);
SafeTransferLib.safeTransfer(toAsset, targetVault, vaultShare);

emit ExpireUnderwrite(
identifier,
Expand Down Expand Up @@ -943,7 +943,7 @@ contract CatalystChainInterface is ICatalystChainInterface, Ownable, Bytes65 {
uint256 underwritingIncentive = (underwrittenTokenAmount * uint256(underwriteIncentiveX16)) >> 16;
refundAmount += underwritingIncentive;

ERC20(toAsset).safeTransfer(refundTo, refundAmount);
SafeTransferLib.safeTransfer(toAsset, refundTo, refundAmount);

emit FulfillUnderwrite(
identifier
Expand Down
7 changes: 3 additions & 4 deletions evm/src/CatalystFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
pragma solidity ^0.8.19;

import { Ownable } from "openzeppelin-contracts/contracts/access/Ownable.sol";
import { ERC20 } from 'solmate/tokens/ERC20.sol';
import { SafeTransferLib } from 'solmate/utils/SafeTransferLib.sol';
import { SafeTransferLib } from 'solady/utils/SafeTransferLib.sol';
import { ICatalystV1Vault } from "./ICatalystV1Vault.sol";
import { Clones } from "openzeppelin-contracts/contracts/proxy/Clones.sol";
import { ICatalystV1Factory } from "./interfaces/ICatalystV1Factory.sol";
Expand All @@ -18,7 +17,6 @@ uint256 constant MAX_GOVERNANCE_FEE_SHARE = 75e16; // 75%
* !The owner of the factory must be a timelock!
*/
contract CatalystFactory is Ownable, ICatalystV1Factory {
using SafeTransferLib for ERC20;

/// @notice A mapping which describes if a vault has been created by this factory. Indexed by chainInterface then vault address.
mapping(address => mapping(address => bool)) public isCreatedByFactory;
Expand Down Expand Up @@ -85,7 +83,8 @@ contract CatalystFactory is Ownable, ICatalystV1Factory {

// The vault expects the balances to exist in the vault when setup is called.
for (uint256 it; it < assets.length;) {
ERC20(assets[it]).safeTransferFrom(
SafeTransferLib.safeTransferFrom(
assets[it],
msg.sender,
vault,
init_balances[it]
Expand Down
Loading

0 comments on commit 1972c8d

Please sign in to comment.