Skip to content

Commit 6b02f06

Browse files
authored
Merge pull request miketout#304 from VerusCoin/dev
0.7.2
2 parents 20f39e5 + 48c6ad9 commit 6b02f06

File tree

7 files changed

+98
-97
lines changed

7 files changed

+98
-97
lines changed

src/core_write.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -536,8 +536,8 @@ UniValue CCoinbaseCurrencyState::ToUniValue() const
536536
{
537537
rowNames.push_back(EncodeDestination(CIdentityID(currencies[i])));
538538
}
539-
std::vector<std::string> columnNames({"reservein", "nativein", "reserveout", "lastconversionprice", "fees", "conversionfees"});
540-
std::vector<const std::vector<CAmount> *> data = {&reserveIn, &nativeIn, &reserveOut, &conversionPrice, &fees, &conversionFees};
539+
std::vector<std::string> columnNames({"reservein", "nativein", "reserveout", "lastconversionprice", "viaconversionprice", "fees", "conversionfees"});
540+
std::vector<const std::vector<CAmount> *> data = {&reserveIn, &nativeIn, &reserveOut, &conversionPrice, &viaConversionPrice, &fees, &conversionFees};
541541

542542
ret.push_back(Pair("currencies", ValueVectorsToUniValue(rowNames, columnNames, data, true)));
543543
ret.push_back(Pair("nativefees", nativeFees));

src/komodo_utils.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -1435,10 +1435,10 @@ void komodo_configfile(char *symbol, uint16_t rpcport)
14351435
// add Verus Coin Foundation sponsored testnet nodes
14361436
if (PBAAS_TESTMODE)
14371437
{
1438-
fprintf(fp,"addnode=%s\n", "168.119.27.242:18538");
1439-
fprintf(fp,"addnode=%s\n", "5.9.224.250:18538");
1440-
fprintf(fp,"addnode=%s\n", "95.216.104.210:18538");
1441-
fprintf(fp,"addnode=%s\n", "135.181.68.2:18538");
1438+
fprintf(fp,"addnode=%s\n", "168.119.27.242:17683");
1439+
fprintf(fp,"addnode=%s\n", "5.9.224.250:17683");
1440+
fprintf(fp,"addnode=%s\n", "95.216.104.210:17683");
1441+
fprintf(fp,"addnode=%s\n", "135.181.68.2:17683");
14421442
}
14431443
}
14441444
else
@@ -1833,7 +1833,7 @@ void komodo_args(char *argv0)
18331833
mapArgs["-ac_supply"] = "5000000000000000";
18341834
mapArgs["-ac_eras"] = "1";
18351835
mapArgs["-ac_reward"] = "2400000000";
1836-
std::string halving = GetArg("-ac_halving", "287474"); // this assignment is required for an ARM compiler workaround
1836+
std::string halving = GetArg("-ac_halving", "301111"); // this assignment is required for an ARM compiler workaround
18371837
mapArgs["-ac_halving"] = halving; // allow testing easily with different values here
18381838
mapArgs["-ac_decay"] = "0";
18391839
mapArgs["-ac_options"] = "72"; // OPTION_ID_REFERRALS + OPTION_CANBERESERVE

src/pbaas/pbaas.cpp

+34-28
Original file line numberDiff line numberDiff line change
@@ -1039,7 +1039,8 @@ CCoinbaseCurrencyState CConnectedChains::AddPrelaunchConversions(CCurrencyDefini
10391039
// currency state to be up to just before the start block
10401040
std::multimap<uint160, std::pair<CInputDescriptor, CReserveTransfer>> unspentTransfers;
10411041
std::map<uint160, int32_t> currencyIndexes = currencyState.GetReserveMap();
1042-
int32_t nativeIdx = -1;
1042+
int32_t nativeIdx = currencyIndexes.count(curDef.systemID) ? currencyIndexes[curDef.systemID] : -1;
1043+
10431044
if (GetChainTransfers(unspentTransfers, curDef.GetID(), fromHeight, height < curDef.startBlock ? height : curDef.startBlock - 1))
10441045
{
10451046
currencyState.ClearForNextBlock();
@@ -1067,11 +1068,10 @@ CCoinbaseCurrencyState CConnectedChains::AddPrelaunchConversions(CCurrencyDefini
10671068
{
10681069
currencyState.nativeConversionFees += conversionFee;
10691070
currencyState.nativeFees += conversionFee;
1070-
nativeIdx = curIdx;
10711071
}
1072-
10731072
currencyState.fees[curIdx] += conversionFee;
10741073
currencyState.nativeFees += transfer.second.second.CalculateTransferFee(transfer.second.second.destination);
1074+
currencyState.fees[nativeIdx] += transfer.second.second.CalculateTransferFee(transfer.second.second.destination);
10751075
currencyState.conversionFees[curIdx] += conversionFee;
10761076
}
10771077
}
@@ -1081,41 +1081,31 @@ CCoinbaseCurrencyState CConnectedChains::AddPrelaunchConversions(CCurrencyDefini
10811081
{
10821082
// convert all non-native fees to native and update the price as a result
10831083
bool isFeeConversion = false;
1084-
std::vector<int64_t> reservesToConvert;
1085-
std::vector<int64_t> fractionalToConvert;
1086-
std::vector<std::vector<int64_t>> crossConversions = std::vector<std::vector<int64_t>>(curDef.currencies.size(), std::vector<int64_t>(curDef.currencies.size()));
1084+
int numCurrencies = curDef.currencies.size();
1085+
std::vector<int64_t> reservesToConvert(numCurrencies, 0);
1086+
std::vector<int64_t> fractionalToConvert(numCurrencies, 0);
1087+
CAmount newSupply = currencyState.supply;
10871088

1088-
for (int i = 0; i < curDef.currencies.size(); i++)
1089+
for (int i = 0; i < numCurrencies; i++)
10891090
{
1090-
currencyState.conversionPrice[i] = currencyState.PriceInReserve(i, true);
1091+
curDef.conversions[i] = currencyState.conversionPrice[i] = currencyState.PriceInReserve(i, true);
10911092

10921093
// all currencies except the native currency of the system will be converted to the native currency
10931094
if (currencyState.fees[i] && curDef.currencies[i] != curDef.systemID)
10941095
{
1095-
reservesToConvert.push_back(currencyState.fees[i] + currencyState.reserves[i]);
1096-
fractionalToConvert.push_back(currencyState.ReserveToNative(currencyState.reserves[i], i));
1097-
if (nativeIdx != -1)
1098-
{
1099-
crossConversions[i][nativeIdx] = currencyState.fees[i];
1100-
isFeeConversion = true;
1101-
}
1102-
}
1103-
else
1104-
{
1105-
reservesToConvert.push_back(0);
1106-
fractionalToConvert.push_back(0);
1096+
fractionalToConvert[nativeIdx] += currencyState.ReserveToNativeRaw(currencyState.fees[i], currencyState.conversionPrice[i]);
1097+
newSupply += fractionalToConvert[i];
1098+
isFeeConversion = true;
11071099
}
11081100
}
1101+
currencyState.supply = newSupply;
11091102

11101103
// convert all non-native fee currencies to native and adjust prices
11111104
if (isFeeConversion)
11121105
{
11131106
CCurrencyState converterState = static_cast<CCurrencyState>(currencyState);
1114-
curDef.conversions = currencyState.conversionPrice = converterState.ConvertAmounts(reservesToConvert, fractionalToConvert, currencyState, &crossConversions);
1115-
}
1116-
else
1117-
{
1118-
curDef.conversions = currencyState.PricesInReserve();
1107+
currencyState.viaConversionPrice =
1108+
converterState.ConvertAmounts(reservesToConvert, fractionalToConvert, currencyState);
11191109
}
11201110
}
11211111

@@ -1136,19 +1126,35 @@ CCoinbaseCurrencyState CConnectedChains::AddPrelaunchConversions(CCurrencyDefini
11361126
{
11371127
// get a ratio and reduce all prices by that ratio
11381128
static arith_uint256 bigSatoshi(SATOSHIDEN);
1139-
arith_uint256 newRatio((calculatedSupply * bigSatoshi) / currencyState.supply);
1129+
arith_uint256 bigMultipliedSupply(calculatedSupply * bigSatoshi);
1130+
arith_uint256 newRatio(bigMultipliedSupply / curDef.initialFractionalSupply);
1131+
// truncate up, not down, to prevent any overflow at all
1132+
if (newRatio * curDef.initialFractionalSupply < bigMultipliedSupply)
1133+
{
1134+
newRatio++;
1135+
}
11401136
for (auto &rate : currencyState.conversionPrice)
11411137
{
11421138
arith_uint256 numerator = rate * newRatio;
11431139
rate = (numerator / bigSatoshi).GetLow64();
1144-
// truncate up, not down, to prevent any overflow at all
1145-
if (((numerator / bigSatoshi) >> 1) > 0)
1140+
if ((numerator - (bigSatoshi * rate)) > 0)
11461141
{
11471142
rate++;
11481143
}
11491144
}
11501145
}
11511146

1147+
calculatedSupply = 0;
1148+
for (auto &transfer : unspentTransfers)
1149+
{
1150+
if (transfer.second.second.IsPreConversion())
1151+
{
1152+
CAmount toConvert = transfer.second.second.nValue - CReserveTransactionDescriptor::CalculateConversionFee(transfer.second.second.nValue);
1153+
calculatedSupply += CCurrencyState::ReserveToNativeRaw(toConvert, currencyState.conversionPrice[currencyIndexes[transfer.second.second.currencyID]]);
1154+
}
1155+
}
1156+
printf("Calculated supply %s\n", ValueFromAmount(calculatedSupply).write().c_str());
1157+
11521158
// now, remove carveout percentage from each weight & reserve
11531159
// for currency state
11541160
int32_t preLaunchCarveOutTotal = 0;

0 commit comments

Comments
 (0)