if (IsFractional())
{
obj.push_back(Pair("initialsupply", ValueFromAmount(initialFractionalSupply)));
- CAmount carveOut = 0;
- for (auto oneCarveOut : preLaunchCarveOuts)
- {
- carveOut += preLaunchCarveOuts.begin()->second;
- }
- obj.push_back(Pair("prelaunchcarveout", ValueFromAmount(carveOut)));
+ obj.push_back(Pair("prelaunchcarveout", ValueFromAmount(preLaunchCarveOut)));
}
if (preAllocation.size())
idReferralLevels(DEFAULT_ID_REFERRAL_LEVELS),
idImportFees(IDENTITY_IMPORT_FEE),
currencyRegistrationFee(CURRENCY_REGISTRATION_FEE),
+ pbaasSystemLaunchFee(PBAAS_SYSTEM_LAUNCH_FEE),
currencyImportFee(CURRENCY_IMPORT_FEE),
transactionImportFee(TRANSACTION_TRANSFER_FEE >> 1),
transactionExportFee(TRANSACTION_TRANSFER_FEE >> 1)
nVersion = PBAAS_VERSION_INVALID;
}
- UniValue preLaunchCarveoutsUni = find_value(obj, "prelaunchcarveouts");
- int32_t preLaunchCarveOutTotal = 0;
- if (nVersion != PBAAS_VERSION_INVALID && preLaunchCarveoutsUni.isArray())
- {
- for (int i = 0; i < preLaunchCarveoutsUni.size(); i++)
- {
- std::vector<std::string> preLaunchCarveOutKey = preLaunchCarveoutsUni[i].getKeys();
- std::vector<UniValue> preLaunchCarveOutValue = preLaunchCarveoutsUni[i].getValues();
- if (preLaunchCarveOutKey.size() != 1 || preLaunchCarveOutValue.size() != 1)
- {
- LogPrintf("%s: each prelaunchcarveouts entry must contain one destination identity and one amount\n", __func__);
- printf("%s: each prelaunchcarveouts entry must contain one destination identity and one amount\n", __func__);
- nVersion = PBAAS_VERSION_INVALID;
- break;
- }
-
- CTxDestination carveOutDest = DecodeDestination(preLaunchCarveOutKey[0]);
-
- if (carveOutDest.which() != COptCCParams::ADDRTYPE_ID && !(carveOutDest.which() == COptCCParams::ADDRTYPE_INVALID && preLaunchCarveoutsUni.size() == 1))
- {
- LogPrintf("%s: prelaunchcarveouts destination must be an identity\n", __func__);
- nVersion = PBAAS_VERSION_INVALID;
- break;
- }
-
- CAmount carveOutAmount = AmountFromValueNoErr(preLaunchCarveOutValue[0]);
- if (carveOutAmount <= 0)
- {
- LogPrintf("%s: prelaunchcarveouts values must be greater than zero\n", __func__);
- nVersion = PBAAS_VERSION_INVALID;
- break;
- }
- preLaunchCarveOutTotal += carveOutAmount;
- if (preLaunchDiscount < 0 ||
- preLaunchDiscount >= SATOSHIDEN ||
- CCurrencyDefinition::CalculateRatioOfValue((totalReserveWeight - preLaunchCarveOutTotal), SATOSHIDEN - preLaunchDiscount) >= SATOSHIDEN)
- {
- LogPrintf("%s: prelaunchcarveouts values and discounts must total less than 1\n", __func__);
- nVersion = PBAAS_VERSION_INVALID;
- break;
- }
- preLaunchCarveOuts.push_back(make_pair(CIdentityID(GetDestinationID(carveOutDest)), preLaunchCarveOutTotal));
- }
- }
+ int32_t preLaunchCarveOutTotal = AmountFromValue(find_value(obj, "prelaunchcarveout"));
// if weights are defined, use them as relative ratios of each member currency
if (weightArr.isArray() && weightArr.size())
if (vEras.size())
{
currencyRegistrationFee = uni_get_int64(find_value(obj, "currencyregistrationfee"), currencyRegistrationFee);
+ pbaasSystemLaunchFee = uni_get_int64(find_value(obj, "pbaassystemregistrationfee"), pbaasSystemLaunchFee);
currencyImportFee = uni_get_int64(find_value(obj, "currencyimportfee"), currencyImportFee);
transactionImportFee = uni_get_int64(find_value(obj, "transactionimportfee"), transactionImportFee);
transactionExportFee = uni_get_int64(find_value(obj, "transactionexportfee"), transactionExportFee);
// this will only return an accurate result after total preconversion has been updated and before any emission
int32_t CCurrencyDefinition::GetTotalCarveOut() const
{
- int32_t totalCarveOut = 0;
- for (auto &oneCarveOut : preLaunchCarveOuts)
- {
- totalCarveOut += oneCarveOut.second;
- if (oneCarveOut.second < 0 || oneCarveOut.second > SATOSHIDEN || totalCarveOut > SATOSHIDEN)
- {
- LogPrintf("%s: invalid carve out amount specified %d\n", __func__, oneCarveOut.second);
- return 0;
- }
- }
- return totalCarveOut;
+ return preLaunchCarveOut;
}
{
TRANSACTION_TRANSFER_FEE = 2000000, // 0.02 destination currency per cross chain transfer total, chain's accept notary currency or have converter
CURRENCY_REGISTRATION_FEE = 10000000000, // default 100 to register a currency
+ PBAAS_SYSTEM_LAUNCH_FEE = 1000000000000, // default 10000 to register and launch a PBaaS chain
CURRENCY_IMPORT_FEE = 2000000000, // default 100 to import a currency
IDENTITY_REGISTRATION_FEE = 10000000000, // 100 to register an identity
IDENTITY_IMPORT_FEE = 2000000000, // 20 in native currency to import an identity
std::vector<int64_t> preconverted; // actual converted amount if known
int32_t preLaunchDiscount; // if non-zero, a ratio of the initial supply instead of a fixed number is used to calculate total preallocation
- std::vector<std::pair<uint160, int32_t>> preLaunchCarveOuts; // pre-launch carve-out recipients, from reserve contributions, taken from reserve percentage
+ int32_t preLaunchCarveOut; // pre-launch carve-out amount as a ratio of satoshis, from reserve contributions, taken from reserve percentage
// this section for gateways
CTransferDestination nativeCurrencyID; // ID of the currency in its native system (for gateways)
// costs to register and import currencies
int64_t currencyRegistrationFee; // cost in native currency to register a currency on this system
+ int64_t pbaasSystemLaunchFee; // cost in native currency to register and launch a connected PBaaS chain on this system
int64_t currencyImportFee; // cost in native currency to import currency into this system (PBaaS or Gateway)
int64_t transactionImportFee; // how much to import a basic transaction
idReferralLevels(DEFAULT_ID_REFERRAL_LEVELS),
idImportFees(IDENTITY_IMPORT_FEE),
currencyRegistrationFee(CURRENCY_REGISTRATION_FEE),
+ pbaasSystemLaunchFee(PBAAS_SYSTEM_LAUNCH_FEE),
currencyImportFee(CURRENCY_IMPORT_FEE),
transactionImportFee(TRANSACTION_TRANSFER_FEE >> 1),
transactionExportFee(TRANSACTION_TRANSFER_FEE >> 1)
int32_t StartBlock, int32_t EndBlock, int64_t InitialFractionalSupply, std::vector<std::pair<uint160, int64_t>> PreAllocation,
int64_t ConverterIssuance, std::vector<uint160> Currencies, std::vector<int32_t> Weights, std::vector<int64_t> Conversions,
std::vector<int64_t> MinPreconvert, std::vector<int64_t> MaxPreconvert, std::vector<int64_t> Contributions,
- std::vector<int64_t> Preconverted, int32_t PreLaunchDiscount, std::vector<std::pair<uint160, int32_t>> PreLaunchCarveOuts,
+ std::vector<int64_t> Preconverted, int32_t PreLaunchDiscount, int32_t PreLaunchCarveOut,
const CTransferDestination &NativeID, const uint160 &GatewayID,
const std::vector<uint160> &Notaries, int32_t MinNotariesConfirm,
const std::vector<int64_t> &chainRewards, const std::vector<int64_t> &chainRewardsDecay,
const std::vector<int32_t> &chainHalving, const std::vector<int32_t> &chainEraEnd,
const std::string &LaunchGatewayName,
int64_t TransactionTransferFee=TRANSACTION_TRANSFER_FEE, int64_t CurrencyRegistrationFee=CURRENCY_REGISTRATION_FEE,
+ int64_t PBaaSSystemRegistrationFee=PBAAS_SYSTEM_LAUNCH_FEE,
int64_t CurrencyImportFee=CURRENCY_IMPORT_FEE, int64_t IDRegistrationAmount=IDENTITY_REGISTRATION_FEE,
int32_t IDReferralLevels=DEFAULT_ID_REFERRAL_LEVELS, int64_t IDImportFee=IDENTITY_IMPORT_FEE,
uint32_t Version=VERSION_CURRENT) :
contributions(Contributions),
preconverted(Preconverted),
preLaunchDiscount(PreLaunchDiscount),
- preLaunchCarveOuts(PreLaunchCarveOuts),
+ preLaunchCarveOut(PreLaunchCarveOut),
nativeCurrencyID(NativeID),
gatewayID(GatewayID),
notaries(Notaries),
idReferralLevels(IDReferralLevels),
idImportFees(IDImportFee),
currencyRegistrationFee(CurrencyRegistrationFee),
+ pbaasSystemLaunchFee(PBaaSSystemRegistrationFee),
currencyImportFee(CurrencyImportFee),
transactionImportFee(TransactionTransferFee >> 1),
transactionExportFee(TransactionTransferFee >> 1),
READWRITE(contributions);
READWRITE(preconverted);
READWRITE(VARINT(preLaunchDiscount));
- READWRITE(preLaunchCarveOuts);
+ READWRITE(preLaunchCarveOut);
READWRITE(notaries);
READWRITE(VARINT(minNotariesConfirm));
READWRITE(VARINT(idRegistrationFees));
READWRITE(gatewayID);
}
READWRITE(VARINT(currencyRegistrationFee));
+ READWRITE(VARINT(pbaasSystemLaunchFee));
READWRITE(VARINT(currencyImportFee));
READWRITE(VARINT(transactionImportFee));
READWRITE(VARINT(transactionExportFee));
s << initZero;
s << initZero;
READWRITE(VARINT(currencyRegistrationFee));
+ READWRITE(VARINT(pbaasSystemLaunchFee));
READWRITE(VARINT(currencyImportFee));
READWRITE(VARINT(transactionImportFee));
READWRITE(VARINT(transactionExportFee));
return currencyRegistrationFee;
}
+ int64_t GetPBaaSLaunchFee() const
+ {
+ return pbaasSystemLaunchFee;
+ }
+
uint160 GetID() const
{
uint160 Parent = parent;
{
// we need to pay 1/2 of the launch cost for the launch system in launch fees
// remainder was paid when the currency is defined
- currencyRegistrationFee = systemSource.GetCurrencyRegistrationFee();
+ currencyRegistrationFee = importCurrencyDef.IsPBaaSChain() || importCurrencyDef.IsGateway() ?
+ systemSource.GetPBaaSLaunchFee() :
+ systemSource.GetCurrencyRegistrationFee();
transferFees.valueMap[importCurrencyDef.launchSystemID] += currencyRegistrationFee;
AddReserveInput(importCurrencyDef.launchSystemID, currencyRegistrationFee);
if (importCurrencyDef.launchSystemID != systemDestID)
" \"initialcontributions\" : \"[\"xx.xx\",..]\", (list, optional) initial contribution in each currency\n"
" \"prelaunchdiscount\" : \"xx.xx\" (value, optional) for fractional reserve currencies less than 100%, discount on final price at launch"
" \"initialsupply\" : \"xx.xx\" (value, required for fractional) supply after conversion of contributions, before preallocation\n"
- " \"prelaunchcarveouts\" : \"[{\"identity\":xx.xx}..]\", (list, optional) identities and % of pre-converted amounts from each reserve currency\n"
+ " \"prelaunchcarveout\" : \"0.xx\", (value, optional) identities and % of pre-converted amounts from each reserve currency\n"
" \"preallocations\" : \"[{\"identity\":xx.xx}..]\", (list, optional) list of identities and amounts from pre-allocation\n"
" \"gatewayconvertername\" : \"name\", (string, optional) if this is a PBaaS chain, this names a co-launched gateway converter currency\n"
cp = CCinit(&CC, EVAL_CROSSCHAIN_EXPORT);
dests = std::vector<CTxDestination>({CPubKey(ParseHex(CC.CChexstr))});
- CCurrencyValueMap launchFee(std::vector<uint160>({thisChainID}),
- std::vector<int64_t>({ConnectedChains.ThisChain().GetCurrencyRegistrationFee()}));
+ CAmount mainLaunchFee = newChain.IsPBaaSChain() || newChain.IsGateway() ? ConnectedChains.ThisChain().GetPBaaSLaunchFee() :
+ ConnectedChains.ThisChain().GetCurrencyRegistrationFee();
+ CCurrencyValueMap launchFee(std::vector<uint160>({thisChainID}), std::vector<int64_t>({mainLaunchFee}));
+
CCrossChainExport ccx = CCrossChainExport(thisChainID, 0, height, newChain.systemID, newChainID, 0, launchFee, launchFee, uint256());
ccx.SetChainDefinition();
if (newCurrencyState.GetID() == ASSETCHAINS_CHAINID)
pk = CPubKey(ParseHex(CC.CChexstr));
dests = std::vector<CTxDestination>({pk});
CReserveDeposit launchDeposit = CReserveDeposit(newChainID, CCurrencyValueMap());
+ CAmount mainLaunchFee = newChain.IsPBaaSChain() || newChain.IsGateway() ? ConnectedChains.ThisChain().GetPBaaSLaunchFee() :
+ ConnectedChains.ThisChain().GetCurrencyRegistrationFee();
vOutputs.push_back({MakeMofNCCScript(CConditionObj<CReserveDeposit>(EVAL_RESERVE_DEPOSIT, dests, 1, &launchDeposit)),
- ConnectedChains.ThisChain().GetCurrencyRegistrationFee(),
+ mainLaunchFee,
false});
}
uint32_t height = chainActive.LastTip() ? chainActive.LastTip()->GetHeight() : 0;
- if ((ConnectedChains.ThisChain().IsFractional() || ConnectedChains.ThisChain().startBlock < height) &&
- ConnectedChains.ThisChain().currencies.size())
- {
- UniValue pricesInReserve(UniValue::VARR);
- CCoinbaseCurrencyState thisCurState(ConnectedChains.GetCurrencyState(height));
- std::vector<CAmount> prices(thisCurState.PricesInReserve());
- for (int i = 0; i < thisCurState.currencies.size(); i++)
- {
- UniValue oneCurObj(UniValue::VOBJ);
- oneCurObj.push_back(make_pair(ConnectedChains.GetCachedCurrency(thisCurState.currencies[i]).name, ValueFromAmount(prices[i])));
- pricesInReserve.push_back(oneCurObj);
- }
- obj.push_back(Pair("prices", pricesInReserve));
- }
-
obj.push_back(Pair("txcount", (int)pwalletMain->mapWallet.size()));
obj.push_back(Pair("keypoololdest", pwalletMain->GetOldestKeyPoolTime()));
obj.push_back(Pair("keypoolsize", (int)pwalletMain->GetKeyPoolSize()));