// SPDX-License-Identifier: AGPL-3.0-onlypragmasolidity ^0.8.7;import { IERC20Like } from"./interfaces/IERC20Like.sol";
/**
* @title Small Library to standardize erc20 token interactions.
*/libraryERC20Helper{
/**************************************************************************************************************************************//*** Internal Functions ***//**************************************************************************************************************************************/functiontransfer(address token_, address to_, uint256 amount_) internalreturns (bool success_) {
return _call(token_, abi.encodeWithSelector(IERC20Like.transfer.selector, to_, amount_));
}
functiontransferFrom(address token_, address from_, address to_, uint256 amount_) internalreturns (bool success_) {
return _call(token_, abi.encodeWithSelector(IERC20Like.transferFrom.selector, from_, to_, amount_));
}
functionapprove(address token_, address spender_, uint256 amount_) internalreturns (bool success_) {
// If setting approval to zero fails, return false.if (!_call(token_, abi.encodeWithSelector(IERC20Like.approve.selector, spender_, uint256(0)))) returnfalse;
// If `amount_` is zero, return true as the previous step already did this.if (amount_ ==uint256(0)) returntrue;
// Return the result of setting the approval to `amount_`.return _call(token_, abi.encodeWithSelector(IERC20Like.approve.selector, spender_, amount_));
}
function_call(address token_, bytesmemory data_) privatereturns (bool success_) {
if (token_.code.length==uint256(0)) returnfalse;
bytesmemory returnData;
( success_, returnData ) = token_.call(data_);
return success_ && (returnData.length==uint256(0) ||abi.decode(returnData, (bool)));
}
}
Contract Source Code
File 2 of 5: IERC20Like.sol
// SPDX-License-Identifier: AGPL-3.0-onlypragmasolidity ^0.8.7;/// @title Interface of the ERC20 standard as needed by ERC20Helper.interfaceIERC20Like{
functionapprove(address spender_, uint256 amount_) externalreturns (bool success_);
functiontransfer(address recipient_, uint256 amount_) externalreturns (bool success_);
functiontransferFrom(address owner_, address recipient_, uint256 amount_) externalreturns (bool success_);
}
Contract Source Code
File 3 of 5: ISyrupRouter.sol
// SPDX-License-Identifier: BUSL-1.1pragmasolidity 0.8.7;interfaceISyrupRouter{
/**
* @dev Optional Deposit Data for off-chain processing.
* @param owner The receiver of the shares.
* @param amount The amount of assets to deposit.
* @param depositData Optional deposit data.
*/eventDepositData(addressindexed owner, uint256 amount, bytes32 depositData);
/**
* @dev The address of the underlying asset used by the ERC4626 Vault.
* @return asset The address of the underlying asset.
*/functionasset() externalviewreturns (address asset);
/**
* @dev Authorizes and deposits assets into the Vault.
* @param bitmap_ The bitmap of the permission.
* @param deadline_ The timestamp after which the `authorize` signature is no longer valid.
* @param auth_v ECDSA signature v component.
* @param auth_r ECDSA signature r component.
* @param auth_s ECDSA signature s component.
* @param amount_ The amount of assets to deposit.
* @param depositData_ Optional deposit data.
* @return shares_ The amount of shares minted.
*/functionauthorizeAndDeposit(uint256 bitmap_,
uint256 deadline_,
uint8 auth_v,
bytes32 auth_r,
bytes32 auth_s,
uint256 amount_,
bytes32 depositData_
) externalreturns (uint256 shares_);
/**
* @dev Authorizes and deposits assets into the Vault with a ERC-2612 `permit`.
* @param bitmap_ The bitmap of the permission.
* @param auth_deadline_ The timestamp after which the `authorize` signature is no longer valid.
* @param auth_v ECDSA signature v component of the authorization.
* @param auth_r ECDSA signature r component of the authorization.
* @param auth_s ECDSA signature s component of the authorization.
* @param amount_ The amount of assets to deposit.
* @param depositData_ Optional deposit data.
* @param permit_deadline The timestamp after which the `permit` signature is no longer valid.
* @param permit_v_ ECDSA signature v component of the token permit.
* @param permit_r_ ECDSA signature r component of the token permit.
* @param permit_s_ ECDSA signature s component of the token permit.
* @return shares_ The amount of shares minted.
*/functionauthorizeAndDepositWithPermit(uint256 bitmap_,
uint256 auth_deadline_,
uint8 auth_v,
bytes32 auth_r,
bytes32 auth_s,
uint256 amount_,
bytes32 depositData_,
uint256 permit_deadline,
uint8 permit_v_,
bytes32 permit_r_,
bytes32 permit_s_
) externalreturns (uint256 shares_);
/**
* @dev Mints `shares` to sender by depositing `assets` into the Vault.
* @param assets The amount of assets to deposit.
* @param depositData Optional deposit data.
* @return shares The amount of shares minted.
*/functiondeposit(uint256 assets, bytes32 depositData) externalreturns (uint256 shares);
/**
* @dev Does a ERC4626 `deposit` into a Maple Pool with a ERC-2612 `permit`.
* @param amount The amount of assets to deposit.
* @param deadline The timestamp after which the `permit` signature is no longer valid.
* @param v ECDSA signature v component.
* @param r ECDSA signature r component.
* @param s ECDSA signature s component.
* @param depositData Optional deposit data.
* @return shares The amount of shares minted.
*/functiondepositWithPermit(uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s, bytes32 depositData)
externalreturns (uint256 shares);
/**
* @dev Returns the nonce for the given owner.
* @param owner_ The address of the owner account.
* @return nonce_ The nonce for the given owner.
*/functionnonces(address owner_) externalviewreturns (uint256 nonce_);
/**
* @dev The address of the ERC4626 Vault.
* @return pool The address of the ERC4626 Vault.
*/functionpool() externalviewreturns (address pool);
/**
* @dev The address of the Pool Manager.
* @return poolManager The address of the Pool Manager.
*/functionpoolManager() externalviewreturns (address poolManager);
/**
* @dev The address of the Pool Permission Manager.
* @return poolPermissionManager The address of the Pool Permission Manager.
*/functionpoolPermissionManager() externalviewreturns (address poolPermissionManager);
}