tx · Ey95ev4ZQjzjxifq5tnLJ3VFZQkinZJpDAYq35oyXxuo

3N4yYqBkTUq1mDdHhvAd3St7spCbm84DytS:  -0.05000000 Waves

2023.07.28 14:27 [2685653] smart account 3N4yYqBkTUq1mDdHhvAd3St7spCbm84DytS > SELF 0.00000000 Waves

{ "type": 13, "id": "Ey95ev4ZQjzjxifq5tnLJ3VFZQkinZJpDAYq35oyXxuo", "fee": 5000000, "feeAssetId": null, "timestamp": 1690543652550, "version": 2, "chainId": 84, "sender": "3N4yYqBkTUq1mDdHhvAd3St7spCbm84DytS", "senderPublicKey": "8h7G4haeVwXKNHXNHsWkC1miUp5CQtk3WmpBKazQPxRh", "proofs": [ "3T8Hv2aaZDYrV94qkDe1oLjHDD2cg2XEqNQdDkFcEcZoaMkikhGM2iPTcTHxDSjHt76eoqyz9Ajq2DkzZhH3Boyx" ], "script": "base64:BgIfCAISAwoBARIAEgMKAQgSAwoBARIDCgEIEgASAwoBCC4ADGNvbnRyYWN0RmlsZQIRbDJtcF9zdGFraW5nLnJpZGUAA1NFUAICX18ABnNjYWxlOACAwtcvABJBRERSRVNTX0JZVEVTX1NJWkUAGgANQkxPQ0tTX0lOX0RBWQCgCwEIdGhyb3dFcnIBA21zZwkAAgEJAKwCAgkArAICBQxjb250cmFjdEZpbGUCAjogBQNtc2cACmtleUFzc2V0SWQJALkJAgkAzAgCAgIlcwkAzAgCAgdhc3NldElkBQNuaWwFA1NFUAATa2V5RW1pc3Npb25QZXJCbG9jawkAuQkCCQDMCAICAiVzCQDMCAICEGVtaXNzaW9uUGVyQmxvY2sFA25pbAUDU0VQABlrZXlFbWlzc2lvblBlcmlvZEluQmxvY2tzCQC5CQIJAMwIAgICJXMJAMwIAgIWZW1pc3Npb25QZXJpb2RJbkJsb2NrcwUDbmlsBQNTRVAADWtleVN0YXJ0QmxvY2sJALkJAgkAzAgCAgIlcwkAzAgCAgpzdGFydEJsb2NrBQNuaWwFA1NFUAAQa2V5VG90YWxMcEFtb3VudAkA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ZHkgYWxsb3dlZAUDbmlsAwkAAAIFA2VycgUDZXJyCQEMdm90ZUlOVEVSTkFMBAUTY2FsbGVyQWRkcmVzc1N0cmluZwUJa2V5UHJlZml4BQZRVU9SVU0FBnJlc3VsdAkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgECdHgBBnZlcmlmeQAECGJ5QWRtaW5zCQAAAggFAnR4AmlkCQDZBAEJAQt2YWx1ZU9yRWxzZQIJAJ0IAgUEdGhpcwkBDmtleUFsbG93ZWRUeElkAAIABAdieU93bmVyAwkAZwIJAJADAQkBDWdldEFkbWluc0xpc3QABQZRVU9SVU0HCQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwAACAUCdHgPc2VuZGVyUHVibGljS2V5AwUIYnlBZG1pbnMGBQdieU93bmVyDjHUaQ==", "height": 2685653, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: vHYMbbJP8uE7VcxZnHFz9nBMBeSLdy1SCisTgNfkDs3 Next: DcnuuFfkHwSRmQJz4b88tRFeeyGNbMcGQ8Tetory6KJB Diff:
OldNewDifferences
66 let SEP = "__"
77
88 let scale8 = 100000000
9-
10-let scale18 = 1000000000000000000
11-
12-let scale18BigInt = toBigInt(scale18)
139
1410 let ADDRESS_BYTES_SIZE = 26
1511
3935 func keyUserTotalAssetStaked (userAddress) = makeString(["%s%s", "totalAssetStaked", userAddress], SEP)
4036
4137
42-func keyHistory (type,userAddress,txId) = makeString(["%s%s%s", type, userAddress, toBase58String(txId)], SEP)
43-
44-
45-func formatHistory (totalProfit,price,totalAssetAmount,totalLpAmount) = makeString(["%d%d", toString(totalProfit), toString(price), toString(totalAssetAmount), toString(totalLpAmount)], SEP)
46-
47-
4838 let totalLpAmount = valueOrElse(getInteger(this, keyTotalLpAmount), 0)
4939
5040 let totalAssetAmount = valueOrElse(getInteger(this, keyTotalAssetAmount), 0)
5848 let emissionPeriodInBlocks = valueOrElse(getInteger(this, keyEmissionPeriodInBlocks), BLOCKS_IN_DAY)
5949
6050 let emissionPerPeriod = (valueOrElse(getInteger(this, keyEmissionPerBlock), 0) * emissionPeriodInBlocks)
51+
52+let heightInPeriods = fraction(height, 1, emissionPeriodInBlocks)
6153
6254 let ADMIN_LIST_SIZE = 5
6355
9587
9688
9789 func genVotesKeysHelper (a,adminAddress) = {
98- let $t030453069 = a
99- let result = $t030453069._1
100- let prefix = $t030453069._2
90+ let $t026392663 = a
91+ let result = $t026392663._1
92+ let prefix = $t026392663._2
10193 $Tuple2((result :+ keyFullAdminVote(prefix, adminAddress)), prefix)
10294 }
10395
10496
10597 func genVotesKeys (keyPrefix) = {
10698 let adminList = keyAdminAddressList()
107- let $t032163300 = {
99+ let $t028102894 = {
108100 let $l = getAdminsList()
109101 let $s = size($l)
110102 let $acc0 = $Tuple2(nil, keyPrefix)
118110
119111 $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5)
120112 }
121- let result = $t032163300._1
122- let prefix = $t032163300._2
113+ let result = $t028102894._1
114+ let prefix = $t028102894._2
123115 result
124116 }
125117
186178 }
187179
188180
189-func calcTotalProfitForHeight (h) = {
181+func calcTotalProfit () = {
190182 let startBlock = valueOrElse(getInteger(this, keyStartBlock), 0)
191183 let startPeriod = fraction(startBlock, 1, emissionPeriodInBlocks)
192- let elapsedPeriods = ((h / emissionPeriodInBlocks) - startPeriod)
184+ let elapsedPeriods = (heightInPeriods - startPeriod)
193185 max([0, (emissionPerPeriod * elapsedPeriods)])
194186 }
195-
196-
197-func calcTotalProfit () = calcTotalProfitForHeight(height)
198187
199188
200189 func getTotalAssetAmountWithProfitOrMaxAvailable () = {
214203
215204
216205 func getCurrentPrice () = if ((totalLpAmount != 0))
217- then fraction(toBigInt(getTotalAssetAmountWithProfitOrMaxAvailable()), scale18BigInt, toBigInt(totalLpAmount))
218- else scale18BigInt
206+ then fraction(getTotalAssetAmountWithProfitOrMaxAvailable(), scale8, totalLpAmount)
207+ else (1 * scale8)
219208
220209
221210 func getUserLpAmount (userAddress) = valueOrElse(getInteger(this, keyUserLpAmount(userAddress)), 0)
223212
224213 func getUserAvailableAssetsToWithdraw (userAddress) = {
225214 let userLpAmount = getUserLpAmount(userAddress)
226- let userAvailableAssetToWithdraw = toInt(fraction(toBigInt(userLpAmount), getCurrentPrice(), scale18BigInt))
215+ let userAvailableAssetToWithdraw = fraction(userLpAmount, getCurrentPrice(), scale8)
227216 if ((0 > userAvailableAssetToWithdraw))
228217 then 0
229218 else userAvailableAssetToWithdraw
241230 if ((checks == checks))
242231 then {
243232 let paymentAmount = i.payments[0].amount
244- let paymentLpAmount = toInt(fraction(toBigInt(paymentAmount), scale18BigInt, getCurrentPrice()))
233+ let paymentLpAmount = fraction(paymentAmount, scale8, getCurrentPrice())
245234 let userLpAmount = getUserLpAmount(userAddress)
246235 let userTotalStakedAmount = valueOrElse(getInteger(this, keyUserTotalAssetStaked(userAddress)), 0)
247236 let newTotalLpAmount = (totalLpAmount + paymentLpAmount)
251240 let updateStartHeightAction = if ((totalLpAmount == 0))
252241 then [IntegerEntry(keyStartBlock, height)]
253242 else nil
254- ([StringEntry(keyHistory("stake", userAddress, i.transactionId), formatHistory(calcTotalProfit(), getCurrentPrice(), totalLpAmount, totalAssetAmount)), IntegerEntry(keyTotalLpAmount, newTotalLpAmount), IntegerEntry(keyTotalAssetAmount, newTotalAssetAmount), IntegerEntry(keyUserLpAmount(userAddress), newUserLpAmount), IntegerEntry(keyUserTotalAssetStaked(userAddress), newUserTotalStakedAmount)] ++ updateStartHeightAction)
243+ ([IntegerEntry(keyTotalLpAmount, newTotalLpAmount), IntegerEntry(keyTotalAssetAmount, newTotalAssetAmount), IntegerEntry(keyUserLpAmount(userAddress), newUserLpAmount), IntegerEntry(keyUserTotalAssetStaked(userAddress), newUserTotalStakedAmount)] ++ updateStartHeightAction)
255244 }
256245 else throw("Strict value is not equal to itself.")
257246 }
268257 if ((check == check))
269258 then {
270259 let newUserLpAmount = (userLpAmount - lpAssetWithdrawAmount)
271- let withdrawAssetAmount = toInt(fraction(toBigInt(lpAssetWithdrawAmount), getCurrentPrice(), scale18BigInt))
260+ let withdrawAssetAmount = fraction(lpAssetWithdrawAmount, getCurrentPrice(), scale8)
272261 let newTotalLpAmount = (totalLpAmount - lpAssetWithdrawAmount)
273- let newTotalAssetAmount = toInt(fraction(toBigInt(newTotalLpAmount), getCurrentPrice(), scale18BigInt))
262+ let newTotalAssetAmount = fraction(newTotalLpAmount, getCurrentPrice(), scale8)
274263 let userTotalAssetWithdrawn = valueOrElse(getInteger(this, keyUserTotalAssetWithdrawn(userAddress)), 0)
275264 let newUserTotalAssetWithdrawn = (userTotalAssetWithdrawn + withdrawAssetAmount)
276-[StringEntry(keyHistory("withdraw", userAddress, i.transactionId), formatHistory(calcTotalProfit(), getCurrentPrice(), totalAssetAmount, totalLpAmount)), IntegerEntry(keyTotalLpAmount, newTotalLpAmount), IntegerEntry(keyTotalAssetAmount, newTotalAssetAmount), IntegerEntry(keyUserLpAmount(userAddress), newUserLpAmount), IntegerEntry(keyUserTotalAssetWithdrawn(userAddress), newUserTotalAssetWithdrawn), IntegerEntry(keyStartBlock, height), ScriptTransfer(i.caller, withdrawAssetAmount, assetIdBytes)]
265+[IntegerEntry(keyTotalLpAmount, newTotalLpAmount), IntegerEntry(keyTotalAssetAmount, newTotalAssetAmount), IntegerEntry(keyUserLpAmount(userAddress), newUserLpAmount), IntegerEntry(keyUserTotalAssetWithdrawn(userAddress), newUserTotalAssetWithdrawn), IntegerEntry(keyStartBlock, height), ScriptTransfer(i.caller, withdrawAssetAmount, assetIdBytes)]
277266 }
278267 else throw("Strict value is not equal to itself.")
279268 }
312301 func withdraw (withdrawAssetAmount) = {
313302 let userAddress = toString(i.caller)
314303 let userLpAmount = getUserLpAmount(userAddress)
315- let lpAmountToWithdraw = toInt(fraction(toBigInt(withdrawAssetAmount), scale18BigInt, getCurrentPrice()))
304+ let lpAmountToWithdraw = fraction(withdrawAssetAmount, scale8, getCurrentPrice())
316305 let userAvailableAssetToWithdraw = getUserAvailableAssetsToWithdraw(userAddress)
317- let minWithdrawAssetAmount = toInt(fraction(getCurrentPrice(), toBigInt(1), scale18BigInt, CEILING))
306+ let minWithdrawAssetAmount = fraction(getCurrentPrice(), 1, scale8, CEILING)
318307 let check = [if ((withdrawAssetAmount > 0))
319308 then true
320309 else throwErr("withdraw amount should be more than 0"), if ((userAvailableAssetToWithdraw >= withdrawAssetAmount))
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let contractFile = "l2mp_staking.ride"
55
66 let SEP = "__"
77
88 let scale8 = 100000000
9-
10-let scale18 = 1000000000000000000
11-
12-let scale18BigInt = toBigInt(scale18)
139
1410 let ADDRESS_BYTES_SIZE = 26
1511
1612 let BLOCKS_IN_DAY = 1440
1713
1814 func throwErr (msg) = throw(((contractFile + ": ") + msg))
1915
2016
2117 let keyAssetId = makeString(["%s", "assetId"], SEP)
2218
2319 let keyEmissionPerBlock = makeString(["%s", "emissionPerBlock"], SEP)
2420
2521 let keyEmissionPeriodInBlocks = makeString(["%s", "emissionPeriodInBlocks"], SEP)
2622
2723 let keyStartBlock = makeString(["%s", "startBlock"], SEP)
2824
2925 let keyTotalLpAmount = makeString(["%s", "totalLpAmount"], SEP)
3026
3127 let keyTotalAssetAmount = makeString(["%s", "totalAssetAmount"], SEP)
3228
3329 func keyUserLpAmount (userAddress) = makeString(["%s%s", "userLpAmount", userAddress], SEP)
3430
3531
3632 func keyUserTotalAssetWithdrawn (userAddress) = makeString(["%s%s", "totalAssetWithdrawn", userAddress], SEP)
3733
3834
3935 func keyUserTotalAssetStaked (userAddress) = makeString(["%s%s", "totalAssetStaked", userAddress], SEP)
4036
4137
42-func keyHistory (type,userAddress,txId) = makeString(["%s%s%s", type, userAddress, toBase58String(txId)], SEP)
43-
44-
45-func formatHistory (totalProfit,price,totalAssetAmount,totalLpAmount) = makeString(["%d%d", toString(totalProfit), toString(price), toString(totalAssetAmount), toString(totalLpAmount)], SEP)
46-
47-
4838 let totalLpAmount = valueOrElse(getInteger(this, keyTotalLpAmount), 0)
4939
5040 let totalAssetAmount = valueOrElse(getInteger(this, keyTotalAssetAmount), 0)
5141
5242 let assetIdString = valueOrElse(getString(this, keyAssetId), "WAVES")
5343
5444 let assetIdBytes = if ((assetIdString == "WAVES"))
5545 then unit
5646 else fromBase58String(assetIdString)
5747
5848 let emissionPeriodInBlocks = valueOrElse(getInteger(this, keyEmissionPeriodInBlocks), BLOCKS_IN_DAY)
5949
6050 let emissionPerPeriod = (valueOrElse(getInteger(this, keyEmissionPerBlock), 0) * emissionPeriodInBlocks)
51+
52+let heightInPeriods = fraction(height, 1, emissionPeriodInBlocks)
6153
6254 let ADMIN_LIST_SIZE = 5
6355
6456 let QUORUM = 3
6557
6658 let TXID_BYTES_LENGTH = 32
6759
6860 func keyAllowedTxIdVotePrefix (txId) = makeString(["%s%s%s", "allowTxId", txId], SEP)
6961
7062
7163 func keyFullAdminVote (prefix,adminAddress) = makeString([prefix, adminAddress], SEP)
7264
7365
7466 func keyAdminAddressList () = makeString(["%s", "adminAddressList"], SEP)
7567
7668
7769 func keyAllowedTxId () = makeString(["%s", "txId"], SEP)
7870
7971
8072 func getAdminVote (prefix,admin) = {
8173 let voteKey = keyFullAdminVote(prefix, admin)
8274 valueOrElse(getInteger(voteKey), 0)
8375 }
8476
8577
8678 func getAdminsList () = match getString(this, keyAdminAddressList()) {
8779 case s: String =>
8880 split(s, SEP)
8981 case _ =>
9082 nil
9183 }
9284
9385
9486 func isInAdminList (address) = containsElement(getAdminsList(), address)
9587
9688
9789 func genVotesKeysHelper (a,adminAddress) = {
98- let $t030453069 = a
99- let result = $t030453069._1
100- let prefix = $t030453069._2
90+ let $t026392663 = a
91+ let result = $t026392663._1
92+ let prefix = $t026392663._2
10193 $Tuple2((result :+ keyFullAdminVote(prefix, adminAddress)), prefix)
10294 }
10395
10496
10597 func genVotesKeys (keyPrefix) = {
10698 let adminList = keyAdminAddressList()
107- let $t032163300 = {
99+ let $t028102894 = {
108100 let $l = getAdminsList()
109101 let $s = size($l)
110102 let $acc0 = $Tuple2(nil, keyPrefix)
111103 func $f0_1 ($a,$i) = if (($i >= $s))
112104 then $a
113105 else genVotesKeysHelper($a, $l[$i])
114106
115107 func $f0_2 ($a,$i) = if (($i >= $s))
116108 then $a
117109 else throw("List size exceeds 5")
118110
119111 $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5)
120112 }
121- let result = $t032163300._1
122- let prefix = $t032163300._2
113+ let result = $t028102894._1
114+ let prefix = $t028102894._2
123115 result
124116 }
125117
126118
127119 func countVotesHelper (result,voteKey) = (result + valueOrElse(getInteger(voteKey), 0))
128120
129121
130122 func countVotes (prefix) = {
131123 let votes = genVotesKeys(prefix)
132124 let $l = votes
133125 let $s = size($l)
134126 let $acc0 = 0
135127 func $f0_1 ($a,$i) = if (($i >= $s))
136128 then $a
137129 else countVotesHelper($a, $l[$i])
138130
139131 func $f0_2 ($a,$i) = if (($i >= $s))
140132 then $a
141133 else throw("List size exceeds 5")
142134
143135 $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5)
144136 }
145137
146138
147139 func clearVotesHelper (result,key) = (result :+ DeleteEntry(key))
148140
149141
150142 func getClearVoteEntries (prefix) = {
151143 let votes = genVotesKeys(prefix)
152144 let $l = votes
153145 let $s = size($l)
154146 let $acc0 = nil
155147 func $f0_1 ($a,$i) = if (($i >= $s))
156148 then $a
157149 else clearVotesHelper($a, $l[$i])
158150
159151 func $f0_2 ($a,$i) = if (($i >= $s))
160152 then $a
161153 else throw("List size exceeds 5")
162154
163155 $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5)
164156 }
165157
166158
167159 func voteINTERNAL (callerAddressString,keyPrefix,minVotes,voteResult) = {
168160 let voteKey = keyFullAdminVote(keyPrefix, callerAddressString)
169161 let adminCurrentVote = getAdminVote(keyPrefix, callerAddressString)
170162 let err = if (!(isInAdminList(callerAddressString)))
171163 then throwErr((("Address: " + callerAddressString) + " not in Admin list"))
172164 else if ((adminCurrentVote == 1))
173165 then throwErr((voteKey + " you already voted"))
174166 else unit
175167 if ((err == err))
176168 then {
177169 let votes = countVotes(keyPrefix)
178170 if (((votes + 1) >= minVotes))
179171 then {
180172 let clearVoteEntries = getClearVoteEntries(keyPrefix)
181173 (clearVoteEntries ++ voteResult)
182174 }
183175 else [IntegerEntry(voteKey, 1)]
184176 }
185177 else throw("Strict value is not equal to itself.")
186178 }
187179
188180
189-func calcTotalProfitForHeight (h) = {
181+func calcTotalProfit () = {
190182 let startBlock = valueOrElse(getInteger(this, keyStartBlock), 0)
191183 let startPeriod = fraction(startBlock, 1, emissionPeriodInBlocks)
192- let elapsedPeriods = ((h / emissionPeriodInBlocks) - startPeriod)
184+ let elapsedPeriods = (heightInPeriods - startPeriod)
193185 max([0, (emissionPerPeriod * elapsedPeriods)])
194186 }
195-
196-
197-func calcTotalProfit () = calcTotalProfitForHeight(height)
198187
199188
200189 func getTotalAssetAmountWithProfitOrMaxAvailable () = {
201190 let totalAssetAmountWithProfit = (totalAssetAmount + calcTotalProfit())
202191 let totalAmount = match assetIdBytes {
203192 case u: Unit =>
204193 min([totalAssetAmountWithProfit, wavesBalance(this).available])
205194 case b: ByteVector =>
206195 min([totalAssetAmountWithProfit, assetBalance(this, b)])
207196 case _ =>
208197 throw("Match error")
209198 }
210199 if ((totalLpAmount == 0))
211200 then 0
212201 else totalAmount
213202 }
214203
215204
216205 func getCurrentPrice () = if ((totalLpAmount != 0))
217- then fraction(toBigInt(getTotalAssetAmountWithProfitOrMaxAvailable()), scale18BigInt, toBigInt(totalLpAmount))
218- else scale18BigInt
206+ then fraction(getTotalAssetAmountWithProfitOrMaxAvailable(), scale8, totalLpAmount)
207+ else (1 * scale8)
219208
220209
221210 func getUserLpAmount (userAddress) = valueOrElse(getInteger(this, keyUserLpAmount(userAddress)), 0)
222211
223212
224213 func getUserAvailableAssetsToWithdraw (userAddress) = {
225214 let userLpAmount = getUserLpAmount(userAddress)
226- let userAvailableAssetToWithdraw = toInt(fraction(toBigInt(userLpAmount), getCurrentPrice(), scale18BigInt))
215+ let userAvailableAssetToWithdraw = fraction(userLpAmount, getCurrentPrice(), scale8)
227216 if ((0 > userAvailableAssetToWithdraw))
228217 then 0
229218 else userAvailableAssetToWithdraw
230219 }
231220
232221
233222 func getStakeActions (i,userAddress) = {
234223 let checks = [if ((size(i.payments) == 1))
235224 then true
236225 else throwErr("should include 1 payment"), if ((i.payments[0].assetId == assetIdBytes))
237226 then true
238227 else throwErr(("payment should be in " + assetIdString)), if ((i.payments[0].amount > 0))
239228 then true
240229 else "payment amount should be greater than 0"]
241230 if ((checks == checks))
242231 then {
243232 let paymentAmount = i.payments[0].amount
244- let paymentLpAmount = toInt(fraction(toBigInt(paymentAmount), scale18BigInt, getCurrentPrice()))
233+ let paymentLpAmount = fraction(paymentAmount, scale8, getCurrentPrice())
245234 let userLpAmount = getUserLpAmount(userAddress)
246235 let userTotalStakedAmount = valueOrElse(getInteger(this, keyUserTotalAssetStaked(userAddress)), 0)
247236 let newTotalLpAmount = (totalLpAmount + paymentLpAmount)
248237 let newTotalAssetAmount = (totalAssetAmount + paymentAmount)
249238 let newUserLpAmount = (userLpAmount + paymentLpAmount)
250239 let newUserTotalStakedAmount = (userTotalStakedAmount + paymentAmount)
251240 let updateStartHeightAction = if ((totalLpAmount == 0))
252241 then [IntegerEntry(keyStartBlock, height)]
253242 else nil
254- ([StringEntry(keyHistory("stake", userAddress, i.transactionId), formatHistory(calcTotalProfit(), getCurrentPrice(), totalLpAmount, totalAssetAmount)), IntegerEntry(keyTotalLpAmount, newTotalLpAmount), IntegerEntry(keyTotalAssetAmount, newTotalAssetAmount), IntegerEntry(keyUserLpAmount(userAddress), newUserLpAmount), IntegerEntry(keyUserTotalAssetStaked(userAddress), newUserTotalStakedAmount)] ++ updateStartHeightAction)
243+ ([IntegerEntry(keyTotalLpAmount, newTotalLpAmount), IntegerEntry(keyTotalAssetAmount, newTotalAssetAmount), IntegerEntry(keyUserLpAmount(userAddress), newUserLpAmount), IntegerEntry(keyUserTotalAssetStaked(userAddress), newUserTotalStakedAmount)] ++ updateStartHeightAction)
255244 }
256245 else throw("Strict value is not equal to itself.")
257246 }
258247
259248
260249 func getWithdrawActions (i,lpAssetWithdrawAmount) = {
261250 let userAddress = toString(i.caller)
262251 let userLpAmount = getUserLpAmount(userAddress)
263252 let check = [if ((lpAssetWithdrawAmount > 0))
264253 then true
265254 else throwErr("LP amount should be more than 0"), if ((userLpAmount >= lpAssetWithdrawAmount))
266255 then true
267256 else throwErr((("cannot withdraw more than available LP (" + toString(userLpAmount)) + ")"))]
268257 if ((check == check))
269258 then {
270259 let newUserLpAmount = (userLpAmount - lpAssetWithdrawAmount)
271- let withdrawAssetAmount = toInt(fraction(toBigInt(lpAssetWithdrawAmount), getCurrentPrice(), scale18BigInt))
260+ let withdrawAssetAmount = fraction(lpAssetWithdrawAmount, getCurrentPrice(), scale8)
272261 let newTotalLpAmount = (totalLpAmount - lpAssetWithdrawAmount)
273- let newTotalAssetAmount = toInt(fraction(toBigInt(newTotalLpAmount), getCurrentPrice(), scale18BigInt))
262+ let newTotalAssetAmount = fraction(newTotalLpAmount, getCurrentPrice(), scale8)
274263 let userTotalAssetWithdrawn = valueOrElse(getInteger(this, keyUserTotalAssetWithdrawn(userAddress)), 0)
275264 let newUserTotalAssetWithdrawn = (userTotalAssetWithdrawn + withdrawAssetAmount)
276-[StringEntry(keyHistory("withdraw", userAddress, i.transactionId), formatHistory(calcTotalProfit(), getCurrentPrice(), totalAssetAmount, totalLpAmount)), IntegerEntry(keyTotalLpAmount, newTotalLpAmount), IntegerEntry(keyTotalAssetAmount, newTotalAssetAmount), IntegerEntry(keyUserLpAmount(userAddress), newUserLpAmount), IntegerEntry(keyUserTotalAssetWithdrawn(userAddress), newUserTotalAssetWithdrawn), IntegerEntry(keyStartBlock, height), ScriptTransfer(i.caller, withdrawAssetAmount, assetIdBytes)]
265+[IntegerEntry(keyTotalLpAmount, newTotalLpAmount), IntegerEntry(keyTotalAssetAmount, newTotalAssetAmount), IntegerEntry(keyUserLpAmount(userAddress), newUserLpAmount), IntegerEntry(keyUserTotalAssetWithdrawn(userAddress), newUserTotalAssetWithdrawn), IntegerEntry(keyStartBlock, height), ScriptTransfer(i.caller, withdrawAssetAmount, assetIdBytes)]
277266 }
278267 else throw("Strict value is not equal to itself.")
279268 }
280269
281270
282271 @Callable(i)
283272 func setEmissionPerBlock (emissionPerBlock) = {
284273 let check = [if ((i.caller == this))
285274 then true
286275 else throwErr("permission denied")]
287276 if ((check == check))
288277 then [IntegerEntry(keyTotalAssetAmount, getTotalAssetAmountWithProfitOrMaxAvailable()), IntegerEntry(keyStartBlock, height), IntegerEntry(keyEmissionPerBlock, max([0, emissionPerBlock]))]
289278 else throw("Strict value is not equal to itself.")
290279 }
291280
292281
293282
294283 @Callable(i)
295284 func stake () = getStakeActions(i, toString(i.caller))
296285
297286
298287
299288 @Callable(i)
300289 func stakeFor (userAddress) = {
301290 let check = [if ((size(fromBase58String(userAddress)) == ADDRESS_BYTES_SIZE))
302291 then true
303292 else throwErr("address is not valid")]
304293 if ((check == check))
305294 then getStakeActions(i, userAddress)
306295 else throw("Strict value is not equal to itself.")
307296 }
308297
309298
310299
311300 @Callable(i)
312301 func withdraw (withdrawAssetAmount) = {
313302 let userAddress = toString(i.caller)
314303 let userLpAmount = getUserLpAmount(userAddress)
315- let lpAmountToWithdraw = toInt(fraction(toBigInt(withdrawAssetAmount), scale18BigInt, getCurrentPrice()))
304+ let lpAmountToWithdraw = fraction(withdrawAssetAmount, scale8, getCurrentPrice())
316305 let userAvailableAssetToWithdraw = getUserAvailableAssetsToWithdraw(userAddress)
317- let minWithdrawAssetAmount = toInt(fraction(getCurrentPrice(), toBigInt(1), scale18BigInt, CEILING))
306+ let minWithdrawAssetAmount = fraction(getCurrentPrice(), 1, scale8, CEILING)
318307 let check = [if ((withdrawAssetAmount > 0))
319308 then true
320309 else throwErr("withdraw amount should be more than 0"), if ((userAvailableAssetToWithdraw >= withdrawAssetAmount))
321310 then true
322311 else throwErr((("cannot withdraw more than available (" + toString(userAvailableAssetToWithdraw)) + ")")), if ((withdrawAssetAmount >= minWithdrawAssetAmount))
323312 then true
324313 else throwErr((("withdraw amount is too small. Min: (" + toString(minWithdrawAssetAmount)) + ")"))]
325314 if ((check == check))
326315 then getWithdrawActions(i, lpAmountToWithdraw)
327316 else throw("Strict value is not equal to itself.")
328317 }
329318
330319
331320
332321 @Callable(i)
333322 func getUserAssetsREADONLY (userAddress) = {
334323 let userLpAmount = getUserLpAmount(userAddress)
335324 let userAvailableAssetToWithdraw = getUserAvailableAssetsToWithdraw(userAddress)
336325 let userTotalStakedAmount = valueOrElse(getInteger(this, keyUserTotalAssetStaked(userAddress)), 0)
337326 let userTotalAssetWithdrawn = valueOrElse(getInteger(this, keyUserTotalAssetWithdrawn(userAddress)), 0)
338327 $Tuple2(nil, $Tuple5(userLpAmount, userAvailableAssetToWithdraw, getCurrentPrice(), userTotalStakedAmount, userTotalAssetWithdrawn))
339328 }
340329
341330
342331
343332 @Callable(i)
344333 func getTotalAssetsREADONLY () = $Tuple2(nil, $Tuple3(totalLpAmount, getTotalAssetAmountWithProfitOrMaxAvailable(), getCurrentPrice()))
345334
346335
347336
348337 @Callable(i)
349338 func voteForTxId (txId) = {
350339 let callerAddressString = toBase58String(i.caller.bytes)
351340 let keyPrefix = keyAllowedTxIdVotePrefix(txId)
352341 let result = [StringEntry(keyAllowedTxId(), txId)]
353342 let allowedTxIdOption = getString(this, keyAllowedTxId())
354343 let err = [if ((size(fromBase58String(txId)) == TXID_BYTES_LENGTH))
355344 then true
356345 else throwErr((txId + " is not valid txId")), if (if ((allowedTxIdOption == unit))
357346 then true
358347 else (value(allowedTxIdOption) != txId))
359348 then true
360349 else throwErr((txId + " is already allowed"))]
361350 if ((err == err))
362351 then voteINTERNAL(callerAddressString, keyPrefix, QUORUM, result)
363352 else throw("Strict value is not equal to itself.")
364353 }
365354
366355
367356 @Verifier(tx)
368357 func verify () = {
369358 let byAdmins = (tx.id == fromBase58String(valueOrElse(getString(this, keyAllowedTxId()), "")))
370359 let byOwner = if ((size(getAdminsList()) >= QUORUM))
371360 then false
372361 else sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
373362 if (byAdmins)
374363 then true
375364 else byOwner
376365 }
377366

github/deemru/w8io/026f985 
51.35 ms