tx · xNdrfhkYUJxGwz9JFF1EiwbWZSFHcNawLiTtRAqnhwM 3MrtHeXquGPcRd3YjJQHfY1Ss6oSDpfxGuL: -0.01400000 Waves 2019.09.18 10:30 [681397] smart account 3MrtHeXquGPcRd3YjJQHfY1Ss6oSDpfxGuL > SELF 0.00000000 Waves
{ "type": 13, "id": "xNdrfhkYUJxGwz9JFF1EiwbWZSFHcNawLiTtRAqnhwM", "fee": 1400000, "feeAssetId": null, "timestamp": 1568791802725, "version": 1, "sender": "3MrtHeXquGPcRd3YjJQHfY1Ss6oSDpfxGuL", "senderPublicKey": "3nmDHSgwcZ79tNbGjppGBY9MbYm4qLZEJcZ32D2WmxkG", "proofs": [ "FH9yQA5D2eNFTUd4WT2RVghfWWQuU4rW1qNVzjfTyzsPJMCqu1VnxLiKn3797SoP62NA9HS1QobZmKV4Ckv4vPu" ], "script": "base64:AAIDAAAAAAAAAAAAAABGAQAAAA5nZXROdW1iZXJCeUtleQAAAAEAAAADa2V5BAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAAAQAAAA5nZXRTdHJpbmdCeUtleQAAAAEAAAADa2V5BAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAgAAAAABAAAADGdldEJvb2xCeUtleQAAAAEAAAADa2V5BAAAAAckbWF0Y2gwCQAEGwAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAHQm9vbGVhbgQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQcBAAAAGGdldE51bWJlckJ5S2V5QW5kQWRkcmVzcwAAAAIAAAAHYWRkcmVzcwAAAANrZXkEAAAA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ycGx1c0JvbmQFAAAABmFtb3VudAUAAAAKb3JkZXJUb3RhbAUAAAALc3VycGx1c0JvbmQJAQAAAAxTY3JpcHRSZXN1bHQAAAACCQEAAAAIV3JpdGVTZXQAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACBQAAAAxPcmRlcmJvb2tLZXkJAAGRAAAAAgkABLUAAAACBQAAAAlvcmRlcmJvb2sJAAEsAAAAAgUAAAAHb3JkZXJJZAUAAAAPTGlzdFNwbGl0U3ltYm9sAAAAAAAAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQABLAAAAAIFAAAAE09yZGVyRmlsbGVkVG90YWxLZXkFAAAAB29yZGVySWQJAABkAAAAAgUAAAALZmlsbGVkVG90YWwFAAAADm5ld0ZpbGxlZFRvdGFsCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQABLAAAAAIFAAAADk9yZGVyU3RhdHVzS2V5BQAAAAdvcmRlcklkBQAAAAZzdGF0dXMFAAAAA25pbAkBAAAAC1RyYW5zZmVyU2V0AAAAAQkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCQEAAAAcQGV4dHJVc2VyKGFkZHJlc3NGcm9tU3RyaW5nKQAAAAEFAAAACm9yZGVyT3duZXIJAQAAABVjb252ZXJ0Qm9uZFRvTmV1dHJpbm8AAAABBQAAAA5uZXdGaWxsZWRUb3RhbAUAAAAPbmV1dHJpbm9Bc3NldElkBQAAAANuaWwAAAAA2JoVUQ==", "chainId": 84, "height": 681397, "spentComplexity": 0 } View: original | compacted Prev: 4LoBcYALToq4aumjUjYaUDK95DHvzLSnsS5SceTMUSrR Next: none Diff:
Old | New | Differences | |
---|---|---|---|
87 | 87 | ||
88 | 88 | let OrderHeightKey = "order_height_" | |
89 | 89 | ||
90 | - | let OrderbookTotalKey = "orderbook_total" | |
91 | - | ||
92 | - | let OrderbookTotalSnapshotKey = "orderbook_total_snapshot" | |
90 | + | let OrderFilledTotalKey = "order_filled_total_" | |
93 | 91 | ||
94 | 92 | let SnapshotBlockKey = "snapshot_block" | |
95 | 93 | ||
113 | 111 | ||
114 | 112 | let NodeProviderStatus = "node_status" | |
115 | 113 | ||
114 | + | let OrderStatusKey = "order_status_" | |
115 | + | ||
116 | 116 | let neutrinoAssetId = fromBase58String(getStringByKey(NeutrinoAssetIdKey)) | |
117 | 117 | ||
118 | 118 | let price = getNumberByKey(PriceKey) | |
124 | 124 | (info.quantity - assetBalance(this, neutrinoAssetId)) | |
125 | 125 | } | |
126 | 126 | ||
127 | - | let orderbookTotal = getNumberByKey(OrderbookTotalKey) | |
128 | - | ||
129 | 127 | let orderbook = getStringByKey(OrderbookKey) | |
130 | 128 | ||
131 | 129 | let snapshotBlock = getNumberByKey(SnapshotBlockKey) | |
133 | 131 | let lastBondGenerated = getNumberByKey(BondGeneratedBlockKey) | |
134 | 132 | ||
135 | 133 | let orderbookSnapshot = getStringByKey(OrderbookSnapshotKey) | |
136 | - | ||
137 | - | let orderbookTotalSnapshot = getNumberByKey(OrderbookTotalSnapshotKey) | |
138 | 134 | ||
139 | 135 | let bondAssetId = fromBase58String(getStringByKey(BondAssetIdKey)) | |
140 | 136 | ||
177 | 173 | func isSentNodeBalance (address,block) = getBoolByKey((((IsSentNodeBalanceKey + address) + ListSplitSymbol) + toString(block))) | |
178 | 174 | ||
179 | 175 | ||
176 | + | func getOrderFilledTotal (id) = getNumberByKey((OrderFilledTotalKey + id)) | |
177 | + | ||
178 | + | ||
180 | 179 | func convertNeutrinoToWaves (amount) = ((amount * 100) / price) | |
181 | 180 | ||
182 | 181 | ||
193 | 192 | ||
194 | 193 | ||
195 | 194 | let surplus = (convertWavesToNeutrino(reserve) - neutrinoSupply) | |
195 | + | ||
196 | + | let CANCELED = "canceled" | |
197 | + | ||
198 | + | let NEW = "new" | |
199 | + | ||
200 | + | let FILLED = "filled" | |
196 | 201 | ||
197 | 202 | @Callable(i) | |
198 | 203 | func setCurrentPrice (price) = WriteSet([DataEntry(PriceKey, price), DataEntry(((PriceKey + ListSplitSymbol) + toString(height)), price)]) | |
254 | 259 | then throw("can use bond only") | |
255 | 260 | else if ((getOrderOwner(newOrderId) != "")) | |
256 | 261 | then throw("order exists") | |
257 | - | else WriteSet([ | |
262 | + | else WriteSet([DataEntry(OrderbookKey, ((orderbook + newOrderId) + ListSplitSymbol)), DataEntry((OrderTotalKey + newOrderId), pmt.amount), DataEntry((OrderOwnerKey + newOrderId), toString(i.caller)), DataEntry((OrderHeightKey + newOrderId), height)]) | |
258 | 263 | } | |
259 | 264 | ||
260 | 265 | ||
262 | 267 | @Callable(i) | |
263 | 268 | func cancelOrder (orderId) = { | |
264 | 269 | let owner = getOrderOwner(orderId) | |
265 | - | let | |
270 | + | let amount = (getOrderTotal(orderId) - getOrderFilledTotal(orderId)) | |
266 | 271 | if ((owner != toString(i.caller))) | |
267 | 272 | then throw("permission denied") | |
268 | 273 | else { | |
269 | - | let newOrderBookOnePart = split(orderbook, (orderId + ListSplitSymbol))[0] | |
270 | - | let newOrderBookTwoPart = split(orderbook, (orderId + ListSplitSymbol))[1] | |
271 | - | ScriptResult(WriteSet([DataEntry(OrderbookTotalKey, (orderbookTotal - total)), DataEntry(OrderbookKey, (newOrderBookOnePart + newOrderBookTwoPart)), DataEntry((OrderTotalKey + orderId), 0)]), TransferSet([ScriptTransfer(i.caller, total, unit)])) | |
274 | + | let parts = split(orderbook, (orderId + ListSplitSymbol)) | |
275 | + | ScriptResult(WriteSet([DataEntry(OrderbookKey, (parts[0] + parts[1])), DataEntry((OrderStatusKey + orderId), CANCELED)]), TransferSet([ScriptTransfer(i.caller, amount, bondAssetId)])) | |
272 | 276 | } | |
273 | 277 | } | |
274 | 278 | ||
279 | 283 | let orderId = split(orderbook, ListSplitSymbol)[0] | |
280 | 284 | let orderTotal = getOrderTotal(orderId) | |
281 | 285 | let orderOwner = getOrderOwner(orderId) | |
286 | + | let filledTotal = getOrderFilledTotal(orderId) | |
282 | 287 | if ((0 >= surplus)) | |
283 | 288 | then throw("surplus is less than zero") | |
284 | 289 | else { | |
285 | - | let amount = convertBondToNeutrino((orderTotal - convertNeutrinoToBond(surplus))) | |
286 | - | ScriptResult(WriteSet([DataEntry(OrderbookTotalKey, (orderbookTotal - (if ((surplus >= orderTotal)) | |
290 | + | let amount = (orderTotal - filledTotal) | |
291 | + | let surplusBond = convertNeutrinoToBond(surplus) | |
292 | + | let status = if ((surplusBond >= amount)) | |
293 | + | then FILLED | |
294 | + | else NEW | |
295 | + | let newFilledTotal = if ((surplusBond >= amount)) | |
287 | 296 | then orderTotal | |
288 | - | else surplus))), DataEntry(OrderbookKey, split(orderbook, (orderId + ListSplitSymbol))[1]), DataEntry((OrderTotalKey + orderId), if ((0 >= amount)) | |
289 | - | then 0 | |
290 | - | else amount)]), TransferSet([ScriptTransfer(addressFromStringValue(orderOwner), if ((surplus >= orderTotal)) | |
291 | - | then convertBondToNeutrino(orderTotal) | |
292 | - | else surplus, neutrinoAssetId)])) | |
297 | + | else surplusBond | |
298 | + | ScriptResult(WriteSet([DataEntry(OrderbookKey, split(orderbook, (orderId + ListSplitSymbol))[1]), DataEntry((OrderFilledTotalKey + orderId), (filledTotal + newFilledTotal)), DataEntry((OrderStatusKey + orderId), status)]), TransferSet([ScriptTransfer(addressFromStringValue(orderOwner), convertBondToNeutrino(newFilledTotal), neutrinoAssetId)])) | |
293 | 299 | } | |
294 | 300 | } | |
295 | 301 |
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 getNumberByKeyAndAddress (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 getStringByKeyAndAddress (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 getBoolByKeyAndAddress (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 ListSplitSymbol = "_" | |
53 | 53 | ||
54 | 54 | let BalanceLockBlock = 0 | |
55 | 55 | ||
56 | 56 | let ListDataSplitSymbol = "+" | |
57 | 57 | ||
58 | 58 | let Wavelet = 100000000 | |
59 | 59 | ||
60 | 60 | let MinimalBondOrder = (10 * Wavelet) | |
61 | 61 | ||
62 | 62 | let MinimalSurplus = (10 * Wavelet) | |
63 | 63 | ||
64 | 64 | let ApplyBlockTimeout = 10 | |
65 | 65 | ||
66 | 66 | let LeaseContractKey = "lease_contract" | |
67 | 67 | ||
68 | 68 | let NeutrinoAssetIdKey = "neutrino_asset_id" | |
69 | 69 | ||
70 | 70 | let BondAssetIdKey = "bond_asset_id" | |
71 | 71 | ||
72 | 72 | let AuctionContractKey = "auction_contract" | |
73 | 73 | ||
74 | 74 | let PriceKey = "price" | |
75 | 75 | ||
76 | 76 | let NeutrinoBalanceKey = "neutrino_" | |
77 | 77 | ||
78 | 78 | let WavesBalanceKey = "waves_" | |
79 | 79 | ||
80 | 80 | let BalanceBlockKey = "balance_block_" | |
81 | 81 | ||
82 | 82 | let OrderbookKey = "orderbook" | |
83 | 83 | ||
84 | 84 | let OrderTotalKey = "order_total_" | |
85 | 85 | ||
86 | 86 | let OrderOwnerKey = "order_owner_" | |
87 | 87 | ||
88 | 88 | let OrderHeightKey = "order_height_" | |
89 | 89 | ||
90 | - | let OrderbookTotalKey = "orderbook_total" | |
91 | - | ||
92 | - | let OrderbookTotalSnapshotKey = "orderbook_total_snapshot" | |
90 | + | let OrderFilledTotalKey = "order_filled_total_" | |
93 | 91 | ||
94 | 92 | let SnapshotBlockKey = "snapshot_block" | |
95 | 93 | ||
96 | 94 | let OrderbookSnapshotKey = "orderbook_snapshot" | |
97 | 95 | ||
98 | 96 | let BondGeneratedBlockKey = "bond_generated_block" | |
99 | 97 | ||
100 | 98 | let AccountSnapshotBlockKey = "account_snapshot_block_" | |
101 | 99 | ||
102 | 100 | let AccountSnapshotOwnerKey = "account_snapshot_owner_" | |
103 | 101 | ||
104 | 102 | let AccountSnapshotAmountKey = "account_snapshot_amount_" | |
105 | 103 | ||
106 | 104 | let AccountSnapshotNodeKey = "account_snapshot_node_" | |
107 | 105 | ||
108 | 106 | let SnapshotNodeBalanceKey = "snapshot_node_balance_" | |
109 | 107 | ||
110 | 108 | let NodeBalanceKey = "node_balance_" | |
111 | 109 | ||
112 | 110 | let IsSentNodeBalanceKey = "is_sent_node_balance_" | |
113 | 111 | ||
114 | 112 | let NodeProviderStatus = "node_status" | |
115 | 113 | ||
114 | + | let OrderStatusKey = "order_status_" | |
115 | + | ||
116 | 116 | let neutrinoAssetId = fromBase58String(getStringByKey(NeutrinoAssetIdKey)) | |
117 | 117 | ||
118 | 118 | let price = getNumberByKey(PriceKey) | |
119 | 119 | ||
120 | 120 | let reserve = wavesBalance(this) | |
121 | 121 | ||
122 | 122 | let neutrinoSupply = { | |
123 | 123 | let info = extract(assetInfo(neutrinoAssetId)) | |
124 | 124 | (info.quantity - assetBalance(this, neutrinoAssetId)) | |
125 | 125 | } | |
126 | 126 | ||
127 | - | let orderbookTotal = getNumberByKey(OrderbookTotalKey) | |
128 | - | ||
129 | 127 | let orderbook = getStringByKey(OrderbookKey) | |
130 | 128 | ||
131 | 129 | let snapshotBlock = getNumberByKey(SnapshotBlockKey) | |
132 | 130 | ||
133 | 131 | let lastBondGenerated = getNumberByKey(BondGeneratedBlockKey) | |
134 | 132 | ||
135 | 133 | let orderbookSnapshot = getStringByKey(OrderbookSnapshotKey) | |
136 | - | ||
137 | - | let orderbookTotalSnapshot = getNumberByKey(OrderbookTotalSnapshotKey) | |
138 | 134 | ||
139 | 135 | let bondAssetId = fromBase58String(getStringByKey(BondAssetIdKey)) | |
140 | 136 | ||
141 | 137 | let auctionContract = getStringByKey(AuctionContractKey) | |
142 | 138 | ||
143 | 139 | let leaseContract = getStringByKey(LeaseContractKey) | |
144 | 140 | ||
145 | 141 | let bondSupply = { | |
146 | 142 | let info = extract(assetInfo(bondAssetId)) | |
147 | 143 | (info.quantity - assetBalance(this, bondAssetId)) | |
148 | 144 | } | |
149 | 145 | ||
150 | 146 | func getWavesBalance (owner) = getNumberByKey((WavesBalanceKey + owner)) | |
151 | 147 | ||
152 | 148 | ||
153 | 149 | func getNeutrinoBalance (owner) = getNumberByKey((NeutrinoBalanceKey + owner)) | |
154 | 150 | ||
155 | 151 | ||
156 | 152 | func getBalanceBlock (owner) = getNumberByKey((BalanceBlockKey + owner)) | |
157 | 153 | ||
158 | 154 | ||
159 | 155 | func getOrderTotal (id) = getNumberByKey((OrderTotalKey + id)) | |
160 | 156 | ||
161 | 157 | ||
162 | 158 | func getOrderOwner (id) = getStringByKey((OrderOwnerKey + id)) | |
163 | 159 | ||
164 | 160 | ||
165 | 161 | func getAccountSnapshotBlock (id) = getNumberByKey((AccountSnapshotBlockKey + id)) | |
166 | 162 | ||
167 | 163 | ||
168 | 164 | func getAccountSnapshotOwner (id) = getStringByKey((AccountSnapshotOwnerKey + id)) | |
169 | 165 | ||
170 | 166 | ||
171 | 167 | func getAccountSnapshotAmount (id) = getNumberByKey((AccountSnapshotAmountKey + id)) | |
172 | 168 | ||
173 | 169 | ||
174 | 170 | func getNodeBalance (address,block) = getNumberByKeyAndAddress(leaseContract, (((NodeBalanceKey + address) + ListSplitSymbol) + toString(block))) | |
175 | 171 | ||
176 | 172 | ||
177 | 173 | func isSentNodeBalance (address,block) = getBoolByKey((((IsSentNodeBalanceKey + address) + ListSplitSymbol) + toString(block))) | |
178 | 174 | ||
179 | 175 | ||
176 | + | func getOrderFilledTotal (id) = getNumberByKey((OrderFilledTotalKey + id)) | |
177 | + | ||
178 | + | ||
180 | 179 | func convertNeutrinoToWaves (amount) = ((amount * 100) / price) | |
181 | 180 | ||
182 | 181 | ||
183 | 182 | func convertWavesToNeutrino (amount) = ((amount * price) / 100) | |
184 | 183 | ||
185 | 184 | ||
186 | 185 | func convertNeutrinoToBond (amount) = (amount / Wavelet) | |
187 | 186 | ||
188 | 187 | ||
189 | 188 | func convertBondToNeutrino (amount) = (amount * Wavelet) | |
190 | 189 | ||
191 | 190 | ||
192 | 191 | func convertWavesToBond (amount) = convertNeutrinoToBond(convertWavesToNeutrino(amount)) | |
193 | 192 | ||
194 | 193 | ||
195 | 194 | let surplus = (convertWavesToNeutrino(reserve) - neutrinoSupply) | |
195 | + | ||
196 | + | let CANCELED = "canceled" | |
197 | + | ||
198 | + | let NEW = "new" | |
199 | + | ||
200 | + | let FILLED = "filled" | |
196 | 201 | ||
197 | 202 | @Callable(i) | |
198 | 203 | func setCurrentPrice (price) = WriteSet([DataEntry(PriceKey, price), DataEntry(((PriceKey + ListSplitSymbol) + toString(height)), price)]) | |
199 | 204 | ||
200 | 205 | ||
201 | 206 | ||
202 | 207 | @Callable(i) | |
203 | 208 | func swapWavesToNeutrino () = { | |
204 | 209 | let pmt = extract(i.payment) | |
205 | 210 | if (isDefined(pmt.assetId)) | |
206 | 211 | then throw("can use waves only") | |
207 | 212 | else { | |
208 | 213 | let account = toBase58String(i.caller.bytes) | |
209 | 214 | let amount = convertWavesToNeutrino(pmt.amount) | |
210 | 215 | WriteSet([DataEntry((NeutrinoBalanceKey + toString(i.caller)), (amount + getNeutrinoBalance(account))), DataEntry((BalanceBlockKey + toString(i.caller)), height)]) | |
211 | 216 | } | |
212 | 217 | } | |
213 | 218 | ||
214 | 219 | ||
215 | 220 | ||
216 | 221 | @Callable(i) | |
217 | 222 | func swapNeutrinoToWaves () = { | |
218 | 223 | let pmt = extract(i.payment) | |
219 | 224 | if ((pmt.assetId != neutrinoAssetId)) | |
220 | 225 | then throw("can use neutrino only") | |
221 | 226 | else { | |
222 | 227 | let account = toBase58String(i.caller.bytes) | |
223 | 228 | let amount = convertNeutrinoToWaves(pmt.amount) | |
224 | 229 | WriteSet([DataEntry((WavesBalanceKey + toString(i.caller)), (amount + getWavesBalance(account))), DataEntry((BalanceBlockKey + toString(i.caller)), height)]) | |
225 | 230 | } | |
226 | 231 | } | |
227 | 232 | ||
228 | 233 | ||
229 | 234 | ||
230 | 235 | @Callable(i) | |
231 | 236 | func withdraw (account) = if (((getBalanceBlock(account) + BalanceLockBlock) >= height)) | |
232 | 237 | then throw("wait a couple of blocks for withdraw") | |
233 | 238 | else ScriptResult(WriteSet([DataEntry((WavesBalanceKey + account), 0), DataEntry((NeutrinoBalanceKey + account), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(account), getNeutrinoBalance(account), neutrinoAssetId), ScriptTransfer(addressFromStringValue(account), getWavesBalance(account), unit)])) | |
234 | 239 | ||
235 | 240 | ||
236 | 241 | ||
237 | 242 | @Callable(i) | |
238 | 243 | func generateBond () = { | |
239 | 244 | let deficit = (neutrinoSupply - convertWavesToNeutrino(reserve)) | |
240 | 245 | let balanceAuction = assetBalance(addressFromStringValue(auctionContract), bondAssetId) | |
241 | 246 | let amount = (convertNeutrinoToBond(deficit) - balanceAuction) | |
242 | 247 | if ((amount > 0)) | |
243 | 248 | then TransferSet([ScriptTransfer(addressFromStringValue(auctionContract), amount, bondAssetId)]) | |
244 | 249 | else throw(("deficit did not reach the threshold. deficit =" + toString(deficit))) | |
245 | 250 | } | |
246 | 251 | ||
247 | 252 | ||
248 | 253 | ||
249 | 254 | @Callable(i) | |
250 | 255 | func setOrder () = { | |
251 | 256 | let pmt = extract(i.payment) | |
252 | 257 | let newOrderId = toBase58String(keccak256(((toBytes(pmt.amount) + i.caller.bytes) + toBytes(height)))) | |
253 | 258 | if ((pmt.assetId != bondAssetId)) | |
254 | 259 | then throw("can use bond only") | |
255 | 260 | else if ((getOrderOwner(newOrderId) != "")) | |
256 | 261 | then throw("order exists") | |
257 | - | else WriteSet([ | |
262 | + | else WriteSet([DataEntry(OrderbookKey, ((orderbook + newOrderId) + ListSplitSymbol)), DataEntry((OrderTotalKey + newOrderId), pmt.amount), DataEntry((OrderOwnerKey + newOrderId), toString(i.caller)), DataEntry((OrderHeightKey + newOrderId), height)]) | |
258 | 263 | } | |
259 | 264 | ||
260 | 265 | ||
261 | 266 | ||
262 | 267 | @Callable(i) | |
263 | 268 | func cancelOrder (orderId) = { | |
264 | 269 | let owner = getOrderOwner(orderId) | |
265 | - | let | |
270 | + | let amount = (getOrderTotal(orderId) - getOrderFilledTotal(orderId)) | |
266 | 271 | if ((owner != toString(i.caller))) | |
267 | 272 | then throw("permission denied") | |
268 | 273 | else { | |
269 | - | let newOrderBookOnePart = split(orderbook, (orderId + ListSplitSymbol))[0] | |
270 | - | let newOrderBookTwoPart = split(orderbook, (orderId + ListSplitSymbol))[1] | |
271 | - | ScriptResult(WriteSet([DataEntry(OrderbookTotalKey, (orderbookTotal - total)), DataEntry(OrderbookKey, (newOrderBookOnePart + newOrderBookTwoPart)), DataEntry((OrderTotalKey + orderId), 0)]), TransferSet([ScriptTransfer(i.caller, total, unit)])) | |
274 | + | let parts = split(orderbook, (orderId + ListSplitSymbol)) | |
275 | + | ScriptResult(WriteSet([DataEntry(OrderbookKey, (parts[0] + parts[1])), DataEntry((OrderStatusKey + orderId), CANCELED)]), TransferSet([ScriptTransfer(i.caller, amount, bondAssetId)])) | |
272 | 276 | } | |
273 | 277 | } | |
274 | 278 | ||
275 | 279 | ||
276 | 280 | ||
277 | 281 | @Callable(i) | |
278 | 282 | func executeOrder () = { | |
279 | 283 | let orderId = split(orderbook, ListSplitSymbol)[0] | |
280 | 284 | let orderTotal = getOrderTotal(orderId) | |
281 | 285 | let orderOwner = getOrderOwner(orderId) | |
286 | + | let filledTotal = getOrderFilledTotal(orderId) | |
282 | 287 | if ((0 >= surplus)) | |
283 | 288 | then throw("surplus is less than zero") | |
284 | 289 | else { | |
285 | - | let amount = convertBondToNeutrino((orderTotal - convertNeutrinoToBond(surplus))) | |
286 | - | ScriptResult(WriteSet([DataEntry(OrderbookTotalKey, (orderbookTotal - (if ((surplus >= orderTotal)) | |
290 | + | let amount = (orderTotal - filledTotal) | |
291 | + | let surplusBond = convertNeutrinoToBond(surplus) | |
292 | + | let status = if ((surplusBond >= amount)) | |
293 | + | then FILLED | |
294 | + | else NEW | |
295 | + | let newFilledTotal = if ((surplusBond >= amount)) | |
287 | 296 | then orderTotal | |
288 | - | else surplus))), DataEntry(OrderbookKey, split(orderbook, (orderId + ListSplitSymbol))[1]), DataEntry((OrderTotalKey + orderId), if ((0 >= amount)) | |
289 | - | then 0 | |
290 | - | else amount)]), TransferSet([ScriptTransfer(addressFromStringValue(orderOwner), if ((surplus >= orderTotal)) | |
291 | - | then convertBondToNeutrino(orderTotal) | |
292 | - | else surplus, neutrinoAssetId)])) | |
297 | + | else surplusBond | |
298 | + | ScriptResult(WriteSet([DataEntry(OrderbookKey, split(orderbook, (orderId + ListSplitSymbol))[1]), DataEntry((OrderFilledTotalKey + orderId), (filledTotal + newFilledTotal)), DataEntry((OrderStatusKey + orderId), status)]), TransferSet([ScriptTransfer(addressFromStringValue(orderOwner), convertBondToNeutrino(newFilledTotal), neutrinoAssetId)])) | |
293 | 299 | } | |
294 | 300 | } | |
295 | 301 | ||
296 | 302 |
github/deemru/w8io/169f3d6 65.39 ms ◑