Verified contractPartialBUSL-1.1
FintochPool
Address0x29bc8ab14caa6c1f6ec9c82805ee94ccca9bde90
- Balance
0 ETH
- Transactions
32,123
- Compiler
solc 0.8.10
- Same code
39 more contracts
Details
- Compiler
- solc 0.8.10+commit.fc410830
- Language
- solidity
- Optimization
- Yes, 199 runs
- EVM version
- london
- License
- BUSL-1.1
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 16,184,400
- Creation transaction
- 0x8913d07b2d…672d5986ca
- Main copy (most transactions)
- 0xeebc1b0e…7568dceb
123 files
The source code is large: one file is shown at a time. Choose a file in the list.
- protocol/pool/FintochPool.solmain13.01 KB
- dependencies/chainlink/AggregatorInterface.sol627 B
- dependencies/gnosis/contracts/GPv2SafeERC20.sol4.76 KB
- dependencies/openzeppelin/contracts/AccessControl.sol6.61 KB
- dependencies/openzeppelin/contracts/Address.sol2.53 KB
- dependencies/openzeppelin/contracts/Context.sol922 B
- dependencies/openzeppelin/contracts/ERC165.sol908 B
- dependencies/openzeppelin/contracts/ERC20.sol10.36 KB
- dependencies/openzeppelin/contracts/IAccessControl.sol2.73 KB
- dependencies/openzeppelin/contracts/IERC165.sol769 B
- dependencies/openzeppelin/contracts/IERC20.sol2.6 KB
- dependencies/openzeppelin/contracts/IERC20Detailed.sol311 B
- dependencies/openzeppelin/contracts/Ownable.sol2.11 KB
- dependencies/openzeppelin/contracts/SafeCast.sol7.44 KB
- dependencies/openzeppelin/contracts/SafeMath.sol1.79 KB
- dependencies/openzeppelin/contracts/Strings.sol1.78 KB
- dependencies/openzeppelin/upgradeability/AdminUpgradeabilityProxy.sol1.39 KB
- dependencies/openzeppelin/upgradeability/BaseAdminUpgradeabilityProxy.sol3.85 KB
- dependencies/openzeppelin/upgradeability/BaseUpgradeabilityProxy.sol1.96 KB
- dependencies/openzeppelin/upgradeability/Initializable.sol2.07 KB
- dependencies/openzeppelin/upgradeability/InitializableAdminUpgradeabilityProxy.sol1.57 KB
- dependencies/openzeppelin/upgradeability/InitializableUpgradeabilityProxy.sol1.23 KB
- dependencies/openzeppelin/upgradeability/Proxy.sol2.25 KB
- dependencies/openzeppelin/upgradeability/UpgradeabilityProxy.sol1.14 KB
- dependencies/weth/WETH9.sol37.55 KB
- flashloan/base/FlashLoanReceiverBase.sol693 B
- flashloan/base/FlashLoanSimpleReceiverBase.sol723 B
- flashloan/interfaces/IFlashLoanReceiver.sol1.43 KB
- flashloan/interfaces/IFlashLoanSimpleReceiver.sol1.39 KB
- interfaces/IACLManager.sol5.45 KB
- interfaces/IAToken.sol5.41 KB
- interfaces/ICreditDelegationToken.sol2.01 KB
- interfaces/IDelegationToken.sol377 B
- interfaces/IERC20WithPermit.sol927 B
- interfaces/IFintochIncentivesController.sol5.69 KB
- interfaces/IFintochOracle.sol2.39 KB
- interfaces/IInitializableAToken.sol2.05 KB
- interfaces/IInitializableDebtToken.sol1.94 KB
- interfaces/IInvestmentEarnings.sol532 B
- interfaces/IL1Pool.sol33.07 KB
- interfaces/IL2Pool.sol6.68 KB
- interfaces/IPool.sol1.31 KB
- interfaces/IPoolAddressesProvider.sol8.22 KB
- interfaces/IPoolAddressesProviderRegistry.sol2.43 KB
- interfaces/IPoolConfigurator.sol18.75 KB
- interfaces/IPoolDataProvider.sol2.06 KB
- interfaces/IPriceOracle.sol610 B
- interfaces/IPriceOracleGetter.sol848 B
- interfaces/IPriceOracleSentinel.sol2.19 KB
- interfaces/IReserveInterestRateStrategy.sol1.25 KB
- interfaces/IScaledBalanceToken.sol2.6 KB
- interfaces/ISequencerOracle.sol970 B
- interfaces/IStableDebtToken.sol5.28 KB
- interfaces/IVariableDebtToken.sol1.8 KB
- misc/FintochOracle.sol5.11 KB
- misc/FintochProtocolDataProvider.sol14.78 KB
- misc/L2Encoder.sol13.18 KB
- misc/interfaces/IWETH.sol338 B
- mocks/flashloan/MockFlashLoanReceiver.sol2.42 KB
- mocks/flashloan/MockSimpleFlashLoanReceiver.sol2.44 KB
- mocks/helpers/MockIncentivesController.sol1.8 KB
- mocks/helpers/MockL2Pool.sol435 B
- mocks/helpers/MockPeripheryContract.sol949 B
- mocks/helpers/MockPool.sol1.28 KB
- mocks/helpers/MockReserveConfiguration.sol4.98 KB
- mocks/helpers/SelfDestructTransfer.sol192 B
- mocks/oracle/CLAggregators/MockAggregator.sol594 B
- mocks/oracle/PriceOracle.sol930 B
- mocks/oracle/SequencerOracle.sol1.19 KB
- mocks/tests/FlashloanAttacker.sol2.06 KB
- mocks/tests/MockReserveInterestRateStrategy.sol2.85 KB
- mocks/tests/WadRayMathWrapper.sol1.17 KB
- mocks/tokens/MintableDelegationERC20.sol911 B
- mocks/tokens/MintableERC20.sol2.67 KB
- mocks/tokens/WETH9Mocked.sol548 B
- mocks/upgradeability/MockAToken.sol444 B
- mocks/upgradeability/MockInitializableImplementation.sol2.63 KB
- mocks/upgradeability/MockStableDebtToken.sol393 B
- mocks/upgradeability/MockVariableDebtToken.sol403 B
- protocol/configuration/ACLManager.sol4.38 KB
- protocol/configuration/PoolAddressesProvider.sol8.3 KB
- protocol/configuration/PoolAddressesProviderRegistry.sol4.11 KB
- protocol/configuration/PriceOracleSentinel.sol3.51 KB
- protocol/libraries/configuration/ReserveConfiguration.sol22.85 KB
- protocol/libraries/configuration/UserConfiguration.sol8.86 KB
- protocol/libraries/fintoch-upgradeability/BaseImmutableAdminUpgradeabilityProxy.sol2.76 KB
- protocol/libraries/fintoch-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol1.06 KB
- protocol/libraries/fintoch-upgradeability/VersionedInitializable.sol2.57 KB
- protocol/libraries/helpers/Errors.sol9.82 KB
- protocol/libraries/helpers/Helpers.sol805 B
- protocol/libraries/logic/BorrowLogic.sol12.99 KB
- protocol/libraries/logic/BridgeLogic.sol5.44 KB
- protocol/libraries/logic/CalldataLogic.sol9.32 KB
- protocol/libraries/logic/ConfiguratorLogic.sol8.55 KB
- protocol/libraries/logic/EModeLogic.sol4.37 KB
- protocol/libraries/logic/FlashLoanLogic.sol10.57 KB
- protocol/libraries/logic/GenericLogic.sol10.02 KB
- protocol/libraries/logic/IsolationModeLogic.sol2.72 KB
- protocol/libraries/logic/LiquidationLogic.sol20.68 KB
- protocol/libraries/logic/PoolLogic.sol7.29 KB
- protocol/libraries/logic/ReserveLogic.sol13.91 KB
- protocol/libraries/logic/SupplyLogic.sol11.46 KB
- protocol/libraries/logic/ValidationLogic.sol28.07 KB
- protocol/libraries/math/MathUtils.sol3.35 KB
- protocol/libraries/math/PercentageMath.sol2.34 KB
- protocol/libraries/math/WadRayMath.sol4.15 KB
- protocol/libraries/types/ConfiguratorInputTypes.sol948 B
- protocol/libraries/types/DataTypes.sol8.34 KB
- protocol/pool/DefaultReserveInterestRateStrategy.sol11.56 KB
- protocol/pool/FTHToken.sol2.43 KB
- protocol/pool/FintochBorrow.sol15.97 KB
- protocol/pool/L2Pool.sol784 B
- protocol/pool/PoolConfigurator.sol19.03 KB
- protocol/pool/PoolStorage.sol2.2 KB
- protocol/tokenization/AToken.sol8.36 KB
- protocol/tokenization/DelegationAwareAToken.sol1.19 KB
- protocol/tokenization/StableDebtToken.sol13.39 KB
- protocol/tokenization/VariableDebtToken.sol5.07 KB
- protocol/tokenization/base/DebtTokenBase.sol3.65 KB
- protocol/tokenization/base/EIP712Base.sol1.97 KB
- protocol/tokenization/base/IncentivizedERC20.sol8.14 KB
- protocol/tokenization/base/MintableIncentivizedERC20.sol2.31 KB
- protocol/tokenization/base/ScaledBalanceTokenBase.sol4.43 KB
protocol/pool/FintochPool.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.10;
import {IInvestmentEarnings} from '../../interfaces/IInvestmentEarnings.sol';
import {IPool} from '../../interfaces/IPool.sol';
import {FTHToken} from './FTHToken.sol';
/**
* @title FintochPool contract
*
* @notice Main point of interaction with an Fintoch protocol's market
* - Users can:
* # Supply
* # Withdraw
* # Borrow
* # Repay
* # Swap their loans between variable and stable rate
* # Enable/disable their supplied assets as collateral rebalance stable rate borrow positions
* # Liquidate positions
* # Execute Flash Loans
* @dev To be covered by a proxy contract, owned by the PoolAddressesProvider of the specific market
* @dev All admin functions are callable by the PoolConfigurator contract defined also in the
* PoolAddressesProvider
**/
contract FintochPool is FTHToken, IPool {
uint256 public constant POOL_REVISION = 0x2;
IInvestmentEarnings public immutable INVESTMENT_EARNINGS_CONTRACT;
address public immutable SRC_TOKEN; // 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE stands for ETH
uint constant public MAX_OWNER_COUNT = 9;
// The N addresses which control the funds in this contract. The
// owners of M of these addresses will need to both sign a message
// allowing the funds in this contract to be spent.
mapping(address => bool) private isOwner;
address[] private owners;
uint private immutable required;
// The contract nonce is not accessible to the contract so we
// implement a nonce-like variable for replay protection.
uint256 private spendNonce = 0;
uint public allowInternalCall = 1;
bytes4 private constant TRANSFER_SELECTOR = bytes4(keccak256(bytes('transfer(address,uint256)')));
bytes4 private constant TRANSFER_FROM_SELECTOR = bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));
address private constant ETH_CONTRACT = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
// An event sent when funds are received.
event Funded(address from, uint value);
// An event sent when a setAllowInternalCall is triggered.
event AllowInternalCallUpdated(uint value);
// An event sent when a spend is triggered to the given address.
event Spent(address to, uint transfer);
// An event sent when a spendERC20 is triggered to the given address.
event SpentERC20(address erc20contract, address to, uint transfer);
modifier validRequirement(uint ownerCount, uint _required) {
require(ownerCount <= MAX_OWNER_COUNT
&& _required <= ownerCount
&& _required >= 1);
_;
}
/**
* @dev Constructor.
* @param _owners List of initial owners.
* @param _required Number of required confirmations.
*/
constructor(
IInvestmentEarnings investmentEarnings,
address srcToken,
address[] memory _owners,
uint _required
) validRequirement(_owners.length, _required) {
INVESTMENT_EARNINGS_CONTRACT = investmentEarnings;
SRC_TOKEN = srcToken;
for (uint i = 0; i < _owners.length; i++) {
//onwer should be distinct, and non-zero
if (isOwner[_owners[i]] || _owners[i] == address(0x0)) {
revert();
}
isOwner[_owners[i]] = true;
}
owners = _owners;
required = _required;
}
/**
* @dev Leaves the contract without owners. It will not be possible to call
* with signature check anymore. Can only be called by the current owners.
*
* NOTE: Renouncing ownership will leave the contract without owners,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership(uint8[] calldata vs, bytes32[] calldata rs, bytes32[] calldata ss) external {
bytes32 renounceOwnershipTypeHash = keccak256("RenounceOwnership(uint256 spendNonce)");
bytes32 digest = keccak256(
abi.encodePacked(
'\x19\x01',
DOMAIN_SEPARATOR,
keccak256(abi.encode(renounceOwnershipTypeHash, spendNonce))
)
);
require(_validMsgSignature(digest, vs, rs, ss), "invalid signatures");
for (uint i = 0; i < owners.length; i++) {
isOwner[owners[i]] = false;
}
delete owners;
}
// The receive function for this contract.
receive() external payable {
if (msg.value > 0) {
emit Funded(msg.sender, msg.value);
}
}
// @dev Returns list of owners.
// @return List of owner addresses.
function getOwners() external view returns (address[] memory) {
return owners;
}
function getSpendNonce() external view returns (uint256) {
return spendNonce;
}
function getRequired() external view returns (uint) {
return required;
}
function _safeTransfer(address token, address to, uint value) private {
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(TRANSFER_SELECTOR, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), 'FintochPool: TRANSFER_FAILED');
}
function _safeTransferFrom(address token, address from, address to, uint value) private {
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(TRANSFER_FROM_SELECTOR, from, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), 'FintochPool: TRANSFER_FROM_FAILED');
}
// Generates the message to sign given the output destination address and amount.
// includes this contract's address and a nonce for replay protection.
// One option to independently verify: https://leventozturk.com/engineering/sha3/ and select keccak
function generateMessageToSign(address erc20Contract, address destination, uint256 value) private view returns (bytes32) {
require(destination != address(this));
//the sequence should match generateMultiSigV2 in JS
bytes32 message = keccak256(abi.encodePacked(address(this), erc20Contract, destination, value, spendNonce));
return message;
}
function _messageToRecover(address erc20Contract, address destination, uint256 value) private view returns (bytes32) {
bytes32 hashedUnsignedMessage = generateMessageToSign(erc20Contract, destination, value);
bytes memory prefix = "\x19Ethereum Signed Message:\n32";
return keccak256(abi.encodePacked(prefix, hashedUnsignedMessage));
}
/**
* @param _allowInternalCall: the new allowInternalCall value.
* @param vs, rs, ss: the signatures
*/
function setAllowInternalCall(uint _allowInternalCall, uint8[] calldata vs, bytes32[] calldata rs, bytes32[] calldata ss) external {
require(_validSignature(address(this), msg.sender, _allowInternalCall, vs, rs, ss), "invalid signatures");
spendNonce = spendNonce + 1;
allowInternalCall = _allowInternalCall;
emit AllowInternalCallUpdated(allowInternalCall);
}
/**
* @param destination: the ether receiver address.
* @param value: the ether value, in wei.
* @param vs, rs, ss: the signatures
*/
function spend(address destination, uint256 value, uint8[] calldata vs, bytes32[] calldata rs, bytes32[] calldata ss) external {
require(destination != address(this), "Not allow sending to yourself");
require(address(this).balance >= value && value > 0, "balance or spend value invalid");
require(_validSignature(address(0x0), destination, value, vs, rs, ss), "invalid signatures");
spendNonce = spendNonce + 1;
(bool success,) = destination.call{value : value}("");
require(success, "transfer fail");
emit Spent(destination, value);
}
/**
* @param erc20contract: the erc20 contract address.
* @param destination: the token receiver address.
* @param value: the token value, in token minimum unit.
* @param vs, rs, ss: the signatures
*/
function spendERC20(address destination, address erc20contract, uint256 value, uint8[] calldata vs, bytes32[] calldata rs, bytes32[] calldata ss) external {
require(destination != address(this), "Not allow sending to yourself");
//transfer erc20 token
require(value > 0, "Erc20 spend value invalid");
require(_validSignature(erc20contract, destination, value, vs, rs, ss), "invalid signatures");
spendNonce = spendNonce + 1;
// transfer tokens from this contract to the destination address
_safeTransfer(erc20contract, destination, value);
emit SpentERC20(erc20contract, destination, value);
}
/**
* @param destination: the token receiver address.
* @param value: the token value, in token minimum unit.
*/
function redemption(address destination, uint256 value) external {
require(destination != address(this), "Not allow sending to yourself");
//transfer erc20 token
require(value > 0, "withdraw value invalid");
_burn(msg.sender, value);
if (SRC_TOKEN == ETH_CONTRACT) {
// transfer ETH
(bool success,) = destination.call{value : value}("");
require(success, "transfer fail");
} else {
// transfer erc20 token
_safeTransfer(SRC_TOKEN, destination, value);
}
emit Redeemed(msg.sender, destination, SRC_TOKEN, value);
}
function mint(address destination, uint256 value) external payable {
require(destination != address(0), 'ERC20: mint to the zero address');
uint256 mintAmount = msg.value;
if (SRC_TOKEN != ETH_CONTRACT) {
// transfer erc20 token
mintAmount = value;
_safeTransferFrom(SRC_TOKEN, msg.sender, address(this), mintAmount);
}
_mint(destination, mintAmount);
emit Mint(msg.sender, destination, mintAmount);
}
function cancelReinvest(string calldata orderId) external {
uint256 size;
address callerAddress = msg.sender;
assembly {
size := extcodesize(callerAddress)
}
require(size == 0 || allowInternalCall == 1, "forbidden");
INVESTMENT_EARNINGS_CONTRACT.noteCancelReinvest(orderId);
}
function withdrawalIncome(uint64[] calldata recordIds) external {
uint256 size;
address callerAddress = msg.sender;
assembly {
size := extcodesize(callerAddress)
}
require(size == 0 || allowInternalCall == 1, "forbidden");
for (uint i = 0; i < recordIds.length; i++) {
require(recordIds[i] > 0, "invalid record id");
for (uint j = 0; j < i; j++) {
if (recordIds[i] == recordIds[j]) {
revert("duplicate record id");
}
}
}
INVESTMENT_EARNINGS_CONTRACT.noteWithdrawal(recordIds);
}
// Confirm that the signature triplets (v1, r1, s1) (v2, r2, s2) ...
// authorize a spend of this contract's funds to the given destination address.
function _validMsgSignature(
bytes32 message,
uint8[] calldata vs,
bytes32[] calldata rs,
bytes32[] calldata ss
) private view returns (bool) {
require(vs.length == rs.length);
require(rs.length == ss.length);
require(vs.length <= owners.length);
require(vs.length >= required);
address[] memory addrs = new address[](vs.length);
for (uint i = 0; i < vs.length; i++) {
//recover the address associated with the public key from elliptic curve signature or return zero on error
addrs[i] = ecrecover(message, vs[i] + 27, rs[i], ss[i]);
}
require(_distinctOwners(addrs));
return true;
}
// Confirm that the signature triplets (v1, r1, s1) (v2, r2, s2) ...
// authorize a spend of this contract's funds to the given destination address.
function _validSignature(
address erc20Contract,
address destination,
uint256 value,
uint8[] calldata vs,
bytes32[] calldata rs,
bytes32[] calldata ss
) private view returns (bool) {
bytes32 message = _messageToRecover(erc20Contract, destination, value);
return _validMsgSignature(message, vs, rs, ss);
}
// Confirm the addresses as distinct owners of this contract.
function _distinctOwners(address[] memory addrs) private view returns (bool) {
if (addrs.length > owners.length) {
return false;
}
for (uint i = 0; i < addrs.length; i++) {
if (!isOwner[addrs[i]]) {
return false;
}
//address should be distinct
for (uint j = 0; j < i; j++) {
if (addrs[i] == addrs[j]) {
return false;
}
}
}
return true;
}
}
Compiler settingsShow
{
"metadata": {
"bytecodeHash": "ipfs"
},
"libraries": {},
"optimizer": {
"runs": 199,
"enabled": true
},
"evmVersion": "london",
"remappings": []
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.