Solidity Contract Integration
If you want to integrate SLPx in your contract, please see a sample code.
// 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);
}
}