tx · AjxmAyBmg6NhyfiEgatzbnCi3MfvUGqGVofNEry9Pjnf 3N4Pj4MutKVgrmcuX7jgyVGWoBhDyKYFZBj: -0.01400000 Waves 2019.11.15 14:43 [766151] smart account 3N4Pj4MutKVgrmcuX7jgyVGWoBhDyKYFZBj > SELF 0.00000000 Waves
{ "type": 13, "id": "AjxmAyBmg6NhyfiEgatzbnCi3MfvUGqGVofNEry9Pjnf", "fee": 1400000, "feeAssetId": null, "timestamp": 1573818281326, "version": 1, "sender": "3N4Pj4MutKVgrmcuX7jgyVGWoBhDyKYFZBj", "senderPublicKey": "7YuxEiQSearE3DvFS84DXzV5gad9qxsq4bTy633SAYBj", "proofs": [ "UnHTE2JnkViA2msHLja3ubjEnjAZLwsa8QCYD4nZWy4bnbhdYAMEJm1x459NoUdcUAYhtx6GhKcvStHSYWQqxE9" ], "script": "base64:AAIDAAAAAAAAACwIARIAEgASBQoDCAEIEgASAwoBCBIAEgYKBAgBAQgSAwoBCBIHCgUICAEBCAAAAGYBAAAADmdldE51bWJlckJ5S2V5AAAAAQAAAANrZXkEAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEAAAAAAAAAAAABAAAADmdldFN0cmluZ0J5S2V5AAAAAQAAAANrZXkEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWECAAAAAAEAAAAMZ2V0Qm9vbEJ5S2V5AAAAAQAAAANrZXkEAAAAByRtYXRjaDAJAAQbAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAdCb29sZWFuBAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhBwEAAAAYZ2V0TnVtYmVy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prev: 8M7Vhsc4YYVbpyUyxpUrXehUV5fmMbv4EeiPLXN9b3qS Next: none Diff:
Old | New | Differences | |
---|---|---|---|
33 | 33 | } | |
34 | 34 | ||
35 | 35 | ||
36 | - | func getStringByAddressAndKey (address,key) = match getString( | |
36 | + | func getStringByAddressAndKey (address,key) = match getString(addressFromStringValue(address), key) { | |
37 | 37 | case a: String => | |
38 | 38 | a | |
39 | 39 | case _ => | |
41 | 41 | } | |
42 | 42 | ||
43 | 43 | ||
44 | + | func getBoolByAddressAndKey (address,key) = match getBoolean(addressFromStringValue(address), key) { | |
45 | + | case a: Boolean => | |
46 | + | a | |
47 | + | case _ => | |
48 | + | false | |
49 | + | } | |
50 | + | ||
51 | + | ||
52 | + | let SENDTXEXPIRE = 30 | |
53 | + | ||
44 | 54 | let LISTSPLITSYMBOL = "_" | |
45 | 55 | ||
46 | 56 | let LISTDATASYMBOL = "+" | |
47 | 57 | ||
48 | 58 | let WAVELET = 100000000 | |
49 | 59 | ||
50 | - | let CENTSINDOLLAR = 100 | |
60 | + | let PAULI = 100 | |
61 | + | ||
62 | + | let CRYTICALSHARE = 20 | |
63 | + | ||
64 | + | let LEASINGSHARE = 90 | |
65 | + | ||
66 | + | let LEASINTXCOUNT = 10 | |
67 | + | ||
68 | + | let DEFICITOFFSET = 10 | |
69 | + | ||
70 | + | let WAVESASSETID = "waves" | |
51 | 71 | ||
52 | 72 | let CANCELED = "canceled" | |
53 | 73 | ||
54 | 74 | let NEW = "new" | |
55 | 75 | ||
56 | - | let FILLED = "filled" | |
57 | - | ||
58 | 76 | let NeutrinoAssetIdKey = "neutrino_asset_id" | |
59 | 77 | ||
60 | 78 | let BondAssetIdKey = "bond_asset_id" | |
61 | 79 | ||
80 | + | let ReserveContractKey = "reserve_contract" | |
81 | + | ||
62 | 82 | let AuctionContractKey = "auction_contract" | |
83 | + | ||
84 | + | let LiquidationContractKey = "liquidation_contract" | |
63 | 85 | ||
64 | 86 | let RPDContractKey = "rpd_contract" | |
65 | 87 | ||
88 | + | let ContolContractKey = "control_contract" | |
89 | + | ||
66 | 90 | let BalanceLockIntervalKey = "balance_lock_interval" | |
67 | - | ||
68 | - | let VoteIntervalKey = "vote_interval" | |
69 | 91 | ||
70 | 92 | let MinWavesSwapAmountKey = "min_waves_swap_amount" | |
71 | 93 | ||
72 | 94 | let MinNeutrinoSwapAmountKey = "min_neutrino_swap_amount" | |
73 | 95 | ||
74 | - | let | |
96 | + | let NodeAddressKey = "node_address" | |
75 | 97 | ||
76 | - | let ProvidingIntervalKey = "providing_interval" | |
98 | + | let NodeOracleProviderKey = "oracle_node_provider" | |
99 | + | ||
100 | + | let LeasingIntervalKey = "leasing_interval" | |
101 | + | ||
102 | + | let RPDBalanceKey = "rpd_balance" | |
103 | + | ||
104 | + | func getRPDContractBalanceKey (assetId) = ((RPDBalanceKey + "_") + toBase58String(assetId)) | |
105 | + | ||
106 | + | ||
107 | + | let TotalOrderbookKey = "total_orderbook" | |
108 | + | ||
109 | + | let TotalLiquidationOrderbookKey = "total_liquidation_orderbook" | |
77 | 110 | ||
78 | 111 | let PriceKey = "price" | |
79 | 112 | ||
80 | - | let NeutrinoBalanceKey = "neutrino_" | |
81 | - | ||
82 | - | let WavesBalanceKey = "waves_" | |
83 | - | ||
84 | - | let BalanceUnlockBlockKey = "balance_block_" | |
85 | - | ||
86 | - | let OrderbookKey = "orderbook" | |
87 | - | ||
88 | - | let OrderTotalKey = "order_total_" | |
89 | - | ||
90 | - | let OrderOwnerKey = "order_owner_" | |
91 | - | ||
92 | - | let OrderHeightKey = "order_height_" | |
93 | - | ||
94 | - | let OrderFilledTotalKey = "order_filled_total_" | |
95 | - | ||
96 | - | let OrderStatusKey = "order_status_" | |
97 | - | ||
98 | - | let RPDSyncIndexKey = "rpd_sync_index" | |
99 | - | ||
100 | - | let RPDProfitKey = "rpd_profit" | |
101 | - | ||
102 | - | let RPDBalanceKey = "rpd_balance" | |
113 | + | let PriceIndexKey = "price_index" | |
103 | 114 | ||
104 | 115 | let IsBlockedKey = "is_blocked" | |
105 | 116 | ||
106 | - | let | |
117 | + | let LeasingExpireBlockKey = "leasing_expire_block" | |
107 | 118 | ||
108 | - | let | |
119 | + | let IsRebalanceKey = "is_rebalance" | |
109 | 120 | ||
110 | - | let | |
121 | + | let LeasingTxCountKey = "leasing_index" | |
111 | 122 | ||
112 | - | let | |
123 | + | let LeasingAmountKey = "leasing_amount" | |
113 | 124 | ||
114 | - | let AdminKey = "admin_" | |
115 | - | ||
116 | - | let IsPricePendingKey = "is_pending_price" | |
117 | - | ||
118 | - | let OracleKey = "oracle_" | |
119 | - | ||
120 | - | let OracleIsProvideKey = "oracle_is_provide_" | |
121 | - | ||
122 | - | let OracleProvidePriceKey = "oracle_price_provide_" | |
123 | - | ||
124 | - | let BlockExpireProvidingKey = "providing_expire_block" | |
125 | - | ||
126 | - | let ApprovedLeaseTxKey = "leasetx" | |
127 | - | ||
128 | - | let IsLeasingProfitTxExistKey = "is_leasing_profit" | |
129 | - | ||
130 | - | func getAdminKey (count) = (AdminKey + toString(count)) | |
125 | + | func getPriceHistoryKey (block) = ((PriceKey + "_") + toString(block)) | |
131 | 126 | ||
132 | 127 | ||
133 | - | func | |
128 | + | func getHeightPriceByIndexKey (index) = ((PriceIndexKey + "_") + toString(index)) | |
134 | 129 | ||
135 | 130 | ||
136 | - | func getAdminVotePriceKey (owner) = (AdminVotePriceKey + owner) | |
137 | - | ||
138 | - | ||
139 | - | func getOracleKey (count) = (OracleKey + toString(count)) | |
140 | - | ||
141 | - | ||
142 | - | func getOracleIsProvideKey (owner) = (OracleIsProvideKey + owner) | |
143 | - | ||
144 | - | ||
145 | - | func getOracleProvidePriceKey (owner) = (OracleProvidePriceKey + owner) | |
146 | - | ||
131 | + | let RPDSyncIndexKey = "rpd_sync_index" | |
147 | 132 | ||
148 | 133 | func getRPDSnapshotContractBalanceKey (count,assetId) = ((((RPDBalanceKey + "_") + toBase58String(assetId)) + "_") + toString(count)) | |
149 | 134 | ||
150 | 135 | ||
151 | - | func | |
136 | + | func getCancelLeaseTxReserveFeeKey (hash) = (("cancel_lease_tx_reserve_fee" + "_") + hash) | |
152 | 137 | ||
153 | 138 | ||
154 | - | func | |
139 | + | func getAccountLockedBalanceKey (owner,assetId) = ((("balance_" + assetId) + "_") + owner) | |
155 | 140 | ||
156 | 141 | ||
157 | - | func | |
142 | + | func getBalanceUnlockBlockKey (owner) = ("balance_block_" + owner) | |
158 | 143 | ||
159 | 144 | ||
160 | - | func | |
145 | + | func getRPDProfitKey (count) = (("rpd_profit" + "_") + toString(count)) | |
161 | 146 | ||
162 | 147 | ||
163 | - | func | |
148 | + | func getLockedBalanceKey (assetId) = ("balance_" + assetId) | |
164 | 149 | ||
165 | 150 | ||
166 | - | func | |
151 | + | func getLeaseTxStatusKey (hash) = (("lease_tx_status" + "_") + hash) | |
167 | 152 | ||
168 | 153 | ||
169 | - | func | |
154 | + | func getLeaseTxAmountByHashKey (hash) = ((LeasingAmountKey + "_") + hash) | |
170 | 155 | ||
171 | 156 | ||
172 | - | func | |
157 | + | func getLeaseTxBytesByHashKey (hash) = (("lease_tx" + "_") + hash) | |
173 | 158 | ||
174 | 159 | ||
175 | - | func | |
160 | + | func getLeaseTxExpireSendBlockKey (hash) = (("leasing_expire_send" + "_") + hash) | |
176 | 161 | ||
177 | 162 | ||
178 | - | func | |
163 | + | func convertNeutrinoToWaves (amount,price) = ((((amount * 100) / price) * WAVELET) / PAULI) | |
179 | 164 | ||
180 | 165 | ||
181 | - | func | |
166 | + | func convertWavesToNeutrino (amount,price) = ((((amount * price) / 100) * PAULI) / WAVELET) | |
182 | 167 | ||
183 | 168 | ||
184 | - | func | |
169 | + | func convertNeutrinoToBond (amount) = (amount / PAULI) | |
185 | 170 | ||
186 | 171 | ||
187 | - | func | |
172 | + | func convertBondToNeutrino (amount) = (amount * PAULI) | |
188 | 173 | ||
189 | 174 | ||
190 | - | func | |
175 | + | func convertWavesToBond (amount,price) = convertNeutrinoToBond(convertWavesToNeutrino(amount, price)) | |
191 | 176 | ||
192 | 177 | ||
193 | - | let price = getNumberByKey(PriceKey) | |
194 | - | ||
195 | - | func convertNeutrinoToWaves (amount) = ((((amount * 100) / price) * WAVELET) / CENTSINDOLLAR) | |
178 | + | func getLockedBalance (assetId) = getNumberByKey(getLockedBalanceKey(assetId)) | |
196 | 179 | ||
197 | 180 | ||
198 | - | ||
181 | + | let liquidationContract = getStringByKey(LiquidationContractKey) | |
199 | 182 | ||
183 | + | let neutrinoAssetIdString = getStringByKey(NeutrinoAssetIdKey) | |
200 | 184 | ||
201 | - | ||
185 | + | let neutrinoAssetId = fromBase58String(neutrinoAssetIdString) | |
202 | 186 | ||
187 | + | let reserveContract = getStringByKey(ReserveContractKey) | |
203 | 188 | ||
204 | - | ||
189 | + | let auctionContract = getStringByKey(AuctionContractKey) | |
205 | 190 | ||
191 | + | let rpdContract = getStringByKey(RPDContractKey) | |
206 | 192 | ||
207 | - | ||
193 | + | let controlContract = getStringByKey(ContolContractKey) | |
208 | 194 | ||
195 | + | let currentPrice = getNumberByAddressAndKey(controlContract, PriceKey) | |
209 | 196 | ||
210 | - | let | |
197 | + | let priceIndex = getNumberByAddressAndKey(controlContract, PriceIndexKey) | |
211 | 198 | ||
212 | - | let | |
199 | + | let isBlocked = getBoolByAddressAndKey(controlContract, IsBlockedKey) | |
213 | 200 | ||
214 | - | let | |
201 | + | let leasingTxCount = getNumberByKey(LeasingTxCountKey) | |
215 | 202 | ||
216 | - | let percentPriceOffset = getNumberByKey(PriceOffsetKey) | |
203 | + | let isRebalance = getBoolByKey(IsRebalanceKey) | |
204 | + | ||
205 | + | let leasingInterval = getNumberByKey(LeasingIntervalKey) | |
206 | + | ||
207 | + | let leasingExpireBlock = getNumberByKey(LeasingExpireBlockKey) | |
208 | + | ||
209 | + | let leasingAmount = getNumberByKey(LeasingAmountKey) | |
210 | + | ||
211 | + | let nodeAddress = getStringByKey(NodeAddressKey) | |
212 | + | ||
213 | + | let nodeOracleProviderKey = getStringByKey(NodeOracleProviderKey) | |
217 | 214 | ||
218 | 215 | let rpdSyncIndex = getNumberByKey(RPDSyncIndexKey) | |
219 | 216 | ||
220 | - | let voteInterval = getNumberByKey(VoteIntervalKey) | |
221 | - | ||
222 | - | let blockExpireVote = getNumberByKey(BlockExpireVoteKey) | |
223 | - | ||
224 | 217 | let balanceLockInterval = getNumberByKey(BalanceLockIntervalKey) | |
225 | - | ||
226 | - | let isBlocked = getBoolByKey(IsBlockedKey) | |
227 | 218 | ||
228 | 219 | let minWavesSwapAmount = getNumberByKey(MinWavesSwapAmountKey) | |
229 | 220 | ||
230 | 221 | let minNeutrinoSwapAmount = getNumberByKey(MinNeutrinoSwapAmountKey) | |
231 | 222 | ||
232 | - | let | |
223 | + | let reserve = (wavesBalance(this) - getLockedBalance(WAVESASSETID)) | |
233 | 224 | ||
234 | - | let auctionContract = getStringByKey(AuctionContractKey) | |
235 | - | ||
236 | - | let rpdContract = getStringByKey(RPDContractKey) | |
237 | - | ||
238 | - | let reserve = wavesBalance(this) | |
239 | - | ||
240 | - | let orderbook = getStringByKey(OrderbookKey) | |
225 | + | let reserveWithoutLeasing = (reserve - leasingAmount) | |
241 | 226 | ||
242 | 227 | let bondAssetId = fromBase58String(getStringByKey(BondAssetIdKey)) | |
243 | 228 | ||
244 | - | let bondSupply = { | |
245 | - | let info = extract(assetInfo(bondAssetId)) | |
246 | - | (info.quantity - assetBalance(this, bondAssetId)) | |
247 | - | } | |
229 | + | let bondSupply = (extract(assetInfo(bondAssetId)).quantity - assetBalance(this, bondAssetId)) | |
248 | 230 | ||
249 | - | let neutrinoSupply = { | |
250 | - | let info = extract(assetInfo(neutrinoAssetId)) | |
251 | - | (info.quantity - assetBalance(this, neutrinoAssetId)) | |
252 | - | } | |
231 | + | let neutrinoSupply = ((extract(assetInfo(neutrinoAssetId)).quantity - assetBalance(this, neutrinoAssetId)) + getLockedBalance(neutrinoAssetIdString)) | |
253 | 232 | ||
254 | - | let surplus = (convertWavesToNeutrino(reserve) - neutrinoSupply) | |
233 | + | let surplus = (convertWavesToNeutrino(reserve, currentPrice) - neutrinoSupply) | |
255 | 234 | ||
256 | - | let oracleOne = getStringByKey(getOracleKey(0)) | |
257 | - | ||
258 | - | let oracleTwo = getStringByKey(getOracleKey(1)) | |
259 | - | ||
260 | - | let oracleThree = getStringByKey(getOracleKey(2)) | |
261 | - | ||
262 | - | let adminOne = getStringByKey(getAdminKey(0)) | |
263 | - | ||
264 | - | let adminTwo = getStringByKey(getAdminKey(1)) | |
265 | - | ||
266 | - | let adminThree = getStringByKey(getAdminKey(2)) | |
267 | - | ||
268 | - | func getOwnerPubKeyByLeaseTxId (owner) = getStringByAddressAndKey(rpdContract, getOwnerPubKeyByLeaseTxIdKey(owner)) | |
269 | - | ||
235 | + | let deficit = (neutrinoSupply - convertWavesToNeutrino(reserve, currentPrice)) | |
270 | 236 | ||
271 | 237 | func getRPDContractBalance (assetId) = getNumberByAddressAndKey(rpdContract, getRPDContractBalanceKey(assetId)) | |
272 | 238 | ||
273 | 239 | ||
274 | - | func isLeasingProfitTxExist (txId) = getBoolByKey(getIsLeasingProfitTxExistKey(txId)) | |
240 | + | let totalLiquidationOrderbook = getNumberByAddressAndKey(auctionContract, TotalLiquidationOrderbookKey) | |
241 | + | ||
242 | + | let totalOrderbook = getNumberByAddressAndKey(auctionContract, TotalOrderbookKey) | |
243 | + | ||
244 | + | func getPriceHistory (block) = getNumberByAddressAndKey(controlContract, getPriceHistoryKey(block)) | |
275 | 245 | ||
276 | 246 | ||
277 | - | func getAdminVoteInt (owner) = if (getBoolByKey(getAdminVoteKey(owner))) | |
278 | - | then 1 | |
279 | - | else 0 | |
247 | + | func getHeightPriceByIndex (index) = getNumberByAddressAndKey(controlContract, getHeightPriceByIndexKey(index)) | |
280 | 248 | ||
281 | 249 | ||
282 | - | func | |
250 | + | func getCancelLeaseTxReserveFee (hash) = getNumberByKey(getCancelLeaseTxReserveFeeKey(hash)) | |
283 | 251 | ||
284 | 252 | ||
285 | - | func isOracleProvide (owner) = getBoolByKey(getOracleIsProvideKey(owner)) | |
286 | - | ||
287 | - | ||
288 | - | func isOracleProvideInt (owner) = if (isOracleProvide(owner)) | |
289 | - | then 1 | |
290 | - | else 0 | |
291 | - | ||
292 | - | ||
293 | - | func getOracleProvidePrice (owner) = getNumberByKey(getOracleProvidePriceKey(owner)) | |
294 | - | ||
295 | - | ||
296 | - | func getWavesBalance (owner) = getNumberByKey(getWavesBalanceKey(owner)) | |
297 | - | ||
298 | - | ||
299 | - | func getNeutrinoBalance (owner) = getNumberByKey(getNeutrinoBalanceKey(owner)) | |
253 | + | func getAccountLockedBalance (owner,assetId) = getNumberByKey(getAccountLockedBalanceKey(owner, assetId)) | |
300 | 254 | ||
301 | 255 | ||
302 | 256 | func getUnlockBalanceBlock (owner) = getNumberByKey(getBalanceUnlockBlockKey(owner)) | |
303 | 257 | ||
304 | 258 | ||
305 | - | func getOrderTotal (id) = getNumberByKey(getOrderTotalKey(id)) | |
306 | - | ||
307 | - | ||
308 | - | func getOrderOwner (id) = getStringByKey(getOrderOwnerKey(id)) | |
309 | - | ||
310 | - | ||
311 | - | func getOrderFilledTotal (id) = getNumberByKey(getOrderFilledTotalKey(id)) | |
312 | - | ||
313 | - | ||
314 | 259 | func getRPDProfit (count) = getNumberByKey(getRPDProfitKey(count)) | |
315 | 260 | ||
316 | 261 | ||
317 | - | func | |
262 | + | func getLeaseTxStatus (hash) = getStringByKey(getLeaseTxStatusKey(hash)) | |
318 | 263 | ||
319 | 264 | ||
320 | - | func | |
265 | + | func getLeaseTxAmountByHash (hash) = getNumberByKey(getLeaseTxAmountByHashKey(hash)) | |
321 | 266 | ||
322 | 267 | ||
323 | - | func dropOrder (orderId) = { | |
324 | - | let parts = split(orderbook, getOrderElementById(orderId)) | |
325 | - | (parts[0] + parts[1]) | |
326 | - | } | |
268 | + | func getLeaseTxBytesByHash (hash) = getStringByKey(getLeaseTxBytesByHashKey(hash)) | |
327 | 269 | ||
328 | 270 | ||
329 | - | @Callable(i) | |
330 | - | func setCurrentPrice (newPrice) = { | |
331 | - | let account = toString(i.caller) | |
332 | - | let priceProvidingCount = (((isOracleProvideInt(oracleOne) + isOracleProvideInt(oracleTwo)) + isOracleProvideInt(oracleThree)) + 1) | |
333 | - | if (isBlocked) | |
334 | - | then throw("contract is blocked") | |
335 | - | else if (if (if ((account != oracleOne)) | |
336 | - | then (account != oracleTwo) | |
337 | - | else false) | |
338 | - | then (account != oracleThree) | |
339 | - | else false) | |
340 | - | then throw("permission denied") | |
341 | - | else if (if ((blockExpireProviding >= height)) | |
342 | - | then isOracleProvide(account) | |
343 | - | else false) | |
344 | - | then throw("price is already provided") | |
345 | - | else if (if ((height > blockExpireProviding)) | |
346 | - | then isPricePending | |
347 | - | else false) | |
348 | - | then throw("use finilizeCurrentPrice") | |
349 | - | else WriteSet([DataEntry(getOracleProvidePriceKey(account), newPrice), DataEntry(BlockExpireProvidingKey, if ((height > blockExpireProviding)) | |
350 | - | then (height + providingInterval) | |
351 | - | else blockExpireProviding), DataEntry(getOracleIsProvideKey(oracleOne), if ((height > blockExpireProviding)) | |
352 | - | then false | |
353 | - | else isOracleProvide(oracleOne)), DataEntry(getOracleIsProvideKey(oracleTwo), if ((height > blockExpireProviding)) | |
354 | - | then false | |
355 | - | else isOracleProvide(oracleTwo)), DataEntry(getOracleIsProvideKey(oracleThree), if ((height > blockExpireProviding)) | |
356 | - | then false | |
357 | - | else isOracleProvide(oracleThree)), DataEntry(getOracleIsProvideKey(account), true), DataEntry(IsPricePendingKey, if (if ((blockExpireProviding >= height)) | |
358 | - | then (priceProvidingCount >= 2) | |
359 | - | else false) | |
360 | - | then true | |
361 | - | else isPricePending)]) | |
362 | - | } | |
363 | - | ||
364 | - | ||
365 | - | ||
366 | - | @Callable(i) | |
367 | - | func finilizeCurrentPrice () = { | |
368 | - | let account = toString(i.caller) | |
369 | - | let priceProvidingCount = ((isOracleProvideInt(oracleOne) + isOracleProvideInt(oracleTwo)) + isOracleProvideInt(oracleThree)) | |
370 | - | let newPrice = ((((getOracleProvidePrice(oracleOne) * isOracleProvideInt(oracleOne)) + (getOracleProvidePrice(oracleTwo) * isOracleProvideInt(oracleTwo))) + (getOracleProvidePrice(oracleThree) * isOracleProvideInt(oracleThree))) / priceProvidingCount) | |
371 | - | if (isBlocked) | |
372 | - | then throw("contract is blocked") | |
373 | - | else if (if (if ((account != oracleOne)) | |
374 | - | then (account != oracleTwo) | |
375 | - | else false) | |
376 | - | then (account != oracleThree) | |
377 | - | else false) | |
378 | - | then throw("permission denied") | |
379 | - | else if (if (!(isPricePending)) | |
380 | - | then true | |
381 | - | else (blockExpireProviding >= height)) | |
382 | - | then throw("wait for the end of the price providing") | |
383 | - | else if ((2 > priceProvidingCount)) | |
384 | - | then throw("2/3 oracles need to set a price") | |
385 | - | else if (if ((newPrice >= (price + ((price * percentPriceOffset) / 100)))) | |
386 | - | then true | |
387 | - | else ((price - ((price * percentPriceOffset) / 100)) >= newPrice)) | |
388 | - | then WriteSet([DataEntry(IsBlockedKey, true), DataEntry(getBlackSwarmPriceKey(height), newPrice)]) | |
389 | - | else WriteSet([DataEntry(PriceKey, newPrice), DataEntry(getPriceHistoryKey(height), newPrice), DataEntry(IsPricePendingKey, false)]) | |
390 | - | } | |
391 | - | ||
392 | - | ||
393 | - | ||
394 | - | @Callable(i) | |
395 | - | func adminUnlock (newPrice) = { | |
396 | - | let account = toString(i.caller) | |
397 | - | let adminOneVote = if ((account != adminOne)) | |
398 | - | then getAdminVoteInt(adminOne) | |
399 | - | else 0 | |
400 | - | let adminTwoVote = if ((account != adminTwo)) | |
401 | - | then getAdminVoteInt(adminTwo) | |
402 | - | else 0 | |
403 | - | let adminThreeVote = if ((account != adminThree)) | |
404 | - | then getAdminVoteInt(adminThree) | |
405 | - | else 0 | |
406 | - | let adminOnePrice = if (((getAdminVotePrice(adminOne) * adminOneVote) == newPrice)) | |
407 | - | then 1 | |
408 | - | else 0 | |
409 | - | let adminTwoPrice = if (((getAdminVotePrice(adminTwo) * adminTwoVote) == newPrice)) | |
410 | - | then 1 | |
411 | - | else 0 | |
412 | - | let adminThreePrice = if (((getAdminVotePrice(adminThree) * adminThreeVote) == newPrice)) | |
413 | - | then 1 | |
414 | - | else 0 | |
415 | - | if (!(isBlocked)) | |
416 | - | then throw("Contract is not blocked") | |
417 | - | else if (if (((((adminOnePrice + adminTwoPrice) + adminThreePrice) + 1) >= 2)) | |
418 | - | then (blockExpireVote >= height) | |
419 | - | else false) | |
420 | - | then WriteSet([DataEntry(IsBlockedKey, false), DataEntry(PriceKey, newPrice), DataEntry(getPriceHistoryKey(height), newPrice), DataEntry(getAdminVoteKey(adminOne), false), DataEntry(getAdminVoteKey(adminTwo), false), DataEntry(getAdminVoteKey(adminThree), false), DataEntry(BlockExpireVoteKey, 0), DataEntry(BlockExpireProvidingKey, 0), DataEntry(IsPricePendingKey, false)]) | |
421 | - | else WriteSet([DataEntry(getAdminVotePriceKey(account), newPrice), DataEntry(BlockExpireVoteKey, if ((height > blockExpireVote)) | |
422 | - | then (height + voteInterval) | |
423 | - | else blockExpireVote), DataEntry(getAdminVoteKey(adminOne), if ((height > blockExpireVote)) | |
424 | - | then false | |
425 | - | else (adminOneVote == 1)), DataEntry(getAdminVoteKey(adminTwo), if ((height > blockExpireVote)) | |
426 | - | then false | |
427 | - | else (adminTwoVote == 1)), DataEntry(getAdminVoteKey(adminThree), if ((height > blockExpireVote)) | |
428 | - | then false | |
429 | - | else (adminThreeVote == 1)), DataEntry(getAdminVoteKey(account), true)]) | |
430 | - | } | |
431 | - | ||
432 | - | ||
433 | - | ||
434 | - | @Callable(i) | |
435 | - | func adminLock () = { | |
436 | - | let account = toString(i.caller) | |
437 | - | let adminOneVote = if ((account != adminOne)) | |
438 | - | then getAdminVoteInt(adminOne) | |
439 | - | else 1 | |
440 | - | let adminTwoVote = if ((account != adminTwo)) | |
441 | - | then getAdminVoteInt(adminTwo) | |
442 | - | else 1 | |
443 | - | let adminThreeVote = if ((account != adminThree)) | |
444 | - | then getAdminVoteInt(adminThree) | |
445 | - | else 1 | |
446 | - | if (isBlocked) | |
447 | - | then throw("Contract is blocked") | |
448 | - | else if ((((adminOneVote + adminTwoVote) + adminThreeVote) >= 2)) | |
449 | - | then WriteSet([DataEntry(IsBlockedKey, true), DataEntry(getAdminVoteKey(adminOne), false), DataEntry(getAdminVoteKey(adminTwo), false), DataEntry(getAdminVoteKey(adminThree), false), DataEntry(BlockExpireVoteKey, 0)]) | |
450 | - | else WriteSet([DataEntry(BlockExpireVoteKey, if ((height > blockExpireVote)) | |
451 | - | then (height + voteInterval) | |
452 | - | else blockExpireVote), DataEntry(getAdminVoteKey(adminOne), if ((height > blockExpireVote)) | |
453 | - | then false | |
454 | - | else (adminOneVote == 1)), DataEntry(getAdminVoteKey(adminTwo), if ((height > blockExpireVote)) | |
455 | - | then false | |
456 | - | else (adminTwoVote == 1)), DataEntry(getAdminVoteKey(adminThree), if ((height > blockExpireVote)) | |
457 | - | then false | |
458 | - | else (adminThreeVote == 1))]) | |
459 | - | } | |
460 | - | ||
271 | + | func getLeaseTxExpireSendBlock (hash) = getNumberByKey(getLeaseTxExpireSendBlockKey(hash)) | |
461 | 272 | ||
462 | 273 | ||
463 | 274 | @Callable(i) | |
464 | 275 | func swapWavesToNeutrino () = { | |
465 | 276 | let pmt = extract(i.payment) | |
277 | + | let account = toString(i.caller) | |
466 | 278 | if ((minWavesSwapAmount > pmt.amount)) | |
467 | - | then throw("amount less min") | |
279 | + | then throw((("an amount is less than min available amount: " + toString(minWavesSwapAmount)) + " wavelets")) | |
468 | 280 | else if (isDefined(pmt.assetId)) | |
469 | 281 | then throw("can use waves only") | |
470 | 282 | else if (isBlocked) | |
471 | - | then throw("contract is blocked") | |
472 | - | else { | |
473 | - | let amount = convertWavesToNeutrino(pmt.amount) | |
474 | - | TransferSet([ScriptTransfer(i.caller, amount, neutrinoAssetId)]) | |
475 | - | } | |
283 | + | then throw("contract is blocked by EMERGENCY SHUTDOWN actions untill reactivation by emergency oracles") | |
284 | + | else if ((getUnlockBalanceBlock(account) > height)) | |
285 | + | then throw((("await " + toString((getUnlockBalanceBlock(account) - height))) + " blocks")) | |
286 | + | else if ((getAccountLockedBalance(account, WAVESASSETID) != 0)) | |
287 | + | then throw("please withdraw locked funds first") | |
288 | + | else WriteSet([DataEntry(getAccountLockedBalanceKey(account, WAVESASSETID), pmt.amount), DataEntry(getBalanceUnlockBlockKey(account), (height + balanceLockInterval)), DataEntry(getLockedBalanceKey(WAVESASSETID), (getLockedBalance(WAVESASSETID) + pmt.amount))]) | |
476 | 289 | } | |
477 | 290 | ||
478 | 291 | ||
480 | 293 | @Callable(i) | |
481 | 294 | func swapNeutrinoToWaves () = { | |
482 | 295 | let pmt = extract(i.payment) | |
296 | + | let account = toString(i.caller) | |
483 | 297 | if ((minNeutrinoSwapAmount > pmt.amount)) | |
484 | - | then throw("amount less min") | |
298 | + | then throw((("an amount is less than min available amount: " + toString(minNeutrinoSwapAmount)) + " neutrino cents")) | |
485 | 299 | else if (isBlocked) | |
486 | - | then throw("contract is blocked") | |
300 | + | then throw("contract is blocked by EMERGENCY SHUTDOWN actions untill reactivation by emergency oracles") | |
487 | 301 | else if ((pmt.assetId != neutrinoAssetId)) | |
488 | - | then throw("can use neutrino only") | |
489 | - | else { | |
490 | - | let account = toBase58String(i.caller.bytes) | |
491 | - | let amount = convertNeutrinoToWaves(pmt.amount) | |
492 | - | WriteSet([DataEntry(getWavesBalanceKey(account), (getWavesBalance(account) + amount)), DataEntry(getBalanceUnlockBlockKey(account), (height + balanceLockInterval))]) | |
493 | - | } | |
302 | + | then throw("can use appropriate neutrino tokens only") | |
303 | + | else if ((getUnlockBalanceBlock(account) > height)) | |
304 | + | then throw((("await " + toString((getUnlockBalanceBlock(account) - height))) + " blocks")) | |
305 | + | else if ((getAccountLockedBalance(account, neutrinoAssetIdString) != 0)) | |
306 | + | then throw("please withdraw locked funds first") | |
307 | + | else { | |
308 | + | let newLockedBalance = (getLockedBalance(neutrinoAssetIdString) + pmt.amount) | |
309 | + | WriteSet([DataEntry(getAccountLockedBalanceKey(account, neutrinoAssetIdString), pmt.amount), DataEntry(getBalanceUnlockBlockKey(account), (height + balanceLockInterval)), DataEntry(getLockedBalanceKey(neutrinoAssetIdString), newLockedBalance), DataEntry(IsRebalanceKey, if ((reserveWithoutLeasing >= convertNeutrinoToWaves(newLockedBalance, currentPrice))) | |
310 | + | then false | |
311 | + | else true)]) | |
312 | + | } | |
494 | 313 | } | |
495 | 314 | ||
496 | 315 | ||
497 | 316 | ||
498 | 317 | @Callable(i) | |
499 | - | func withdraw (account) = if ((getUnlockBalanceBlock(account) > height)) | |
500 | - | then throw("wait a couple of blocks for withdraw") | |
501 | - | else ScriptResult(WriteSet([DataEntry(getWavesBalanceKey(account), 0), DataEntry(getNeutrinoBalanceKey(account), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(account), getNeutrinoBalance(account), neutrinoAssetId), ScriptTransfer(addressFromStringValue(account), getWavesBalance(account), unit)])) | |
502 | - | ||
503 | - | ||
504 | - | ||
505 | - | @Callable(i) | |
506 | - | func generateBond () = { | |
507 | - | let deficit = (neutrinoSupply - convertWavesToNeutrino(reserve)) | |
508 | - | let balanceAuction = assetBalance(addressFromStringValue(auctionContract), bondAssetId) | |
509 | - | let amount = (convertNeutrinoToBond(deficit) - balanceAuction) | |
318 | + | func withdraw (account,index,lockedAssetId) = { | |
319 | + | let unlockHeight = getUnlockBalanceBlock(account) | |
320 | + | let lockedBalance = getAccountLockedBalance(account, lockedAssetId) | |
321 | + | let indexHeight = getHeightPriceByIndex(index) | |
322 | + | let nextIndexHeight = getHeightPriceByIndex((index + 1)) | |
323 | + | let priceByIndex = getPriceHistory(indexHeight) | |
324 | + | let amount = if ((lockedAssetId == neutrinoAssetIdString)) | |
325 | + | then convertNeutrinoToWaves(lockedBalance, priceByIndex) | |
326 | + | else convertWavesToNeutrino(lockedBalance, priceByIndex) | |
510 | 327 | if (isBlocked) | |
511 | - | then throw("contract is blocked") | |
512 | - | else if ((amount > 0)) | |
513 | - | then TransferSet([ScriptTransfer(addressFromStringValue(auctionContract), amount, bondAssetId)]) | |
514 | - | else throw("bond were generated or do not need it") | |
328 | + | then throw("contract is blocked by EMERGENCY SHUTDOWN actions untill reactivation by emergency oracles") | |
329 | + | else if ((0 >= amount)) | |
330 | + | then throw((("balance equals zero (" + lockedAssetId) + ")")) | |
331 | + | else if ((unlockHeight > height)) | |
332 | + | then throw((("please wait for: " + toString(unlockHeight)) + " block height to withdraw WAVES funds")) | |
333 | + | else if (if (if ((index > priceIndex)) | |
334 | + | then true | |
335 | + | else (indexHeight > unlockHeight)) | |
336 | + | then true | |
337 | + | else if ((nextIndexHeight != 0)) | |
338 | + | then (unlockHeight >= nextIndexHeight) | |
339 | + | else false) | |
340 | + | then throw("invalid price history index") | |
341 | + | else ScriptResult(WriteSet([DataEntry(getAccountLockedBalanceKey(account, lockedAssetId), 0), DataEntry(getLockedBalanceKey(lockedAssetId), (getLockedBalance(lockedAssetId) - lockedBalance))]), TransferSet([ScriptTransfer(addressFromStringValue(account), amount, if ((lockedAssetId == neutrinoAssetIdString)) | |
342 | + | then unit | |
343 | + | else neutrinoAssetId)])) | |
515 | 344 | } | |
516 | 345 | ||
517 | 346 | ||
518 | 347 | ||
519 | 348 | @Callable(i) | |
520 | - | func setOrder () = { | |
521 | - | let pmt = extract(i.payment) | |
522 | - | let newOrderId = toBase58String(keccak256(((toBytes(pmt.amount) + i.caller.bytes) + toBytes(height)))) | |
523 | - | if ((pmt.assetId != bondAssetId)) | |
524 | - | then throw("can use bond only") | |
525 | - | else if ((getOrderOwner(newOrderId) != "")) | |
526 | - | then throw("order exists") | |
527 | - | else WriteSet([DataEntry(OrderbookKey, addOrder(newOrderId)), DataEntry(getOrderTotalKey(newOrderId), pmt.amount), DataEntry(getOrderOwnerKey(newOrderId), toString(i.caller)), DataEntry(getOrderHeightKey(newOrderId), height), DataEntry(getOrderStatusKey(newOrderId), NEW)]) | |
528 | - | } | |
529 | - | ||
530 | - | ||
531 | - | ||
532 | - | @Callable(i) | |
533 | - | func cancelOrder (orderId) = { | |
534 | - | let owner = getOrderOwner(orderId) | |
535 | - | let amount = (getOrderTotal(orderId) - getOrderFilledTotal(orderId)) | |
536 | - | if ((owner != toString(i.caller))) | |
537 | - | then throw("permission denied") | |
538 | - | else ScriptResult(WriteSet([DataEntry(OrderbookKey, dropOrder(orderId)), DataEntry(getOrderStatusKey(orderId), CANCELED)]), TransferSet([ScriptTransfer(i.caller, amount, bondAssetId)])) | |
539 | - | } | |
540 | - | ||
541 | - | ||
542 | - | ||
543 | - | @Callable(i) | |
544 | - | func addLeasingCheck (id) = { | |
545 | - | let tx = value(transferTransactionById(fromBase58String(id))) | |
546 | - | if (if ((tx.recipient != addressFromStringValue(rpdContract))) | |
547 | - | then true | |
548 | - | else isLeasingProfitTxExist(id)) | |
549 | - | then throw("invalid transaction id") | |
550 | - | else { | |
551 | - | let amount = convertWavesToNeutrino(tx.amount) | |
552 | - | let newRpdSyncIndex = (rpdSyncIndex + 1) | |
553 | - | ScriptResult(WriteSet([DataEntry(RPDSyncIndexKey, newRpdSyncIndex), DataEntry(getRPDProfitKey(rpdSyncIndex), amount), DataEntry(getRPDSnapshotContractBalanceKey(rpdSyncIndex, neutrinoAssetId), getRPDContractBalance(neutrinoAssetId)), DataEntry(getRPDSnapshotContractBalanceKey(rpdSyncIndex, bondAssetId), getRPDContractBalance(bondAssetId)), DataEntry(getIsLeasingProfitTxExistKey(id), true)]), TransferSet([ScriptTransfer(addressFromStringValue(rpdContract), amount, neutrinoAssetId)])) | |
554 | - | } | |
555 | - | } | |
556 | - | ||
557 | - | ||
558 | - | ||
559 | - | @Callable(i) | |
560 | - | func executeOrder () = { | |
561 | - | let orderId = split(orderbook, LISTSPLITSYMBOL)[0] | |
562 | - | let orderTotal = getOrderTotal(orderId) | |
563 | - | let orderOwner = getOrderOwner(orderId) | |
564 | - | let filledTotal = getOrderFilledTotal(orderId) | |
349 | + | func transferToAuction () = { | |
350 | + | let deficitBondAmount = ((convertNeutrinoToBond(deficit) - assetBalance(addressFromStringValue(auctionContract), bondAssetId)) - totalLiquidationOrderbook) | |
351 | + | let surplusBond = ((convertNeutrinoToBond(surplus) - assetBalance(addressFromStringValue(auctionContract), neutrinoAssetId)) - totalOrderbook) | |
565 | 352 | if (isBlocked) | |
566 | - | then throw("contract is blocked") | |
567 | - | else if ((0 >= surplus)) | |
568 | - | then throw("surplus is less than zero") | |
569 | - | else if ((orderOwner == "")) | |
570 | - | then { | |
571 | - | let newRpdSyncIndex = (rpdSyncIndex + 1) | |
572 | - | ScriptResult(WriteSet([DataEntry(RPDSyncIndexKey, newRpdSyncIndex), DataEntry(getRPDProfitKey(rpdSyncIndex), surplus), DataEntry(getRPDSnapshotContractBalanceKey(rpdSyncIndex, neutrinoAssetId), getRPDContractBalance(neutrinoAssetId)), DataEntry(getRPDSnapshotContractBalanceKey(rpdSyncIndex, bondAssetId), getRPDContractBalance(bondAssetId))]), TransferSet([ScriptTransfer(addressFromStringValue(rpdContract), surplus, neutrinoAssetId)])) | |
573 | - | } | |
574 | - | else { | |
575 | - | let amount = (orderTotal - filledTotal) | |
576 | - | let surplusBond = convertNeutrinoToBond(surplus) | |
577 | - | let status = if ((surplusBond >= amount)) | |
578 | - | then FILLED | |
579 | - | else NEW | |
580 | - | let newFilledTotal = if ((surplusBond >= amount)) | |
581 | - | then orderTotal | |
582 | - | else surplusBond | |
583 | - | ScriptResult(WriteSet([DataEntry(OrderbookKey, dropOrder(orderId)), DataEntry(getOrderFilledTotalKey(orderId), (filledTotal + newFilledTotal)), DataEntry(getOrderStatusKey(orderId), status)]), TransferSet([ScriptTransfer(addressFromStringValue(orderOwner), convertBondToNeutrino(newFilledTotal), neutrinoAssetId)])) | |
584 | - | } | |
353 | + | then throw("contract is blocked by EMERGENCY SHUTDOWN actions untill reactivation by emergency oracles") | |
354 | + | else if ((deficitBondAmount >= ((neutrinoSupply * DEFICITOFFSET) / 100))) | |
355 | + | then TransferSet([ScriptTransfer(addressFromStringValue(auctionContract), deficitBondAmount, bondAssetId)]) | |
356 | + | else if ((surplusBond > 0)) | |
357 | + | then TransferSet([ScriptTransfer(addressFromStringValue(liquidationContract), convertBondToNeutrino(surplusBond), neutrinoAssetId)]) | |
358 | + | else throw("bond were generated or do not need it") | |
585 | 359 | } | |
586 | 360 | ||
587 | 361 | ||
589 | 363 | @Callable(i) | |
590 | 364 | func transfer (account) = { | |
591 | 365 | let pmt = extract(i.payment) | |
592 | - | if (isDefined(pmt.assetId)) | |
593 | - | then throw("can use waves only at the moment") | |
594 | - | else TransferSet([ScriptTransfer(addressFromStringValue(account), pmt.amount, unit)]) | |
366 | + | TransferSet([ScriptTransfer(addressFromStringValue(account), pmt.amount, pmt.assetId)]) | |
367 | + | } | |
368 | + | ||
369 | + | ||
370 | + | ||
371 | + | @Callable(i) | |
372 | + | func nodeReward () = { | |
373 | + | let pmt = value(i.payment) | |
374 | + | if ((i.caller != addressFromStringValue(nodeAddress))) | |
375 | + | then throw("only node account is able to transfer staking rewards from main account") | |
376 | + | else if (isDefined(pmt.assetId)) | |
377 | + | then throw("waves tokens only allowed") | |
378 | + | else { | |
379 | + | let amount = convertWavesToNeutrino(pmt.amount, currentPrice) | |
380 | + | let newRpdSyncIndex = (rpdSyncIndex + 1) | |
381 | + | ScriptResult(WriteSet([DataEntry(RPDSyncIndexKey, newRpdSyncIndex), DataEntry(getRPDProfitKey(rpdSyncIndex), amount), DataEntry(getRPDSnapshotContractBalanceKey(rpdSyncIndex, neutrinoAssetId), getRPDContractBalance(neutrinoAssetId))]), TransferSet([ScriptTransfer(addressFromStringValue(rpdContract), amount, neutrinoAssetId)])) | |
382 | + | } | |
383 | + | } | |
384 | + | ||
385 | + | ||
386 | + | ||
387 | + | @Callable(i) | |
388 | + | func registrationLeaseTx (senderPublicKey,fee,timestamp,leaseTxHash) = { | |
389 | + | let totalFreeReserve = (((reserve * LEASINGSHARE) / 100) - convertNeutrinoToWaves(getLockedBalance(neutrinoAssetIdString), currentPrice)) | |
390 | + | let amount = (totalFreeReserve / LEASINTXCOUNT) | |
391 | + | let txBytes = (((((base58'3h1H' + fromBase58String(senderPublicKey)) + fromBase58String(nodeAddress)) + toBytes(amount)) + toBytes(fee)) + toBytes(timestamp)) | |
392 | + | let txHashBytes = blake2b256(txBytes) | |
393 | + | let txHash = toBase58String(txHashBytes) | |
394 | + | let pmt = extract(i.payment) | |
395 | + | if ((toString(i.caller) == nodeOracleProviderKey)) | |
396 | + | then throw("invalid caller") | |
397 | + | else if (isDefined(pmt.assetId)) | |
398 | + | then throw("invalid paymtn asset") | |
399 | + | else if ((leaseTxHash != txHash)) | |
400 | + | then throw((("invalid tx hash(amount:" + toString(amount)) + ")")) | |
401 | + | else if ((leasingTxCount >= LEASINTXCOUNT)) | |
402 | + | then throw("the number of leasing transactions is equal to the maximum") | |
403 | + | else if ((this != addressFromPublicKey(fromBase58String(senderPublicKey)))) | |
404 | + | then throw("invalid pubKey") | |
405 | + | else if (if ((lastBlock.timestamp > timestamp)) | |
406 | + | then true | |
407 | + | else (timestamp > (lastBlock.timestamp + 5400000))) | |
408 | + | then throw((("invalid timestamp(lastBlock: " + toString(lastBlock.timestamp)) + ")")) | |
409 | + | else if ((getLeaseTxStatus(txHash) != "")) | |
410 | + | then throw("tx is exist") | |
411 | + | else if ((pmt.amount != (fee * 2))) | |
412 | + | then throw("invalid payment amount") | |
413 | + | else if (if ((fee > 1000000)) | |
414 | + | then true | |
415 | + | else (500000 > fee)) | |
416 | + | then throw("invalid fee") | |
417 | + | else if (((totalFreeReserve - (leasingAmount + amount)) > reserveWithoutLeasing)) | |
418 | + | then throw((("invalid amount(result:" + toString(((totalFreeReserve - (leasingAmount + amount)) > reserveWithoutLeasing))) + ")")) | |
419 | + | else WriteSet([DataEntry(getCancelLeaseTxReserveFeeKey(txHash), fee), DataEntry(LeasingTxCountKey, if ((getLeaseTxStatus(txHash) == "")) | |
420 | + | then (leasingTxCount + 1) | |
421 | + | else leasingTxCount), DataEntry(LeasingAmountKey, (leasingAmount + amount)), DataEntry(LeasingExpireBlockKey, if ((height > leasingExpireBlock)) | |
422 | + | then (height + leasingInterval) | |
423 | + | else leasingExpireBlock), DataEntry(getLeaseTxStatusKey(txHash), NEW), DataEntry(getLeaseTxExpireSendBlockKey(txHash), (height + SENDTXEXPIRE)), DataEntry(getLeaseTxAmountByHashKey(txHash), amount), DataEntry(getLeaseTxBytesByHashKey(txHash), toBase64String(txBytes))]) | |
424 | + | } | |
425 | + | ||
426 | + | ||
427 | + | ||
428 | + | @Callable(i) | |
429 | + | func cancelStuckLeaseTx (txHash) = if (if (if ((getLeaseTxStatus(txHash) == NEW)) | |
430 | + | then !(isDefined(transactionHeightById(fromBase58String(txHash)))) | |
431 | + | else false) | |
432 | + | then (height > getLeaseTxExpireSendBlock(txHash)) | |
433 | + | else false) | |
434 | + | then { | |
435 | + | let amount = getLeaseTxAmountByHash(txHash) | |
436 | + | WriteSet([DataEntry(LeasingTxCountKey, (leasingTxCount - 1)), DataEntry(LeasingAmountKey, (leasingAmount - amount)), DataEntry(getLeaseTxStatusKey(txHash), CANCELED), DataEntry(IsRebalanceKey, if (((reserveWithoutLeasing - amount) >= convertNeutrinoToWaves(getLockedBalance(neutrinoAssetIdString), currentPrice))) | |
437 | + | then false | |
438 | + | else true)]) | |
439 | + | } | |
440 | + | else throw("invalid tx hash") | |
441 | + | ||
442 | + | ||
443 | + | ||
444 | + | @Callable(i) | |
445 | + | func registrationUnleaseTx (chainIdString,senderPublicKey,fee,timestamp,leaseTxHash) = { | |
446 | + | let txBytes = (((((base58'gm' + toBytes(chainIdString)) + fromBase58String(senderPublicKey)) + toBytes(fee)) + toBytes(timestamp)) + fromBase58String(leaseTxHash)) | |
447 | + | let txHash = blake2b256(txBytes) | |
448 | + | if ((getLeaseTxStatus(leaseTxHash) != NEW)) | |
449 | + | then throw("invalid tx status") | |
450 | + | else if ((this != addressFromPublicKey(fromBase58String(senderPublicKey)))) | |
451 | + | then throw("invalid pubKey") | |
452 | + | else if (!(isDefined(transactionHeightById(txHash)))) | |
453 | + | then throw("blockchain does not contain this transaction") | |
454 | + | else { | |
455 | + | let amount = getLeaseTxAmountByHash(leaseTxHash) | |
456 | + | WriteSet([DataEntry(LeasingTxCountKey, (leasingTxCount - 1)), DataEntry(LeasingAmountKey, (leasingAmount - amount)), DataEntry(getLeaseTxStatusKey(leaseTxHash), CANCELED), DataEntry(IsRebalanceKey, if (((reserveWithoutLeasing - amount) >= convertNeutrinoToWaves(getLockedBalance(neutrinoAssetIdString), currentPrice))) | |
457 | + | then false | |
458 | + | else true)]) | |
459 | + | } | |
595 | 460 | } | |
596 | 461 | ||
597 | 462 | ||
598 | 463 | @Verifier(tx) | |
599 | - | func verify () = match tx { | |
600 | - | case leaseTx: LeaseTransaction => | |
601 | - | sigVerify(tx.bodyBytes, tx.proofs[0], fromBase58String(getOwnerPubKeyByLeaseTxId(toBase58String(leaseTx.id)))) | |
602 | - | case unleaseTx: LeaseCancelTransaction => | |
603 | - | sigVerify(tx.bodyBytes, tx.proofs[0], fromBase58String(getOwnerPubKeyByLeaseTxId(toBase58String(unleaseTx.leaseId)))) | |
604 | - | case _ => | |
605 | - | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
606 | - | } | |
464 | + | func verify () = { | |
465 | + | let id = toBase58String(tx.id) | |
466 | + | match tx { | |
467 | + | case leaseTx: LeaseTransaction => | |
468 | + | if (if ((leasingExpireBlock >= height)) | |
469 | + | then (getLeaseTxExpireSendBlock(id) >= height) | |
470 | + | else false) | |
471 | + | then (getLeaseTxStatus(id) == NEW) | |
472 | + | else false | |
473 | + | case unleaseTx: LeaseCancelTransaction => | |
474 | + | let leaseId = toBase58String(unleaseTx.leaseId) | |
475 | + | if (if (if ((height > leasingExpireBlock)) | |
476 | + | then true | |
477 | + | else isRebalance) | |
478 | + | then (unleaseTx.fee == getCancelLeaseTxReserveFee(leaseId)) | |
479 | + | else false) | |
480 | + | then (getLeaseTxStatus(leaseId) == NEW) | |
481 | + | else false | |
482 | + | case _ => | |
483 | + | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
484 | + | } | |
485 | + | } | |
607 | 486 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | func getNumberByKey (key) = match getInteger(this, key) { | |
5 | 5 | case a: Int => | |
6 | 6 | a | |
7 | 7 | case _ => | |
8 | 8 | 0 | |
9 | 9 | } | |
10 | 10 | ||
11 | 11 | ||
12 | 12 | func getStringByKey (key) = match getString(this, key) { | |
13 | 13 | case a: String => | |
14 | 14 | a | |
15 | 15 | case _ => | |
16 | 16 | "" | |
17 | 17 | } | |
18 | 18 | ||
19 | 19 | ||
20 | 20 | func getBoolByKey (key) = match getBoolean(this, key) { | |
21 | 21 | case a: Boolean => | |
22 | 22 | a | |
23 | 23 | case _ => | |
24 | 24 | false | |
25 | 25 | } | |
26 | 26 | ||
27 | 27 | ||
28 | 28 | func getNumberByAddressAndKey (address,key) = match getInteger(addressFromStringValue(address), key) { | |
29 | 29 | case a: Int => | |
30 | 30 | a | |
31 | 31 | case _ => | |
32 | 32 | 0 | |
33 | 33 | } | |
34 | 34 | ||
35 | 35 | ||
36 | - | func getStringByAddressAndKey (address,key) = match getString( | |
36 | + | func getStringByAddressAndKey (address,key) = match getString(addressFromStringValue(address), key) { | |
37 | 37 | case a: String => | |
38 | 38 | a | |
39 | 39 | case _ => | |
40 | 40 | "" | |
41 | 41 | } | |
42 | 42 | ||
43 | 43 | ||
44 | + | func getBoolByAddressAndKey (address,key) = match getBoolean(addressFromStringValue(address), key) { | |
45 | + | case a: Boolean => | |
46 | + | a | |
47 | + | case _ => | |
48 | + | false | |
49 | + | } | |
50 | + | ||
51 | + | ||
52 | + | let SENDTXEXPIRE = 30 | |
53 | + | ||
44 | 54 | let LISTSPLITSYMBOL = "_" | |
45 | 55 | ||
46 | 56 | let LISTDATASYMBOL = "+" | |
47 | 57 | ||
48 | 58 | let WAVELET = 100000000 | |
49 | 59 | ||
50 | - | let CENTSINDOLLAR = 100 | |
60 | + | let PAULI = 100 | |
61 | + | ||
62 | + | let CRYTICALSHARE = 20 | |
63 | + | ||
64 | + | let LEASINGSHARE = 90 | |
65 | + | ||
66 | + | let LEASINTXCOUNT = 10 | |
67 | + | ||
68 | + | let DEFICITOFFSET = 10 | |
69 | + | ||
70 | + | let WAVESASSETID = "waves" | |
51 | 71 | ||
52 | 72 | let CANCELED = "canceled" | |
53 | 73 | ||
54 | 74 | let NEW = "new" | |
55 | 75 | ||
56 | - | let FILLED = "filled" | |
57 | - | ||
58 | 76 | let NeutrinoAssetIdKey = "neutrino_asset_id" | |
59 | 77 | ||
60 | 78 | let BondAssetIdKey = "bond_asset_id" | |
61 | 79 | ||
80 | + | let ReserveContractKey = "reserve_contract" | |
81 | + | ||
62 | 82 | let AuctionContractKey = "auction_contract" | |
83 | + | ||
84 | + | let LiquidationContractKey = "liquidation_contract" | |
63 | 85 | ||
64 | 86 | let RPDContractKey = "rpd_contract" | |
65 | 87 | ||
88 | + | let ContolContractKey = "control_contract" | |
89 | + | ||
66 | 90 | let BalanceLockIntervalKey = "balance_lock_interval" | |
67 | - | ||
68 | - | let VoteIntervalKey = "vote_interval" | |
69 | 91 | ||
70 | 92 | let MinWavesSwapAmountKey = "min_waves_swap_amount" | |
71 | 93 | ||
72 | 94 | let MinNeutrinoSwapAmountKey = "min_neutrino_swap_amount" | |
73 | 95 | ||
74 | - | let | |
96 | + | let NodeAddressKey = "node_address" | |
75 | 97 | ||
76 | - | let ProvidingIntervalKey = "providing_interval" | |
98 | + | let NodeOracleProviderKey = "oracle_node_provider" | |
99 | + | ||
100 | + | let LeasingIntervalKey = "leasing_interval" | |
101 | + | ||
102 | + | let RPDBalanceKey = "rpd_balance" | |
103 | + | ||
104 | + | func getRPDContractBalanceKey (assetId) = ((RPDBalanceKey + "_") + toBase58String(assetId)) | |
105 | + | ||
106 | + | ||
107 | + | let TotalOrderbookKey = "total_orderbook" | |
108 | + | ||
109 | + | let TotalLiquidationOrderbookKey = "total_liquidation_orderbook" | |
77 | 110 | ||
78 | 111 | let PriceKey = "price" | |
79 | 112 | ||
80 | - | let NeutrinoBalanceKey = "neutrino_" | |
81 | - | ||
82 | - | let WavesBalanceKey = "waves_" | |
83 | - | ||
84 | - | let BalanceUnlockBlockKey = "balance_block_" | |
85 | - | ||
86 | - | let OrderbookKey = "orderbook" | |
87 | - | ||
88 | - | let OrderTotalKey = "order_total_" | |
89 | - | ||
90 | - | let OrderOwnerKey = "order_owner_" | |
91 | - | ||
92 | - | let OrderHeightKey = "order_height_" | |
93 | - | ||
94 | - | let OrderFilledTotalKey = "order_filled_total_" | |
95 | - | ||
96 | - | let OrderStatusKey = "order_status_" | |
97 | - | ||
98 | - | let RPDSyncIndexKey = "rpd_sync_index" | |
99 | - | ||
100 | - | let RPDProfitKey = "rpd_profit" | |
101 | - | ||
102 | - | let RPDBalanceKey = "rpd_balance" | |
113 | + | let PriceIndexKey = "price_index" | |
103 | 114 | ||
104 | 115 | let IsBlockedKey = "is_blocked" | |
105 | 116 | ||
106 | - | let | |
117 | + | let LeasingExpireBlockKey = "leasing_expire_block" | |
107 | 118 | ||
108 | - | let | |
119 | + | let IsRebalanceKey = "is_rebalance" | |
109 | 120 | ||
110 | - | let | |
121 | + | let LeasingTxCountKey = "leasing_index" | |
111 | 122 | ||
112 | - | let | |
123 | + | let LeasingAmountKey = "leasing_amount" | |
113 | 124 | ||
114 | - | let AdminKey = "admin_" | |
115 | - | ||
116 | - | let IsPricePendingKey = "is_pending_price" | |
117 | - | ||
118 | - | let OracleKey = "oracle_" | |
119 | - | ||
120 | - | let OracleIsProvideKey = "oracle_is_provide_" | |
121 | - | ||
122 | - | let OracleProvidePriceKey = "oracle_price_provide_" | |
123 | - | ||
124 | - | let BlockExpireProvidingKey = "providing_expire_block" | |
125 | - | ||
126 | - | let ApprovedLeaseTxKey = "leasetx" | |
127 | - | ||
128 | - | let IsLeasingProfitTxExistKey = "is_leasing_profit" | |
129 | - | ||
130 | - | func getAdminKey (count) = (AdminKey + toString(count)) | |
125 | + | func getPriceHistoryKey (block) = ((PriceKey + "_") + toString(block)) | |
131 | 126 | ||
132 | 127 | ||
133 | - | func | |
128 | + | func getHeightPriceByIndexKey (index) = ((PriceIndexKey + "_") + toString(index)) | |
134 | 129 | ||
135 | 130 | ||
136 | - | func getAdminVotePriceKey (owner) = (AdminVotePriceKey + owner) | |
137 | - | ||
138 | - | ||
139 | - | func getOracleKey (count) = (OracleKey + toString(count)) | |
140 | - | ||
141 | - | ||
142 | - | func getOracleIsProvideKey (owner) = (OracleIsProvideKey + owner) | |
143 | - | ||
144 | - | ||
145 | - | func getOracleProvidePriceKey (owner) = (OracleProvidePriceKey + owner) | |
146 | - | ||
131 | + | let RPDSyncIndexKey = "rpd_sync_index" | |
147 | 132 | ||
148 | 133 | func getRPDSnapshotContractBalanceKey (count,assetId) = ((((RPDBalanceKey + "_") + toBase58String(assetId)) + "_") + toString(count)) | |
149 | 134 | ||
150 | 135 | ||
151 | - | func | |
136 | + | func getCancelLeaseTxReserveFeeKey (hash) = (("cancel_lease_tx_reserve_fee" + "_") + hash) | |
152 | 137 | ||
153 | 138 | ||
154 | - | func | |
139 | + | func getAccountLockedBalanceKey (owner,assetId) = ((("balance_" + assetId) + "_") + owner) | |
155 | 140 | ||
156 | 141 | ||
157 | - | func | |
142 | + | func getBalanceUnlockBlockKey (owner) = ("balance_block_" + owner) | |
158 | 143 | ||
159 | 144 | ||
160 | - | func | |
145 | + | func getRPDProfitKey (count) = (("rpd_profit" + "_") + toString(count)) | |
161 | 146 | ||
162 | 147 | ||
163 | - | func | |
148 | + | func getLockedBalanceKey (assetId) = ("balance_" + assetId) | |
164 | 149 | ||
165 | 150 | ||
166 | - | func | |
151 | + | func getLeaseTxStatusKey (hash) = (("lease_tx_status" + "_") + hash) | |
167 | 152 | ||
168 | 153 | ||
169 | - | func | |
154 | + | func getLeaseTxAmountByHashKey (hash) = ((LeasingAmountKey + "_") + hash) | |
170 | 155 | ||
171 | 156 | ||
172 | - | func | |
157 | + | func getLeaseTxBytesByHashKey (hash) = (("lease_tx" + "_") + hash) | |
173 | 158 | ||
174 | 159 | ||
175 | - | func | |
160 | + | func getLeaseTxExpireSendBlockKey (hash) = (("leasing_expire_send" + "_") + hash) | |
176 | 161 | ||
177 | 162 | ||
178 | - | func | |
163 | + | func convertNeutrinoToWaves (amount,price) = ((((amount * 100) / price) * WAVELET) / PAULI) | |
179 | 164 | ||
180 | 165 | ||
181 | - | func | |
166 | + | func convertWavesToNeutrino (amount,price) = ((((amount * price) / 100) * PAULI) / WAVELET) | |
182 | 167 | ||
183 | 168 | ||
184 | - | func | |
169 | + | func convertNeutrinoToBond (amount) = (amount / PAULI) | |
185 | 170 | ||
186 | 171 | ||
187 | - | func | |
172 | + | func convertBondToNeutrino (amount) = (amount * PAULI) | |
188 | 173 | ||
189 | 174 | ||
190 | - | func | |
175 | + | func convertWavesToBond (amount,price) = convertNeutrinoToBond(convertWavesToNeutrino(amount, price)) | |
191 | 176 | ||
192 | 177 | ||
193 | - | let price = getNumberByKey(PriceKey) | |
194 | - | ||
195 | - | func convertNeutrinoToWaves (amount) = ((((amount * 100) / price) * WAVELET) / CENTSINDOLLAR) | |
178 | + | func getLockedBalance (assetId) = getNumberByKey(getLockedBalanceKey(assetId)) | |
196 | 179 | ||
197 | 180 | ||
198 | - | ||
181 | + | let liquidationContract = getStringByKey(LiquidationContractKey) | |
199 | 182 | ||
183 | + | let neutrinoAssetIdString = getStringByKey(NeutrinoAssetIdKey) | |
200 | 184 | ||
201 | - | ||
185 | + | let neutrinoAssetId = fromBase58String(neutrinoAssetIdString) | |
202 | 186 | ||
187 | + | let reserveContract = getStringByKey(ReserveContractKey) | |
203 | 188 | ||
204 | - | ||
189 | + | let auctionContract = getStringByKey(AuctionContractKey) | |
205 | 190 | ||
191 | + | let rpdContract = getStringByKey(RPDContractKey) | |
206 | 192 | ||
207 | - | ||
193 | + | let controlContract = getStringByKey(ContolContractKey) | |
208 | 194 | ||
195 | + | let currentPrice = getNumberByAddressAndKey(controlContract, PriceKey) | |
209 | 196 | ||
210 | - | let | |
197 | + | let priceIndex = getNumberByAddressAndKey(controlContract, PriceIndexKey) | |
211 | 198 | ||
212 | - | let | |
199 | + | let isBlocked = getBoolByAddressAndKey(controlContract, IsBlockedKey) | |
213 | 200 | ||
214 | - | let | |
201 | + | let leasingTxCount = getNumberByKey(LeasingTxCountKey) | |
215 | 202 | ||
216 | - | let percentPriceOffset = getNumberByKey(PriceOffsetKey) | |
203 | + | let isRebalance = getBoolByKey(IsRebalanceKey) | |
204 | + | ||
205 | + | let leasingInterval = getNumberByKey(LeasingIntervalKey) | |
206 | + | ||
207 | + | let leasingExpireBlock = getNumberByKey(LeasingExpireBlockKey) | |
208 | + | ||
209 | + | let leasingAmount = getNumberByKey(LeasingAmountKey) | |
210 | + | ||
211 | + | let nodeAddress = getStringByKey(NodeAddressKey) | |
212 | + | ||
213 | + | let nodeOracleProviderKey = getStringByKey(NodeOracleProviderKey) | |
217 | 214 | ||
218 | 215 | let rpdSyncIndex = getNumberByKey(RPDSyncIndexKey) | |
219 | 216 | ||
220 | - | let voteInterval = getNumberByKey(VoteIntervalKey) | |
221 | - | ||
222 | - | let blockExpireVote = getNumberByKey(BlockExpireVoteKey) | |
223 | - | ||
224 | 217 | let balanceLockInterval = getNumberByKey(BalanceLockIntervalKey) | |
225 | - | ||
226 | - | let isBlocked = getBoolByKey(IsBlockedKey) | |
227 | 218 | ||
228 | 219 | let minWavesSwapAmount = getNumberByKey(MinWavesSwapAmountKey) | |
229 | 220 | ||
230 | 221 | let minNeutrinoSwapAmount = getNumberByKey(MinNeutrinoSwapAmountKey) | |
231 | 222 | ||
232 | - | let | |
223 | + | let reserve = (wavesBalance(this) - getLockedBalance(WAVESASSETID)) | |
233 | 224 | ||
234 | - | let auctionContract = getStringByKey(AuctionContractKey) | |
235 | - | ||
236 | - | let rpdContract = getStringByKey(RPDContractKey) | |
237 | - | ||
238 | - | let reserve = wavesBalance(this) | |
239 | - | ||
240 | - | let orderbook = getStringByKey(OrderbookKey) | |
225 | + | let reserveWithoutLeasing = (reserve - leasingAmount) | |
241 | 226 | ||
242 | 227 | let bondAssetId = fromBase58String(getStringByKey(BondAssetIdKey)) | |
243 | 228 | ||
244 | - | let bondSupply = { | |
245 | - | let info = extract(assetInfo(bondAssetId)) | |
246 | - | (info.quantity - assetBalance(this, bondAssetId)) | |
247 | - | } | |
229 | + | let bondSupply = (extract(assetInfo(bondAssetId)).quantity - assetBalance(this, bondAssetId)) | |
248 | 230 | ||
249 | - | let neutrinoSupply = { | |
250 | - | let info = extract(assetInfo(neutrinoAssetId)) | |
251 | - | (info.quantity - assetBalance(this, neutrinoAssetId)) | |
252 | - | } | |
231 | + | let neutrinoSupply = ((extract(assetInfo(neutrinoAssetId)).quantity - assetBalance(this, neutrinoAssetId)) + getLockedBalance(neutrinoAssetIdString)) | |
253 | 232 | ||
254 | - | let surplus = (convertWavesToNeutrino(reserve) - neutrinoSupply) | |
233 | + | let surplus = (convertWavesToNeutrino(reserve, currentPrice) - neutrinoSupply) | |
255 | 234 | ||
256 | - | let oracleOne = getStringByKey(getOracleKey(0)) | |
257 | - | ||
258 | - | let oracleTwo = getStringByKey(getOracleKey(1)) | |
259 | - | ||
260 | - | let oracleThree = getStringByKey(getOracleKey(2)) | |
261 | - | ||
262 | - | let adminOne = getStringByKey(getAdminKey(0)) | |
263 | - | ||
264 | - | let adminTwo = getStringByKey(getAdminKey(1)) | |
265 | - | ||
266 | - | let adminThree = getStringByKey(getAdminKey(2)) | |
267 | - | ||
268 | - | func getOwnerPubKeyByLeaseTxId (owner) = getStringByAddressAndKey(rpdContract, getOwnerPubKeyByLeaseTxIdKey(owner)) | |
269 | - | ||
235 | + | let deficit = (neutrinoSupply - convertWavesToNeutrino(reserve, currentPrice)) | |
270 | 236 | ||
271 | 237 | func getRPDContractBalance (assetId) = getNumberByAddressAndKey(rpdContract, getRPDContractBalanceKey(assetId)) | |
272 | 238 | ||
273 | 239 | ||
274 | - | func isLeasingProfitTxExist (txId) = getBoolByKey(getIsLeasingProfitTxExistKey(txId)) | |
240 | + | let totalLiquidationOrderbook = getNumberByAddressAndKey(auctionContract, TotalLiquidationOrderbookKey) | |
241 | + | ||
242 | + | let totalOrderbook = getNumberByAddressAndKey(auctionContract, TotalOrderbookKey) | |
243 | + | ||
244 | + | func getPriceHistory (block) = getNumberByAddressAndKey(controlContract, getPriceHistoryKey(block)) | |
275 | 245 | ||
276 | 246 | ||
277 | - | func getAdminVoteInt (owner) = if (getBoolByKey(getAdminVoteKey(owner))) | |
278 | - | then 1 | |
279 | - | else 0 | |
247 | + | func getHeightPriceByIndex (index) = getNumberByAddressAndKey(controlContract, getHeightPriceByIndexKey(index)) | |
280 | 248 | ||
281 | 249 | ||
282 | - | func | |
250 | + | func getCancelLeaseTxReserveFee (hash) = getNumberByKey(getCancelLeaseTxReserveFeeKey(hash)) | |
283 | 251 | ||
284 | 252 | ||
285 | - | func isOracleProvide (owner) = getBoolByKey(getOracleIsProvideKey(owner)) | |
286 | - | ||
287 | - | ||
288 | - | func isOracleProvideInt (owner) = if (isOracleProvide(owner)) | |
289 | - | then 1 | |
290 | - | else 0 | |
291 | - | ||
292 | - | ||
293 | - | func getOracleProvidePrice (owner) = getNumberByKey(getOracleProvidePriceKey(owner)) | |
294 | - | ||
295 | - | ||
296 | - | func getWavesBalance (owner) = getNumberByKey(getWavesBalanceKey(owner)) | |
297 | - | ||
298 | - | ||
299 | - | func getNeutrinoBalance (owner) = getNumberByKey(getNeutrinoBalanceKey(owner)) | |
253 | + | func getAccountLockedBalance (owner,assetId) = getNumberByKey(getAccountLockedBalanceKey(owner, assetId)) | |
300 | 254 | ||
301 | 255 | ||
302 | 256 | func getUnlockBalanceBlock (owner) = getNumberByKey(getBalanceUnlockBlockKey(owner)) | |
303 | 257 | ||
304 | 258 | ||
305 | - | func getOrderTotal (id) = getNumberByKey(getOrderTotalKey(id)) | |
306 | - | ||
307 | - | ||
308 | - | func getOrderOwner (id) = getStringByKey(getOrderOwnerKey(id)) | |
309 | - | ||
310 | - | ||
311 | - | func getOrderFilledTotal (id) = getNumberByKey(getOrderFilledTotalKey(id)) | |
312 | - | ||
313 | - | ||
314 | 259 | func getRPDProfit (count) = getNumberByKey(getRPDProfitKey(count)) | |
315 | 260 | ||
316 | 261 | ||
317 | - | func | |
262 | + | func getLeaseTxStatus (hash) = getStringByKey(getLeaseTxStatusKey(hash)) | |
318 | 263 | ||
319 | 264 | ||
320 | - | func | |
265 | + | func getLeaseTxAmountByHash (hash) = getNumberByKey(getLeaseTxAmountByHashKey(hash)) | |
321 | 266 | ||
322 | 267 | ||
323 | - | func dropOrder (orderId) = { | |
324 | - | let parts = split(orderbook, getOrderElementById(orderId)) | |
325 | - | (parts[0] + parts[1]) | |
326 | - | } | |
268 | + | func getLeaseTxBytesByHash (hash) = getStringByKey(getLeaseTxBytesByHashKey(hash)) | |
327 | 269 | ||
328 | 270 | ||
329 | - | @Callable(i) | |
330 | - | func setCurrentPrice (newPrice) = { | |
331 | - | let account = toString(i.caller) | |
332 | - | let priceProvidingCount = (((isOracleProvideInt(oracleOne) + isOracleProvideInt(oracleTwo)) + isOracleProvideInt(oracleThree)) + 1) | |
333 | - | if (isBlocked) | |
334 | - | then throw("contract is blocked") | |
335 | - | else if (if (if ((account != oracleOne)) | |
336 | - | then (account != oracleTwo) | |
337 | - | else false) | |
338 | - | then (account != oracleThree) | |
339 | - | else false) | |
340 | - | then throw("permission denied") | |
341 | - | else if (if ((blockExpireProviding >= height)) | |
342 | - | then isOracleProvide(account) | |
343 | - | else false) | |
344 | - | then throw("price is already provided") | |
345 | - | else if (if ((height > blockExpireProviding)) | |
346 | - | then isPricePending | |
347 | - | else false) | |
348 | - | then throw("use finilizeCurrentPrice") | |
349 | - | else WriteSet([DataEntry(getOracleProvidePriceKey(account), newPrice), DataEntry(BlockExpireProvidingKey, if ((height > blockExpireProviding)) | |
350 | - | then (height + providingInterval) | |
351 | - | else blockExpireProviding), DataEntry(getOracleIsProvideKey(oracleOne), if ((height > blockExpireProviding)) | |
352 | - | then false | |
353 | - | else isOracleProvide(oracleOne)), DataEntry(getOracleIsProvideKey(oracleTwo), if ((height > blockExpireProviding)) | |
354 | - | then false | |
355 | - | else isOracleProvide(oracleTwo)), DataEntry(getOracleIsProvideKey(oracleThree), if ((height > blockExpireProviding)) | |
356 | - | then false | |
357 | - | else isOracleProvide(oracleThree)), DataEntry(getOracleIsProvideKey(account), true), DataEntry(IsPricePendingKey, if (if ((blockExpireProviding >= height)) | |
358 | - | then (priceProvidingCount >= 2) | |
359 | - | else false) | |
360 | - | then true | |
361 | - | else isPricePending)]) | |
362 | - | } | |
363 | - | ||
364 | - | ||
365 | - | ||
366 | - | @Callable(i) | |
367 | - | func finilizeCurrentPrice () = { | |
368 | - | let account = toString(i.caller) | |
369 | - | let priceProvidingCount = ((isOracleProvideInt(oracleOne) + isOracleProvideInt(oracleTwo)) + isOracleProvideInt(oracleThree)) | |
370 | - | let newPrice = ((((getOracleProvidePrice(oracleOne) * isOracleProvideInt(oracleOne)) + (getOracleProvidePrice(oracleTwo) * isOracleProvideInt(oracleTwo))) + (getOracleProvidePrice(oracleThree) * isOracleProvideInt(oracleThree))) / priceProvidingCount) | |
371 | - | if (isBlocked) | |
372 | - | then throw("contract is blocked") | |
373 | - | else if (if (if ((account != oracleOne)) | |
374 | - | then (account != oracleTwo) | |
375 | - | else false) | |
376 | - | then (account != oracleThree) | |
377 | - | else false) | |
378 | - | then throw("permission denied") | |
379 | - | else if (if (!(isPricePending)) | |
380 | - | then true | |
381 | - | else (blockExpireProviding >= height)) | |
382 | - | then throw("wait for the end of the price providing") | |
383 | - | else if ((2 > priceProvidingCount)) | |
384 | - | then throw("2/3 oracles need to set a price") | |
385 | - | else if (if ((newPrice >= (price + ((price * percentPriceOffset) / 100)))) | |
386 | - | then true | |
387 | - | else ((price - ((price * percentPriceOffset) / 100)) >= newPrice)) | |
388 | - | then WriteSet([DataEntry(IsBlockedKey, true), DataEntry(getBlackSwarmPriceKey(height), newPrice)]) | |
389 | - | else WriteSet([DataEntry(PriceKey, newPrice), DataEntry(getPriceHistoryKey(height), newPrice), DataEntry(IsPricePendingKey, false)]) | |
390 | - | } | |
391 | - | ||
392 | - | ||
393 | - | ||
394 | - | @Callable(i) | |
395 | - | func adminUnlock (newPrice) = { | |
396 | - | let account = toString(i.caller) | |
397 | - | let adminOneVote = if ((account != adminOne)) | |
398 | - | then getAdminVoteInt(adminOne) | |
399 | - | else 0 | |
400 | - | let adminTwoVote = if ((account != adminTwo)) | |
401 | - | then getAdminVoteInt(adminTwo) | |
402 | - | else 0 | |
403 | - | let adminThreeVote = if ((account != adminThree)) | |
404 | - | then getAdminVoteInt(adminThree) | |
405 | - | else 0 | |
406 | - | let adminOnePrice = if (((getAdminVotePrice(adminOne) * adminOneVote) == newPrice)) | |
407 | - | then 1 | |
408 | - | else 0 | |
409 | - | let adminTwoPrice = if (((getAdminVotePrice(adminTwo) * adminTwoVote) == newPrice)) | |
410 | - | then 1 | |
411 | - | else 0 | |
412 | - | let adminThreePrice = if (((getAdminVotePrice(adminThree) * adminThreeVote) == newPrice)) | |
413 | - | then 1 | |
414 | - | else 0 | |
415 | - | if (!(isBlocked)) | |
416 | - | then throw("Contract is not blocked") | |
417 | - | else if (if (((((adminOnePrice + adminTwoPrice) + adminThreePrice) + 1) >= 2)) | |
418 | - | then (blockExpireVote >= height) | |
419 | - | else false) | |
420 | - | then WriteSet([DataEntry(IsBlockedKey, false), DataEntry(PriceKey, newPrice), DataEntry(getPriceHistoryKey(height), newPrice), DataEntry(getAdminVoteKey(adminOne), false), DataEntry(getAdminVoteKey(adminTwo), false), DataEntry(getAdminVoteKey(adminThree), false), DataEntry(BlockExpireVoteKey, 0), DataEntry(BlockExpireProvidingKey, 0), DataEntry(IsPricePendingKey, false)]) | |
421 | - | else WriteSet([DataEntry(getAdminVotePriceKey(account), newPrice), DataEntry(BlockExpireVoteKey, if ((height > blockExpireVote)) | |
422 | - | then (height + voteInterval) | |
423 | - | else blockExpireVote), DataEntry(getAdminVoteKey(adminOne), if ((height > blockExpireVote)) | |
424 | - | then false | |
425 | - | else (adminOneVote == 1)), DataEntry(getAdminVoteKey(adminTwo), if ((height > blockExpireVote)) | |
426 | - | then false | |
427 | - | else (adminTwoVote == 1)), DataEntry(getAdminVoteKey(adminThree), if ((height > blockExpireVote)) | |
428 | - | then false | |
429 | - | else (adminThreeVote == 1)), DataEntry(getAdminVoteKey(account), true)]) | |
430 | - | } | |
431 | - | ||
432 | - | ||
433 | - | ||
434 | - | @Callable(i) | |
435 | - | func adminLock () = { | |
436 | - | let account = toString(i.caller) | |
437 | - | let adminOneVote = if ((account != adminOne)) | |
438 | - | then getAdminVoteInt(adminOne) | |
439 | - | else 1 | |
440 | - | let adminTwoVote = if ((account != adminTwo)) | |
441 | - | then getAdminVoteInt(adminTwo) | |
442 | - | else 1 | |
443 | - | let adminThreeVote = if ((account != adminThree)) | |
444 | - | then getAdminVoteInt(adminThree) | |
445 | - | else 1 | |
446 | - | if (isBlocked) | |
447 | - | then throw("Contract is blocked") | |
448 | - | else if ((((adminOneVote + adminTwoVote) + adminThreeVote) >= 2)) | |
449 | - | then WriteSet([DataEntry(IsBlockedKey, true), DataEntry(getAdminVoteKey(adminOne), false), DataEntry(getAdminVoteKey(adminTwo), false), DataEntry(getAdminVoteKey(adminThree), false), DataEntry(BlockExpireVoteKey, 0)]) | |
450 | - | else WriteSet([DataEntry(BlockExpireVoteKey, if ((height > blockExpireVote)) | |
451 | - | then (height + voteInterval) | |
452 | - | else blockExpireVote), DataEntry(getAdminVoteKey(adminOne), if ((height > blockExpireVote)) | |
453 | - | then false | |
454 | - | else (adminOneVote == 1)), DataEntry(getAdminVoteKey(adminTwo), if ((height > blockExpireVote)) | |
455 | - | then false | |
456 | - | else (adminTwoVote == 1)), DataEntry(getAdminVoteKey(adminThree), if ((height > blockExpireVote)) | |
457 | - | then false | |
458 | - | else (adminThreeVote == 1))]) | |
459 | - | } | |
460 | - | ||
271 | + | func getLeaseTxExpireSendBlock (hash) = getNumberByKey(getLeaseTxExpireSendBlockKey(hash)) | |
461 | 272 | ||
462 | 273 | ||
463 | 274 | @Callable(i) | |
464 | 275 | func swapWavesToNeutrino () = { | |
465 | 276 | let pmt = extract(i.payment) | |
277 | + | let account = toString(i.caller) | |
466 | 278 | if ((minWavesSwapAmount > pmt.amount)) | |
467 | - | then throw("amount less min") | |
279 | + | then throw((("an amount is less than min available amount: " + toString(minWavesSwapAmount)) + " wavelets")) | |
468 | 280 | else if (isDefined(pmt.assetId)) | |
469 | 281 | then throw("can use waves only") | |
470 | 282 | else if (isBlocked) | |
471 | - | then throw("contract is blocked") | |
472 | - | else { | |
473 | - | let amount = convertWavesToNeutrino(pmt.amount) | |
474 | - | TransferSet([ScriptTransfer(i.caller, amount, neutrinoAssetId)]) | |
475 | - | } | |
283 | + | then throw("contract is blocked by EMERGENCY SHUTDOWN actions untill reactivation by emergency oracles") | |
284 | + | else if ((getUnlockBalanceBlock(account) > height)) | |
285 | + | then throw((("await " + toString((getUnlockBalanceBlock(account) - height))) + " blocks")) | |
286 | + | else if ((getAccountLockedBalance(account, WAVESASSETID) != 0)) | |
287 | + | then throw("please withdraw locked funds first") | |
288 | + | else WriteSet([DataEntry(getAccountLockedBalanceKey(account, WAVESASSETID), pmt.amount), DataEntry(getBalanceUnlockBlockKey(account), (height + balanceLockInterval)), DataEntry(getLockedBalanceKey(WAVESASSETID), (getLockedBalance(WAVESASSETID) + pmt.amount))]) | |
476 | 289 | } | |
477 | 290 | ||
478 | 291 | ||
479 | 292 | ||
480 | 293 | @Callable(i) | |
481 | 294 | func swapNeutrinoToWaves () = { | |
482 | 295 | let pmt = extract(i.payment) | |
296 | + | let account = toString(i.caller) | |
483 | 297 | if ((minNeutrinoSwapAmount > pmt.amount)) | |
484 | - | then throw("amount less min") | |
298 | + | then throw((("an amount is less than min available amount: " + toString(minNeutrinoSwapAmount)) + " neutrino cents")) | |
485 | 299 | else if (isBlocked) | |
486 | - | then throw("contract is blocked") | |
300 | + | then throw("contract is blocked by EMERGENCY SHUTDOWN actions untill reactivation by emergency oracles") | |
487 | 301 | else if ((pmt.assetId != neutrinoAssetId)) | |
488 | - | then throw("can use neutrino only") | |
489 | - | else { | |
490 | - | let account = toBase58String(i.caller.bytes) | |
491 | - | let amount = convertNeutrinoToWaves(pmt.amount) | |
492 | - | WriteSet([DataEntry(getWavesBalanceKey(account), (getWavesBalance(account) + amount)), DataEntry(getBalanceUnlockBlockKey(account), (height + balanceLockInterval))]) | |
493 | - | } | |
302 | + | then throw("can use appropriate neutrino tokens only") | |
303 | + | else if ((getUnlockBalanceBlock(account) > height)) | |
304 | + | then throw((("await " + toString((getUnlockBalanceBlock(account) - height))) + " blocks")) | |
305 | + | else if ((getAccountLockedBalance(account, neutrinoAssetIdString) != 0)) | |
306 | + | then throw("please withdraw locked funds first") | |
307 | + | else { | |
308 | + | let newLockedBalance = (getLockedBalance(neutrinoAssetIdString) + pmt.amount) | |
309 | + | WriteSet([DataEntry(getAccountLockedBalanceKey(account, neutrinoAssetIdString), pmt.amount), DataEntry(getBalanceUnlockBlockKey(account), (height + balanceLockInterval)), DataEntry(getLockedBalanceKey(neutrinoAssetIdString), newLockedBalance), DataEntry(IsRebalanceKey, if ((reserveWithoutLeasing >= convertNeutrinoToWaves(newLockedBalance, currentPrice))) | |
310 | + | then false | |
311 | + | else true)]) | |
312 | + | } | |
494 | 313 | } | |
495 | 314 | ||
496 | 315 | ||
497 | 316 | ||
498 | 317 | @Callable(i) | |
499 | - | func withdraw (account) = if ((getUnlockBalanceBlock(account) > height)) | |
500 | - | then throw("wait a couple of blocks for withdraw") | |
501 | - | else ScriptResult(WriteSet([DataEntry(getWavesBalanceKey(account), 0), DataEntry(getNeutrinoBalanceKey(account), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(account), getNeutrinoBalance(account), neutrinoAssetId), ScriptTransfer(addressFromStringValue(account), getWavesBalance(account), unit)])) | |
502 | - | ||
503 | - | ||
504 | - | ||
505 | - | @Callable(i) | |
506 | - | func generateBond () = { | |
507 | - | let deficit = (neutrinoSupply - convertWavesToNeutrino(reserve)) | |
508 | - | let balanceAuction = assetBalance(addressFromStringValue(auctionContract), bondAssetId) | |
509 | - | let amount = (convertNeutrinoToBond(deficit) - balanceAuction) | |
318 | + | func withdraw (account,index,lockedAssetId) = { | |
319 | + | let unlockHeight = getUnlockBalanceBlock(account) | |
320 | + | let lockedBalance = getAccountLockedBalance(account, lockedAssetId) | |
321 | + | let indexHeight = getHeightPriceByIndex(index) | |
322 | + | let nextIndexHeight = getHeightPriceByIndex((index + 1)) | |
323 | + | let priceByIndex = getPriceHistory(indexHeight) | |
324 | + | let amount = if ((lockedAssetId == neutrinoAssetIdString)) | |
325 | + | then convertNeutrinoToWaves(lockedBalance, priceByIndex) | |
326 | + | else convertWavesToNeutrino(lockedBalance, priceByIndex) | |
510 | 327 | if (isBlocked) | |
511 | - | then throw("contract is blocked") | |
512 | - | else if ((amount > 0)) | |
513 | - | then TransferSet([ScriptTransfer(addressFromStringValue(auctionContract), amount, bondAssetId)]) | |
514 | - | else throw("bond were generated or do not need it") | |
328 | + | then throw("contract is blocked by EMERGENCY SHUTDOWN actions untill reactivation by emergency oracles") | |
329 | + | else if ((0 >= amount)) | |
330 | + | then throw((("balance equals zero (" + lockedAssetId) + ")")) | |
331 | + | else if ((unlockHeight > height)) | |
332 | + | then throw((("please wait for: " + toString(unlockHeight)) + " block height to withdraw WAVES funds")) | |
333 | + | else if (if (if ((index > priceIndex)) | |
334 | + | then true | |
335 | + | else (indexHeight > unlockHeight)) | |
336 | + | then true | |
337 | + | else if ((nextIndexHeight != 0)) | |
338 | + | then (unlockHeight >= nextIndexHeight) | |
339 | + | else false) | |
340 | + | then throw("invalid price history index") | |
341 | + | else ScriptResult(WriteSet([DataEntry(getAccountLockedBalanceKey(account, lockedAssetId), 0), DataEntry(getLockedBalanceKey(lockedAssetId), (getLockedBalance(lockedAssetId) - lockedBalance))]), TransferSet([ScriptTransfer(addressFromStringValue(account), amount, if ((lockedAssetId == neutrinoAssetIdString)) | |
342 | + | then unit | |
343 | + | else neutrinoAssetId)])) | |
515 | 344 | } | |
516 | 345 | ||
517 | 346 | ||
518 | 347 | ||
519 | 348 | @Callable(i) | |
520 | - | func setOrder () = { | |
521 | - | let pmt = extract(i.payment) | |
522 | - | let newOrderId = toBase58String(keccak256(((toBytes(pmt.amount) + i.caller.bytes) + toBytes(height)))) | |
523 | - | if ((pmt.assetId != bondAssetId)) | |
524 | - | then throw("can use bond only") | |
525 | - | else if ((getOrderOwner(newOrderId) != "")) | |
526 | - | then throw("order exists") | |
527 | - | else WriteSet([DataEntry(OrderbookKey, addOrder(newOrderId)), DataEntry(getOrderTotalKey(newOrderId), pmt.amount), DataEntry(getOrderOwnerKey(newOrderId), toString(i.caller)), DataEntry(getOrderHeightKey(newOrderId), height), DataEntry(getOrderStatusKey(newOrderId), NEW)]) | |
528 | - | } | |
529 | - | ||
530 | - | ||
531 | - | ||
532 | - | @Callable(i) | |
533 | - | func cancelOrder (orderId) = { | |
534 | - | let owner = getOrderOwner(orderId) | |
535 | - | let amount = (getOrderTotal(orderId) - getOrderFilledTotal(orderId)) | |
536 | - | if ((owner != toString(i.caller))) | |
537 | - | then throw("permission denied") | |
538 | - | else ScriptResult(WriteSet([DataEntry(OrderbookKey, dropOrder(orderId)), DataEntry(getOrderStatusKey(orderId), CANCELED)]), TransferSet([ScriptTransfer(i.caller, amount, bondAssetId)])) | |
539 | - | } | |
540 | - | ||
541 | - | ||
542 | - | ||
543 | - | @Callable(i) | |
544 | - | func addLeasingCheck (id) = { | |
545 | - | let tx = value(transferTransactionById(fromBase58String(id))) | |
546 | - | if (if ((tx.recipient != addressFromStringValue(rpdContract))) | |
547 | - | then true | |
548 | - | else isLeasingProfitTxExist(id)) | |
549 | - | then throw("invalid transaction id") | |
550 | - | else { | |
551 | - | let amount = convertWavesToNeutrino(tx.amount) | |
552 | - | let newRpdSyncIndex = (rpdSyncIndex + 1) | |
553 | - | ScriptResult(WriteSet([DataEntry(RPDSyncIndexKey, newRpdSyncIndex), DataEntry(getRPDProfitKey(rpdSyncIndex), amount), DataEntry(getRPDSnapshotContractBalanceKey(rpdSyncIndex, neutrinoAssetId), getRPDContractBalance(neutrinoAssetId)), DataEntry(getRPDSnapshotContractBalanceKey(rpdSyncIndex, bondAssetId), getRPDContractBalance(bondAssetId)), DataEntry(getIsLeasingProfitTxExistKey(id), true)]), TransferSet([ScriptTransfer(addressFromStringValue(rpdContract), amount, neutrinoAssetId)])) | |
554 | - | } | |
555 | - | } | |
556 | - | ||
557 | - | ||
558 | - | ||
559 | - | @Callable(i) | |
560 | - | func executeOrder () = { | |
561 | - | let orderId = split(orderbook, LISTSPLITSYMBOL)[0] | |
562 | - | let orderTotal = getOrderTotal(orderId) | |
563 | - | let orderOwner = getOrderOwner(orderId) | |
564 | - | let filledTotal = getOrderFilledTotal(orderId) | |
349 | + | func transferToAuction () = { | |
350 | + | let deficitBondAmount = ((convertNeutrinoToBond(deficit) - assetBalance(addressFromStringValue(auctionContract), bondAssetId)) - totalLiquidationOrderbook) | |
351 | + | let surplusBond = ((convertNeutrinoToBond(surplus) - assetBalance(addressFromStringValue(auctionContract), neutrinoAssetId)) - totalOrderbook) | |
565 | 352 | if (isBlocked) | |
566 | - | then throw("contract is blocked") | |
567 | - | else if ((0 >= surplus)) | |
568 | - | then throw("surplus is less than zero") | |
569 | - | else if ((orderOwner == "")) | |
570 | - | then { | |
571 | - | let newRpdSyncIndex = (rpdSyncIndex + 1) | |
572 | - | ScriptResult(WriteSet([DataEntry(RPDSyncIndexKey, newRpdSyncIndex), DataEntry(getRPDProfitKey(rpdSyncIndex), surplus), DataEntry(getRPDSnapshotContractBalanceKey(rpdSyncIndex, neutrinoAssetId), getRPDContractBalance(neutrinoAssetId)), DataEntry(getRPDSnapshotContractBalanceKey(rpdSyncIndex, bondAssetId), getRPDContractBalance(bondAssetId))]), TransferSet([ScriptTransfer(addressFromStringValue(rpdContract), surplus, neutrinoAssetId)])) | |
573 | - | } | |
574 | - | else { | |
575 | - | let amount = (orderTotal - filledTotal) | |
576 | - | let surplusBond = convertNeutrinoToBond(surplus) | |
577 | - | let status = if ((surplusBond >= amount)) | |
578 | - | then FILLED | |
579 | - | else NEW | |
580 | - | let newFilledTotal = if ((surplusBond >= amount)) | |
581 | - | then orderTotal | |
582 | - | else surplusBond | |
583 | - | ScriptResult(WriteSet([DataEntry(OrderbookKey, dropOrder(orderId)), DataEntry(getOrderFilledTotalKey(orderId), (filledTotal + newFilledTotal)), DataEntry(getOrderStatusKey(orderId), status)]), TransferSet([ScriptTransfer(addressFromStringValue(orderOwner), convertBondToNeutrino(newFilledTotal), neutrinoAssetId)])) | |
584 | - | } | |
353 | + | then throw("contract is blocked by EMERGENCY SHUTDOWN actions untill reactivation by emergency oracles") | |
354 | + | else if ((deficitBondAmount >= ((neutrinoSupply * DEFICITOFFSET) / 100))) | |
355 | + | then TransferSet([ScriptTransfer(addressFromStringValue(auctionContract), deficitBondAmount, bondAssetId)]) | |
356 | + | else if ((surplusBond > 0)) | |
357 | + | then TransferSet([ScriptTransfer(addressFromStringValue(liquidationContract), convertBondToNeutrino(surplusBond), neutrinoAssetId)]) | |
358 | + | else throw("bond were generated or do not need it") | |
585 | 359 | } | |
586 | 360 | ||
587 | 361 | ||
588 | 362 | ||
589 | 363 | @Callable(i) | |
590 | 364 | func transfer (account) = { | |
591 | 365 | let pmt = extract(i.payment) | |
592 | - | if (isDefined(pmt.assetId)) | |
593 | - | then throw("can use waves only at the moment") | |
594 | - | else TransferSet([ScriptTransfer(addressFromStringValue(account), pmt.amount, unit)]) | |
366 | + | TransferSet([ScriptTransfer(addressFromStringValue(account), pmt.amount, pmt.assetId)]) | |
367 | + | } | |
368 | + | ||
369 | + | ||
370 | + | ||
371 | + | @Callable(i) | |
372 | + | func nodeReward () = { | |
373 | + | let pmt = value(i.payment) | |
374 | + | if ((i.caller != addressFromStringValue(nodeAddress))) | |
375 | + | then throw("only node account is able to transfer staking rewards from main account") | |
376 | + | else if (isDefined(pmt.assetId)) | |
377 | + | then throw("waves tokens only allowed") | |
378 | + | else { | |
379 | + | let amount = convertWavesToNeutrino(pmt.amount, currentPrice) | |
380 | + | let newRpdSyncIndex = (rpdSyncIndex + 1) | |
381 | + | ScriptResult(WriteSet([DataEntry(RPDSyncIndexKey, newRpdSyncIndex), DataEntry(getRPDProfitKey(rpdSyncIndex), amount), DataEntry(getRPDSnapshotContractBalanceKey(rpdSyncIndex, neutrinoAssetId), getRPDContractBalance(neutrinoAssetId))]), TransferSet([ScriptTransfer(addressFromStringValue(rpdContract), amount, neutrinoAssetId)])) | |
382 | + | } | |
383 | + | } | |
384 | + | ||
385 | + | ||
386 | + | ||
387 | + | @Callable(i) | |
388 | + | func registrationLeaseTx (senderPublicKey,fee,timestamp,leaseTxHash) = { | |
389 | + | let totalFreeReserve = (((reserve * LEASINGSHARE) / 100) - convertNeutrinoToWaves(getLockedBalance(neutrinoAssetIdString), currentPrice)) | |
390 | + | let amount = (totalFreeReserve / LEASINTXCOUNT) | |
391 | + | let txBytes = (((((base58'3h1H' + fromBase58String(senderPublicKey)) + fromBase58String(nodeAddress)) + toBytes(amount)) + toBytes(fee)) + toBytes(timestamp)) | |
392 | + | let txHashBytes = blake2b256(txBytes) | |
393 | + | let txHash = toBase58String(txHashBytes) | |
394 | + | let pmt = extract(i.payment) | |
395 | + | if ((toString(i.caller) == nodeOracleProviderKey)) | |
396 | + | then throw("invalid caller") | |
397 | + | else if (isDefined(pmt.assetId)) | |
398 | + | then throw("invalid paymtn asset") | |
399 | + | else if ((leaseTxHash != txHash)) | |
400 | + | then throw((("invalid tx hash(amount:" + toString(amount)) + ")")) | |
401 | + | else if ((leasingTxCount >= LEASINTXCOUNT)) | |
402 | + | then throw("the number of leasing transactions is equal to the maximum") | |
403 | + | else if ((this != addressFromPublicKey(fromBase58String(senderPublicKey)))) | |
404 | + | then throw("invalid pubKey") | |
405 | + | else if (if ((lastBlock.timestamp > timestamp)) | |
406 | + | then true | |
407 | + | else (timestamp > (lastBlock.timestamp + 5400000))) | |
408 | + | then throw((("invalid timestamp(lastBlock: " + toString(lastBlock.timestamp)) + ")")) | |
409 | + | else if ((getLeaseTxStatus(txHash) != "")) | |
410 | + | then throw("tx is exist") | |
411 | + | else if ((pmt.amount != (fee * 2))) | |
412 | + | then throw("invalid payment amount") | |
413 | + | else if (if ((fee > 1000000)) | |
414 | + | then true | |
415 | + | else (500000 > fee)) | |
416 | + | then throw("invalid fee") | |
417 | + | else if (((totalFreeReserve - (leasingAmount + amount)) > reserveWithoutLeasing)) | |
418 | + | then throw((("invalid amount(result:" + toString(((totalFreeReserve - (leasingAmount + amount)) > reserveWithoutLeasing))) + ")")) | |
419 | + | else WriteSet([DataEntry(getCancelLeaseTxReserveFeeKey(txHash), fee), DataEntry(LeasingTxCountKey, if ((getLeaseTxStatus(txHash) == "")) | |
420 | + | then (leasingTxCount + 1) | |
421 | + | else leasingTxCount), DataEntry(LeasingAmountKey, (leasingAmount + amount)), DataEntry(LeasingExpireBlockKey, if ((height > leasingExpireBlock)) | |
422 | + | then (height + leasingInterval) | |
423 | + | else leasingExpireBlock), DataEntry(getLeaseTxStatusKey(txHash), NEW), DataEntry(getLeaseTxExpireSendBlockKey(txHash), (height + SENDTXEXPIRE)), DataEntry(getLeaseTxAmountByHashKey(txHash), amount), DataEntry(getLeaseTxBytesByHashKey(txHash), toBase64String(txBytes))]) | |
424 | + | } | |
425 | + | ||
426 | + | ||
427 | + | ||
428 | + | @Callable(i) | |
429 | + | func cancelStuckLeaseTx (txHash) = if (if (if ((getLeaseTxStatus(txHash) == NEW)) | |
430 | + | then !(isDefined(transactionHeightById(fromBase58String(txHash)))) | |
431 | + | else false) | |
432 | + | then (height > getLeaseTxExpireSendBlock(txHash)) | |
433 | + | else false) | |
434 | + | then { | |
435 | + | let amount = getLeaseTxAmountByHash(txHash) | |
436 | + | WriteSet([DataEntry(LeasingTxCountKey, (leasingTxCount - 1)), DataEntry(LeasingAmountKey, (leasingAmount - amount)), DataEntry(getLeaseTxStatusKey(txHash), CANCELED), DataEntry(IsRebalanceKey, if (((reserveWithoutLeasing - amount) >= convertNeutrinoToWaves(getLockedBalance(neutrinoAssetIdString), currentPrice))) | |
437 | + | then false | |
438 | + | else true)]) | |
439 | + | } | |
440 | + | else throw("invalid tx hash") | |
441 | + | ||
442 | + | ||
443 | + | ||
444 | + | @Callable(i) | |
445 | + | func registrationUnleaseTx (chainIdString,senderPublicKey,fee,timestamp,leaseTxHash) = { | |
446 | + | let txBytes = (((((base58'gm' + toBytes(chainIdString)) + fromBase58String(senderPublicKey)) + toBytes(fee)) + toBytes(timestamp)) + fromBase58String(leaseTxHash)) | |
447 | + | let txHash = blake2b256(txBytes) | |
448 | + | if ((getLeaseTxStatus(leaseTxHash) != NEW)) | |
449 | + | then throw("invalid tx status") | |
450 | + | else if ((this != addressFromPublicKey(fromBase58String(senderPublicKey)))) | |
451 | + | then throw("invalid pubKey") | |
452 | + | else if (!(isDefined(transactionHeightById(txHash)))) | |
453 | + | then throw("blockchain does not contain this transaction") | |
454 | + | else { | |
455 | + | let amount = getLeaseTxAmountByHash(leaseTxHash) | |
456 | + | WriteSet([DataEntry(LeasingTxCountKey, (leasingTxCount - 1)), DataEntry(LeasingAmountKey, (leasingAmount - amount)), DataEntry(getLeaseTxStatusKey(leaseTxHash), CANCELED), DataEntry(IsRebalanceKey, if (((reserveWithoutLeasing - amount) >= convertNeutrinoToWaves(getLockedBalance(neutrinoAssetIdString), currentPrice))) | |
457 | + | then false | |
458 | + | else true)]) | |
459 | + | } | |
595 | 460 | } | |
596 | 461 | ||
597 | 462 | ||
598 | 463 | @Verifier(tx) | |
599 | - | func verify () = match tx { | |
600 | - | case leaseTx: LeaseTransaction => | |
601 | - | sigVerify(tx.bodyBytes, tx.proofs[0], fromBase58String(getOwnerPubKeyByLeaseTxId(toBase58String(leaseTx.id)))) | |
602 | - | case unleaseTx: LeaseCancelTransaction => | |
603 | - | sigVerify(tx.bodyBytes, tx.proofs[0], fromBase58String(getOwnerPubKeyByLeaseTxId(toBase58String(unleaseTx.leaseId)))) | |
604 | - | case _ => | |
605 | - | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
606 | - | } | |
464 | + | func verify () = { | |
465 | + | let id = toBase58String(tx.id) | |
466 | + | match tx { | |
467 | + | case leaseTx: LeaseTransaction => | |
468 | + | if (if ((leasingExpireBlock >= height)) | |
469 | + | then (getLeaseTxExpireSendBlock(id) >= height) | |
470 | + | else false) | |
471 | + | then (getLeaseTxStatus(id) == NEW) | |
472 | + | else false | |
473 | + | case unleaseTx: LeaseCancelTransaction => | |
474 | + | let leaseId = toBase58String(unleaseTx.leaseId) | |
475 | + | if (if (if ((height > leasingExpireBlock)) | |
476 | + | then true | |
477 | + | else isRebalance) | |
478 | + | then (unleaseTx.fee == getCancelLeaseTxReserveFee(leaseId)) | |
479 | + | else false) | |
480 | + | then (getLeaseTxStatus(leaseId) == NEW) | |
481 | + | else false | |
482 | + | case _ => | |
483 | + | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
484 | + | } | |
485 | + | } | |
607 | 486 |
github/deemru/w8io/026f985 230.26 ms ◑