tx · Cy4Kj1yjdTyQiMNAWSB2WURe94KyBFh9dsqjinK1kipc 3NA9tVHj5Vzj8azGiMsqGDGnyQRz6urrEP6: -0.01000000 Waves 2020.03.04 14:00 [894155] smart account 3NA9tVHj5Vzj8azGiMsqGDGnyQRz6urrEP6 > SELF 0.00000000 Waves
{ "type": 13, "id": "Cy4Kj1yjdTyQiMNAWSB2WURe94KyBFh9dsqjinK1kipc", "fee": 1000000, "feeAssetId": null, "timestamp": 1583319645102, "version": 1, "sender": "3NA9tVHj5Vzj8azGiMsqGDGnyQRz6urrEP6", "senderPublicKey": "GPoGENweTgzJ4eZPXgLmkJPckGYVThKGU9pF2j8txBNc", "proofs": [ "5SnNSDEStLZAQZxaGJVW3XzV9WAvuHsMzcJa4SZkFNHeL6URxFM1pmoSJuTVGLdZQEDJe4dQn3LFD3hAVLRdVtLj" ], "script": "base64:AAIDAAAAAAAAAA8IARIECgIBCBIDCgEIEgAAAAA5AQAAAA5nZXROdW1iZXJCeUtleQAAAAEAAAADa2V5BAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAAAQAAAA5nZXRTdHJpbmdCeUtleQAAAAEAAAADa2V5BAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAgAAAAABAAAAFmdldEJvb2xCeUFkZHJlc3NBbmRLZXkAAAACAAAAB2FkZHJlc3MAAAADa2V5BAAAAAckbWF0Y2gwCQAEGwAAAAIFAAAAB2FkZHJlc3MFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAHQm9vbGVhbgQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQcBAAAAGGdldFN0cmluZ0J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yZWQFAAAABHVuaXQFAAAAA25pbAAAAABSHl0X", "chainId": 84, "height": 894155, "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 3 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | func getNumberByKey (key) = match getInteger(this, key) { | |
5 | + | case a: Int => | |
6 | + | a | |
7 | + | case _ => | |
8 | + | 0 | |
9 | + | } | |
10 | + | ||
11 | + | ||
12 | + | func getStringByKey (key) = match getString(this, key) { | |
13 | + | case a: String => | |
14 | + | a | |
15 | + | case _ => | |
16 | + | "" | |
17 | + | } | |
18 | + | ||
19 | + | ||
20 | + | func getBoolByAddressAndKey (address,key) = match getBoolean(address, key) { | |
21 | + | case a: Boolean => | |
22 | + | a | |
23 | + | case _ => | |
24 | + | false | |
25 | + | } | |
26 | + | ||
27 | + | ||
28 | + | func getStringByAddressAndKey (address,key) = match getString(address, key) { | |
29 | + | case a: String => | |
30 | + | a | |
31 | + | case _ => | |
32 | + | "" | |
33 | + | } | |
34 | + | ||
35 | + | ||
36 | + | func getNumberByAddressAndKey (address,key) = match getInteger(address, key) { | |
37 | + | case a: Int => | |
38 | + | a | |
39 | + | case _ => | |
40 | + | 0 | |
41 | + | } | |
42 | + | ||
43 | + | ||
44 | + | let WAVELET = 100000000 | |
45 | + | ||
46 | + | let PAULI = 1000000 | |
47 | + | ||
48 | + | let PERCENTACCURACY = 1000 | |
49 | + | ||
50 | + | let MINORDERTOTAL = (10 * WAVELET) | |
51 | + | ||
52 | + | let MAXROI = 100 | |
53 | + | ||
54 | + | let CANCELED = "canceled" | |
55 | + | ||
56 | + | let NEW = "new" | |
57 | + | ||
58 | + | let FILLED = "filled" | |
59 | + | ||
60 | + | let NeutrinoContractKey = "neutrino_contract" | |
61 | + | ||
62 | + | let PriceKey = "price" | |
63 | + | ||
64 | + | let BondAssetIdKey = "bond_asset_id" | |
65 | + | ||
66 | + | let NeutrinoAssetIdKey = "neutrino_asset_id" | |
67 | + | ||
68 | + | let ControlContractKey = "control_contract" | |
69 | + | ||
70 | + | let BalanceLockedkKey = "balance_lock_" | |
71 | + | ||
72 | + | let WavesLockedBalanceKey = (BalanceLockedkKey + "waves") | |
73 | + | ||
74 | + | let NeutrinoLockedBalanceKey = (BalanceLockedkKey + "neutrino") | |
75 | + | ||
76 | + | let LiquidationContractKey = "liquidation_contract" | |
77 | + | ||
78 | + | let FirstOrderKey = "order_first" | |
79 | + | ||
80 | + | func getRoiByOrderIdKey (orderId) = ("debug_order_roi_" + orderId) | |
81 | + | ||
82 | + | ||
83 | + | func getOrderPriceKey (orderId) = ("order_price_" + orderId) | |
84 | + | ||
85 | + | ||
86 | + | func getOrderTotalKey (orderId) = ("order_total_" + orderId) | |
87 | + | ||
88 | + | ||
89 | + | func getOrderOwnerKey (orderId) = ("order_owner_" + orderId) | |
90 | + | ||
91 | + | ||
92 | + | func getOrderHeightKey (orderId) = ("order_height_" + orderId) | |
93 | + | ||
94 | + | ||
95 | + | func getOrderStatusKey (orderId) = ("order_status_" + orderId) | |
96 | + | ||
97 | + | ||
98 | + | func getOrderFilledTotalKey (orderId) = ("order_filled_total_" + orderId) | |
99 | + | ||
100 | + | ||
101 | + | func getPrevOrderKey (orderId) = ("order_prev_" + orderId) | |
102 | + | ||
103 | + | ||
104 | + | func getNextOrderKey (orderId) = ("order_next_" + orderId) | |
105 | + | ||
106 | + | ||
107 | + | func convertNeutrinoToWaves (amount,price) = fraction(fraction(amount, 100, price), WAVELET, PAULI) | |
108 | + | ||
109 | + | ||
110 | + | func convertWavesToNeutrino (amount,price) = fraction(fraction(amount, price, 100), PAULI, WAVELET) | |
111 | + | ||
112 | + | ||
113 | + | func convertNeutrinoToBond (amount) = (amount / PAULI) | |
114 | + | ||
115 | + | ||
116 | + | func convertBondToNeutrino (amount) = (amount * PAULI) | |
117 | + | ||
118 | + | ||
119 | + | func convertWavesToBond (amount,price) = convertNeutrinoToBond(convertWavesToNeutrino(amount, price)) | |
120 | + | ||
121 | + | ||
122 | + | func convertBondToWaves (amount,price) = convertNeutrinoToWaves(convertBondToNeutrino(amount), price) | |
123 | + | ||
124 | + | ||
125 | + | let neutrinoContract = addressFromStringValue("3PC9BfRwJWWiw9AREE2B3eWzCks3CYtg4yo") | |
126 | + | ||
127 | + | let controlContract = addressFromStringValue("3P5Bfd58PPfNvBM2Hy8QfbcDqMeNtzg7KfP") | |
128 | + | ||
129 | + | let liquidationContract = addressFromStringValue("3P4PCxsJqMzQBALo8zANHtBDZRRquobHQp7") | |
130 | + | ||
131 | + | let neutrinoAssetId = fromBase58String("DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p") | |
132 | + | ||
133 | + | let bondAssetId = fromBase58String("975akZBfnMj513U7MZaHKzQrmsEx5aE3wdWKTrHBhbjF") | |
134 | + | ||
135 | + | let isBlocked = getBoolByAddressAndKey(controlContract, "is_blocked") | |
136 | + | ||
137 | + | let currentPrice = getNumberByAddressAndKey(controlContract, PriceKey) | |
138 | + | ||
139 | + | let neutrinoLockedBalance = getNumberByAddressAndKey(neutrinoContract, NeutrinoLockedBalanceKey) | |
140 | + | ||
141 | + | let reserve = (wavesBalance(neutrinoContract) - getNumberByAddressAndKey(neutrinoContract, WavesLockedBalanceKey)) | |
142 | + | ||
143 | + | let neutrinoSupply = (((neutrinoLockedBalance + extract(assetInfo(neutrinoAssetId)).quantity) - assetBalance(neutrinoContract, neutrinoAssetId)) - assetBalance(liquidationContract, neutrinoAssetId)) | |
144 | + | ||
145 | + | let deficit = (neutrinoSupply - convertWavesToNeutrino(reserve, currentPrice)) | |
146 | + | ||
147 | + | let firstOrder = getStringByKey(FirstOrderKey) | |
148 | + | ||
149 | + | func getOrderPrice (id) = getNumberByKey(getOrderPriceKey(id)) | |
150 | + | ||
151 | + | ||
152 | + | func getOrderTotal (id) = getNumberByKey(getOrderTotalKey(id)) | |
153 | + | ||
154 | + | ||
155 | + | func getOrderOwner (id) = getStringByKey(getOrderOwnerKey(id)) | |
156 | + | ||
157 | + | ||
158 | + | func getOrderStatus (id) = getStringByKey(getOrderStatusKey(id)) | |
159 | + | ||
160 | + | ||
161 | + | func getOrderFilledTotal (id) = getNumberByKey(getOrderFilledTotalKey(id)) | |
162 | + | ||
163 | + | ||
164 | + | func getPrevOrder (id) = getStringByKey(getPrevOrderKey(id)) | |
165 | + | ||
166 | + | ||
167 | + | func getNextOrder (id) = getStringByKey(getNextOrderKey(id)) | |
168 | + | ||
169 | + | ||
170 | + | @Callable(i) | |
171 | + | func addBuyBondOrder (price,prevOrder) = { | |
172 | + | let pmt = extract(i.payment) | |
173 | + | let orderId = toBase58String(keccak256(((((toBytes(price) + toBytes(pmt.amount)) + i.caller.bytes) + toBytes(height)) + i.transactionId))) | |
174 | + | let priceWavesByBondCents = fraction(100, 100, price) | |
175 | + | let roi = fraction((priceWavesByBondCents - currentPrice), 100, currentPrice) | |
176 | + | if (isBlocked) | |
177 | + | then throw("contract is blocked by EMERGENCY SHUTDOWN actions untill reactivation by emergency oracles") | |
178 | + | else if ((0 >= deficit)) | |
179 | + | then throw("there is no ability to add order during proficit") | |
180 | + | else if ((MINORDERTOTAL > pmt.amount)) | |
181 | + | then throw(("min order total equals " + toString(MINORDERTOTAL))) | |
182 | + | else if ((roi > MAXROI)) | |
183 | + | then throw("max setOrder ROI is 100%") | |
184 | + | else if ((0 >= roi)) | |
185 | + | then throw("min setOrder ROI is more than 0%") | |
186 | + | else if (isDefined(pmt.assetId)) | |
187 | + | then throw("can use waves only") | |
188 | + | else if ((0 >= price)) | |
189 | + | then throw("price less zero") | |
190 | + | else if ((getOrderOwner(orderId) != "")) | |
191 | + | then throw("order exists") | |
192 | + | else if (if ((prevOrder != "")) | |
193 | + | then (getOrderStatus(prevOrder) != NEW) | |
194 | + | else false) | |
195 | + | then throw("prev order status is not new") | |
196 | + | else { | |
197 | + | let owner = toString(i.caller) | |
198 | + | let nextOrder = if ((prevOrder == "")) | |
199 | + | then firstOrder | |
200 | + | else getNextOrder(prevOrder) | |
201 | + | let nextOrderRoi = getNumberByKey(getRoiByOrderIdKey(nextOrder)) | |
202 | + | let isNextOrderError = if (if ((nextOrder != "")) | |
203 | + | then (roi >= nextOrderRoi) | |
204 | + | else false) | |
205 | + | then true | |
206 | + | else false | |
207 | + | let prevOrderRoi = getNumberByKey(getRoiByOrderIdKey(prevOrder)) | |
208 | + | let isPrevOrderError = if (if ((prevOrder != "")) | |
209 | + | then (prevOrderRoi > roi) | |
210 | + | else false) | |
211 | + | then true | |
212 | + | else false | |
213 | + | if (if (isNextOrderError) | |
214 | + | then true | |
215 | + | else isPrevOrderError) | |
216 | + | then throw(((("invalid order isPrevOrderError:" + toString(isPrevOrderError)) + " isNextOrderError:") + toString(isNextOrderError))) | |
217 | + | else WriteSet([DataEntry(getPrevOrderKey(orderId), prevOrder), DataEntry(getNextOrderKey(orderId), nextOrder), DataEntry(getNextOrderKey(prevOrder), if ((prevOrder == "")) | |
218 | + | then "" | |
219 | + | else orderId), DataEntry(getPrevOrderKey(nextOrder), if ((nextOrder == "")) | |
220 | + | then "" | |
221 | + | else orderId), DataEntry(FirstOrderKey, if (if ((firstOrder == "")) | |
222 | + | then true | |
223 | + | else (firstOrder == nextOrder)) | |
224 | + | then orderId | |
225 | + | else firstOrder), DataEntry(getOrderPriceKey(orderId), price), DataEntry(getOrderTotalKey(orderId), pmt.amount), DataEntry(getOrderOwnerKey(orderId), owner), DataEntry(getOrderHeightKey(orderId), height), DataEntry(getOrderStatusKey(orderId), NEW), DataEntry(("debug_order_currentPrice_" + orderId), currentPrice), DataEntry(getRoiByOrderIdKey(orderId), roi)]) | |
226 | + | } | |
227 | + | } | |
228 | + | ||
229 | + | ||
230 | + | ||
231 | + | @Callable(i) | |
232 | + | func cancelOrder (orderId) = { | |
233 | + | let owner = getOrderOwner(orderId) | |
234 | + | let amount = (getOrderTotal(orderId) - getOrderFilledTotal(orderId)) | |
235 | + | let caller = toString(i.caller) | |
236 | + | let nextOrder = getNextOrder(orderId) | |
237 | + | let prevOrder = getPrevOrder(orderId) | |
238 | + | if (isBlocked) | |
239 | + | then throw("contract is blocked by EMERGENCY SHUTDOWN actions untill reactivation by emergency oracles") | |
240 | + | else if ((owner != caller)) | |
241 | + | then throw("permission denied") | |
242 | + | else if ((getOrderStatus(orderId) != NEW)) | |
243 | + | then throw("invalid order status") | |
244 | + | else ScriptResult(WriteSet([DataEntry(FirstOrderKey, if ((firstOrder == orderId)) | |
245 | + | then nextOrder | |
246 | + | else firstOrder), DataEntry(getNextOrderKey(prevOrder), nextOrder), DataEntry(getPrevOrderKey(nextOrder), prevOrder), DataEntry(getOrderStatusKey(orderId), CANCELED)]), TransferSet([ScriptTransfer(i.caller, amount, unit)])) | |
247 | + | } | |
248 | + | ||
249 | + | ||
250 | + | ||
251 | + | @Callable(i) | |
252 | + | func sellBond () = { | |
253 | + | let bondBalance = assetBalance(this, bondAssetId) | |
254 | + | let deficitPositive = if ((0 >= deficit)) | |
255 | + | then 0 | |
256 | + | else (deficit / PAULI) | |
257 | + | let bondAmount = if ((deficitPositive >= bondBalance)) | |
258 | + | then bondBalance | |
259 | + | else deficitPositive | |
260 | + | let returnAmount = if ((deficitPositive >= bondBalance)) | |
261 | + | then 0 | |
262 | + | else (bondBalance - deficitPositive) | |
263 | + | if (if ((deficitPositive == 0)) | |
264 | + | then (bondBalance == 0) | |
265 | + | else false) | |
266 | + | then throw("without deficit") | |
267 | + | else if ((bondBalance == 0)) | |
268 | + | then throw("without bonds to sell") | |
269 | + | else if ((returnAmount > 0)) | |
270 | + | then TransferSet([ScriptTransfer(neutrinoContract, returnAmount, bondAssetId)]) | |
271 | + | else if ((firstOrder == "")) | |
272 | + | then throw("empty orderbook") | |
273 | + | else { | |
274 | + | let nextOrder = getNextOrder(firstOrder) | |
275 | + | let filledTotal = getOrderFilledTotal(firstOrder) | |
276 | + | let orderPrice = getOrderPrice(firstOrder) | |
277 | + | let priceWavesByBondCents = fraction(100, 100, orderPrice) | |
278 | + | let roi = getNumberByKey(getRoiByOrderIdKey(firstOrder)) | |
279 | + | let remainedTotal = (getOrderTotal(firstOrder) - filledTotal) | |
280 | + | let amountToExecuteOrder = convertWavesToBond(remainedTotal, priceWavesByBondCents) | |
281 | + | let fillOrderCondition = (bondAmount >= amountToExecuteOrder) | |
282 | + | let fillableOrderAmount = if (fillOrderCondition) | |
283 | + | then amountToExecuteOrder | |
284 | + | else bondAmount | |
285 | + | let totalOrderWaveletesRequired = convertBondToWaves(fillableOrderAmount, priceWavesByBondCents) | |
286 | + | if (if ((roi > fraction(deficit, 100, neutrinoSupply))) | |
287 | + | then true | |
288 | + | else (0 >= deficitPositive)) | |
289 | + | then throw(("deficit should be higther or equal than roi: " + toString(roi))) | |
290 | + | else if ((amountToExecuteOrder == 0)) | |
291 | + | then ScriptResult(WriteSet([DataEntry(FirstOrderKey, nextOrder), DataEntry(getPrevOrderKey(nextOrder), ""), DataEntry(FirstOrderKey, nextOrder), DataEntry(getOrderStatusKey(firstOrder), FILLED)]), TransferSet([ScriptTransfer(addressFromStringValue(getOrderOwner(firstOrder)), remainedTotal, unit)])) | |
292 | + | else if ((totalOrderWaveletesRequired == 0)) | |
293 | + | then throw("cannot fill order at the moment") | |
294 | + | else { | |
295 | + | let newStatus = if (if (fillOrderCondition) | |
296 | + | then (remainedTotal == 0) | |
297 | + | else false) | |
298 | + | then FILLED | |
299 | + | else NEW | |
300 | + | ScriptResult(WriteSet([DataEntry(getPrevOrderKey(nextOrder), if ((newStatus == FILLED)) | |
301 | + | then "" | |
302 | + | else firstOrder), DataEntry(FirstOrderKey, if ((newStatus == FILLED)) | |
303 | + | then nextOrder | |
304 | + | else firstOrder), DataEntry(getOrderFilledTotalKey(firstOrder), (filledTotal + totalOrderWaveletesRequired)), DataEntry(getOrderStatusKey(firstOrder), newStatus)]), TransferSet([ScriptTransfer(addressFromStringValue(getOrderOwner(firstOrder)), fillableOrderAmount, bondAssetId), ScriptTransfer(neutrinoContract, totalOrderWaveletesRequired, unit)])) | |
305 | + | } | |
306 | + | } | |
307 | + | } | |
308 | + | ||
309 | + |
github/deemru/w8io/169f3d6 24.36 ms ◑