Examples of Setting Up a Complex Reserve Using Formulas
Formulas for Reserves
Using shortcodes, you can configure a total reserve for multiple currencies, convert reserves into other currencies (for example, from USD to BTC), and much more.
Go to "Modules" → "Modules" and enable the "Reserve Formula" module if it is turned off.
List of Available Shortcodes
corresXX — the amount of currency reserve adjustments.
excursum_giveXX — the total reserve of requests for the currency "Giving."
excursum_getXX — the total reserve of requests for the currency "Receiving."
excursum_autoXX — the total reserve of requests for the currency "Receiving" with statuses from the settings in the "Exchange Settings" → "Reserve Settings" section.
cfilereserve_ZZ — the reserve value for currency in row ZZ from the parsing reserve file.
dfilereserve_ZZ — the exchange direction reserve value for row ZZ from the parsing reserve file.
payoutsXX — the total of partner payouts for the currency.
If the partner program for the exchange direction is turned off, the payoutsXX parameter will have zero values.
[parser_binance_btcusdt] — the rate from the "Parsers 2.0" → "Source Rates" section. In this section, the shortcode appears as [binance_btcusdt], but when used in the reserve formula, you need to add the prefix parser_, making it look like [parser_binance_btcusdt]. The same rule applies to shortcodes for custom coefficients.
XX — the currency ID displayed in the site management panel under the "Currencies" section. You can specify multiple IDs separated by commas.
ZZ — the row number in the reserve file for parsing. You can specify multiple IDs separated by commas.
Example: Linking the Reserve of One Currency to Another
Let's consider an example that demonstrates how to link the reserve of the "Monobank" currency to the reserve of "Privat24."
In the management panel under the "Currencies" section, find the currency IDs for "Privat24" (ID 5) and "Monobank" (ID 47).
Proceed to edit the currencies "Privat24" and "Monobank." In the settings for both currencies, select the option "Reserve Currency" as "By Formula."
In the field "Reserve Formula" that appears below, enter the following formula in the settings for both currencies:
Now, let's complicate the example: we will link the reserves of "Monobank" (ID 47) and "Oschadbank" (ID 23) to the reserve of "Privat24" (ID 5). For all three currencies, we need to set the following formula:
In the site management panel under "Modules" → "Modules," activate the module "Link to Update Currency Reserve (by Cron)" if it has been deactivated. In the "Currencies" section for "Monobank," "Oschadbank," and "Privat24," a "Link" button will appear. For each currency in the example, click this button and copy the address of the opened page.
Add each copied link to the task scheduler (cron) on the server. The link can be run every minute. Here’s an example command for the task scheduler in Unix format for the ISP Manager control panel:
where XX — is the currency ID.
Example: Unified Reserve for Multiple Currencies (Using Reserve Calculated from Requests)
For instance, we have 4 currencies with IDs 5, 42, 47, 61. Our goal is to ensure that all currencies have the same reserve.
We need to determine which currency will be the primary one. In our case, let’s say it will be the currency with ID 47.
The formula will be as follows:
[sum of reserve adjustments for currencies with our IDs 5,42,47,61] + [sum of "giving for reserve" from requests where currency giving is ID 5,42,47,61] - [sum of "receiving for reserve" from requests where currency receiving is ID 5,42,47,61] - [partner payouts for currencies with our IDs 5,42,47,61]
Thus, for the primary currency (ID 47), we create the formula:
[corres5,42,47,61] + [excursum_give5,42,47,61] – [excursum_get5,42,47,61] – [payouts5,42,47,61]
This formula will yield the correct value. The only issue is that the currency reserve changes only when actions occur with our currency.
To ensure that when the primary currency reserve (ID 47) is updated, the same value is applied to other currencies, we need to specify the value in the field "Link Reserve to Currency ID":
5,42,61
Now, when actions occur with currency ID 47, the following will happen:
The reserve will be calculated according to the formula.
The formula value will be recorded in the linked currencies.
This is almost what we need. But what happens when actions occur with other currencies? How do we update the reserve of the primary currency ID 47?
For this, in the settings of each currency, we will select the following:
Take the "Currency Reserve" from the "Reserve Field." This is to save our server resources and avoid recalculating the value (it will be overwritten anyway).
Example: Creating the Same Reserve for Currencies (Using Reserve from Auto Payout)
For instance, we have 4 currencies with IDs 5, 42, 47, 61. Our goal is to ensure that all currencies have the same reserve.
We need to determine which currency will be the primary one. In our case, let’s say it will be the currency with ID 47.
The formula will be as follows:
[auto payout shortcode] - [sum of "receiving for reserve" from requests where currency receiving is ID 5,42,47,61] - [partner payouts for currencies with our IDs 5,42,47,61]
Thus, for the primary currency with ID 47, we create the formula:
[auto payout shortcode] – [excursum_auto5,42,47,61] – [payouts5,42,47,61]
This formula will yield the correct value. The only issue is that the currency reserve changes only when actions occur with our currency.
To ensure that when the primary currency reserve is updated, the same value is applied to other currencies, we need to specify the value in the field "Link Reserve to Currency ID":
5,42,61
Now, when actions occur with the currency with ID 47, the following will happen:
The reserve will be calculated according to the formula.
The formula value will be recorded in the linked currencies.
In the field labeled "Link Reserve to Currency Reserve ID," we enter the value:
rc47
This means that when we perform actions with our currencies, the following will occur:
We use the value from this field and apply it to our currency.
We update the reserve for the currency with ID 47 using a specific formula.
The link in the settings for the currency with ID 47 is activated, which updates all fields with its reserve value.
Example: Creating Identical Reserves for Currencies (Using Reserve from Auto-Payout) with Conversion to Other Currencies
In this example, we use USDT as the primary currency, obtaining its reserve value from the merchant, and we use conversion from USDT for the other currencies.
Primary Currency: USDT TRC (368) Currencies for receiving the reserve value of the primary currency: BTC (348), DOGE (362), ETH (355), SOL (404)
Reserve Settings: USDT TRC (368) Reserve: according to the formula Reserve Formula: [usdttrc_westwallet] - [excursum_auto368] - ([excursum_auto348] * [parser_usdtbtc]) - ([excursum_auto362] * [parser_usdtdoge]) - ([excursum_auto355] * [parser_usdteth]) - ([excursum_auto404] * [parser_usdtsol])
Link to Reserve: 348, 362, 355, 404

BTC (348) Reserve: according to the formula Reserve Formula: ([usdttrc_westwallet] - [excursum_auto368] - ([excursum_auto348] * [parser_usdtbtc]) - ([excursum_auto362] * [parser_usdtdoge]) - ([excursum_auto355] * [parser_usdteth]) - ([excursum_auto404] * [parser_usdtsol])) / [parser_usdtbtc] Link to Reserve: rc368

DOGE (362) Reserve: according to the formula Reserve Formula: ([usdttrc_westwallet] - [excursum_auto368] - ([excursum_auto348] * [parser_usdtbtc]) - ([excursum_auto362] * [parser_usdtdoge]) - ([excursum_auto355] * [parser_usdteth]) - ([excursum_auto404] * [parser_usdtsol])) / [parser_usdtdoge] Link to Reserve: rc368

ETH (355) Reserve: according to the formula Reserve Formula: ([usdttrc_westwallet] - [excursum_auto368] - ([excursum_auto348] * [parser_usdtbtc]) - ([excursum_auto362] * [parser_usdtdoge]) - ([excursum_auto355] * [parser_usdteth]) - ([excursum_auto404] * [parser_usdtsol])) / [parser_usdteth] Link to Reserve: rc368

SOL (404) Reserve: according to the formula Reserve Formula: ([usdttrc_westwallet] - [excursum_auto368] - ([excursum_auto348] * [parser_usdtbtc]) - ([excursum_auto362] * [parser_usdtdoge]) - ([excursum_auto355] * [parser_usdteth]) - ([excursum_auto404] * [parser_usdtsol])) / [parser_usdtsol] Link to Reserve: rc368

Last updated