Skip to main content

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.