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