Corn Silo Zap V1 Contract Implementation
GitHub Repoβ
The Corn Silo Zap implementation is available on the following repo.
Overviewβ
- Inherits:
UUPSUpgradeable
,AuthNoOwner
,PausableUpgradeable
- This contract takes various assets, converts them into Corn Silo-approved assets, and deposits them for the user in one transaction.
State Variablesβ
- cornSilo (
ICornSilo
): The Corn Silo contract. - BTCN (
IERC20
): The Bitcorn (BTCN) token. - CORN_ETH (
ICornEth
): The Ethereum-based Corn token. - SDAI (
ISDai
): The staked DAI token. - DAI (
IERC20
): The DAI stablecoin. - USDC (
IERC20
): The USDC stablecoin. - PSM (
IDssPsm
): The MakerDAO Peg Stability Mechanism (PSM) contract for DAI.
Errorsβ
- ZeroDeposit: Raised when a deposit amount is zero.
Functionsβ
Admin Functionsβ
initializeβ
Initializes the Zap contract and authorizes asset approval for PSM, SDAI, and Corn Silo.
function initialize(address _authority) external initializer;
pauseβ
Pauses all deposit-related actions. Only callable by the contract admin.
function pause() external requiresAuth;
unpauseβ
Unpauses deposit-related actions. Only callable by the contract admin.
function unpause() external requiresAuth;
_authorizeUpgradeβ
Ensures only authorized upgrades.
function _authorizeUpgrade(address target) internal override requiresAuth;
Deposit Functionsβ
depositUSDCβ
Deposits USDC into the Corn Silo, converting it to sDAI via the MakerDAO PSM.
function depositUSDC(uint256 usdcAmount, uint256 minAmountOut) public whenNotPaused;
- usdcAmount: Amount of USDC to deposit.
- minAmountOut: Minimum amount of sDAI expected after conversion.
depositDAIβ
Deposits DAI directly into the Corn Silo, converting it to sDAI first.
function depositDAI(uint256 daiAmount, uint256 minAmountOut) public whenNotPaused;
- daiAmount: Amount of DAI to deposit.
- minAmountOut: Minimum amount of sDAI expected after staking.
Utility Functionsβ
sweepβ
Transfers any stuck tokens or Ether from the contract to the admin.
function sweep(IERC20 token) external requiresAuth;
- token: The ERC20 token to transfer.