Skip to content

Commit

Permalink
Merge pull request #454 from waves-exchange/l2mp-leasing-tmp-stop
Browse files Browse the repository at this point in the history
l2mp leasing out stop
  • Loading branch information
bra1nsurfer authored Sep 2, 2024
2 parents db06838 + 2a102b7 commit 145e168
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions ride/l2mp_leasing.ride
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ func throwErr(msg: String) = {

let keyAssetId = ["%s", "assetId"].makeString(SEP)
let keyForceStop = ["%s", "forceStop"].makeString(SEP)
let keyForceOutStop = ["%s", "forceOutStop"].makeString(SEP)

let keyPeriodOffsetId = ["%s", "offsetId"].makeString(SEP)
let keyPeriodOffsetHeight = ["%s", "offsetHeight"].makeString(SEP)
Expand Down Expand Up @@ -58,6 +59,7 @@ func keyUserLeasingByHeight(nodeAddress: String, userAddress: String) = {
let assetIdString = this.getString(keyAssetId).valueOrElse("WAVES")
let assetIdBytes = if (assetIdString == "WAVES") then unit else assetIdString.fromBase58String()
let isForceStop = this.getBoolean(keyForceStop).valueOrElse(false)
let isForceOutStop = this.getBoolean(keyForceOutStop).valueOrElse(false)

func isValidAddress(address: String) = {
match (address.addressFromString()) {
Expand Down Expand Up @@ -266,6 +268,7 @@ func getUnstakeActions(nodeAddress: String, userAddress: String, unstakeAmount:

strict checks = [
!isForceStop || "contract is temporary stopped".throwErr(),
!isForceOutStop || "unstake is temporary disabled".throwErr(),
unstakeAmount > 0 || "unstake amount should be greater than 0".throwErr(),
unstakeAmount <= userNextLeased ||
"unstake amount should be less or equal user staked amount".throwErr(),
Expand Down Expand Up @@ -301,6 +304,7 @@ func getClaimUnlockedActions(userAddress: String, claimAmount: Int) = {

strict checks = [
!isForceStop || "contract is temporary stopped".throwErr(),
!isForceOutStop || "claim is temporary disabled".throwErr(),
claimAmount > 0 || "claim amount should be greater than 0".throwErr(),
claimAmount <= toClaim ||
"claim amount should be less or equal unlocked amount".throwErr(),
Expand Down Expand Up @@ -414,6 +418,17 @@ func setForceStopFlag(stop: Boolean) = {
]
}

@Callable(i)
func setForceOutStopFlag(stop: Boolean) = {
strict check = [
isInAdminList(i.caller.toString()) || "caller is not in adminList".throwErr()
]

[
BooleanEntry(keyForceOutStop, stop)
]
}

# Node leasing data
# _1 = current period start height
# _2 = current period leased amount
Expand Down

0 comments on commit 145e168

Please sign in to comment.