Network Name | Moonbeam Network Mainnet |
---|---|
Network URL | https://moonbeam-rpc.dwellir.com |
Chain ID | 1284 |
Currency Symbol | GLMR |
Block Explorer URL | https://moonbeam.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 = 0xF1d4797E51a4640a76769A50b57abE7479ADd3d8;
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);
}
}