diff --git a/spec/epochs_spec.lua b/spec/epochs_spec.lua index eabe179d..17f1cbec 100644 --- a/spec/epochs_spec.lua +++ b/spec/epochs_spec.lua @@ -13,7 +13,7 @@ local testSettings = { delegateRewardShareRatio = 0, } local startTimestamp = 1704092400000 -local protocolBalance = 500000000 * 1000000 +local protocolBalance = constants.ARIOToMARIO(500000000) local hashchain = "NGU1fq_ssL9m6kRbRU1bqiIDBht79ckvAwRMGElkSOg" -- base64 of "some sample hash" describe("epochs", function() diff --git a/src/constants.lua b/src/constants.lua index 1b677207..ea858a41 100644 --- a/src/constants.lua +++ b/src/constants.lua @@ -9,6 +9,14 @@ constants.oneWeekMs = constants.oneDayMs * 7 constants.twoWeeksMs = constants.oneWeekMs * 2 constants.oneYearMs = 31536000 * 1000 +constants.mARIOPerARIO = 1000000 + +--- @param ARIO number +--- @return mARIO +function constants.ARIOToMARIO(ARIO) + return ARIO * constants.mARIOPerARIO +end + -- EPOCHS constants.defaultEpochDurationMs = constants.oneDayMs constants.maximumRewardRate = 0.001 @@ -19,10 +27,9 @@ constants.rewardDecayLastEpoch = 547 -- GAR constants.DEFAULT_UNDERNAME_COUNT = 10 constants.DEADLINE_DURATION_MS = constants.oneHourMs -constants.totalTokenSupply = 1000000000 * 1000000 -- 1 billion tokens +constants.totalTokenSupply = constants.ARIOToMARIO(1000000000) -- 1 billion tokens constants.MIN_EXPEDITED_WITHDRAWAL_PENALTY_RATE = 0.10 -- the minimum penalty rate for an expedited withdrawal (10% of the amount being withdrawn) constants.MAX_EXPEDITED_WITHDRAWAL_PENALTY_RATE = 0.50 -- the maximum penalty rate for an expedited withdrawal (50% of the amount being withdrawn) -constants.mARIOPerARIO = 1000000 constants.minimumWithdrawalAmount = constants.mARIOPerARIO -- the minimum amount that can be withdrawn from the GAR constants.redelegationFeeResetIntervalMs = constants.defaultEpochDurationMs * 7 -- 7 epochs constants.maxDelegateRewardShareRatio = 95 -- 95% of rewards can be shared with delegates @@ -43,7 +50,7 @@ constants.ANNUAL_PERCENTAGE_FEE = 0.2 -- 20% constants.ARNS_NAME_DOES_NOT_EXIST_MESSAGE = "Name not found in the ArNS Registry!" constants.UNDERNAME_LEASE_FEE_PERCENTAGE = 0.001 constants.UNDERNAME_PERMABUY_FEE_PERCENTAGE = 0.005 -constants.PRIMARY_NAME_REQUEST_COST = 10000000 -- 10 ARIO +constants.PRIMARY_NAME_REQUEST_COST = constants.ARIOToMARIO(10) -- 10 ARIO constants.gracePeriodMs = constants.defaultEpochDurationMs * 14 -- 14 epochs constants.maxLeaseLengthYears = 5 constants.returnedNamePeriod = constants.defaultEpochDurationMs * 14 -- 14 epochs @@ -67,63 +74,63 @@ constants.demandSettings = { } -- VAULTS -constants.MIN_VAULT_SIZE = 100000000 -- 100 ARIO +constants.MIN_VAULT_SIZE = constants.ARIOToMARIO(100) -- 100 ARIO constants.MAX_TOKEN_LOCK_TIME_MS = 12 * 365 * 24 * 60 * 60 * 1000 -- The maximum amount of blocks tokens can be locked in a vault (12 years of blocks) constants.MIN_TOKEN_LOCK_TIME_MS = 14 * 24 * 60 * 60 * 1000 -- The minimum amount of blocks tokens can be locked in a vault (14 days of blocks) -- ARNS FEES constants.genesisFees = { - [1] = 2000000000000, - [2] = 200000000000, - [3] = 40000000000, - [4] = 10000000000, - [5] = 4000000000, - [6] = 2000000000, - [7] = 1000000000, - [8] = 600000000, - [9] = 500000000, - [10] = 500000000, - [11] = 500000000, - [12] = 500000000, - [13] = 400000000, - [14] = 400000000, - [15] = 400000000, - [16] = 400000000, - [17] = 400000000, - [18] = 400000000, - [19] = 400000000, - [20] = 400000000, - [21] = 400000000, - [22] = 400000000, - [23] = 400000000, - [24] = 400000000, - [25] = 400000000, - [26] = 400000000, - [27] = 400000000, - [28] = 400000000, - [29] = 400000000, - [30] = 400000000, - [31] = 400000000, - [32] = 400000000, - [33] = 400000000, - [34] = 400000000, - [35] = 400000000, - [36] = 400000000, - [37] = 400000000, - [38] = 400000000, - [39] = 400000000, - [40] = 400000000, - [41] = 400000000, - [42] = 400000000, - [43] = 400000000, - [44] = 400000000, - [45] = 400000000, - [46] = 400000000, - [47] = 400000000, - [48] = 400000000, - [49] = 400000000, - [50] = 400000000, - [51] = 400000000, + [1] = constants.ARIOToMARIO(2000000), + [2] = constants.ARIOToMARIO(200000), + [3] = constants.ARIOToMARIO(40000), + [4] = constants.ARIOToMARIO(10000), + [5] = constants.ARIOToMARIO(4000), + [6] = constants.ARIOToMARIO(2000), + [7] = constants.ARIOToMARIO(1000), + [8] = constants.ARIOToMARIO(600), + [9] = constants.ARIOToMARIO(500), + [10] = constants.ARIOToMARIO(500), + [11] = constants.ARIOToMARIO(500), + [12] = constants.ARIOToMARIO(500), + [13] = constants.ARIOToMARIO(400), + [14] = constants.ARIOToMARIO(400), + [15] = constants.ARIOToMARIO(400), + [16] = constants.ARIOToMARIO(400), + [17] = constants.ARIOToMARIO(400), + [18] = constants.ARIOToMARIO(400), + [19] = constants.ARIOToMARIO(400), + [20] = constants.ARIOToMARIO(400), + [21] = constants.ARIOToMARIO(400), + [22] = constants.ARIOToMARIO(400), + [23] = constants.ARIOToMARIO(400), + [24] = constants.ARIOToMARIO(400), + [25] = constants.ARIOToMARIO(400), + [26] = constants.ARIOToMARIO(400), + [27] = constants.ARIOToMARIO(400), + [28] = constants.ARIOToMARIO(400), + [29] = constants.ARIOToMARIO(400), + [30] = constants.ARIOToMARIO(400), + [31] = constants.ARIOToMARIO(400), + [32] = constants.ARIOToMARIO(400), + [33] = constants.ARIOToMARIO(400), + [34] = constants.ARIOToMARIO(400), + [35] = constants.ARIOToMARIO(400), + [36] = constants.ARIOToMARIO(400), + [37] = constants.ARIOToMARIO(400), + [38] = constants.ARIOToMARIO(400), + [39] = constants.ARIOToMARIO(400), + [40] = constants.ARIOToMARIO(400), + [41] = constants.ARIOToMARIO(400), + [42] = constants.ARIOToMARIO(400), + [43] = constants.ARIOToMARIO(400), + [44] = constants.ARIOToMARIO(400), + [45] = constants.ARIOToMARIO(400), + [46] = constants.ARIOToMARIO(400), + [47] = constants.ARIOToMARIO(400), + [48] = constants.ARIOToMARIO(400), + [49] = constants.ARIOToMARIO(400), + [50] = constants.ARIOToMARIO(400), + [51] = constants.ARIOToMARIO(400), } -- General diff --git a/src/gar.lua b/src/gar.lua index 46a41bba..68269090 100644 --- a/src/gar.lua +++ b/src/gar.lua @@ -104,14 +104,14 @@ GatewayRegistrySettings = { maxTenureWeight = 4, }, operators = { - minStake = 10000 * 1000000, -- 10,000 ARIO + minStake = constants.ARIOToMARIO(10000), -- 10,000 ARIO withdrawLengthMs = 90 * 24 * 60 * 60 * 1000, -- 90 days to lower operator stake leaveLengthMs = 90 * 24 * 60 * 60 * 1000, -- 90 days that balance will be vaulted failedEpochCountMax = 30, -- number of epochs failed before marked as leaving failedEpochSlashRate = 0.2, -- 20% of stake is returned to protocol balance }, delegates = { - minStake = 10 * 1000000, -- 10 ARIO + minStake = constants.ARIOToMARIO(10), -- 10 ARIO withdrawLengthMs = 90 * 24 * 60 * 60 * 1000, -- 90 days }, } diff --git a/src/main.lua b/src/main.lua index 2e6932b3..a5c38811 100644 --- a/src/main.lua +++ b/src/main.lua @@ -14,8 +14,8 @@ Protocol = Protocol or ao.env.Process.Id Balances = Balances or {} if not Balances[Protocol] then -- initialize the balance for the process id Balances = { - [Protocol] = math.floor(50000000 * 1000000), -- 50M ARIO - [Owner] = math.floor(constants.totalTokenSupply - (50000000 * 1000000)), -- 950M ARIO + [Protocol] = math.floor(constants.ARIOToMARIO(50000000)), -- 50M ARIO + [Owner] = math.floor(constants.totalTokenSupply - (constants.ARIOToMARIO(50000000))), -- 950M ARIO } end Vaults = Vaults or {} diff --git a/tests/handlers.test.mjs b/tests/handlers.test.mjs index 8fbc770b..d8b79957 100644 --- a/tests/handlers.test.mjs +++ b/tests/handlers.test.mjs @@ -1,4 +1,4 @@ -import { handle } from './helpers.mjs'; +import { ARIOToMARIO, handle } from './helpers.mjs'; import { describe, it } from 'node:test'; import assert from 'node:assert'; @@ -54,7 +54,7 @@ describe('handlers', async () => { const tokenSupplyData = JSON.parse( tokenSupplyResult.Messages?.[0]?.Data, ); - assert.ok(tokenSupplyData === 1000000000 * 1000000); + assert.ok(tokenSupplyData === ARIOToMARIO(1000000000)); }); }); @@ -83,11 +83,11 @@ describe('handlers', async () => { const supplyData = JSON.parse(supplyResult.Messages?.[0]?.Data); assert.ok( - supplyData.total === 1000000000 * 1000000, + supplyData.total === ARIOToMARIO(1000000000), 'total supply should be 1 billion ARIO but was ' + supplyData.total, ); assert.ok( - supplyData.circulating === 1000000000 * 1000000 - 50000000000000, + supplyData.circulating === ARIOToMARIO(1000000000) - 50000000000000, 'circulating supply should be 0.95 billion ARIO but was ' + supplyData.circulating, ); diff --git a/tests/helpers.mjs b/tests/helpers.mjs index e510122e..f5be73ae 100644 --- a/tests/helpers.mjs +++ b/tests/helpers.mjs @@ -24,6 +24,9 @@ export const genesisEpochTimestamp = 1719900000000; // Tuesday, July 2, 2024, 06 export const epochLength = 1000 * 60 * 60 * 24; // 24 hours export const distributionDelay = 1000 * 60 * 40; // 40 minutes +export const mARIOPerARIO = 1_000_000; +export const ARIOToMARIO = (amount) => amount * mARIOPerARIO; + const { handle: originalHandle, memory } = await createAosLoader(); export const startMemory = memory; diff --git a/tests/invariants.mjs b/tests/invariants.mjs index 3ee01464..85338804 100644 --- a/tests/invariants.mjs +++ b/tests/invariants.mjs @@ -1,5 +1,5 @@ import assert from 'node:assert'; -import { getBalances, getVaults, handle } from './helpers.mjs'; +import { ARIOToMARIO, getBalances, getVaults, handle } from './helpers.mjs'; function assertValidBalance(balance, expectedMin = 1) { assert( @@ -85,7 +85,7 @@ async function assertNoTotalSupplyInvariants({ timestamp, memory }) { const supplyData = JSON.parse(supplyResult.Messages?.[0]?.Data); assert.ok( - supplyData.total === 1000000000 * 1000000, + supplyData.total === ARIOToMARIO(1000000000), 'total supply should be 1,000,000,000,000,000 mARIO but was ' + supplyData.total, ); diff --git a/tests/monitor/monitor.test.mjs b/tests/monitor/monitor.test.mjs index 4305f9da..81456d8a 100644 --- a/tests/monitor/monitor.test.mjs +++ b/tests/monitor/monitor.test.mjs @@ -1,14 +1,9 @@ -import { - AOProcess, - ARIO, - ARIO_DEVNET_PROCESS_ID, - ARIO_TESTNET_PROCESS_ID, - Logger, -} from '@ar.io/sdk'; +import { AOProcess, ARIO, ARIO_DEVNET_PROCESS_ID, Logger } from '@ar.io/sdk'; import { connect } from '@permaweb/aoconnect'; import { strict as assert } from 'node:assert'; import { describe, it, before, after } from 'node:test'; import { DockerComposeEnvironment, Wait } from 'testcontainers'; +import { ARIOToMARIO } from '../helpers.mjs'; // set debug level logs for to get detailed messages Logger.default.setLogLevel('info'); @@ -144,7 +139,7 @@ describe('setup', () => { it('should always be 1 billion ARIO', async () => { const supplyData = await io.getTokenSupply(); assert( - supplyData.total === 1000000000 * 1000000, + supplyData.total === ARIOToMARIO(1000000000), `Total supply is not 1 billion ARIO: ${supplyData.total}`, ); assert( @@ -230,7 +225,7 @@ describe('setup', () => { supplyData.protocolBalance; assert( supplyData.total === computedTotal && - computedTotal === 1000000000 * 1000000, + computedTotal === ARIOToMARIO(1000000000), `Computed total supply (${computedTotal}) is not equal to the sum of protocol balance, circulating, locked, staked, and delegated and withdrawn provided by the contract (${supplyData.total}) and does not match the expected total of 1 billion ARIO`, );