tx · BrkV6ZnB28fo3AMKbuDLP5GHPgzyrbBBVsRxAjqjnbJw

3MpMuGN8rW9EpPwzETAQz88Pe9TQhSwiriq:  -0.01000000 Waves

2023.07.19 12:33 [2672569] smart account 3MpMuGN8rW9EpPwzETAQz88Pe9TQhSwiriq > SELF 0.00000000 Waves

{ "type": 13, "id": "BrkV6ZnB28fo3AMKbuDLP5GHPgzyrbBBVsRxAjqjnbJw", "fee": 1000000, "feeAssetId": null, "timestamp": 1689759240288, "version": 2, "chainId": 84, "sender": "3MpMuGN8rW9EpPwzETAQz88Pe9TQhSwiriq", "senderPublicKey": "57SkjQUEwC1ayCqLbXLuzBqifK6B6SR6rfxtGsbAo3zW", "proofs": [ "5UoiXpLcGrQBKDT5vtdDkQgo3crmvpiNXZxAJw5ELx2xomJhiX6zGRTPpAq2m7m6aXrq1ykxmAwcxQeXgrpGLaiD" ], "script": "base64:BgIaCAISAwoBARIAEgMKAQgSAwoBARIDCgEIEgAWAAxjb250cmFjdEZpbGUCEG1ydF9zdGFraW5nLnJpZGUAA1NFUAICX18ABnNjYWxlOACAwtcvABJBRERSRVNTX0JZVEVTX1NJWkUAGgEIdGhyb3dFcnIBA21zZwkAAgEJAKwCAgkArAICBQxjb250cmFjdEZpbGUCAjogBQNtc2cACmtleUFzc2V0SWQJALkJAgkAzAgCAgIlcwkAzAgCAgdhc3NldElkBQNuaWwFA1NFUAATa2V5RW1pc3Npb25QZXJCbG9jawkAuQkCCQDMCAICAiVzCQDMCAICEGVtaXNzaW9uUGVyQmxvY2sFA25pbAUDU0VQAA1rZXlTdGFydEJsb2NrCQC5CQIJAMwIAgICJXMJAMwIAgIKc3RhcnRCbG9jawUDbmlsBQNTRVAAEGtleVRvdGFsTHBBbW91bnQJALkJAgkAzAgCAgIlcwkAzAgCAg10b3RhbExwQW1vdW50BQNuaWwFA1NFUAATa2V5VG90YWxBc3NldEFtb3VudAkAuQkCCQDMCAICAiVzCQDMCAICEHRvdGFsQXNzZXRBbW91bnQFA25p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3RhbEFzc2V0QW1vdW50V2l0aFByb2ZpdE9yTWF4QXZhaWxhYmxlAAkBD2dldEN1cnJlbnRQcmljZQAAYFOd7g==", "height": 2672569, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 9afHXwHh2UxoJQFxqLuw6zqfYFiaKnxC7Q9DZj31CpK9 Next: 9VSJDAE3AHniSi75bSKhCVmtHkc9WfD5jg2kNLKT1KBf Diff:
OldNewDifferences
66 let SEP = "__"
77
88 let scale8 = 100000000
9+
10+let ADDRESS_BYTES_SIZE = 26
911
1012 func throwErr (msg) = throw(((contractFile + ": ") + msg))
1113
113115
114116
115117 @Callable(i)
116-func stakeFor (userAddress) = getStakeAction(i, userAddress)
118+func stakeFor (userAddress) = {
119+ let check = [if ((size(fromBase58String(userAddress)) == ADDRESS_BYTES_SIZE))
120+ then true
121+ else throwErr("address is not valid")]
122+ if ((check == check))
123+ then getStakeAction(i, userAddress)
124+ else throw("Strict value is not equal to itself.")
125+ }
117126
118127
119128
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let contractFile = "mrt_staking.ride"
55
66 let SEP = "__"
77
88 let scale8 = 100000000
9+
10+let ADDRESS_BYTES_SIZE = 26
911
1012 func throwErr (msg) = throw(((contractFile + ": ") + msg))
1113
1214
1315 let keyAssetId = makeString(["%s", "assetId"], SEP)
1416
1517 let keyEmissionPerBlock = makeString(["%s", "emissionPerBlock"], SEP)
1618
1719 let keyStartBlock = makeString(["%s", "startBlock"], SEP)
1820
1921 let keyTotalLpAmount = makeString(["%s", "totalLpAmount"], SEP)
2022
2123 let keyTotalAssetAmount = makeString(["%s", "totalAssetAmount"], SEP)
2224
2325 func keyUserLpAmount (userAddress) = makeString(["%s%s", "userLpAmount", userAddress], SEP)
2426
2527
2628 func keyUserTotalAssetWithdrawn (userAddress) = makeString(["%s%s", "totalAssetWithdrawn", userAddress], SEP)
2729
2830
2931 func keyUserTotalAssetStaked (userAddress) = makeString(["%s%s", "totalAssetStaked", userAddress], SEP)
3032
3133
3234 let totalLpAmount = valueOrElse(getInteger(this, keyTotalLpAmount), 0)
3335
3436 let totalAssetAmount = valueOrElse(getInteger(this, keyTotalAssetAmount), 0)
3537
3638 let assetIdString = valueOrElse(getString(this, keyAssetId), "WAVES")
3739
3840 let assetIdBytes = if ((assetIdString == "WAVES"))
3941 then unit
4042 else fromBase58String(assetIdString)
4143
4244 func getUserLpAmount (userAddress) = valueOrElse(getInteger(this, keyUserLpAmount(userAddress)), 0)
4345
4446
4547 func calcTotalProfit () = {
4648 let emissionPerBlock = valueOrElse(getInteger(this, keyEmissionPerBlock), 0)
4749 let startBlock = valueOrElse(getInteger(this, keyStartBlock), 0)
4850 let elapsedBlocks = (height - startBlock)
4951 max([0, (emissionPerBlock * elapsedBlocks)])
5052 }
5153
5254
5355 func getTotalAssetAmountWithProfitOrMaxAvailable () = {
5456 let totalAssetAmountWithProfit = (totalAssetAmount + calcTotalProfit())
5557 match assetIdBytes {
5658 case u: Unit =>
5759 min([totalAssetAmountWithProfit, wavesBalance(this).available])
5860 case b: ByteVector =>
5961 min([totalAssetAmountWithProfit, assetBalance(this, b)])
6062 case _ =>
6163 throw("Match error")
6264 }
6365 }
6466
6567
6668 func getCurrentPrice () = if ((totalLpAmount != 0))
6769 then fraction(getTotalAssetAmountWithProfitOrMaxAvailable(), scale8, totalLpAmount)
6870 else (1 * scale8)
6971
7072
7173 func getStakeAction (i,userAddress) = {
7274 let checks = [if ((size(i.payments) == 1))
7375 then true
7476 else throwErr("should include 1 payment"), if ((i.payments[0].assetId == assetIdBytes))
7577 then true
7678 else throwErr(("payment should be in " + assetIdString)), if ((i.payments[0].amount > 0))
7779 then true
7880 else "payment amount should be greater than 0"]
7981 if ((checks == checks))
8082 then {
8183 let paymentAmount = i.payments[0].amount
8284 let paymentLpAmount = fraction(paymentAmount, scale8, getCurrentPrice())
8385 let userLpAmount = getUserLpAmount(userAddress)
8486 let userTotalInvestedAmount = valueOrElse(getInteger(this, keyUserTotalAssetStaked(userAddress)), 0)
8587 let newTotalLpAmount = (totalLpAmount + paymentLpAmount)
8688 let newTotalAssetAmount = (totalAssetAmount + paymentAmount)
8789 let newUserLpAmount = (userLpAmount + paymentLpAmount)
8890 let newUserTotalInvestedAmount = (userTotalInvestedAmount + paymentAmount)
8991 let updateStartHeightAction = if ((totalLpAmount == 0))
9092 then [IntegerEntry(keyStartBlock, height)]
9193 else nil
9294 ([IntegerEntry(keyTotalLpAmount, newTotalLpAmount), IntegerEntry(keyTotalAssetAmount, newTotalAssetAmount), IntegerEntry(keyUserLpAmount(userAddress), newUserLpAmount), IntegerEntry(keyUserTotalAssetStaked(userAddress), newUserTotalInvestedAmount)] ++ updateStartHeightAction)
9395 }
9496 else throw("Strict value is not equal to itself.")
9597 }
9698
9799
98100 @Callable(i)
99101 func setEmissionPerBlock (emissionPerBlock) = {
100102 let check = [if ((i.caller == this))
101103 then true
102104 else throwErr("permission denied")]
103105 if ((check == check))
104106 then [IntegerEntry(keyTotalAssetAmount, getTotalAssetAmountWithProfitOrMaxAvailable()), IntegerEntry(keyStartBlock, height), IntegerEntry(keyEmissionPerBlock, max([0, emissionPerBlock]))]
105107 else throw("Strict value is not equal to itself.")
106108 }
107109
108110
109111
110112 @Callable(i)
111113 func stake () = getStakeAction(i, toString(i.caller))
112114
113115
114116
115117 @Callable(i)
116-func stakeFor (userAddress) = getStakeAction(i, userAddress)
118+func stakeFor (userAddress) = {
119+ let check = [if ((size(fromBase58String(userAddress)) == ADDRESS_BYTES_SIZE))
120+ then true
121+ else throwErr("address is not valid")]
122+ if ((check == check))
123+ then getStakeAction(i, userAddress)
124+ else throw("Strict value is not equal to itself.")
125+ }
117126
118127
119128
120129 @Callable(i)
121130 func withdraw (lpAssetWithdrawAmount) = {
122131 let userAddress = toString(i.caller)
123132 let userLpAmount = getUserLpAmount(userAddress)
124133 let check = [if ((lpAssetWithdrawAmount > 0))
125134 then true
126135 else throwErr("amount should be more than 0"), if ((userLpAmount >= lpAssetWithdrawAmount))
127136 then true
128137 else throwErr((("cannot withdraw more than available (" + toString(userLpAmount)) + ")"))]
129138 if ((check == check))
130139 then {
131140 let newUserLpAmount = (userLpAmount - lpAssetWithdrawAmount)
132141 let withdrawAssetAmount = fraction(lpAssetWithdrawAmount, getCurrentPrice(), scale8)
133142 let newTotalLpAmount = (totalLpAmount - lpAssetWithdrawAmount)
134143 let newTotalAssetAmount = fraction(newTotalLpAmount, getCurrentPrice(), scale8)
135144 let userTotalAssetWithdrawn = valueOrElse(getInteger(this, keyUserTotalAssetWithdrawn(userAddress)), 0)
136145 let newUserTotalAssetWithdrawn = (userTotalAssetWithdrawn + withdrawAssetAmount)
137146 [IntegerEntry(keyTotalLpAmount, newTotalLpAmount), IntegerEntry(keyTotalAssetAmount, newTotalAssetAmount), IntegerEntry(keyUserLpAmount(userAddress), newUserLpAmount), IntegerEntry(keyUserTotalAssetWithdrawn(userAddress), newUserTotalAssetWithdrawn), IntegerEntry(keyStartBlock, height), ScriptTransfer(i.caller, withdrawAssetAmount, assetIdBytes)]
138147 }
139148 else throw("Strict value is not equal to itself.")
140149 }
141150
142151
143152
144153 @Callable(i)
145154 func getUserAssetsREADONLY (userAddress) = {
146155 let userLpAmount = getUserLpAmount(userAddress)
147156 let userAvailableAssetToWithdraw = fraction(userLpAmount, getCurrentPrice(), scale8)
148157 $Tuple2(nil, $Tuple3(userLpAmount, userAvailableAssetToWithdraw, getCurrentPrice()))
149158 }
150159
151160
152161
153162 @Callable(i)
154163 func getTotalAssetsREADONLY () = $Tuple2(nil, $Tuple3(totalLpAmount, getTotalAssetAmountWithProfitOrMaxAvailable(), getCurrentPrice()))
155164
156165

github/deemru/w8io/026f985 
28.19 ms