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