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