Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- Homa
- Optimization enabled
- true
- Compiler version
- v0.8.18+commit.87f61d96
- Optimization runs
- 20000
- EVM Version
- default
- Verified at
- 2024-02-07T08:09:10.298938Z
contracts/homa/Homa.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;
import {IHoma} from "./IHoma.sol";
/// @title Homa Predeploy Contract
/// @author Acala Developers
/// @notice You can use this predeploy contract to call homa pallet
/// @dev This contracts will interact with homa pallet
contract Homa is IHoma {
/// @dev The Homa precompile address.
address private constant PRECOMPILE =
address(0x0000000000000000000000000000000000000407);
/// @inheritdoc IHoma
function mint(uint256 mintAmount) public override returns (bool) {
require(mintAmount != 0, "Homa: mintAmount is zero");
(bool success, bytes memory returnData) = PRECOMPILE.call(
abi.encodeWithSignature(
"mint(address,uint256)",
msg.sender,
mintAmount
)
);
assembly {
if eq(success, 0) {
revert(add(returnData, 0x20), returndatasize())
}
}
emit Minted(msg.sender, mintAmount);
return true;
}
/// @inheritdoc IHoma
function requestRedeem(
uint256 redeemAmount,
bool fastMatch
) public override returns (bool) {
require(redeemAmount != 0, "Homa: redeemAmount is zero");
(bool success, bytes memory returnData) = PRECOMPILE.call(
abi.encodeWithSignature(
"requestRedeem(address,uint256,bool)",
msg.sender,
redeemAmount,
fastMatch
)
);
assembly {
if eq(success, 0) {
revert(add(returnData, 0x20), returndatasize())
}
}
emit RequestedRedeem(msg.sender, redeemAmount, fastMatch);
return true;
}
/// @inheritdoc IHoma
function getExchangeRate() public view override returns (uint256) {
(bool success, bytes memory returnData) = PRECOMPILE.staticcall(
abi.encodeWithSignature("getExchangeRate()")
);
assembly {
if eq(success, 0) {
revert(add(returnData, 0x20), returndatasize())
}
}
return abi.decode(returnData, (uint256));
}
/// @inheritdoc IHoma
function getEstimatedRewardRate() public view override returns (uint256) {
(bool success, bytes memory returnData) = PRECOMPILE.staticcall(
abi.encodeWithSignature("getEstimatedRewardRate()")
);
assembly {
if eq(success, 0) {
revert(add(returnData, 0x20), returndatasize())
}
}
return abi.decode(returnData, (uint256));
}
/// @inheritdoc IHoma
function getCommissionRate() public view override returns (uint256) {
(bool success, bytes memory returnData) = PRECOMPILE.staticcall(
abi.encodeWithSignature("getCommissionRate()")
);
assembly {
if eq(success, 0) {
revert(add(returnData, 0x20), returndatasize())
}
}
return abi.decode(returnData, (uint256));
}
/// @inheritdoc IHoma
function getFastMatchFee() public view override returns (uint256) {
(bool success, bytes memory returnData) = PRECOMPILE.staticcall(
abi.encodeWithSignature("getFastMatchFee()")
);
assembly {
if eq(success, 0) {
revert(add(returnData, 0x20), returndatasize())
}
}
return abi.decode(returnData, (uint256));
}
}
contracts/homa/IHoma.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;
/// @title Homa Predeploy Contract Interface
/// @author Acala Developers
/// @notice You can use this predeploy contract to call homa pallet
/// @dev The interface through which solidity contracts will interact with homa pallet
interface IHoma {
/// @notice Minted liquid currency event.
/// @param sender The sender of the transaction.
/// @param amount The minted amount.
event Minted(address indexed sender, uint256 amount);
/// @notice Requested redeem event.
/// @param sender The sender of the transaction.
/// @param amount The requested amount.
/// @param fastMatch Allow the request to be fast matched.
event RequestedRedeem(
address indexed sender,
uint256 amount,
bool fastMatch
);
/// @notice Mint liquid currency with staking currency.
/// @dev It'll emit an {Minted} event.
/// @param mintAmount The amount of staking currency used to mint liquid currency.
/// @return Returns a boolean value indicating whether the operation succeeded.
function mint(uint256 mintAmount) external returns (bool);
/// @notice Request to redeem liquid curency for staking currency.
/// @dev It'll emit an {RequestedRedeem} event.
/// @param redeemAmount The amount of liquid currency to be requested redeemed into Staking currency.
/// @param fastMatch Allow the request to be fast matched, fast match will take a fixed rate as fee.
/// @return Returns a boolean value indicating whether the operation succeeded.
function requestRedeem(
uint256 redeemAmount,
bool fastMatch
) external returns (bool);
/// @notice Get exchange rate.
/// @return returns (exchange_rate), value is FixedU128 with a range of
/// [0.000000000000000000, 340282366920938463463.374607431768211455]
function getExchangeRate() external view returns (uint256);
/// @notice Get estimated reward rate.
/// @return returns (reward_rate), value is FixedU128 with a range of
/// [0.000000000000000000, 340282366920938463463.374607431768211455].
function getEstimatedRewardRate() external view returns (uint256);
/// @notice Get commission rate.
/// @return returns (commission_rate) is a FixedU128 representing a decimal.
function getCommissionRate() external view returns (uint256);
/// @notice Get fast match fee rate.
/// @return returns (fast_match_fee) is a FixedU128 representing a decimal.
function getFastMatchFee() external view returns (uint256);
}
Compiler Settings
{"outputSelection":{"*":{"*":["*"],"":["*"]}},"optimizer":{"runs":20000,"enabled":true},"libraries":{}}
Contract ABI
[{"type":"event","name":"Minted","inputs":[{"type":"address","name":"sender","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"RequestedRedeem","inputs":[{"type":"address","name":"sender","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false},{"type":"bool","name":"fastMatch","internalType":"bool","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getCommissionRate","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getEstimatedRewardRate","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getExchangeRate","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getFastMatchFee","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"mint","inputs":[{"type":"uint256","name":"mintAmount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"requestRedeem","inputs":[{"type":"uint256","name":"redeemAmount","internalType":"uint256"},{"type":"bool","name":"fastMatch","internalType":"bool"}]}]
Contract Creation Code
0x608060405234801561001057600080fd5b5061071a806100206000396000f3fe608060405234801561001057600080fd5b50600436106100725760003560e01c8063c18290dd11610050578063c18290dd146100c8578063d313f77e146100d0578063e6aa216c146100d857600080fd5b80633e4eb36c1461007757806350f9c24514610092578063a0712d68146100b5575b600080fd5b61007f6100e0565b6040519081526020015b60405180910390f35b6100a56100a036600461064e565b6101ba565b6040519015158152602001610089565b6100a56100c3366004610683565b61036b565b61007f610507565b61007f610574565b61007f6105e1565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f3e4eb36c000000000000000000000000000000000000000000000000000000001790529051600091829182916104079161014d919061069c565b600060405180830381855afa9150503d8060008114610188576040519150601f19603f3d011682016040523d82523d6000602084013e61018d565b606091505b5090925090508161019f573d60208201fd5b808060200190518101906101b391906106cb565b9250505090565b60008260000361022b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f486f6d613a2072656465656d416d6f756e74206973207a65726f00000000000060448201526064015b60405180910390fd5b604051336024820152604481018490528215156064820152600090819061040790608401604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fc941744a00000000000000000000000000000000000000000000000000000000179052516102d0919061069c565b6000604051808303816000865af19150503d806000811461030d576040519150601f19603f3d011682016040523d82523d6000602084013e610312565b606091505b50909250905081610324573d60208201fd5b60408051868152851515602082015233917f982867307a227b336c567c7a2aadffd8b9b349a837bfb422794d8b5899f78f79910160405180910390a2506001949350505050565b6000816000036103d7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f486f6d613a206d696e74416d6f756e74206973207a65726f00000000000000006044820152606401610222565b60405133602482015260448101839052600090819061040790606401604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f40c10f190000000000000000000000000000000000000000000000000000000017905251610474919061069c565b6000604051808303816000865af19150503d80600081146104b1576040519150601f19603f3d011682016040523d82523d6000602084013e6104b6565b606091505b509092509050816104c8573d60208201fd5b60405184815233907f30385c845b448a36257a6a1716e6ad2e1bc2cbe333cde1e69fe849ad6511adfe9060200160405180910390a25060019392505050565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fc18290dd000000000000000000000000000000000000000000000000000000001790529051600091829182916104079161014d919061069c565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fd313f77e000000000000000000000000000000000000000000000000000000001790529051600091829182916104079161014d919061069c565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fe6aa216c000000000000000000000000000000000000000000000000000000001790529051600091829182916104079161014d919061069c565b6000806040838503121561066157600080fd5b823591506020830135801515811461067857600080fd5b809150509250929050565b60006020828403121561069557600080fd5b5035919050565b6000825160005b818110156106bd57602081860181015185830152016106a3565b506000920191825250919050565b6000602082840312156106dd57600080fd5b505191905056fea264697066735822122095af2506f9241235cc9f34ab889bdd18f0643e1c20bec89d0663c120ebe716a764736f6c63430008120033
Deployed ByteCode
0x608060405234801561001057600080fd5b50600436106100725760003560e01c8063c18290dd11610050578063c18290dd146100c8578063d313f77e146100d0578063e6aa216c146100d857600080fd5b80633e4eb36c1461007757806350f9c24514610092578063a0712d68146100b5575b600080fd5b61007f6100e0565b6040519081526020015b60405180910390f35b6100a56100a036600461064e565b6101ba565b6040519015158152602001610089565b6100a56100c3366004610683565b61036b565b61007f610507565b61007f610574565b61007f6105e1565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f3e4eb36c000000000000000000000000000000000000000000000000000000001790529051600091829182916104079161014d919061069c565b600060405180830381855afa9150503d8060008114610188576040519150601f19603f3d011682016040523d82523d6000602084013e61018d565b606091505b5090925090508161019f573d60208201fd5b808060200190518101906101b391906106cb565b9250505090565b60008260000361022b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f486f6d613a2072656465656d416d6f756e74206973207a65726f00000000000060448201526064015b60405180910390fd5b604051336024820152604481018490528215156064820152600090819061040790608401604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fc941744a00000000000000000000000000000000000000000000000000000000179052516102d0919061069c565b6000604051808303816000865af19150503d806000811461030d576040519150601f19603f3d011682016040523d82523d6000602084013e610312565b606091505b50909250905081610324573d60208201fd5b60408051868152851515602082015233917f982867307a227b336c567c7a2aadffd8b9b349a837bfb422794d8b5899f78f79910160405180910390a2506001949350505050565b6000816000036103d7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f486f6d613a206d696e74416d6f756e74206973207a65726f00000000000000006044820152606401610222565b60405133602482015260448101839052600090819061040790606401604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f40c10f190000000000000000000000000000000000000000000000000000000017905251610474919061069c565b6000604051808303816000865af19150503d80600081146104b1576040519150601f19603f3d011682016040523d82523d6000602084013e6104b6565b606091505b509092509050816104c8573d60208201fd5b60405184815233907f30385c845b448a36257a6a1716e6ad2e1bc2cbe333cde1e69fe849ad6511adfe9060200160405180910390a25060019392505050565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fc18290dd000000000000000000000000000000000000000000000000000000001790529051600091829182916104079161014d919061069c565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fd313f77e000000000000000000000000000000000000000000000000000000001790529051600091829182916104079161014d919061069c565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fe6aa216c000000000000000000000000000000000000000000000000000000001790529051600091829182916104079161014d919061069c565b6000806040838503121561066157600080fd5b823591506020830135801515811461067857600080fd5b809150509250929050565b60006020828403121561069557600080fd5b5035919050565b6000825160005b818110156106bd57602081860181015185830152016106a3565b506000920191825250919050565b6000602082840312156106dd57600080fd5b505191905056fea264697066735822122095af2506f9241235cc9f34ab889bdd18f0643e1c20bec89d0663c120ebe716a764736f6c63430008120033