From a8de7ed97e987a14b165c592385e594373e634ad Mon Sep 17 00:00:00 2001 From: Waves Rider <108881461+ridev6@users.noreply.github.com> Date: Thu, 10 Aug 2023 12:56:18 +0500 Subject: [PATCH] blocks in period variable --- migrations/wxdefi-435-release/index.mjs | 4 +++- ride/boosting.ride | 12 +++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/migrations/wxdefi-435-release/index.mjs b/migrations/wxdefi-435-release/index.mjs index 6fb98229..2905f9f2 100644 --- a/migrations/wxdefi-435-release/index.mjs +++ b/migrations/wxdefi-435-release/index.mjs @@ -20,6 +20,7 @@ const { MIN_LOCK_AMOUNT, MIN_LOCK_DURATION, MAX_LOCK_DURATION, + BLOCKS_IN_PERIOD, } = process.env; const api = create(NODE_URL); @@ -141,12 +142,13 @@ txs.push({ key: '%s__config', type: 'string', value: [ - '%s%d%d%d%s', + '%s%d%d%d%s%d', WX_ASSET_ID, MIN_LOCK_AMOUNT.toString(), MIN_LOCK_DURATION.toString(), MAX_LOCK_DURATION.toString(), gwxRewardAddress, + BLOCKS_IN_PERIOD.toString(), ].join(separator), } ], diff --git a/ride/boosting.ride b/ride/boosting.ride index 31314dc0..9fa0665c 100644 --- a/ride/boosting.ride +++ b/ride/boosting.ride @@ -6,7 +6,7 @@ # * "%s%s__config__referralsContractAddress": String # * "%s__nextUserNum": Int # * "%s%s__config__factoryAddress": String -# * "%s__config": String ("%s%d%d%d%s__________") +# * "%s__config": String ("%s%d%d%d%s%d____________") # * "%s__lpStakingPoolsContract": String let SEP = "__" @@ -94,6 +94,7 @@ let IdxCfgMinLockAmount = 2 let IdxCfgMinLockDuration = 3 let IdxCfgMaxLockDuration = 4 let IdxCfgMathContract = 5 +let IdxCfgBlocksInPeriod = 6 func keyConfig() = {"%s__config"} func readConfigArrayOrFail() = this.getStringOrFail(keyConfig()).split(SEP) @@ -103,6 +104,7 @@ let minLockAmount = cfgArray[IdxCfgMinLockAmount].parseInt().valueOrErrorMessage let minLockDuration = cfgArray[IdxCfgMinLockDuration].parseInt().valueOrErrorMessage(wrapErr("invalid min lock duration")) let maxLockDuration = cfgArray[IdxCfgMaxLockDuration].parseInt().valueOrErrorMessage(wrapErr("invalid max lock duration")) let mathContract = cfgArray[IdxCfgMathContract].addressFromString().valueOrErrorMessage(wrapErr("invalid math contract address")) +let blocksInPeriod = cfgArray[IdxCfgBlocksInPeriod].parseInt().valueOrErrorMessage(wrapErr("invalid blocks in period")) func formatConfigS(assetId: String, minLockAmount: String, minLockDuration: String, maxLockDuration: String, mathContract: String) = { makeString([ @@ -646,11 +648,11 @@ func getWxWithdrawable(userAddress: Address, txIdOption: ByteVector|Unit) = { let wxClaimed = userRecordArray[IdxLockWxClaimed].parseIntValue() let gwxAmount = userRecordArray[IdxLockGwxAmount].parseIntValue() - let t = (height - lockStart) / blocksInDay + let t = (height - lockStart) / blocksInPeriod let exponent = fraction( t.toBigInt(), - { 8 * blocksInDay }.toBigInt() * MULT18BI, + { 8 * blocksInPeriod }.toBigInt() * MULT18BI, lockDuration.toBigInt() ) let wxWithdrawable = if (height > lockEnd) then { @@ -730,7 +732,7 @@ func unlock(txIdStr: String, amount: Int) = { let wxClaimed = userRecordArray[IdxLockWxClaimed].parseIntValue() let gwxAmount = userRecordArray[IdxLockGwxAmount].parseIntValue() - let t = (height - lockStart) / blocksInDay + let t = (height - lockStart) / blocksInPeriod let wxWithdrawable = getWxWithdrawable( userAddress, @@ -743,7 +745,7 @@ func unlock(txIdStr: String, amount: Int) = { let gwxBurned = max([ amount, - fraction(t * blocksInDay, userAmount, maxLockDuration) + fraction(t * blocksInPeriod, userAmount, maxLockDuration) ]) let gwxRemaining = ensurePositive(gwxAmount - gwxBurned, "gwxRemaining") let lockedGwxAmount = getLockedGwxAmount(userAddress)