Open2
Blastメモ
情報メモ
- Blastからトークンを引き出すには14日間かかる
Receive and claim ETH yield
BlastはNativeでステーキング機能が実装されており、モードが3つある
Void(Defauilt)
- デフォルトの動作
- ステーキングしない(ただコントラクトに預けてるだけ)
Automatic
- ステーキングする(コントラクトの残高が増えていく)
- 例:1ETH預けておくと、1年後には1.04ETHになる(年利4%)
Claimable
- ステーキングする(コントラクトの残高は増えないが、別途Claimできる)
- 例:1ETH預けておくと、1年後もコントラクトの残高は1ETHのままだが、別途0.04ETHをClaimできる
どうやってモードを設定するのか?
IBlast Interfaceをコールして設定する
例えば、Automaticを設定したければ、コンストラクタ内でconfigureAutomaticYield()
をコールする
IBlastの本体は0x4300000000000000000000000000000000000002
らしい
enum YieldMode {
AUTOMATIC,
VOID,
CLAIMABLE
}
enum GasMode {
VOID,
CLAIMABLE
}
interface IBlast{
// configure
function configureContract(address contractAddress, YieldMode _yield, GasMode gasMode, address governor) external;
function configure(YieldMode _yield, GasMode gasMode, address governor) external;
// base configuration options
function configureClaimableYield() external;
function configureClaimableYieldOnBehalf(address contractAddress) external;
function configureAutomaticYield() external;
function configureAutomaticYieldOnBehalf(address contractAddress) external;
function configureVoidYield() external;
function configureVoidYieldOnBehalf(address contractAddress) external;
function configureClaimableGas() external;
function configureClaimableGasOnBehalf(address contractAddress) external;
function configureVoidGas() external;
function configureVoidGasOnBehalf(address contractAddress) external;
function configureGovernor(address _governor) external;
function configureGovernorOnBehalf(address _newGovernor, address contractAddress) external;
// claim yield
function claimYield(address contractAddress, address recipientOfYield, uint256 amount) external returns (uint256);
function claimAllYield(address contractAddress, address recipientOfYield) external returns (uint256);
// claim gas
function claimAllGas(address contractAddress, address recipientOfGas) external returns (uint256);
function claimGasAtMinClaimRate(address contractAddress, address recipientOfGas, uint256 minClaimRateBips) external returns (uint256);
function claimMaxGas(address contractAddress, address recipientOfGas) external returns (uint256);
function claimGas(address contractAddress, address recipientOfGas, uint256 gasToClaim, uint256 gasSecondsToConsume) external returns (uint256);
// read functions
function readClaimableYield(address contractAddress) external view returns (uint256);
function readYieldConfiguration(address contractAddress) external view returns (uint8);
function readGasParams(address contractAddress) external view returns (uint256 etherSeconds, uint256 etherBalance, uint256 lastUpdated, GasMode);
}
こんな感じでただのNFTコントラクトにClimableモードを設定してみた。
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {ERC721} from "openzeppelin-contracts/contracts/token/ERC721/ERC721.sol";
import {Ownable} from "openzeppelin-contracts/contracts/access/Ownable.sol";
import {IBlast} from "./IBlast.sol";
contract ClaimableYieldNFT is ERC721, Ownable {
constructor() ERC721("NFT", "NFT") Ownable(msg.sender) {
IBlast(0x4300000000000000000000000000000000000002).configureClaimableYield();
}
uint256 private _ids = 0;
function mint() external {
_mint(msg.sender, _ids);
_ids++;
}
function claimYield(address recipient, uint256 amount) external {
//This function is public meaning anyone can claim the yield
IBlast(0x4300000000000000000000000000000000000002).claimYield(address(this), recipient, amount);
}
function claimAllYield(address recipient) external {
//This function is public meaning anyone can claim the yield
IBlast(0x4300000000000000000000000000000000000002).claimAllYield(address(this), recipient);
}
function readClimableYield() external view returns (uint256) {
return IBlast(0x4300000000000000000000000000000000000002).readClaimableYield(address(this));
}
function withdraw() external onlyOwner {
//This function is public meaning anyone can withdraw the ETH
payable(msg.sender).transfer(address(this).balance);
}
receive() external payable {
//This function is public meaning anyone can send ETH to the contract
}
}
コントラクトに0.5ETHデポジットした後しばらく待つと、こんな感じでClaimできるようになってた
ちなみに、メインネットでは1日おき、テストネットでは1時間ごとに値が更新されるらしい