Network Name | Moonriver Network Mainnet |
---|---|
Network URL | https://moonriver-rpc.dwellir.com |
Chain ID | 1285 |
Currency Symbol | MOVR |
Block Explorer URL | https://moonriver.moonscan.io/ |
https://github.com/bifrost-finance/slpx-contracts/tree/main/contracts
If you want to integrate SLPx in your contract, please see a sample code.
Among them are calls to the mintVNativeAsset and mintVAsset methods
Because of the use of XCM technology, the result of the call is not real-time, you'd better put the SLPx call at the end of your contract logic.
Copy
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
import "./ISlpx.sol";
import "./IERC20.sol";
contract Test {
address public constant SLPX = 0x6b0A44c64190279f7034b77c13a566E914FE5Ec4;
function test_native_mint (address to) public payable {
// your contract logic.
// ...
// call mint
ISlpx(SLPX).mintVNativeAsset{value: msg.value}(to);
}
function test_mint (address assetAddress, uint256 amount, address to) public {
IERC20(assetAddress).transferFrom(msg.sender,address(this),amount);
IERC20(assetAddress).approve(address(SLPX), amount);
// your contract logic.
// ...
// call mint
ISlpx(SLPX).mintVAsset(assetAddress,amount,to);
}
function test_redeem (address assetAddress, uint256 amount, address to) public {
IERC20(assetAddress).transferFrom(msg.sender,address(this),amount);
IERC20(assetAddress).approve(address(SLPX), amount);
ISlpx(SLPX).redeemAsset(assetAddress,amount);
}
function test_swap(address assetInAddress, address assetOutAddress,uint256 amount, uint128 amountOutMin,address to) public {
IERC20(assetInAddress).transferFrom(msg.sender,address(this),amount);
IERC20(assetInAddress).approve(address(SLPX), amount);
ISlpx(SLPX).swapAssetsForExactAssets(assetInAddress,assetOutAddress,amount,amountOutMin,to);
}
}