-
Notifications
You must be signed in to change notification settings - Fork 1
Create Liquidity Provider
Tan Xiu Haw edited this page Nov 2, 2023
·
3 revisions
- Following parameters required:
- Provider Mosaic ID
- Currency Deposit
- Initial Mosaics Minting
- Slashing Period
- Window Size
- Slashing Account
- Alpha
- Beta
- Maximum Fee
- Deadline
- Network ID
#include <xpxchaincpp/sdk.h>
#include <iostream>
#include <vector>
using namespace xpx_chain_sdk;
int main()
{
xpx_chain_sdk::Config config = xpx_chain_sdk::GetConfig();
config.nodeAddress = "127.0.0.1";
config.port = "3000";
xpx_chain_sdk::NetworkIdentifier networkIdentifier = xpx_chain_sdk::NetworkIdentifier::Mijin_Test;
auto client = xpx_chain_sdk::getClient(config);
xpx_chain_sdk::MosaicId mosaicID = 2761073989369673764;
xpx_chain_sdk::Amount deposit = 1000000;
xpx_chain_sdk::Amount initMosaicsMinting = 100000;
uint32_t slashingPeriod = 500;
uint16_t windowSize = 5;
xpx_chain_sdk::Key slashingAccount;
uint32_t alpha = 500;
uint32_t beta = 500;
auto createLiquidityProviderTransaction = xpx_chain_sdk::CreateCreateLiquidityProviderTransaction
(
mosaicID,
deposit,
initMosaicsMinting,
slashingPeriod,
windowSize,
slashingAccount,
alpha,
beta,
std::nullopt,
std::nullopt,
networkIdentifier
);
std::string privateKey = "819F72066B17FFD71B8B4142C5AEAE4B997B0882ABDF2C263B02869382BD93A0";
auto account = std::make_shared<xpx_chain_sdk::Account>([privateKey](xpx_chain_sdk::PrivateKeySupplierReason reason, xpx_chain_sdk::PrivateKeySupplierParam param)
{
xpx_chain_sdk::Key key;
ParseHexStringIntoContainer(privateKey.c_str(), privateKey.size(), key);
return xpx_chain_sdk::PrivateKey(key.data(), key.size());
}, networkIdentifier);
account->signTransaction(createLiquidityProviderTransaction.get());
xpx_chain_sdk::Hash256 hash = createLiquidityProviderTransaction->hash();
auto bin = createLiquidityProviderTransaction->binary();
client->transactions()->announceNewTransaction(bin);
for (int i = 0; i < sizeof(hash); i++)
{
std::cout << ToHex(hash[i]);
}
std::cout << std::endl;
return 0;
}