tx · BHEjHgmBh55akQ9VE6ibfAYhfiSwqmW8uNYMb2gh8n63 3Mvsbd5G4Xoyy4ib7gLCVSix21CyMr4K7jb: -0.01500000 Waves 2023.07.27 12:32 [2684077] smart account 3Mvsbd5G4Xoyy4ib7gLCVSix21CyMr4K7jb > SELF 0.00000000 Waves
{ "type": 13, "id": "BHEjHgmBh55akQ9VE6ibfAYhfiSwqmW8uNYMb2gh8n63", "fee": 1500000, "feeAssetId": null, "timestamp": 1690450378670, "version": 2, "chainId": 84, "sender": "3Mvsbd5G4Xoyy4ib7gLCVSix21CyMr4K7jb", "senderPublicKey": "8fnW16MobFGpeokNqZLUEqPaJUXn5zaSGf4ch9A3Ctk7", "proofs": [ "241ctTGE99zkczDrKeRS6fd8RJ9kbYhUF9NmuvceUFj6pK7F9LSJA5cSnfcXHNk2zKwvHHyYgNNEt3yLGCNv8Rke" ], "script": "base64:BgIfCAISAwoBARIAEgMKAQgSAwoBARIDCgEIEgASAwoBCDAADGNvbnRyYWN0RmlsZQIRbDJtcF9zdGFraW5nLnJpZGUAA1NFUAICX18ABnNjYWxlOACAwtcvAAdzY2FsZTE4AICAkLu61q3wDQANc2NhbGUxOEJpZ0ludAkAtgIBBQdzY2FsZTE4ABJBRERSRVNTX0JZVEVTX1NJWkUAGgANQkxPQ0tTX0lOX0RBWQCgCwEIdGhyb3dFcnIBA21zZwkAAgEJAKwCAgkArAICBQxjb250cmFjdEZpbGUCAjogBQNtc2cACmtleUFzc2V0SWQJALkJAgkAzAgCAgIlcwkAzAgCAgdhc3NldElkBQNuaWwFA1NFUAATa2V5RW1pc3Npb25QZXJCbG9jawkAuQkCCQDMCAICAiVzCQDMCAICEGVtaXNzaW9uUGVyQmxvY2sFA25pbAUDU0VQABlrZXlFbWlzc2lvblBlcmlvZEluQmxvY2tzCQC5CQIJAMwIAgICJXMJAMwIAgIWZW1pc3Npb25QZXJpb2RJbkJsb2NrcwUDbmlsBQNTRVAADWtleVN0YXJ0QmxvY2sJALkJAgkAz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ZVEVTX0xFTkdUSAYJAQh0aHJvd0VycgEJAKwCAgUEdHhJZAISIGlzIG5vdCB2YWxpZCB0eElkCQDMCAIDAwkAAAIFEWFsbG93ZWRUeElkT3B0aW9uBQR1bml0BgkBAiE9AgkBBXZhbHVlAQURYWxsb3dlZFR4SWRPcHRpb24FBHR4SWQGCQEIdGhyb3dFcnIBCQCsAgIFBHR4SWQCEyBpcyBhbHJlYWR5IGFsbG93ZWQFA25pbAMJAAACBQNlcnIFA2VycgkBDHZvdGVJTlRFUk5BTAQFE2NhbGxlckFkZHJlc3NTdHJpbmcFCWtleVByZWZpeAUGUVVPUlVNBQZyZXN1bHQJAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4BAnR4AQZ2ZXJpZnkABAhieUFkbWlucwkAAAIIBQJ0eAJpZAkA2QQBCQELdmFsdWVPckVsc2UCCQCdCAIFBHRoaXMJAQ5rZXlBbGxvd2VkVHhJZAACAAQHYnlPd25lcgMJAGcCCQCQAwEJAQ1nZXRBZG1pbnNMaXN0AAUGUVVPUlVNBwkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAgFAnR4D3NlbmRlclB1YmxpY0tleQMFCGJ5QWRtaW5zBgUHYnlPd25lckhMyrM=", "height": 2684077, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: Ha51a6tmTwi8QBQAPQiLmMvVdmnNyQRYii4b7W4iV2Gp Next: none Diff:
Old | New | Differences | |
---|---|---|---|
6 | 6 | let SEP = "__" | |
7 | 7 | ||
8 | 8 | let scale8 = 100000000 | |
9 | + | ||
10 | + | let scale18 = 1000000000000000000 | |
11 | + | ||
12 | + | let scale18BigInt = toBigInt(scale18) | |
9 | 13 | ||
10 | 14 | let ADDRESS_BYTES_SIZE = 26 | |
11 | 15 | ||
87 | 91 | ||
88 | 92 | ||
89 | 93 | func genVotesKeysHelper (a,adminAddress) = { | |
90 | - | let $ | |
91 | - | let result = $ | |
92 | - | let prefix = $ | |
94 | + | let $t027182742 = a | |
95 | + | let result = $t027182742._1 | |
96 | + | let prefix = $t027182742._2 | |
93 | 97 | $Tuple2((result :+ keyFullAdminVote(prefix, adminAddress)), prefix) | |
94 | 98 | } | |
95 | 99 | ||
96 | 100 | ||
97 | 101 | func genVotesKeys (keyPrefix) = { | |
98 | 102 | let adminList = keyAdminAddressList() | |
99 | - | let $ | |
103 | + | let $t028892973 = { | |
100 | 104 | let $l = getAdminsList() | |
101 | 105 | let $s = size($l) | |
102 | 106 | let $acc0 = $Tuple2(nil, keyPrefix) | |
110 | 114 | ||
111 | 115 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
112 | 116 | } | |
113 | - | let result = $ | |
114 | - | let prefix = $ | |
117 | + | let result = $t028892973._1 | |
118 | + | let prefix = $t028892973._2 | |
115 | 119 | result | |
116 | 120 | } | |
117 | 121 | ||
203 | 207 | ||
204 | 208 | ||
205 | 209 | func getCurrentPrice () = if ((totalLpAmount != 0)) | |
206 | - | then fraction(getTotalAssetAmountWithProfitOrMaxAvailable(), | |
207 | - | else | |
210 | + | then fraction(toBigInt(getTotalAssetAmountWithProfitOrMaxAvailable()), scale18BigInt, toBigInt(totalLpAmount)) | |
211 | + | else scale18BigInt | |
208 | 212 | ||
209 | 213 | ||
210 | 214 | func getUserLpAmount (userAddress) = valueOrElse(getInteger(this, keyUserLpAmount(userAddress)), 0) | |
212 | 216 | ||
213 | 217 | func getUserAvailableAssetsToWithdraw (userAddress) = { | |
214 | 218 | let userLpAmount = getUserLpAmount(userAddress) | |
215 | - | let userAvailableAssetToWithdraw = fraction(userLpAmount, getCurrentPrice(), | |
219 | + | let userAvailableAssetToWithdraw = toInt(fraction(toBigInt(userLpAmount), getCurrentPrice(), scale18BigInt)) | |
216 | 220 | if ((0 > userAvailableAssetToWithdraw)) | |
217 | 221 | then 0 | |
218 | 222 | else userAvailableAssetToWithdraw | |
230 | 234 | if ((checks == checks)) | |
231 | 235 | then { | |
232 | 236 | let paymentAmount = i.payments[0].amount | |
233 | - | let paymentLpAmount = fraction(paymentAmount, | |
237 | + | let paymentLpAmount = toInt(fraction(toBigInt(paymentAmount), scale18BigInt, getCurrentPrice())) | |
234 | 238 | let userLpAmount = getUserLpAmount(userAddress) | |
235 | 239 | let userTotalStakedAmount = valueOrElse(getInteger(this, keyUserTotalAssetStaked(userAddress)), 0) | |
236 | 240 | let newTotalLpAmount = (totalLpAmount + paymentLpAmount) | |
257 | 261 | if ((check == check)) | |
258 | 262 | then { | |
259 | 263 | let newUserLpAmount = (userLpAmount - lpAssetWithdrawAmount) | |
260 | - | let withdrawAssetAmount = fraction(lpAssetWithdrawAmount, getCurrentPrice(), | |
264 | + | let withdrawAssetAmount = toInt(fraction(toBigInt(lpAssetWithdrawAmount), getCurrentPrice(), scale18BigInt)) | |
261 | 265 | let newTotalLpAmount = (totalLpAmount - lpAssetWithdrawAmount) | |
262 | - | let newTotalAssetAmount = fraction(newTotalLpAmount, getCurrentPrice(), | |
266 | + | let newTotalAssetAmount = toInt(fraction(toBigInt(newTotalLpAmount), getCurrentPrice(), scale18BigInt)) | |
263 | 267 | let userTotalAssetWithdrawn = valueOrElse(getInteger(this, keyUserTotalAssetWithdrawn(userAddress)), 0) | |
264 | 268 | let newUserTotalAssetWithdrawn = (userTotalAssetWithdrawn + withdrawAssetAmount) | |
265 | 269 | [IntegerEntry(keyTotalLpAmount, newTotalLpAmount), IntegerEntry(keyTotalAssetAmount, newTotalAssetAmount), IntegerEntry(keyUserLpAmount(userAddress), newUserLpAmount), IntegerEntry(keyUserTotalAssetWithdrawn(userAddress), newUserTotalAssetWithdrawn), IntegerEntry(keyStartBlock, height), ScriptTransfer(i.caller, withdrawAssetAmount, assetIdBytes)] | |
301 | 305 | func withdraw (withdrawAssetAmount) = { | |
302 | 306 | let userAddress = toString(i.caller) | |
303 | 307 | let userLpAmount = getUserLpAmount(userAddress) | |
304 | - | let lpAmountToWithdraw = fraction(withdrawAssetAmount, | |
308 | + | let lpAmountToWithdraw = toInt(fraction(toBigInt(withdrawAssetAmount), scale18BigInt, getCurrentPrice())) | |
305 | 309 | let userAvailableAssetToWithdraw = getUserAvailableAssetsToWithdraw(userAddress) | |
306 | - | let minWithdrawAssetAmount = fraction(getCurrentPrice(), 1, | |
310 | + | let minWithdrawAssetAmount = toInt(fraction(getCurrentPrice(), toBigInt(1), scale18BigInt, CEILING)) | |
307 | 311 | let check = [if ((withdrawAssetAmount > 0)) | |
308 | 312 | then true | |
309 | 313 | else throwErr("withdraw amount should be more than 0"), if ((userAvailableAssetToWithdraw >= withdrawAssetAmount)) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let contractFile = "l2mp_staking.ride" | |
5 | 5 | ||
6 | 6 | let SEP = "__" | |
7 | 7 | ||
8 | 8 | let scale8 = 100000000 | |
9 | + | ||
10 | + | let scale18 = 1000000000000000000 | |
11 | + | ||
12 | + | let scale18BigInt = toBigInt(scale18) | |
9 | 13 | ||
10 | 14 | let ADDRESS_BYTES_SIZE = 26 | |
11 | 15 | ||
12 | 16 | let BLOCKS_IN_DAY = 1440 | |
13 | 17 | ||
14 | 18 | func throwErr (msg) = throw(((contractFile + ": ") + msg)) | |
15 | 19 | ||
16 | 20 | ||
17 | 21 | let keyAssetId = makeString(["%s", "assetId"], SEP) | |
18 | 22 | ||
19 | 23 | let keyEmissionPerBlock = makeString(["%s", "emissionPerBlock"], SEP) | |
20 | 24 | ||
21 | 25 | let keyEmissionPeriodInBlocks = makeString(["%s", "emissionPeriodInBlocks"], SEP) | |
22 | 26 | ||
23 | 27 | let keyStartBlock = makeString(["%s", "startBlock"], SEP) | |
24 | 28 | ||
25 | 29 | let keyTotalLpAmount = makeString(["%s", "totalLpAmount"], SEP) | |
26 | 30 | ||
27 | 31 | let keyTotalAssetAmount = makeString(["%s", "totalAssetAmount"], SEP) | |
28 | 32 | ||
29 | 33 | func keyUserLpAmount (userAddress) = makeString(["%s%s", "userLpAmount", userAddress], SEP) | |
30 | 34 | ||
31 | 35 | ||
32 | 36 | func keyUserTotalAssetWithdrawn (userAddress) = makeString(["%s%s", "totalAssetWithdrawn", userAddress], SEP) | |
33 | 37 | ||
34 | 38 | ||
35 | 39 | func keyUserTotalAssetStaked (userAddress) = makeString(["%s%s", "totalAssetStaked", userAddress], SEP) | |
36 | 40 | ||
37 | 41 | ||
38 | 42 | let totalLpAmount = valueOrElse(getInteger(this, keyTotalLpAmount), 0) | |
39 | 43 | ||
40 | 44 | let totalAssetAmount = valueOrElse(getInteger(this, keyTotalAssetAmount), 0) | |
41 | 45 | ||
42 | 46 | let assetIdString = valueOrElse(getString(this, keyAssetId), "WAVES") | |
43 | 47 | ||
44 | 48 | let assetIdBytes = if ((assetIdString == "WAVES")) | |
45 | 49 | then unit | |
46 | 50 | else fromBase58String(assetIdString) | |
47 | 51 | ||
48 | 52 | let emissionPeriodInBlocks = valueOrElse(getInteger(this, keyEmissionPeriodInBlocks), BLOCKS_IN_DAY) | |
49 | 53 | ||
50 | 54 | let emissionPerPeriod = (valueOrElse(getInteger(this, keyEmissionPerBlock), 0) * emissionPeriodInBlocks) | |
51 | 55 | ||
52 | 56 | let heightInPeriods = fraction(height, 1, emissionPeriodInBlocks) | |
53 | 57 | ||
54 | 58 | let ADMIN_LIST_SIZE = 5 | |
55 | 59 | ||
56 | 60 | let QUORUM = 3 | |
57 | 61 | ||
58 | 62 | let TXID_BYTES_LENGTH = 32 | |
59 | 63 | ||
60 | 64 | func keyAllowedTxIdVotePrefix (txId) = makeString(["%s%s%s", "allowTxId", txId], SEP) | |
61 | 65 | ||
62 | 66 | ||
63 | 67 | func keyFullAdminVote (prefix,adminAddress) = makeString([prefix, adminAddress], SEP) | |
64 | 68 | ||
65 | 69 | ||
66 | 70 | func keyAdminAddressList () = makeString(["%s", "adminAddressList"], SEP) | |
67 | 71 | ||
68 | 72 | ||
69 | 73 | func keyAllowedTxId () = makeString(["%s", "txId"], SEP) | |
70 | 74 | ||
71 | 75 | ||
72 | 76 | func getAdminVote (prefix,admin) = { | |
73 | 77 | let voteKey = keyFullAdminVote(prefix, admin) | |
74 | 78 | valueOrElse(getInteger(voteKey), 0) | |
75 | 79 | } | |
76 | 80 | ||
77 | 81 | ||
78 | 82 | func getAdminsList () = match getString(this, keyAdminAddressList()) { | |
79 | 83 | case s: String => | |
80 | 84 | split(s, SEP) | |
81 | 85 | case _ => | |
82 | 86 | nil | |
83 | 87 | } | |
84 | 88 | ||
85 | 89 | ||
86 | 90 | func isInAdminList (address) = containsElement(getAdminsList(), address) | |
87 | 91 | ||
88 | 92 | ||
89 | 93 | func genVotesKeysHelper (a,adminAddress) = { | |
90 | - | let $ | |
91 | - | let result = $ | |
92 | - | let prefix = $ | |
94 | + | let $t027182742 = a | |
95 | + | let result = $t027182742._1 | |
96 | + | let prefix = $t027182742._2 | |
93 | 97 | $Tuple2((result :+ keyFullAdminVote(prefix, adminAddress)), prefix) | |
94 | 98 | } | |
95 | 99 | ||
96 | 100 | ||
97 | 101 | func genVotesKeys (keyPrefix) = { | |
98 | 102 | let adminList = keyAdminAddressList() | |
99 | - | let $ | |
103 | + | let $t028892973 = { | |
100 | 104 | let $l = getAdminsList() | |
101 | 105 | let $s = size($l) | |
102 | 106 | let $acc0 = $Tuple2(nil, keyPrefix) | |
103 | 107 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
104 | 108 | then $a | |
105 | 109 | else genVotesKeysHelper($a, $l[$i]) | |
106 | 110 | ||
107 | 111 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
108 | 112 | then $a | |
109 | 113 | else throw("List size exceeds 5") | |
110 | 114 | ||
111 | 115 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
112 | 116 | } | |
113 | - | let result = $ | |
114 | - | let prefix = $ | |
117 | + | let result = $t028892973._1 | |
118 | + | let prefix = $t028892973._2 | |
115 | 119 | result | |
116 | 120 | } | |
117 | 121 | ||
118 | 122 | ||
119 | 123 | func countVotesHelper (result,voteKey) = (result + valueOrElse(getInteger(voteKey), 0)) | |
120 | 124 | ||
121 | 125 | ||
122 | 126 | func countVotes (prefix) = { | |
123 | 127 | let votes = genVotesKeys(prefix) | |
124 | 128 | let $l = votes | |
125 | 129 | let $s = size($l) | |
126 | 130 | let $acc0 = 0 | |
127 | 131 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
128 | 132 | then $a | |
129 | 133 | else countVotesHelper($a, $l[$i]) | |
130 | 134 | ||
131 | 135 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
132 | 136 | then $a | |
133 | 137 | else throw("List size exceeds 5") | |
134 | 138 | ||
135 | 139 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
136 | 140 | } | |
137 | 141 | ||
138 | 142 | ||
139 | 143 | func clearVotesHelper (result,key) = (result :+ DeleteEntry(key)) | |
140 | 144 | ||
141 | 145 | ||
142 | 146 | func getClearVoteEntries (prefix) = { | |
143 | 147 | let votes = genVotesKeys(prefix) | |
144 | 148 | let $l = votes | |
145 | 149 | let $s = size($l) | |
146 | 150 | let $acc0 = nil | |
147 | 151 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
148 | 152 | then $a | |
149 | 153 | else clearVotesHelper($a, $l[$i]) | |
150 | 154 | ||
151 | 155 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
152 | 156 | then $a | |
153 | 157 | else throw("List size exceeds 5") | |
154 | 158 | ||
155 | 159 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
156 | 160 | } | |
157 | 161 | ||
158 | 162 | ||
159 | 163 | func voteINTERNAL (callerAddressString,keyPrefix,minVotes,voteResult) = { | |
160 | 164 | let voteKey = keyFullAdminVote(keyPrefix, callerAddressString) | |
161 | 165 | let adminCurrentVote = getAdminVote(keyPrefix, callerAddressString) | |
162 | 166 | let err = if (!(isInAdminList(callerAddressString))) | |
163 | 167 | then throwErr((("Address: " + callerAddressString) + " not in Admin list")) | |
164 | 168 | else if ((adminCurrentVote == 1)) | |
165 | 169 | then throwErr((voteKey + " you already voted")) | |
166 | 170 | else unit | |
167 | 171 | if ((err == err)) | |
168 | 172 | then { | |
169 | 173 | let votes = countVotes(keyPrefix) | |
170 | 174 | if (((votes + 1) >= minVotes)) | |
171 | 175 | then { | |
172 | 176 | let clearVoteEntries = getClearVoteEntries(keyPrefix) | |
173 | 177 | (clearVoteEntries ++ voteResult) | |
174 | 178 | } | |
175 | 179 | else [IntegerEntry(voteKey, 1)] | |
176 | 180 | } | |
177 | 181 | else throw("Strict value is not equal to itself.") | |
178 | 182 | } | |
179 | 183 | ||
180 | 184 | ||
181 | 185 | func calcTotalProfit () = { | |
182 | 186 | let startBlock = valueOrElse(getInteger(this, keyStartBlock), 0) | |
183 | 187 | let startPeriod = fraction(startBlock, 1, emissionPeriodInBlocks) | |
184 | 188 | let elapsedPeriods = (heightInPeriods - startPeriod) | |
185 | 189 | max([0, (emissionPerPeriod * elapsedPeriods)]) | |
186 | 190 | } | |
187 | 191 | ||
188 | 192 | ||
189 | 193 | func getTotalAssetAmountWithProfitOrMaxAvailable () = { | |
190 | 194 | let totalAssetAmountWithProfit = (totalAssetAmount + calcTotalProfit()) | |
191 | 195 | let totalAmount = match assetIdBytes { | |
192 | 196 | case u: Unit => | |
193 | 197 | min([totalAssetAmountWithProfit, wavesBalance(this).available]) | |
194 | 198 | case b: ByteVector => | |
195 | 199 | min([totalAssetAmountWithProfit, assetBalance(this, b)]) | |
196 | 200 | case _ => | |
197 | 201 | throw("Match error") | |
198 | 202 | } | |
199 | 203 | if ((totalLpAmount == 0)) | |
200 | 204 | then 0 | |
201 | 205 | else totalAmount | |
202 | 206 | } | |
203 | 207 | ||
204 | 208 | ||
205 | 209 | func getCurrentPrice () = if ((totalLpAmount != 0)) | |
206 | - | then fraction(getTotalAssetAmountWithProfitOrMaxAvailable(), | |
207 | - | else | |
210 | + | then fraction(toBigInt(getTotalAssetAmountWithProfitOrMaxAvailable()), scale18BigInt, toBigInt(totalLpAmount)) | |
211 | + | else scale18BigInt | |
208 | 212 | ||
209 | 213 | ||
210 | 214 | func getUserLpAmount (userAddress) = valueOrElse(getInteger(this, keyUserLpAmount(userAddress)), 0) | |
211 | 215 | ||
212 | 216 | ||
213 | 217 | func getUserAvailableAssetsToWithdraw (userAddress) = { | |
214 | 218 | let userLpAmount = getUserLpAmount(userAddress) | |
215 | - | let userAvailableAssetToWithdraw = fraction(userLpAmount, getCurrentPrice(), | |
219 | + | let userAvailableAssetToWithdraw = toInt(fraction(toBigInt(userLpAmount), getCurrentPrice(), scale18BigInt)) | |
216 | 220 | if ((0 > userAvailableAssetToWithdraw)) | |
217 | 221 | then 0 | |
218 | 222 | else userAvailableAssetToWithdraw | |
219 | 223 | } | |
220 | 224 | ||
221 | 225 | ||
222 | 226 | func getStakeActions (i,userAddress) = { | |
223 | 227 | let checks = [if ((size(i.payments) == 1)) | |
224 | 228 | then true | |
225 | 229 | else throwErr("should include 1 payment"), if ((i.payments[0].assetId == assetIdBytes)) | |
226 | 230 | then true | |
227 | 231 | else throwErr(("payment should be in " + assetIdString)), if ((i.payments[0].amount > 0)) | |
228 | 232 | then true | |
229 | 233 | else "payment amount should be greater than 0"] | |
230 | 234 | if ((checks == checks)) | |
231 | 235 | then { | |
232 | 236 | let paymentAmount = i.payments[0].amount | |
233 | - | let paymentLpAmount = fraction(paymentAmount, | |
237 | + | let paymentLpAmount = toInt(fraction(toBigInt(paymentAmount), scale18BigInt, getCurrentPrice())) | |
234 | 238 | let userLpAmount = getUserLpAmount(userAddress) | |
235 | 239 | let userTotalStakedAmount = valueOrElse(getInteger(this, keyUserTotalAssetStaked(userAddress)), 0) | |
236 | 240 | let newTotalLpAmount = (totalLpAmount + paymentLpAmount) | |
237 | 241 | let newTotalAssetAmount = (totalAssetAmount + paymentAmount) | |
238 | 242 | let newUserLpAmount = (userLpAmount + paymentLpAmount) | |
239 | 243 | let newUserTotalStakedAmount = (userTotalStakedAmount + paymentAmount) | |
240 | 244 | let updateStartHeightAction = if ((totalLpAmount == 0)) | |
241 | 245 | then [IntegerEntry(keyStartBlock, height)] | |
242 | 246 | else nil | |
243 | 247 | ([IntegerEntry(keyTotalLpAmount, newTotalLpAmount), IntegerEntry(keyTotalAssetAmount, newTotalAssetAmount), IntegerEntry(keyUserLpAmount(userAddress), newUserLpAmount), IntegerEntry(keyUserTotalAssetStaked(userAddress), newUserTotalStakedAmount)] ++ updateStartHeightAction) | |
244 | 248 | } | |
245 | 249 | else throw("Strict value is not equal to itself.") | |
246 | 250 | } | |
247 | 251 | ||
248 | 252 | ||
249 | 253 | func getWithdrawActions (i,lpAssetWithdrawAmount) = { | |
250 | 254 | let userAddress = toString(i.caller) | |
251 | 255 | let userLpAmount = getUserLpAmount(userAddress) | |
252 | 256 | let check = [if ((lpAssetWithdrawAmount > 0)) | |
253 | 257 | then true | |
254 | 258 | else throwErr("LP amount should be more than 0"), if ((userLpAmount >= lpAssetWithdrawAmount)) | |
255 | 259 | then true | |
256 | 260 | else throwErr((("cannot withdraw more than available LP (" + toString(userLpAmount)) + ")"))] | |
257 | 261 | if ((check == check)) | |
258 | 262 | then { | |
259 | 263 | let newUserLpAmount = (userLpAmount - lpAssetWithdrawAmount) | |
260 | - | let withdrawAssetAmount = fraction(lpAssetWithdrawAmount, getCurrentPrice(), | |
264 | + | let withdrawAssetAmount = toInt(fraction(toBigInt(lpAssetWithdrawAmount), getCurrentPrice(), scale18BigInt)) | |
261 | 265 | let newTotalLpAmount = (totalLpAmount - lpAssetWithdrawAmount) | |
262 | - | let newTotalAssetAmount = fraction(newTotalLpAmount, getCurrentPrice(), | |
266 | + | let newTotalAssetAmount = toInt(fraction(toBigInt(newTotalLpAmount), getCurrentPrice(), scale18BigInt)) | |
263 | 267 | let userTotalAssetWithdrawn = valueOrElse(getInteger(this, keyUserTotalAssetWithdrawn(userAddress)), 0) | |
264 | 268 | let newUserTotalAssetWithdrawn = (userTotalAssetWithdrawn + withdrawAssetAmount) | |
265 | 269 | [IntegerEntry(keyTotalLpAmount, newTotalLpAmount), IntegerEntry(keyTotalAssetAmount, newTotalAssetAmount), IntegerEntry(keyUserLpAmount(userAddress), newUserLpAmount), IntegerEntry(keyUserTotalAssetWithdrawn(userAddress), newUserTotalAssetWithdrawn), IntegerEntry(keyStartBlock, height), ScriptTransfer(i.caller, withdrawAssetAmount, assetIdBytes)] | |
266 | 270 | } | |
267 | 271 | else throw("Strict value is not equal to itself.") | |
268 | 272 | } | |
269 | 273 | ||
270 | 274 | ||
271 | 275 | @Callable(i) | |
272 | 276 | func setEmissionPerBlock (emissionPerBlock) = { | |
273 | 277 | let check = [if ((i.caller == this)) | |
274 | 278 | then true | |
275 | 279 | else throwErr("permission denied")] | |
276 | 280 | if ((check == check)) | |
277 | 281 | then [IntegerEntry(keyTotalAssetAmount, getTotalAssetAmountWithProfitOrMaxAvailable()), IntegerEntry(keyStartBlock, height), IntegerEntry(keyEmissionPerBlock, max([0, emissionPerBlock]))] | |
278 | 282 | else throw("Strict value is not equal to itself.") | |
279 | 283 | } | |
280 | 284 | ||
281 | 285 | ||
282 | 286 | ||
283 | 287 | @Callable(i) | |
284 | 288 | func stake () = getStakeActions(i, toString(i.caller)) | |
285 | 289 | ||
286 | 290 | ||
287 | 291 | ||
288 | 292 | @Callable(i) | |
289 | 293 | func stakeFor (userAddress) = { | |
290 | 294 | let check = [if ((size(fromBase58String(userAddress)) == ADDRESS_BYTES_SIZE)) | |
291 | 295 | then true | |
292 | 296 | else throwErr("address is not valid")] | |
293 | 297 | if ((check == check)) | |
294 | 298 | then getStakeActions(i, userAddress) | |
295 | 299 | else throw("Strict value is not equal to itself.") | |
296 | 300 | } | |
297 | 301 | ||
298 | 302 | ||
299 | 303 | ||
300 | 304 | @Callable(i) | |
301 | 305 | func withdraw (withdrawAssetAmount) = { | |
302 | 306 | let userAddress = toString(i.caller) | |
303 | 307 | let userLpAmount = getUserLpAmount(userAddress) | |
304 | - | let lpAmountToWithdraw = fraction(withdrawAssetAmount, | |
308 | + | let lpAmountToWithdraw = toInt(fraction(toBigInt(withdrawAssetAmount), scale18BigInt, getCurrentPrice())) | |
305 | 309 | let userAvailableAssetToWithdraw = getUserAvailableAssetsToWithdraw(userAddress) | |
306 | - | let minWithdrawAssetAmount = fraction(getCurrentPrice(), 1, | |
310 | + | let minWithdrawAssetAmount = toInt(fraction(getCurrentPrice(), toBigInt(1), scale18BigInt, CEILING)) | |
307 | 311 | let check = [if ((withdrawAssetAmount > 0)) | |
308 | 312 | then true | |
309 | 313 | else throwErr("withdraw amount should be more than 0"), if ((userAvailableAssetToWithdraw >= withdrawAssetAmount)) | |
310 | 314 | then true | |
311 | 315 | else throwErr((("cannot withdraw more than available (" + toString(userAvailableAssetToWithdraw)) + ")")), if ((withdrawAssetAmount >= minWithdrawAssetAmount)) | |
312 | 316 | then true | |
313 | 317 | else throwErr((("withdraw amount is too small. Min: (" + toString(minWithdrawAssetAmount)) + ")"))] | |
314 | 318 | if ((check == check)) | |
315 | 319 | then getWithdrawActions(i, lpAmountToWithdraw) | |
316 | 320 | else throw("Strict value is not equal to itself.") | |
317 | 321 | } | |
318 | 322 | ||
319 | 323 | ||
320 | 324 | ||
321 | 325 | @Callable(i) | |
322 | 326 | func getUserAssetsREADONLY (userAddress) = { | |
323 | 327 | let userLpAmount = getUserLpAmount(userAddress) | |
324 | 328 | let userAvailableAssetToWithdraw = getUserAvailableAssetsToWithdraw(userAddress) | |
325 | 329 | let userTotalStakedAmount = valueOrElse(getInteger(this, keyUserTotalAssetStaked(userAddress)), 0) | |
326 | 330 | let userTotalAssetWithdrawn = valueOrElse(getInteger(this, keyUserTotalAssetWithdrawn(userAddress)), 0) | |
327 | 331 | $Tuple2(nil, $Tuple5(userLpAmount, userAvailableAssetToWithdraw, getCurrentPrice(), userTotalStakedAmount, userTotalAssetWithdrawn)) | |
328 | 332 | } | |
329 | 333 | ||
330 | 334 | ||
331 | 335 | ||
332 | 336 | @Callable(i) | |
333 | 337 | func getTotalAssetsREADONLY () = $Tuple2(nil, $Tuple3(totalLpAmount, getTotalAssetAmountWithProfitOrMaxAvailable(), getCurrentPrice())) | |
334 | 338 | ||
335 | 339 | ||
336 | 340 | ||
337 | 341 | @Callable(i) | |
338 | 342 | func voteForTxId (txId) = { | |
339 | 343 | let callerAddressString = toBase58String(i.caller.bytes) | |
340 | 344 | let keyPrefix = keyAllowedTxIdVotePrefix(txId) | |
341 | 345 | let result = [StringEntry(keyAllowedTxId(), txId)] | |
342 | 346 | let allowedTxIdOption = getString(this, keyAllowedTxId()) | |
343 | 347 | let err = [if ((size(fromBase58String(txId)) == TXID_BYTES_LENGTH)) | |
344 | 348 | then true | |
345 | 349 | else throwErr((txId + " is not valid txId")), if (if ((allowedTxIdOption == unit)) | |
346 | 350 | then true | |
347 | 351 | else (value(allowedTxIdOption) != txId)) | |
348 | 352 | then true | |
349 | 353 | else throwErr((txId + " is already allowed"))] | |
350 | 354 | if ((err == err)) | |
351 | 355 | then voteINTERNAL(callerAddressString, keyPrefix, QUORUM, result) | |
352 | 356 | else throw("Strict value is not equal to itself.") | |
353 | 357 | } | |
354 | 358 | ||
355 | 359 | ||
356 | 360 | @Verifier(tx) | |
357 | 361 | func verify () = { | |
358 | 362 | let byAdmins = (tx.id == fromBase58String(valueOrElse(getString(this, keyAllowedTxId()), ""))) | |
359 | 363 | let byOwner = if ((size(getAdminsList()) >= QUORUM)) | |
360 | 364 | then false | |
361 | 365 | else sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
362 | 366 | if (byAdmins) | |
363 | 367 | then true | |
364 | 368 | else byOwner | |
365 | 369 | } | |
366 | 370 |
github/deemru/w8io/026f985 52.47 ms ◑