tx · HzGeDH5SVpVj39fHMsb8MDoigBoFtGjvdC5HJx8JsoKv 3N5NAftzfcw3gAt8nc35bNr9UdPTVgC81fd: -0.01400000 Waves 2022.03.18 10:35 [1969106] smart account 3N5NAftzfcw3gAt8nc35bNr9UdPTVgC81fd > SELF 0.00000000 Waves
{ "type": 13, "id": "HzGeDH5SVpVj39fHMsb8MDoigBoFtGjvdC5HJx8JsoKv", "fee": 1400000, "feeAssetId": null, "timestamp": 1647588949441, "version": 1, "sender": "3N5NAftzfcw3gAt8nc35bNr9UdPTVgC81fd", "senderPublicKey": "CdnTmMHxT68Qa4MtHEnAiUhsdKTi2YkHPGn92ThinVNt", "proofs": [ "3ndGXx78eE28vLSADWsdXBBYtnKLbqekVyxbnrLj2Vg6LatmtQyxqCZSJY5JmKscz5k88WhW8dGxGhhSsSEaZABJ", "3FDJBQXgfQ8eJaNw115TqbzcWT2SGHgZ3Een6sTdqxfQBVc2Trs6VpyipqXwEKcdG49qtqebxCxbanL7gKcDtkZa", "2VHdbPB8YXdTj8ZWWJMLTr6YYpr5DCJgcpeEwaFdrUaqzXi9642uCAmJFKXevkK54C84wFS9xtHiYP5r9Cait7He" ], "script": "base64:AAIFAAAAAAAAAA8IAhIAEgASAwoBCBIAEgAAAABDAQAAAA5nZXROdW1iZXJCeUtleQAAAAEAAAADa2V5CQEAAAALdmFsdWVPckVsc2UAAAACCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQAAAAAAAAAAAAEAAAAOZ2V0U3RyaW5nQnlLZXkAAAABAAAAA2tleQkBAAAAC3ZhbHVlT3JFbHNlAAAAAgkABB0AAAACBQAAAAR0aGlzBQAAAANrZXkCAAAAAAEAAAAWZ2V0Qm9vbEJ5QWRkcmVzc0FuZEtleQAAAAIAAAAHYWRkcmVzcwAAAANrZXkJAQAAAAt2YWx1ZU9yRWxzZQAAAAIJAAQbAAAAAgUAAAAHYWRkcmVzcwUAAAADa2V5BwEAAAAYZ2V0U3RyaW5nQnlBZGRyZXNzQ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kAAGQAAAACAwkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAJAAJZAAAAAQkAAZEAAAACBQAAABBwdWJLZXlBZG1pbnNMaXN0AAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAwkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAEJAAJZAAAAAQkAAZEAAAACBQAAABBwdWJLZXlBZG1pbnNMaXN0AAAAAAAAAAABAAAAAAAAAAABAAAAAAAAAAAAAwkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAIJAAJZAAAAAQkAAZEAAAACBQAAABBwdWJLZXlBZG1pbnNMaXN0AAAAAAAAAAACAAAAAAAAAAABAAAAAAAAAAAAAwkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAMJAAJZAAAAAQkAAZEAAAACBQAAABBwdWJLZXlBZG1pbnNMaXN0AAAAAAAAAAADAAAAAAAAAAACAAAAAAAAAAAACQAAZwAAAAIFAAAABWNvdW50AAAAAAAAAAADPsQsYg==", "chainId": 84, "height": 1969106, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: hikumg7MGwM6qqCtdBnzEj3snWC3JY8JDJ7Nsh32nbE Next: H6f3X1ng34CrNLJUQPVyS8HUauzTic338HNd6qHjHnyM Diff:
Old | New | Differences | |
---|---|---|---|
175 | 175 | func getReversePrice (price) = ((PRICELET * PRICELET) / price) | |
176 | 176 | ||
177 | 177 | ||
178 | - | func calcNsbt2WavesPriceRaw (spentWavesRaw,receivedNsbtRaw) = fraction(spentWavesRaw, (PAULI * PRICELET), receivedNsbtRaw) | |
178 | + | func calcNsbt2WavesPriceRaw (spentWavesRaw,receivedNsbtRaw) = fraction(toBigInt(spentWavesRaw), toBigInt((PAULI * PRICELET)), toBigInt(receivedNsbtRaw)) | |
179 | 179 | ||
180 | 180 | ||
181 | - | func orderData (orderId,totalWavelets,filledWavelets,owner,status,roi,price,currentPrice) = [ | |
181 | + | func orderData (orderId,totalWavelets,filledWavelets,owner,status,roi,price,currentPrice) = [StringEntry(getOrderPriceKey(orderId), toString(price)), IntegerEntry(getOrderTotalKey(orderId), totalWavelets), IntegerEntry(getOrderFilledTotalKey(orderId), filledWavelets), StringEntry(getOrderOwnerKey(orderId), owner), IntegerEntry(getOrderHeightKey(orderId), height), StringEntry(getOrderStatusKey(orderId), status), IntegerEntry(("debug_order_currentPrice_" + orderId), currentPrice), IntegerEntry(getRoiByOrderIdKey(orderId), roi)] | |
182 | 182 | ||
183 | 183 | ||
184 | 184 | func toStr (name,curveResult) = (((((((((((((((((((((((((((((((((((name + "[nsbtAmountRaw=") + toString(asInt(curveResult[0]))) + " usdnPayment=") + toString(asInt(curveResult[1]))) + " wRaw=") + toString(asInt(curveResult[2]))) + " uRaw=") + toString(asInt(curveResult[3]))) + " mRaw=") + toString(asInt(curveResult[4]))) + " sRaw=") + toString(asInt(curveResult[5]))) + " nsbtCurveParam_a=") + toString(asInt(curveResult[6]))) + " nsbtCurveParam_b=") + toString(asInt(curveResult[7]))) + " wReservesInUsdn=") + toString(asInt(curveResult[8]))) + " price=") + toString(asInt(curveResult[9]))) + " multBR=") + toString(asInt(curveResult[10]))) + " multPower=") + toString(asInt(curveResult[11]))) + " multExpInPower=") + asString(curveResult[12])) + " multK=") + asString(curveResult[13])) + " step1=") + asString(curveResult[14])) + " step2=") + asString(curveResult[15])) + " step3=") + toString(asInt(curveResult[16]))) + "]") | |
198 | 198 | else { | |
199 | 199 | let ownerAddress = i.caller | |
200 | 200 | let neutrinoMetrics = asAnyList(invoke(mathContract, "calcNeutinoMetricsREADONLY", nil, nil)) | |
201 | - | if ((neutrinoMetrics == neutrinoMetrics)) | |
202 | - | then { | |
203 | - | let currentPrice = asInt(neutrinoMetrics[0]) | |
204 | - | let curveResult = asAnyList(invoke(mathContract, "curveFunctionREADONLY", [wavesPay], nil)) | |
205 | - | if ((curveResult == curveResult)) | |
206 | - | then { | |
207 | - | let nsbtAmount = asInt(curveResult[0]) | |
208 | - | if ((0 >= nsbtAmount)) | |
209 | - | then throw("nsbtAmount <= 0") | |
210 | - | else if ((wavesPay > (nsbtAmount * 9223372))) | |
211 | - | then throw(((("Nsbt2Waves price exceeds MAX_INT: " + toString(wavesPay)) + "/") + toString(nsbtAmount))) | |
212 | - | else { | |
213 | - | let nsbt2WavesPriceRaw = calcNsbt2WavesPriceRaw(wavesPay, nsbtAmount) | |
214 | - | let roi = 0 | |
215 | - | let amountLeased = invoke(neutrinoContract, "acceptWaves", nil, i.payments) | |
216 | - | if ((amountLeased == amountLeased)) | |
217 | - | then $Tuple2((orderData(toBase58String(i.transactionId), pmtAmount, pmtAmount, toString(ownerAddress), FILLED, roi, nsbt2WavesPriceRaw, currentPrice) ++ [ScriptTransfer(ownerAddress, nsbtAmount, nsbtAssetId), StringEntry("debug_curveResult", toStr("curveResult", curveResult))]), nsbtAmount) | |
218 | - | else throw("Strict value is not equal to itself.") | |
219 | - | } | |
220 | - | } | |
201 | + | let currentPrice = asInt(neutrinoMetrics[0]) | |
202 | + | let curveResult = asAnyList(invoke(mathContract, "curveFunctionREADONLY", [wavesPay], nil)) | |
203 | + | let nsbtAmount = asInt(curveResult[0]) | |
204 | + | if ((0 >= nsbtAmount)) | |
205 | + | then throw("nsbtAmount <= 0") | |
206 | + | else { | |
207 | + | let nsbt2WavesPriceRaw = calcNsbt2WavesPriceRaw(wavesPay, nsbtAmount) | |
208 | + | let roi = 0 | |
209 | + | let amountLeased = invoke(neutrinoContract, "acceptWaves", nil, i.payments) | |
210 | + | if ((amountLeased == amountLeased)) | |
211 | + | then $Tuple2((orderData(toBase58String(i.transactionId), pmtAmount, pmtAmount, toString(ownerAddress), FILLED, roi, nsbt2WavesPriceRaw, currentPrice) ++ [ScriptTransfer(ownerAddress, nsbtAmount, nsbtAssetId), StringEntry("debug_curveResult", toStr("curveResult", curveResult))]), nsbtAmount) | |
221 | 212 | else throw("Strict value is not equal to itself.") | |
222 | 213 | } | |
223 | - | else throw("Strict value is not equal to itself.") | |
224 | 214 | } | |
225 | 215 | } | |
226 | 216 | ||
237 | 227 | else if ((minNsbtSell > pmtAmount)) | |
238 | 228 | then throw((("min " + toString((minNsbtSell / PAULI))) + " nsbt expected")) | |
239 | 229 | else { | |
240 | - | let neutrinoMetrics = asAnyList(invoke(mathContract, "calcNeutinoMetricsREADONLY", nil, nil)) | |
241 | - | if ((neutrinoMetrics == neutrinoMetrics)) | |
242 | - | then { | |
243 | - | let nsbtSupply = asInt(neutrinoMetrics[10]) | |
244 | - | let newPrice = asInt(asAnyList(invoke(mathContract, "calcContractNsbtPriceBySupplyREADONLY", [(nsbtSupply - pmtAmount)], nil))[0]) | |
245 | - | if ((newPrice == newPrice)) | |
246 | - | then if ((PAULI > newPrice)) | |
247 | - | then throw((("resulting nsbt price would be < 1 (" + toString(newPrice)) + " usdn")) | |
248 | - | else { | |
249 | - | let transf = invoke(neutrinoContract, "transferUsdnToUser", [pmtAmount, toString(i.caller)], nil) | |
250 | - | if ((transf == transf)) | |
251 | - | then $Tuple2(nil, newPrice) | |
252 | - | else throw("Strict value is not equal to itself.") | |
253 | - | } | |
230 | + | let newPrice = asInt(asAnyList(invoke(mathContract, "calcContractNsbtPriceSYSREADONLY", [-(pmtAmount)], nil))[0]) | |
231 | + | if ((PAULI > newPrice)) | |
232 | + | then throw((("resulting nsbt price would be < 1 (" + toString(newPrice)) + " usdn")) | |
233 | + | else { | |
234 | + | let transf = invoke(neutrinoContract, "transferUsdnToUser", [pmtAmount, toString(i.caller)], nil) | |
235 | + | if ((transf == transf)) | |
236 | + | then $Tuple2(nil, newPrice) | |
254 | 237 | else throw("Strict value is not equal to itself.") | |
255 | 238 | } | |
256 | - | else throw("Strict value is not equal to itself.") | |
257 | 239 | } | |
258 | 240 | } | |
259 | 241 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | func getNumberByKey (key) = valueOrElse(getInteger(this, key), 0) | |
5 | 5 | ||
6 | 6 | ||
7 | 7 | func getStringByKey (key) = valueOrElse(getString(this, key), "") | |
8 | 8 | ||
9 | 9 | ||
10 | 10 | func getBoolByAddressAndKey (address,key) = valueOrElse(getBoolean(address, key), false) | |
11 | 11 | ||
12 | 12 | ||
13 | 13 | func getStringByAddressAndKey (address,key) = valueOrElse(getString(address, key), "") | |
14 | 14 | ||
15 | 15 | ||
16 | 16 | func getNumberByAddressAndKey (address,key) = valueOrElse(getInteger(address, key), 0) | |
17 | 17 | ||
18 | 18 | ||
19 | 19 | func asAnyList (val) = match val { | |
20 | 20 | case valAnyLyst: List[Any] => | |
21 | 21 | valAnyLyst | |
22 | 22 | case _ => | |
23 | 23 | throw("fail to cast into List[Any]") | |
24 | 24 | } | |
25 | 25 | ||
26 | 26 | ||
27 | 27 | func asString (val) = match val { | |
28 | 28 | case valStr: String => | |
29 | 29 | valStr | |
30 | 30 | case _ => | |
31 | 31 | throw("fail to cast into String") | |
32 | 32 | } | |
33 | 33 | ||
34 | 34 | ||
35 | 35 | func asInt (val) = match val { | |
36 | 36 | case valInt: Int => | |
37 | 37 | valInt | |
38 | 38 | case _ => | |
39 | 39 | throw("fail to cast into Int") | |
40 | 40 | } | |
41 | 41 | ||
42 | 42 | ||
43 | 43 | let WAVELET = 100000000 | |
44 | 44 | ||
45 | 45 | let PAULI = 1000000 | |
46 | 46 | ||
47 | 47 | let BIGPAULI = toBigInt(1000000) | |
48 | 48 | ||
49 | 49 | let PRICELET = 1000000 | |
50 | 50 | ||
51 | 51 | let MULT = 100000000 | |
52 | 52 | ||
53 | 53 | let BIGMULT16 = toBigInt(10000000000000000) | |
54 | 54 | ||
55 | 55 | let SCALE8 = 8 | |
56 | 56 | ||
57 | 57 | let SCALE16 = 16 | |
58 | 58 | ||
59 | 59 | let MINORDERTOTAL = (10 * WAVELET) | |
60 | 60 | ||
61 | 61 | let MAXROI = 95 | |
62 | 62 | ||
63 | 63 | let CANCELED = "canceled" | |
64 | 64 | ||
65 | 65 | let NEW = "new" | |
66 | 66 | ||
67 | 67 | let FILLED = "filled" | |
68 | 68 | ||
69 | 69 | let PriceKey = "price" | |
70 | 70 | ||
71 | 71 | let NsbtAssetIdKey = "bond_asset_id" | |
72 | 72 | ||
73 | 73 | let NeutrinoAssetIdKey = "neutrino_asset_id" | |
74 | 74 | ||
75 | 75 | let BalanceLockedkKey = "balance_lock_" | |
76 | 76 | ||
77 | 77 | let WavesLockedBalanceKey = (BalanceLockedkKey + "waves") | |
78 | 78 | ||
79 | 79 | let NeutrinoLockedBalanceKey = (BalanceLockedkKey + "neutrino") | |
80 | 80 | ||
81 | 81 | let FirstOrderKey = "order_first" | |
82 | 82 | ||
83 | 83 | let MathContractKey = "math_contract" | |
84 | 84 | ||
85 | 85 | let MinWavesForNsbtBuyKey = "min_waves_nsbt_buy" | |
86 | 86 | ||
87 | 87 | let MinNsbtSellKey = "min_nsbt_sell" | |
88 | 88 | ||
89 | 89 | func getRoiByOrderIdKey (orderId) = ("debug_order_roi_" + orderId) | |
90 | 90 | ||
91 | 91 | ||
92 | 92 | func getOrderPriceKey (orderId) = ("order_price_" + orderId) | |
93 | 93 | ||
94 | 94 | ||
95 | 95 | func getOrderTotalKey (orderId) = ("order_total_" + orderId) | |
96 | 96 | ||
97 | 97 | ||
98 | 98 | func getOrderOwnerKey (orderId) = ("order_owner_" + orderId) | |
99 | 99 | ||
100 | 100 | ||
101 | 101 | func getOrderHeightKey (orderId) = ("order_height_" + orderId) | |
102 | 102 | ||
103 | 103 | ||
104 | 104 | func getOrderStatusKey (orderId) = ("order_status_" + orderId) | |
105 | 105 | ||
106 | 106 | ||
107 | 107 | func getOrderFilledTotalKey (orderId) = ("order_filled_total_" + orderId) | |
108 | 108 | ||
109 | 109 | ||
110 | 110 | func getPrevOrderKey (orderId) = ("order_prev_" + orderId) | |
111 | 111 | ||
112 | 112 | ||
113 | 113 | func getNextOrderKey (orderId) = ("order_next_" + orderId) | |
114 | 114 | ||
115 | 115 | ||
116 | 116 | func convertNeutrinoToWaves (amount,price) = fraction(fraction(amount, PRICELET, price), WAVELET, PAULI) | |
117 | 117 | ||
118 | 118 | ||
119 | 119 | func convertWavesToNeutrino (amount,price) = fraction(fraction(amount, price, PRICELET), PAULI, WAVELET) | |
120 | 120 | ||
121 | 121 | ||
122 | 122 | func convertWavesToBond (amount,price) = convertWavesToNeutrino(amount, price) | |
123 | 123 | ||
124 | 124 | ||
125 | 125 | func convertBondToWaves (amount,price) = convertNeutrinoToWaves(amount, price) | |
126 | 126 | ||
127 | 127 | ||
128 | 128 | func toX16 (origVal,origScaleMult) = fraction(toBigInt(origVal), BIGMULT16, toBigInt(origScaleMult)) | |
129 | 129 | ||
130 | 130 | ||
131 | 131 | func fromX16 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), BIGMULT16)) | |
132 | 132 | ||
133 | 133 | ||
134 | 134 | let neutrinoContract = Address(base58'3N9be2mwrA52WJho6DiesZkk4351GvpnWuj') | |
135 | 135 | ||
136 | 136 | let controlContract = Address(base58'3MrwvfA9VRYwhHy4NuWPQGdxCtZdhH4LMMa') | |
137 | 137 | ||
138 | 138 | let liquidationContract = Address(base58'3N24ZPUAMhFm76N3vbNiiDtFqfUnmBHTc5N') | |
139 | 139 | ||
140 | 140 | let mathContract = addressFromStringValue(getStringByKey(MathContractKey)) | |
141 | 141 | ||
142 | 142 | let neutrinoAssetId = base58'HezsdQuRDtzksAYUy97gfhKy7Z1NW2uXYSHA3bgqenNZ' | |
143 | 143 | ||
144 | 144 | let nsbtAssetId = base58'F3iaxzruFeKujfVfYSZEkejpjh67wmRfPCRHiNmWKp3Z' | |
145 | 145 | ||
146 | 146 | let isBlocked = getBoolByAddressAndKey(controlContract, "is_blocked") | |
147 | 147 | ||
148 | 148 | let minWavesAmountNsbtBuy = valueOrElse(getInteger(this, MinWavesForNsbtBuyKey), 1000000000) | |
149 | 149 | ||
150 | 150 | let minNsbtSell = valueOrElse(getInteger(this, MinNsbtSellKey), 1000000) | |
151 | 151 | ||
152 | 152 | let firstOrder = getStringByKey(FirstOrderKey) | |
153 | 153 | ||
154 | 154 | func getOrderPrice (id) = getNumberByKey(getOrderPriceKey(id)) | |
155 | 155 | ||
156 | 156 | ||
157 | 157 | func getOrderTotal (id) = getNumberByKey(getOrderTotalKey(id)) | |
158 | 158 | ||
159 | 159 | ||
160 | 160 | func getOrderOwner (id) = getStringByKey(getOrderOwnerKey(id)) | |
161 | 161 | ||
162 | 162 | ||
163 | 163 | func getOrderStatus (id) = getStringByKey(getOrderStatusKey(id)) | |
164 | 164 | ||
165 | 165 | ||
166 | 166 | func getOrderFilledTotal (id) = getNumberByKey(getOrderFilledTotalKey(id)) | |
167 | 167 | ||
168 | 168 | ||
169 | 169 | func getPrevOrder (id) = getStringByKey(getPrevOrderKey(id)) | |
170 | 170 | ||
171 | 171 | ||
172 | 172 | func getNextOrder (id) = getStringByKey(getNextOrderKey(id)) | |
173 | 173 | ||
174 | 174 | ||
175 | 175 | func getReversePrice (price) = ((PRICELET * PRICELET) / price) | |
176 | 176 | ||
177 | 177 | ||
178 | - | func calcNsbt2WavesPriceRaw (spentWavesRaw,receivedNsbtRaw) = fraction(spentWavesRaw, (PAULI * PRICELET), receivedNsbtRaw) | |
178 | + | func calcNsbt2WavesPriceRaw (spentWavesRaw,receivedNsbtRaw) = fraction(toBigInt(spentWavesRaw), toBigInt((PAULI * PRICELET)), toBigInt(receivedNsbtRaw)) | |
179 | 179 | ||
180 | 180 | ||
181 | - | func orderData (orderId,totalWavelets,filledWavelets,owner,status,roi,price,currentPrice) = [ | |
181 | + | func orderData (orderId,totalWavelets,filledWavelets,owner,status,roi,price,currentPrice) = [StringEntry(getOrderPriceKey(orderId), toString(price)), IntegerEntry(getOrderTotalKey(orderId), totalWavelets), IntegerEntry(getOrderFilledTotalKey(orderId), filledWavelets), StringEntry(getOrderOwnerKey(orderId), owner), IntegerEntry(getOrderHeightKey(orderId), height), StringEntry(getOrderStatusKey(orderId), status), IntegerEntry(("debug_order_currentPrice_" + orderId), currentPrice), IntegerEntry(getRoiByOrderIdKey(orderId), roi)] | |
182 | 182 | ||
183 | 183 | ||
184 | 184 | func toStr (name,curveResult) = (((((((((((((((((((((((((((((((((((name + "[nsbtAmountRaw=") + toString(asInt(curveResult[0]))) + " usdnPayment=") + toString(asInt(curveResult[1]))) + " wRaw=") + toString(asInt(curveResult[2]))) + " uRaw=") + toString(asInt(curveResult[3]))) + " mRaw=") + toString(asInt(curveResult[4]))) + " sRaw=") + toString(asInt(curveResult[5]))) + " nsbtCurveParam_a=") + toString(asInt(curveResult[6]))) + " nsbtCurveParam_b=") + toString(asInt(curveResult[7]))) + " wReservesInUsdn=") + toString(asInt(curveResult[8]))) + " price=") + toString(asInt(curveResult[9]))) + " multBR=") + toString(asInt(curveResult[10]))) + " multPower=") + toString(asInt(curveResult[11]))) + " multExpInPower=") + asString(curveResult[12])) + " multK=") + asString(curveResult[13])) + " step1=") + asString(curveResult[14])) + " step2=") + asString(curveResult[15])) + " step3=") + toString(asInt(curveResult[16]))) + "]") | |
185 | 185 | ||
186 | 186 | ||
187 | 187 | @Callable(i) | |
188 | 188 | func buyNsbt () = { | |
189 | 189 | let pmt = value(i.payments[0]) | |
190 | 190 | let pmtAmount = pmt.amount | |
191 | 191 | let wavesPay = pmtAmount | |
192 | 192 | if (isBlocked) | |
193 | 193 | then throw("contract is blocked by EMERGENCY SHUTDOWN actions until reactivation by emergency oracles") | |
194 | 194 | else if (isDefined(pmt.assetId)) | |
195 | 195 | then throw("can use waves only") | |
196 | 196 | else if ((minWavesAmountNsbtBuy > pmtAmount)) | |
197 | 197 | then throw((("min " + toString((minWavesAmountNsbtBuy / WAVELET))) + " waves expected")) | |
198 | 198 | else { | |
199 | 199 | let ownerAddress = i.caller | |
200 | 200 | let neutrinoMetrics = asAnyList(invoke(mathContract, "calcNeutinoMetricsREADONLY", nil, nil)) | |
201 | - | if ((neutrinoMetrics == neutrinoMetrics)) | |
202 | - | then { | |
203 | - | let currentPrice = asInt(neutrinoMetrics[0]) | |
204 | - | let curveResult = asAnyList(invoke(mathContract, "curveFunctionREADONLY", [wavesPay], nil)) | |
205 | - | if ((curveResult == curveResult)) | |
206 | - | then { | |
207 | - | let nsbtAmount = asInt(curveResult[0]) | |
208 | - | if ((0 >= nsbtAmount)) | |
209 | - | then throw("nsbtAmount <= 0") | |
210 | - | else if ((wavesPay > (nsbtAmount * 9223372))) | |
211 | - | then throw(((("Nsbt2Waves price exceeds MAX_INT: " + toString(wavesPay)) + "/") + toString(nsbtAmount))) | |
212 | - | else { | |
213 | - | let nsbt2WavesPriceRaw = calcNsbt2WavesPriceRaw(wavesPay, nsbtAmount) | |
214 | - | let roi = 0 | |
215 | - | let amountLeased = invoke(neutrinoContract, "acceptWaves", nil, i.payments) | |
216 | - | if ((amountLeased == amountLeased)) | |
217 | - | then $Tuple2((orderData(toBase58String(i.transactionId), pmtAmount, pmtAmount, toString(ownerAddress), FILLED, roi, nsbt2WavesPriceRaw, currentPrice) ++ [ScriptTransfer(ownerAddress, nsbtAmount, nsbtAssetId), StringEntry("debug_curveResult", toStr("curveResult", curveResult))]), nsbtAmount) | |
218 | - | else throw("Strict value is not equal to itself.") | |
219 | - | } | |
220 | - | } | |
201 | + | let currentPrice = asInt(neutrinoMetrics[0]) | |
202 | + | let curveResult = asAnyList(invoke(mathContract, "curveFunctionREADONLY", [wavesPay], nil)) | |
203 | + | let nsbtAmount = asInt(curveResult[0]) | |
204 | + | if ((0 >= nsbtAmount)) | |
205 | + | then throw("nsbtAmount <= 0") | |
206 | + | else { | |
207 | + | let nsbt2WavesPriceRaw = calcNsbt2WavesPriceRaw(wavesPay, nsbtAmount) | |
208 | + | let roi = 0 | |
209 | + | let amountLeased = invoke(neutrinoContract, "acceptWaves", nil, i.payments) | |
210 | + | if ((amountLeased == amountLeased)) | |
211 | + | then $Tuple2((orderData(toBase58String(i.transactionId), pmtAmount, pmtAmount, toString(ownerAddress), FILLED, roi, nsbt2WavesPriceRaw, currentPrice) ++ [ScriptTransfer(ownerAddress, nsbtAmount, nsbtAssetId), StringEntry("debug_curveResult", toStr("curveResult", curveResult))]), nsbtAmount) | |
221 | 212 | else throw("Strict value is not equal to itself.") | |
222 | 213 | } | |
223 | - | else throw("Strict value is not equal to itself.") | |
224 | 214 | } | |
225 | 215 | } | |
226 | 216 | ||
227 | 217 | ||
228 | 218 | ||
229 | 219 | @Callable(i) | |
230 | 220 | func sellNsbt () = if (isBlocked) | |
231 | 221 | then throw("contract is blocked by EMERGENCY SHUTDOWN actions until reactivation by emergency oracles") | |
232 | 222 | else { | |
233 | 223 | let pmt = value(i.payments[0]) | |
234 | 224 | let pmtAmount = pmt.amount | |
235 | 225 | if ((pmt.assetId != nsbtAssetId)) | |
236 | 226 | then throw("can use NSBT only") | |
237 | 227 | else if ((minNsbtSell > pmtAmount)) | |
238 | 228 | then throw((("min " + toString((minNsbtSell / PAULI))) + " nsbt expected")) | |
239 | 229 | else { | |
240 | - | let neutrinoMetrics = asAnyList(invoke(mathContract, "calcNeutinoMetricsREADONLY", nil, nil)) | |
241 | - | if ((neutrinoMetrics == neutrinoMetrics)) | |
242 | - | then { | |
243 | - | let nsbtSupply = asInt(neutrinoMetrics[10]) | |
244 | - | let newPrice = asInt(asAnyList(invoke(mathContract, "calcContractNsbtPriceBySupplyREADONLY", [(nsbtSupply - pmtAmount)], nil))[0]) | |
245 | - | if ((newPrice == newPrice)) | |
246 | - | then if ((PAULI > newPrice)) | |
247 | - | then throw((("resulting nsbt price would be < 1 (" + toString(newPrice)) + " usdn")) | |
248 | - | else { | |
249 | - | let transf = invoke(neutrinoContract, "transferUsdnToUser", [pmtAmount, toString(i.caller)], nil) | |
250 | - | if ((transf == transf)) | |
251 | - | then $Tuple2(nil, newPrice) | |
252 | - | else throw("Strict value is not equal to itself.") | |
253 | - | } | |
230 | + | let newPrice = asInt(asAnyList(invoke(mathContract, "calcContractNsbtPriceSYSREADONLY", [-(pmtAmount)], nil))[0]) | |
231 | + | if ((PAULI > newPrice)) | |
232 | + | then throw((("resulting nsbt price would be < 1 (" + toString(newPrice)) + " usdn")) | |
233 | + | else { | |
234 | + | let transf = invoke(neutrinoContract, "transferUsdnToUser", [pmtAmount, toString(i.caller)], nil) | |
235 | + | if ((transf == transf)) | |
236 | + | then $Tuple2(nil, newPrice) | |
254 | 237 | else throw("Strict value is not equal to itself.") | |
255 | 238 | } | |
256 | - | else throw("Strict value is not equal to itself.") | |
257 | 239 | } | |
258 | 240 | } | |
259 | 241 | ||
260 | 242 | ||
261 | 243 | ||
262 | 244 | @Callable(i) | |
263 | 245 | func cancelOrder (orderId) = { | |
264 | 246 | let owner = getOrderOwner(orderId) | |
265 | 247 | let amount = (getOrderTotal(orderId) - getOrderFilledTotal(orderId)) | |
266 | 248 | let caller = toString(i.caller) | |
267 | 249 | let nextOrder = getNextOrder(orderId) | |
268 | 250 | let prevOrder = getPrevOrder(orderId) | |
269 | 251 | if ((getOrderStatus(orderId) != NEW)) | |
270 | 252 | then throw("invalid order status") | |
271 | 253 | else [StringEntry(FirstOrderKey, if ((firstOrder == orderId)) | |
272 | 254 | then nextOrder | |
273 | 255 | else firstOrder), StringEntry(getNextOrderKey(prevOrder), nextOrder), StringEntry(getPrevOrderKey(nextOrder), prevOrder), StringEntry(getOrderStatusKey(orderId), CANCELED), ScriptTransfer(i.caller, amount, unit)] | |
274 | 256 | } | |
275 | 257 | ||
276 | 258 | ||
277 | 259 | ||
278 | 260 | @Callable(i) | |
279 | 261 | func minWavesAmountNsbtBuySYSREADONLY () = $Tuple2(nil, minWavesAmountNsbtBuy) | |
280 | 262 | ||
281 | 263 | ||
282 | 264 | ||
283 | 265 | @Callable(i) | |
284 | 266 | func minNsbtAmountForSellSYSREADONLY () = $Tuple2(nil, minNsbtSell) | |
285 | 267 | ||
286 | 268 | ||
287 | 269 | @Verifier(tx) | |
288 | 270 | func verify () = { | |
289 | 271 | let pubKeyAdminsList = ["ExtEEK19nmKj9mCpnWyvEEJFYATLMcVEMvohhUHkyHNm", "Ev5py5FfBQX9cZpYKnfQrTB49Byf8QmpZWeDVRim4yV7", "DUuuLjXu98nBwZc7fqwCTjtA3nnRwgTbkMSr5SU2NmDR", "5WRXFSjwcTbNfKcJs8ZqXmSSWYsSVJUtMvMqZj5hH4Nc"] | |
290 | 272 | let count = ((((if (sigVerify(tx.bodyBytes, tx.proofs[0], fromBase58String(pubKeyAdminsList[0]))) | |
291 | 273 | then 1 | |
292 | 274 | else 0) + (if (sigVerify(tx.bodyBytes, tx.proofs[1], fromBase58String(pubKeyAdminsList[1]))) | |
293 | 275 | then 1 | |
294 | 276 | else 0)) + (if (sigVerify(tx.bodyBytes, tx.proofs[2], fromBase58String(pubKeyAdminsList[2]))) | |
295 | 277 | then 1 | |
296 | 278 | else 0)) + (if (sigVerify(tx.bodyBytes, tx.proofs[3], fromBase58String(pubKeyAdminsList[3]))) | |
297 | 279 | then 2 | |
298 | 280 | else 0)) | |
299 | 281 | (count >= 3) | |
300 | 282 | } | |
301 | 283 |
github/deemru/w8io/026f985 55.69 ms ◑