Address Contract Partially Verified
Address
0x1EB4CF3A948E7D72A198fe073cCb8C7a948cD853
Balance
0 ETH
Nonce
1
Code Size
8140 bytes
Creator
0xdA0C0de0...0445 at tx 0x9a5f3038...3c8190
Indexed Transactions
0
Contract Bytecode
8140 bytes
0x608060405234801561001057600080fd5b50600436106101165760003560e01c80638237e538116100a2578063bf353dbb11610071578063bf353dbb146104af578063c11645bc14610507578063d9d98ce41461053b578063f4b9fa751461059d578063f8ba4cff146105d157610116565b80638237e538146104255780638878e8c71461044357806391bbdcc7146104615780639c52a7f11461046b57610116565b80635cffe9de116100e95780635cffe9de1461025e578063613255ab14610337578063626cb3c51461038f57806365fae35e146103c35780636ac5db191461040757610116565b8063285aaa201461011b57806329ae81141461013957806336569e77146101715780633f03653f146101a5575b600080fd5b6101236105db565b6040518082815260200191505060405180910390f35b61016f6004803603604081101561014f57600080fd5b8101908080359060200190929190803590602001909291905050506105e1565b005b61017961082f565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610246600480360360608110156101bb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291908035906020019064010000000081111561020257600080fd5b82018360208201111561021457600080fd5b8035906020019184600183028401116401000000008311171561023657600080fd5b9091929391929390505050610853565b60405180821515815260200191505060405180910390f35b61031f6004803603608081101561027457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001906401000000008111156102db57600080fd5b8201836020820111156102ed57600080fd5b8035906020019184600183028401116401000000008311171561030f57600080fd5b9091929391929390505050610ec2565b60405180821515815260200191505060405180910390f35b6103796004803603602081101561034d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061167a565b6040518082815260200191505060405180910390f35b6103976116f2565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610405600480360360208110156103d957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611716565b005b61040f611854565b6040518082815260200191505060405180910390f35b61042d61185a565b6040518082815260200191505060405180910390f35b61044b61187e565b6040518082815260200191505060405180910390f35b6104696118a2565b005b6104ad6004803603602081101561048157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611a98565b005b6104f1600480360360208110156104c557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611bd6565b6040518082815260200191505060405180910390f35b61050f611bee565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6105876004803603604081101561055157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611c12565b6040518082815260200191505060405180910390f35b6105a5611cfa565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6105d9611d1e565b005b60025481565b60016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414610695576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260178152602001807f447373466c6173682f6e6f742d617574686f72697a656400000000000000000081525060200191505060405180910390fd5b7f6d6178000000000000000000000000000000000000000000000000000000000082141561075057722cd76fe086b93ce2f768a00b22a00000000000816001819055111561074b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f447373466c6173682f6365696c696e672d746f6f2d686967680000000000000081525060200191505060405180910390fd5b6107f3565b7f746f6c6c0000000000000000000000000000000000000000000000000000000082141561078457806002819055506107f2565b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f447373466c6173682f66696c652d756e7265636f676e697a65642d706172616d81525060200191505060405180910390fd5b5b817fe986e40cc8c151830d4f61050f4fb2e4add8567caad2d5f5496f9158e91fe4c7826040518082815260200191505060405180910390a25050565b7f00000000000000000000000035d1b3f3d7966a1dfe207aa4514c12a259a0492b81565b600080600354146108cc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f447373466c6173682f7265656e7472616e63792d67756172640000000000000081525060200191505060405180910390fd5b60016003819055506108ec6001546b033b2e3c9fd0803ce8000000611f50565b841115610961576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f447373466c6173682f6365696c696e672d65786365656465640000000000000081525060200191505060405180910390fd5b60007f00000000000000000000000035d1b3f3d7966a1dfe207aa4514c12a259a0492b73ffffffffffffffffffffffffffffffffffffffff16636c25b346306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156109ea57600080fd5b505afa1580156109fe573d6000803e3d6000fd5b505050506040513d6020811015610a1457600080fd5b810190808051906020019092919050505090506000670de0b6b3a7640000610a3e87600254611f50565b81610a4557fe5b0490507f00000000000000000000000035d1b3f3d7966a1dfe207aa4514c12a259a0492b73ffffffffffffffffffffffffffffffffffffffff1663f24e23eb3089896040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050600060405180830381600087803b158015610af757600080fd5b505af1158015610b0b573d6000803e3d6000fd5b505050508673ffffffffffffffffffffffffffffffffffffffff167fbca56acc64a74a4c131755895cf7f72fc3f9e39af64241f7ad0f77e86f41ada98783604051808381526020018281526020019250505060405180910390a27f0cceaa4ec34688ca5ae62e4ade215985d2d08dffd7fdb3eb79768a5dc372e8b18773ffffffffffffffffffffffffffffffffffffffff166342bf04b63389858a8a6040518663ffffffff1660e01b8152600401808673ffffffffffffffffffffffffffffffffffffffff168152602001858152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509650505050505050602060405180830381600087803b158015610c3357600080fd5b505af1158015610c47573d6000803e3d6000fd5b505050506040513d6020811015610c5d57600080fd5b810190808051906020019092919050505014610ce1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f447373466c6173682f63616c6c6261636b2d6661696c6564000000000000000081525060200191505060405180910390fd5b7f00000000000000000000000035d1b3f3d7966a1dfe207aa4514c12a259a0492b73ffffffffffffffffffffffffffffffffffffffff1663f37ac61c876040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b158015610d5457600080fd5b505af1158015610d68573d6000803e3d6000fd5b50505050610d768282611f7c565b7f00000000000000000000000035d1b3f3d7966a1dfe207aa4514c12a259a0492b73ffffffffffffffffffffffffffffffffffffffff16636c25b346306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015610dfd57600080fd5b505afa158015610e11573d6000803e3d6000fd5b505050506040513d6020811015610e2757600080fd5b81019080805190602001909291905050501015610eac576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f447373466c6173682f696e73756666696369656e742d6665650000000000000081525060200191505060405180910390fd5b6001925050506000600381905550949350505050565b60008060035414610f3b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f447373466c6173682f7265656e7472616e63792d67756172640000000000000081525060200191505060405180910390fd5b60016003819055507f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614611004576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f447373466c6173682f746f6b656e2d756e737570706f7274656400000000000081525060200191505060405180910390fd5b60015484111561107c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f447373466c6173682f6365696c696e672d65786365656465640000000000000081525060200191505060405180910390fd5b6000611094856b033b2e3c9fd0803ce8000000611f50565b90506000670de0b6b3a76400006110ad87600254611f50565b816110b457fe5b04905060006110c38783611f7c565b90507f00000000000000000000000035d1b3f3d7966a1dfe207aa4514c12a259a0492b73ffffffffffffffffffffffffffffffffffffffff1663f24e23eb3030866040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050600060405180830381600087803b15801561117457600080fd5b505af1158015611188573d6000803e3d6000fd5b505050507f0000000000000000000000009759a6ac90977b93b58547b4a71c78317f391a2873ffffffffffffffffffffffffffffffffffffffff1663ef693bed8a896040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b15801561121d57600080fd5b505af1158015611231573d6000803e3d6000fd5b505050508873ffffffffffffffffffffffffffffffffffffffff167f0d7d75e01ab95780d3cd1c8ec0dd6c2ce19e3a20427eec8bf53283b6fb8e95f0898985604051808473ffffffffffffffffffffffffffffffffffffffff168152602001838152602001828152602001935050505060405180910390a27f439148f0bbc682ca079e46d6e2c2f0c1e3b820f1a291b069d8882abf8cf18dd98973ffffffffffffffffffffffffffffffffffffffff166323e30c8b338b8b878c8c6040518763ffffffff1660e01b8152600401808773ffffffffffffffffffffffffffffffffffffffff1681526020018673ffffffffffffffffffffffffffffffffffffffff168152602001858152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f820116905080830192505050975050505050505050602060405180830381600087803b15801561139557600080fd5b505af11580156113a9573d6000803e3d6000fd5b505050506040513d60208110156113bf57600080fd5b810190808051906020019092919050505014611443576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f447373466c6173682f63616c6c6261636b2d6661696c6564000000000000000081525060200191505060405180910390fd5b7f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f73ffffffffffffffffffffffffffffffffffffffff166323b872dd8a30846040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b1580156114f257600080fd5b505af1158015611506573d6000803e3d6000fd5b505050506040513d602081101561151c57600080fd5b8101908080519060200190929190505050507f0000000000000000000000009759a6ac90977b93b58547b4a71c78317f391a2873ffffffffffffffffffffffffffffffffffffffff16633b4da69f30836040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b1580156115bf57600080fd5b505af11580156115d3573d6000803e3d6000fd5b505050507f00000000000000000000000035d1b3f3d7966a1dfe207aa4514c12a259a0492b73ffffffffffffffffffffffffffffffffffffffff1663f37ac61c846040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561164a57600080fd5b505af115801561165e573d6000803e3d6000fd5b5050505060019350505050600060038190555095945050505050565b60007f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161480156116d957506000600354145b156116e85760015490506116ed565b600090505b919050565b7f000000000000000000000000a950524441892a31ebddf91d3ceefa04bf45446681565b60016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054146117ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260178152602001807f447373466c6173682f6e6f742d617574686f72697a656400000000000000000081525060200191505060405180910390fd5b60016000808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508073ffffffffffffffffffffffffffffffffffffffff167fdd0e34038ac38b2a1ce960229778ac48a8719bc900b6c4f8d0475c6e8b385a6060405160405180910390a250565b60015481565b7f439148f0bbc682ca079e46d6e2c2f0c1e3b820f1a291b069d8882abf8cf18dd981565b7f0cceaa4ec34688ca5ae62e4ade215985d2d08dffd7fdb3eb79768a5dc372e8b181565b60006003541461191a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f447373466c6173682f7265656e7472616e63792d67756172640000000000000081525060200191505060405180910390fd5b60016003819055507f0000000000000000000000009759a6ac90977b93b58547b4a71c78317f391a2873ffffffffffffffffffffffffffffffffffffffff16633b4da69f307f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f73ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1580156119e857600080fd5b505af11580156119fc573d6000803e3d6000fd5b505050506040513d6020811015611a1257600080fd5b81019080805190602001909291905050506040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b158015611a7657600080fd5b505af1158015611a8a573d6000803e3d6000fd5b505050506000600381905550565b60016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414611b4c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260178152602001807f447373466c6173682f6e6f742d617574686f72697a656400000000000000000081525060200191505060405180910390fd5b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508073ffffffffffffffffffffffffffffffffffffffff167f184450df2e323acec0ed3b5c7531b81f9b4cdef7914dfd4c0a4317416bb5251b60405160405180910390a250565b60006020528060005260406000206000915090505481565b7f0000000000000000000000009759a6ac90977b93b58547b4a71c78317f391a2881565b60007f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614611cd5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f447373466c6173682f746f6b656e2d756e737570706f7274656400000000000081525060200191505060405180910390fd5b670de0b6b3a7640000611cea83600254611f50565b81611cf157fe5b04905092915050565b7f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f81565b600060035414611d96576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f447373466c6173682f7265656e7472616e63792d67756172640000000000000081525060200191505060405180910390fd5b60016003819055507f00000000000000000000000035d1b3f3d7966a1dfe207aa4514c12a259a0492b73ffffffffffffffffffffffffffffffffffffffff1663bb35783b307f000000000000000000000000a950524441892a31ebddf91d3ceefa04bf4544667f00000000000000000000000035d1b3f3d7966a1dfe207aa4514c12a259a0492b73ffffffffffffffffffffffffffffffffffffffff16636c25b346306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015611e8357600080fd5b505afa158015611e97573d6000803e3d6000fd5b505050506040513d6020811015611ead57600080fd5b81019080805190602001909291905050506040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050600060405180830381600087803b158015611f2e57600080fd5b505af1158015611f42573d6000803e3d6000fd5b505050506000600381905550565b600080821480611f6d5750828283850292508281611f6a57fe5b04145b611f7657600080fd5b92915050565b6000828284019150811015611f9057600080fd5b9291505056fea26469706673582212202d33df4a3e1743c69ab21cab7f8f112a87fe7d5a66d47e439bc2b2f4419920d264736f6c634300060c0033
Verified Source Code Partial Match
Compiler: v0.6.12+commit.27d51765
EVM: istanbul
Optimization: No
DssFlash.sol 369 lines
// hevm: flattened sources of src/flash.sol
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity =0.6.12 >=0.6.12;
////// src/interface/IERC3156FlashBorrower.sol
// Copyright (C) 2021 Dai Foundation
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
/* pragma solidity >=0.6.12; */
interface IERC3156FlashBorrower {
/**
* @dev Receive a flash loan.
* @param initiator The initiator of the loan.
* @param token The loan currency.
* @param amount The amount of tokens lent.
* @param fee The additional amount of tokens to repay.
* @param data Arbitrary data structure, intended to contain user-defined parameters.
* @return The keccak256 hash of "ERC3156FlashBorrower.onFlashLoan"
*/
function onFlashLoan(
address initiator,
address token,
uint256 amount,
uint256 fee,
bytes calldata data
) external returns (bytes32);
}
////// src/interface/IERC3156FlashLender.sol
// Copyright (C) 2021 Dai Foundation
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
/* pragma solidity >=0.6.12; */
/* import "./IERC3156FlashBorrower.sol"; */
interface IERC3156FlashLender {
/**
* @dev The amount of currency available to be lent.
* @param token The loan currency.
* @return The amount of `token` that can be borrowed.
*/
function maxFlashLoan(
address token
) external view returns (uint256);
/**
* @dev The fee to be charged for a given loan.
* @param token The loan currency.
* @param amount The amount of tokens lent.
* @return The amount of `token` to be charged for the loan, on top of the returned principal.
*/
function flashFee(
address token,
uint256 amount
) external view returns (uint256);
/**
* @dev Initiate a flash loan.
* @param receiver The receiver of the tokens in the loan, and the receiver of the callback.
* @param token The loan currency.
* @param amount The amount of tokens lent.
* @param data Arbitrary data structure, intended to contain user-defined parameters.
*/
function flashLoan(
IERC3156FlashBorrower receiver,
address token,
uint256 amount,
bytes calldata data
) external returns (bool);
}
////// src/interface/IVatDaiFlashBorrower.sol
// Copyright (C) 2021 Dai Foundation
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
/* pragma solidity >=0.6.12; */
interface IVatDaiFlashBorrower {
/**
* @dev Receive a flash loan.
* @param initiator The initiator of the loan.
* @param amount The amount of tokens lent. [rad]
* @param fee The additional amount of tokens to repay. [rad]
* @param data Arbitrary data structure, intended to contain user-defined parameters.
* @return The keccak256 hash of "IVatDaiFlashLoanReceiver.onVatDaiFlashLoan"
*/
function onVatDaiFlashLoan(
address initiator,
uint256 amount,
uint256 fee,
bytes calldata data
) external returns (bytes32);
}
////// src/interface/IVatDaiFlashLender.sol
// Copyright (C) 2021 Dai Foundation
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
/* pragma solidity >=0.6.12; */
/* import "./IVatDaiFlashBorrower.sol"; */
interface IVatDaiFlashLender {
/**
* @dev Initiate a flash loan.
* @param receiver The receiver of the tokens in the loan, and the receiver of the callback.
* @param amount The amount of tokens lent. [rad]
* @param data Arbitrary data structure, intended to contain user-defined parameters.
*/
function vatDaiFlashLoan(
IVatDaiFlashBorrower receiver,
uint256 amount,
bytes calldata data
) external returns (bool);
}
////// src/flash.sol
// Copyright (C) 2021 Dai Foundation
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
/* pragma solidity 0.6.12; */
/* import "./interface/IERC3156FlashLender.sol"; */
/* import "./interface/IERC3156FlashBorrower.sol"; */
/* import "./interface/IVatDaiFlashLender.sol"; */
interface DaiLike {
function balanceOf(address) external returns (uint256);
function transferFrom(address, address, uint256) external returns (bool);
function approve(address, uint256) external returns (bool);
}
interface DaiJoinLike {
function dai() external view returns (address);
function vat() external view returns (address);
function join(address, uint256) external;
function exit(address, uint256) external;
}
interface VatLike_4 {
function hope(address) external;
function dai(address) external view returns (uint256);
function move(address, address, uint256) external;
function heal(uint256) external;
function suck(address, address, uint256) external;
}
contract DssFlash is IERC3156FlashLender, IVatDaiFlashLender {
// --- Auth ---
function rely(address usr) external auth { wards[usr] = 1; emit Rely(usr); }
function deny(address usr) external auth { wards[usr] = 0; emit Deny(usr); }
mapping (address => uint256) public wards;
modifier auth {
require(wards[msg.sender] == 1, "DssFlash/not-authorized");
_;
}
// --- Data ---
VatLike_4 public immutable vat;
DaiJoinLike public immutable daiJoin;
DaiLike public immutable dai;
address public immutable vow; // vow intentionally set immutable to save gas
uint256 public max; // Maximum borrowable Dai [wad]
uint256 public toll; // Fee [wad = 100%]
uint256 private locked; // Reentrancy guard
bytes32 public constant CALLBACK_SUCCESS = keccak256("ERC3156FlashBorrower.onFlashLoan");
bytes32 public constant CALLBACK_SUCCESS_VAT_DAI = keccak256("VatDaiFlashBorrower.onVatDaiFlashLoan");
// --- Events ---
event Rely(address indexed usr);
event Deny(address indexed usr);
event File(bytes32 indexed what, uint256 data);
event FlashLoan(address indexed receiver, address token, uint256 amount, uint256 fee);
event VatDaiFlashLoan(address indexed receiver, uint256 amount, uint256 fee);
modifier lock {
require(locked == 0, "DssFlash/reentrancy-guard");
locked = 1;
_;
locked = 0;
}
// --- Init ---
constructor(address daiJoin_, address vow_) public {
wards[msg.sender] = 1;
emit Rely(msg.sender);
VatLike_4 vat_ = vat = VatLike_4(DaiJoinLike(daiJoin_).vat());
daiJoin = DaiJoinLike(daiJoin_);
DaiLike dai_ = dai = DaiLike(DaiJoinLike(daiJoin_).dai());
vow = vow_;
vat_.hope(daiJoin_);
dai_.approve(daiJoin_, type(uint256).max);
}
// --- Math ---
uint256 constant WAD = 10 ** 18;
uint256 constant RAY = 10 ** 27;
uint256 constant RAD = 10 ** 45;
function _add(uint256 x, uint256 y) internal pure returns (uint256 z) {
require((z = x + y) >= x);
}
function _mul(uint256 x, uint256 y) internal pure returns (uint256 z) {
require(y == 0 || (z = x * y) / y == x);
}
// --- Administration ---
function file(bytes32 what, uint256 data) external auth {
if (what == "max") {
// Add an upper limit of 10^27 DAI to avoid breaking technical assumptions of DAI << 2^256 - 1
require((max = data) <= RAD, "DssFlash/ceiling-too-high");
} else if (what == "toll") toll = data;
else revert("DssFlash/file-unrecognized-param");
emit File(what, data);
}
// --- ERC 3156 Spec ---
function maxFlashLoan(
address token
) external override view returns (uint256) {
if (token == address(dai) && locked == 0) {
return max;
} else {
return 0;
}
}
function flashFee(
address token,
uint256 amount
) external override view returns (uint256) {
require(token == address(dai), "DssFlash/token-unsupported");
return _mul(amount, toll) / WAD;
}
function flashLoan(
IERC3156FlashBorrower receiver,
address token,
uint256 amount,
bytes calldata data
) external override lock returns (bool) {
require(token == address(dai), "DssFlash/token-unsupported");
require(amount <= max, "DssFlash/ceiling-exceeded");
uint256 amt = _mul(amount, RAY);
uint256 fee = _mul(amount, toll) / WAD;
uint256 total = _add(amount, fee);
vat.suck(address(this), address(this), amt);
daiJoin.exit(address(receiver), amount);
emit FlashLoan(address(receiver), token, amount, fee);
require(
receiver.onFlashLoan(msg.sender, token, amount, fee, data) == CALLBACK_SUCCESS,
"DssFlash/callback-failed"
);
dai.transferFrom(address(receiver), address(this), total); // The fee is also enforced here
daiJoin.join(address(this), total);
vat.heal(amt);
return true;
}
// --- Vat Dai Flash Loan ---
function vatDaiFlashLoan(
IVatDaiFlashBorrower receiver, // address of conformant IVatDaiFlashBorrower
uint256 amount, // amount to flash loan [rad]
bytes calldata data // arbitrary data to pass to the receiver
) external override lock returns (bool) {
require(amount <= _mul(max, RAY), "DssFlash/ceiling-exceeded");
uint256 prev = vat.dai(address(this));
uint256 fee = _mul(amount, toll) / WAD;
vat.suck(address(this), address(receiver), amount);
emit VatDaiFlashLoan(address(receiver), amount, fee);
require(
receiver.onVatDaiFlashLoan(msg.sender, amount, fee, data) == CALLBACK_SUCCESS_VAT_DAI,
"DssFlash/callback-failed"
);
vat.heal(amount);
require(vat.dai(address(this)) >= _add(prev, fee), "DssFlash/insufficient-fee");
return true;
}
function convert() external lock {
daiJoin.join(address(this), dai.balanceOf(address(this)));
}
function accrue() external lock {
vat.move(address(this), vow, vat.dai(address(this)));
}
}
Read Contract
CALLBACK_SUCCESS 0x8237e538 → bytes32
CALLBACK_SUCCESS_VAT_DAI 0x8878e8c7 → bytes32
dai 0xf4b9fa75 → address
daiJoin 0xc11645bc → address
flashFee 0xd9d98ce4 → uint256
max 0x6ac5db19 → uint256
maxFlashLoan 0x613255ab → uint256
toll 0x285aaa20 → uint256
vat 0x36569e77 → address
vow 0x626cb3c5 → address
wards 0xbf353dbb → uint256
Write Contract 7 functions
These functions modify contract state and require a wallet transaction to execute.
accrue 0xf8ba4cff
No parameters
convert 0x91bbdcc7
No parameters
deny 0x9c52a7f1
address usr
file 0x29ae8114
bytes32 what
uint256 data
flashLoan 0x5cffe9de
address receiver
address token
uint256 amount
bytes data
returns: bool
rely 0x65fae35e
address usr
vatDaiFlashLoan 0x3f03653f
address receiver
uint256 amount
bytes data
returns: bool
Recent Transactions
No transactions found for this address