You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/** * @dev Create order to mint vAsset or redeem vAsset on bifrost chain * @param assetAddress The address of the asset to mint or redeem * @param amount The amount of the asset to mint or redeem * @param dest_chain_id When order is executed on Bifrost, Asset/vAsset will be transferred to this chain * @param receiver The receiver address on the destination chain, 20 bytes for EVM, 32 bytes for Substrate * @param remark The remark of the order, less than 32 bytes. For example, "OmniLS" * @param channel_id The channel id of the order, you can set it. Bifrost chain will use it to share reward. **/function create_order(
addressassetAddress,
uint128amount,
uint64dest_chain_id,
bytesmemoryreceiver,
stringmemoryremark,
uint32channel_id
) externalpayable;
Examples
Mint 1 DOT into VDOT and send it to Hydration.
Redeem 1 VDOT into DOT and send it to Hydration.
// SPDX-License-Identifier: Apache-2.0pragma solidity0.8.10;
import"./ISlpx.sol";
import"./IERC20.sol";
contractExample {
ISlpx public slpx =ISlpx(0xF1d4797E51a4640a76769A50b57abE7479ADd3d8);
address dot =0xFfFFfFff1FcaCBd218EDc0EbA20Fc2308C778080;
address vdot =0xFFFfffFf15e1b7E3dF971DD813Bc394deB899aBf;
// hydration parachain iduint64 hydration_chain_id =2034;
// Substrate account public keybytes32 receiver =0xa05d045646ecff8760f9bc3ae4266e910a307f0c11250c3f6fe3ae611dbf8f24;
uint128 amount =10_000_000_000;
string remark ="Hello Slpx";
uint32 channel_id =0;
function mint_vdot() publicpayable {
IERC20(dot).transferFrom(msg.sender, address(this), amount);
IERC20(dot).approve(address(slpx), amount);
slpx.create_order(
dot,
amount,
hydration_chain_id,
abi.encodePacked(receiver),
remark,
channel_id
);
//Your contract logic:
}
// Redeem DOT for 0-28 days, once redeemed, it will be sent to the receiver of dest chainfunction redeem_dot() publicpayable {
IERC20(vdot).transferFrom(msg.sender, address(this), amount);
IERC20(vdot).approve(address(slpx), amount);
slpx.create_order(
vdot,
amount,
hydration_chain_id,
abi.encodePacked(receiver),
remark,
channel_id
);
//Your contract logic:
}
}