tx · A7RbCAPni9vLq8pW1yuduYuBcKWKByDWkTXXmgAve9M7 3N2F6PGcAYAGEzdPYsUmj834cKMD1tP9SMo: -0.01400000 Waves 2020.10.15 10:17 [1221362] smart account 3N2F6PGcAYAGEzdPYsUmj834cKMD1tP9SMo > SELF 0.00000000 Waves
{ "type": 13, "id": "A7RbCAPni9vLq8pW1yuduYuBcKWKByDWkTXXmgAve9M7", "fee": 1400000, "feeAssetId": null, "timestamp": 1602746296770, "version": 1, "sender": "3N2F6PGcAYAGEzdPYsUmj834cKMD1tP9SMo", "senderPublicKey": "3ZF3FgCAeTQkaBVhAkH83Gn6AmTucqvG3hzHnxsba9rZ", "proofs": [ "mrA1VRgCGdxtsc9uyzHEypmd7tgEGTXESX4WWSGdMF13zDDBAh7Du9yienn5VRfUFBbFF74srP4XJE76LuZGu3h" ], "script": "base64:AAIEAAAAAAAAAA4IAhIAEgASBAoCCAgSAAAAAFkBAAAAEWtleUFjY3VtdWxhdGVkRmVlAAAAAAIAAAASJXNfX2FjY3VtdWxhdGVkRmVlAQAAAA5rZXlVY29sbGF0ZXJhbAAAAAACAAAADyVzX191Y29sbGF0ZXJhbAEAAAAZa2V5VG90YWxMZW5kZWRBdE90aGVyQWNjcwAAAAACAAAAGiVzX190b3RhbExlbmRlZEF0T3RoZXJBY2NzAQAAABNrZXlBc3NldExvY2tlZFRvdGFsAAAAAQAAAAdhc3NldElkCQABLAAAAAICAAAAGCVzJXNfX2Fzc2V0TG9ja2VkVG90YWxfXwUAAAAHYXNzZXRJZAEAAAATa2V5QWNjb3VudE9wZXJhdGlvbgAAAAMAAAAMdW5sb2NrSGVpZ2h0AAAAB2FkZHJlc3MAAAAGc3RhdHVzCQABLAAAAAIJAAEsAAAAAgkAASwAAAACCQABLAAAAAIJAAEsAAAAAgIAAAAeJXMlcyVkJXNfX2RlZm9Bc3NldE9wZXJhdGlvbl9fBQAAAAdhZGRyZXNzAgAAAAJfXwkAAaQAAAABBQAAAAx1bmxvY2tIZWlnaH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ABCUAAAABBQAAABJuZXV0cmlub1N0YWtpbmdBY2MJAAQlAAAAAQkABCQAAAABCAUAAAADaW52AAAABGRBcHAJAAACAAAAAQIAAAAlaW52YWxpZCBuZXV0cmlubyBzdGFraW5nIGRhcHAgYWRkcmVzcwkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAJAQAAACJmYWN0b3J5UmVhZERlZm9TdGFraW5nUGFjZW1ha2VyUHViAAAAAAkAAAIAAAABAgAAACNOb3QgYWxsb3dlZCBpbnZvY2F0aW9uIG1ldGhvZCBjYWxscwkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXkp/WyD", "chainId": 84, "height": 1221362, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 2YmXejsWkxkqVD9sKu4nwSG2CZcJUmTacMYDj5pnP519 Next: CKSknZfgMoZFqUq5ehQjp353zkk8spQeqmDeUWSTghtF Diff:
Old | New | Differences | |
---|---|---|---|
23 | 23 | ||
24 | 24 | ||
25 | 25 | func keyPrice (assetCode) = ("%s%s__price__" + assetCode) | |
26 | + | ||
27 | + | ||
28 | + | func keyControlLastHeight (assetCode) = ("%s%s__lastHeight__" + assetCode) | |
26 | 29 | ||
27 | 30 | ||
28 | 31 | let IdxOperationAmountIn = 1 | |
150 | 153 | ||
151 | 154 | let sellFeePercent = parseIntValue(thisCfgArray[IdxSellFeePercent]) | |
152 | 155 | ||
156 | + | func keyIsBlocked () = "%s__isBlocked" | |
157 | + | ||
158 | + | ||
159 | + | let isBlocked = valueOrElse(getBoolean(priceOracleAcc, keyIsBlocked()), false) | |
160 | + | ||
153 | 161 | func controlAccReadPrice (assetCode) = valueOrErrorMessage(getInteger(priceOracleAcc, keyPrice(assetCode)), ((("No price at priceOracle=" + toString(priceOracleAcc)) + " for key=") + keyPrice(assetCode))) | |
162 | + | ||
163 | + | ||
164 | + | func controlAccReadLastHeight (assetCode) = valueOrErrorMessage(getInteger(priceOracleAcc, keyControlLastHeight(assetCode)), ((("No lastHeight at priceOracle=" + toString(priceOracleAcc)) + " for key=") + keyControlLastHeight(assetCode))) | |
154 | 165 | ||
155 | 166 | ||
156 | 167 | func controlAccReadCurrIdxOrFail () = valueOrErrorMessage(getInteger(priceOracleAcc, "currIdx"), ("No currIdx at controlAcc=" + toString(priceOracleAcc))) | |
167 | 178 | valueOrErrorMessage(getInteger(priceOracleAcc, priceByHeightKey), ((("No " + priceByHeightKey) + " at controlAcc=") + toString(priceOracleAcc))) | |
168 | 179 | } | |
169 | 180 | ||
181 | + | ||
182 | + | let priceLastHeight = controlAccReadLastHeight(defoAssetCode) | |
183 | + | ||
184 | + | let isBlockedByLastHeight = ((priceLastHeight - priceLastHeight) > 5) | |
170 | 185 | ||
171 | 186 | let keyDefoStakingAddress = "%s%s__commonConfig__defoStakingAddress" | |
172 | 187 | ||
209 | 224 | let emission = (value(assetInfo(defoAssetId)).quantity - assetBalance(this, defoAssetId)) | |
210 | 225 | ||
211 | 226 | func internalBuyAsset (sellerAddr,sellAmt,sellAssetId,minSellAmt,buy2sellPrice,feePercent) = { | |
212 | - | let availableDefoAssetInPool = (fraction(currentBaseAssetBalance, overPrice, priceDecimals) - emission) | |
213 | - | let defoAssetAmountNoPoolLimit = fraction(sellAmt, buy2sellPrice, priceDecimals) | |
214 | - | let defoAssetAmountGross = if ((defoAssetAmountNoPoolLimit > availableDefoAssetInPool)) | |
215 | - | then availableDefoAssetInPool | |
216 | - | else defoAssetAmountNoPoolLimit | |
227 | + | let defoAssetAmountGross = fraction(sellAmt, buy2sellPrice, priceDecimals) | |
217 | 228 | let defoAssetAmount = fraction((priceDecimals - feePercent), defoAssetAmountGross, priceDecimals) | |
218 | 229 | let feeAmount = (defoAssetAmountGross - defoAssetAmount) | |
219 | 230 | let requiredBasicAssetAmount = fraction(defoAssetAmountGross, priceDecimals, buy2sellPrice) | |
220 | 231 | let change = (sellAmt - requiredBasicAssetAmount) | |
221 | - | if ((0 >= availableDefoAssetInPool)) | |
222 | - | then throw((("impossible to issue new " + defoAssetCode) + ": not enough collateral")) | |
223 | - | else if (if ((minSellAmt > sellAmt)) | |
224 | - | then (toString(sellerAddr) != toString(defoStakingAcc)) | |
225 | - | else false) | |
226 | - | then throw(((((("impossible to issue new " + defoAssetCode) + ": payment=") + toString(sellAmt)) + "is less then min amount=") + toString(minSellAmt))) | |
227 | - | else $Tuple2([IntegerEntry(keyUcollateral(), (ucollateral + requiredBasicAssetAmount)), StringEntry(keyAccountOperation(height, toString(sellerAddr), "FINISHED"), assetDataSwapOperation(sellAmt, toBase58String(sellAssetId), price, defoAssetAmount, toBase58String(defoAssetId), defoAssetAmountGross, feeAmount)), Reissue(defoAssetId, (defoAssetAmount + feeAmount), true), ScriptTransfer(sellerAddr, defoAssetAmount, defoAssetId), ScriptTransfer(sellerAddr, change, sellAssetId), ScriptTransfer(factoryReadNextPoolMakerToDistributeFee(toString(this)), feeAmount, defoAssetId), IntegerEntry(keyAccumulatedFee(), (accumulatedFee + feeAmount))], change) | |
232 | + | if (if ((minSellAmt > sellAmt)) | |
233 | + | then (toString(sellerAddr) != toString(defoStakingAcc)) | |
234 | + | else false) | |
235 | + | then throw(((((("impossible to issue new " + defoAssetCode) + ": payment=") + toString(sellAmt)) + "is less then min amount=") + toString(minSellAmt))) | |
236 | + | else $Tuple2([IntegerEntry(keyUcollateral(), (ucollateral + requiredBasicAssetAmount)), StringEntry(keyAccountOperation(height, toString(sellerAddr), "FINISHED"), assetDataSwapOperation(sellAmt, toBase58String(sellAssetId), price, defoAssetAmount, toBase58String(defoAssetId), defoAssetAmountGross, feeAmount)), Reissue(defoAssetId, (defoAssetAmount + feeAmount), true), ScriptTransfer(sellerAddr, defoAssetAmount, defoAssetId), ScriptTransfer(sellerAddr, change, sellAssetId), ScriptTransfer(factoryReadNextPoolMakerToDistributeFee(toString(this)), feeAmount, defoAssetId), IntegerEntry(keyAccumulatedFee(), (accumulatedFee + feeAmount))], change) | |
228 | 237 | } | |
229 | 238 | ||
230 | 239 | ||
232 | 241 | func buyAsset () = { | |
233 | 242 | let pmt = value(i.payments[0]) | |
234 | 243 | let pmtAssetId = value(pmt.assetId) | |
235 | - | if ((pmtAssetId != baseAssetId)) | |
236 | - | then throw(((("Payment asset id doesn't match basic asset: expected=" + toBase58String(baseAssetId)) + " actual=") + toBase58String(pmtAssetId))) | |
237 | - | else internalBuyAsset(i.caller, pmt.amount, pmtAssetId, minBasicBuyAmount, price, buyFeePercent)._1 | |
244 | + | if (isBlocked) | |
245 | + | then throw("contract is blocked by EMERGENCY SHUTDOWN actions untill reactivation by emergency oracles") | |
246 | + | else if (isBlockedByLastHeight) | |
247 | + | then throw(((("last price finalization has been more then 5 blocks ago: priceLastHeight=" + toString(priceLastHeight)) + " currHeight=") + toString(height))) | |
248 | + | else if ((pmtAssetId != baseAssetId)) | |
249 | + | then throw(((("Payment asset id doesn't match basic asset: expected=" + toBase58String(baseAssetId)) + " actual=") + toBase58String(pmtAssetId))) | |
250 | + | else internalBuyAsset(i.caller, pmt.amount, pmtAssetId, minBasicBuyAmount, price, buyFeePercent)._1 | |
238 | 251 | } | |
239 | 252 | ||
240 | 253 | ||
244 | 257 | let pmt = value(i.payments[0]) | |
245 | 258 | let pmtAsset = value(pmt.assetId) | |
246 | 259 | let callerAddress = toString(i.caller) | |
247 | - | if ((pmtAsset != defoAssetId)) | |
248 | - | then throw(((("Invalid payment asset id: expected=" + toBase58String(defoAssetId)) + " actual=") + toBase58String(pmtAsset))) | |
249 | - | else if ((minSynthSellAmount > pmt.amount)) | |
250 | - | then throw(((("Payment amount less then mininimal allowed: paymentAmount=" + toString(pmt.amount)) + " minAmount=") + toString(minSynthSellAmount))) | |
251 | - | else { | |
252 | - | let baseAssetAmountNoBalanceLimit = fraction(pmt.amount, priceDecimals, price) | |
253 | - | let baseAssetAmountAvailable = if ((baseAssetAmountNoBalanceLimit > currentBaseAssetBalance)) | |
254 | - | then currentBaseAssetBalance | |
255 | - | else baseAssetAmountNoBalanceLimit | |
256 | - | let soldDefoAssetAmountGross = fraction(baseAssetAmountAvailable, price, priceDecimals) | |
257 | - | let change = (pmt.amount - soldDefoAssetAmountGross) | |
258 | - | let defoAmountFee = fraction(sellFeePercent, soldDefoAssetAmountGross, priceDecimals) | |
259 | - | let soldDefoAssetAmount = (soldDefoAssetAmountGross - defoAmountFee) | |
260 | - | let baseAssetAmountToSend = fraction(soldDefoAssetAmount, priceDecimals, price) | |
260 | + | if (isBlocked) | |
261 | + | then throw("contract is blocked by EMERGENCY SHUTDOWN actions untill reactivation by emergency oracles") | |
262 | + | else if (isBlockedByLastHeight) | |
263 | + | then throw(((("last price finalization has been more then 5 blocks ago: priceLastHeight=" + toString(priceLastHeight)) + " currHeight=") + toString(height))) | |
264 | + | else if ((pmtAsset != defoAssetId)) | |
265 | + | then throw(((("Invalid payment asset id: expected=" + toBase58String(defoAssetId)) + " actual=") + toBase58String(pmtAsset))) | |
266 | + | else if ((minSynthSellAmount > pmt.amount)) | |
267 | + | then throw(((("Payment amount less then mininimal allowed: paymentAmount=" + toString(pmt.amount)) + " minAmount=") + toString(minSynthSellAmount))) | |
268 | + | else { | |
269 | + | let baseAssetAmountNoBalanceLimit = fraction(pmt.amount, priceDecimals, price) | |
270 | + | let baseAssetAmountAvailable = if ((baseAssetAmountNoBalanceLimit > currentBaseAssetBalance)) | |
271 | + | then currentBaseAssetBalance | |
272 | + | else baseAssetAmountNoBalanceLimit | |
273 | + | let soldDefoAssetAmountGross = fraction(baseAssetAmountAvailable, price, priceDecimals) | |
274 | + | let change = (pmt.amount - soldDefoAssetAmountGross) | |
275 | + | let defoAmountFee = fraction(sellFeePercent, soldDefoAssetAmountGross, priceDecimals) | |
276 | + | let soldDefoAssetAmount = (soldDefoAssetAmountGross - defoAmountFee) | |
277 | + | let baseAssetAmountToSend = fraction(soldDefoAssetAmount, priceDecimals, price) | |
261 | 278 | [IntegerEntry(keyUcollateral(), (ucollateral - baseAssetAmountToSend)), StringEntry(keyAccountOperation(height, callerAddress, "FINISHED"), assetDataSwapOperation(pmt.amount, toBase58String(pmtAsset), price, baseAssetAmountToSend, baseAssetIdStr, soldDefoAssetAmountGross, defoAmountFee)), Burn(defoAssetId, soldDefoAssetAmount), ScriptTransfer(i.caller, baseAssetAmountToSend, baseAssetId), ScriptTransfer(i.caller, change, defoAssetId), ScriptTransfer(factoryReadNextPoolMakerToDistributeFee(toString(this)), defoAmountFee, defoAssetId), IntegerEntry(keyAccumulatedFee(), (accumulatedFee + defoAmountFee))] | |
262 | - | } | |
279 | + | } | |
263 | 280 | } | |
264 | 281 | ||
265 | 282 | ||
276 | 293 | let sellAssetCfg = sellAssetTuple._2 | |
277 | 294 | let sellAssetAccAddress = valueOrErrorMessage(addressFromString(sellAssetTuple._1), ("couldn't parse address from string for assetCode=" + sellAssetCodeConfirm)) | |
278 | 295 | let minSellPmt = valueOrErrorMessage(parseInt(sellAssetCfg[IdxMinSellPayment]), ("minSellPmt parsing error: rawVal=" + sellAssetCfg[IdxMinSellPayment])) | |
279 | - | if ((thisCfgArray[IdxDefoAssetCode] != buyAssetCodeConfirm)) | |
280 | - | then throw(((("buyAsset confirmation failed: buyAssetIdConfirm=" + thisCfgArray[IdxDefoAssetCode]) + " BUT buyAssetId=") + buyAssetCodeConfirm)) | |
281 | - | else if ((sellAssetCfg[IdxDefoAssetId] != pmtAssetStr)) | |
282 | - | then throw(((("sellAsset confirmation failed: sellAssetIdConfirm=" + sellAssetCfg[IdxDefoAssetId]) + "BUT pmtAsset=") + pmtAssetStr)) | |
283 | - | else if ((thisCfgArray[IdxDefoAssetStatus] != "ISSUED")) | |
284 | - | then throw(((("toAsset has not been issued yet: buyAssetId=" + buyAssetCodeConfirm) + " BUT status=") + thisCfgArray[IdxDefoAssetStatus])) | |
285 | - | else if ((sellAssetCfg[IdxDefoAssetStatus] != "ISSUED")) | |
286 | - | then throw(((("fromAssetCfg has not been issued yet: sellAssetId=" + pmtAssetStr) + " BUT status=") + sellAssetCfg[IdxDefoAssetStatus])) | |
287 | - | else { | |
288 | - | let buyAssetUsdPrice = price | |
289 | - | let sellAssetUsdPrice = controlAccReadPrice(sellAssetCodeConfirm) | |
290 | - | let buy2sellPrice = fraction(buyAssetUsdPrice, priceDecimals, sellAssetUsdPrice) | |
291 | - | let usdnDebt = fraction(pmtAmount, priceDecimals, sellAssetUsdPrice) | |
292 | - | let totalLendedAtOtherAccs = valueOrElse(getInteger(this, keyTotalLendedAtOtherAccs()), 0) | |
293 | - | let lendedAmountByAssetCodeKey = keyLendedAmountByAssetCode(sellAssetCodeConfirm) | |
294 | - | let lendedAmtByAssetCode = valueOrElse(getInteger(this, lendedAmountByAssetCodeKey), 0) | |
295 | - | let sellAssetSellFeePercent = parseIntValue(sellAssetCfg[IdxSellFeePercent]) | |
296 | - | let buyAssetResult = internalBuyAsset(i.caller, pmtAmount, pmtAsset, minSellPmt, buy2sellPrice, fraction((buyFeePercent + sellAssetSellFeePercent), 75, 100)) | |
297 | - | ((((buyAssetResult._1 :+ ScriptTransfer(sellAssetAccAddress, usdnDebt, debtAssetId)) :+ ScriptTransfer(sellAssetAccAddress, (pmtAmount - buyAssetResult._2), pmtAsset)) :+ IntegerEntry(lendedAmountByAssetCodeKey, (lendedAmtByAssetCode + usdnDebt))) :+ IntegerEntry(keyTotalLendedAtOtherAccs(), (totalLendedAtOtherAccs + usdnDebt))) | |
298 | - | } | |
296 | + | let sellPriceLastHeight = controlAccReadLastHeight(sellAssetCodeConfirm) | |
297 | + | let isSellBlockedByLastHeight = ((sellPriceLastHeight - sellPriceLastHeight) > 5) | |
298 | + | if (isBlocked) | |
299 | + | then throw("contract is blocked by EMERGENCY SHUTDOWN actions untill reactivation by emergency oracles") | |
300 | + | else if ((sellAssetCfg[IdxDefoAssetCode] == "NGN")) | |
301 | + | then throw("crossExchange for NGN is temporary disabled") | |
302 | + | else if ((thisCfgArray[IdxDefoAssetCode] != buyAssetCodeConfirm)) | |
303 | + | then throw(((("buyAsset confirmation failed: buyAssetIdConfirm=" + thisCfgArray[IdxDefoAssetCode]) + " BUT buyAssetId=") + buyAssetCodeConfirm)) | |
304 | + | else if ((sellAssetCfg[IdxDefoAssetId] != pmtAssetStr)) | |
305 | + | then throw(((("sellAsset confirmation failed: sellAssetIdConfirm=" + sellAssetCfg[IdxDefoAssetId]) + "BUT pmtAsset=") + pmtAssetStr)) | |
306 | + | else if ((thisCfgArray[IdxDefoAssetStatus] != "ISSUED")) | |
307 | + | then throw(((("toAsset has not been issued yet: buyAssetId=" + buyAssetCodeConfirm) + " BUT status=") + thisCfgArray[IdxDefoAssetStatus])) | |
308 | + | else if ((sellAssetCfg[IdxDefoAssetStatus] != "ISSUED")) | |
309 | + | then throw(((("fromAssetCfg has not been issued yet: sellAssetId=" + pmtAssetStr) + " BUT status=") + sellAssetCfg[IdxDefoAssetStatus])) | |
310 | + | else if (isBlockedByLastHeight) | |
311 | + | then throw(((((("buy last price finalization has been more then 5 blocks ago: priceLastHeight=" + toString(priceLastHeight)) + " currHeight=") + toString(height)) + " buyCode=") + buyAssetCodeConfirm)) | |
312 | + | else if (isSellBlockedByLastHeight) | |
313 | + | then throw(((((("sell last price finalization has been more then 5 blocks ago: priceLastHeight=" + toString(priceLastHeight)) + " currHeight=") + toString(height)) + " sellCode=") + sellAssetCodeConfirm)) | |
314 | + | else { | |
315 | + | let buyAssetUsdPrice = price | |
316 | + | let sellAssetUsdPrice = controlAccReadPrice(sellAssetCodeConfirm) | |
317 | + | let buy2sellPrice = fraction(buyAssetUsdPrice, priceDecimals, sellAssetUsdPrice) | |
318 | + | let usdnDebt = fraction(pmtAmount, priceDecimals, sellAssetUsdPrice) | |
319 | + | let totalLendedAtOtherAccs = valueOrElse(getInteger(this, keyTotalLendedAtOtherAccs()), 0) | |
320 | + | let lendedAmountByAssetCodeKey = keyLendedAmountByAssetCode(sellAssetCodeConfirm) | |
321 | + | let lendedAmtByAssetCode = valueOrElse(getInteger(this, lendedAmountByAssetCodeKey), 0) | |
322 | + | let sellAssetSellFeePercent = parseIntValue(sellAssetCfg[IdxSellFeePercent]) | |
323 | + | let buyAssetResult = internalBuyAsset(i.caller, pmtAmount, pmtAsset, minSellPmt, buy2sellPrice, fraction((buyFeePercent + sellAssetSellFeePercent), 50, 100)) | |
324 | + | ((((buyAssetResult._1 :+ ScriptTransfer(sellAssetAccAddress, usdnDebt, debtAssetId)) :+ ScriptTransfer(sellAssetAccAddress, (pmtAmount - buyAssetResult._2), pmtAsset)) :+ IntegerEntry(lendedAmountByAssetCodeKey, (lendedAmtByAssetCode + usdnDebt))) :+ IntegerEntry(keyTotalLendedAtOtherAccs(), (totalLendedAtOtherAccs + usdnDebt))) | |
325 | + | } | |
299 | 326 | } | |
300 | 327 | ||
301 | 328 | ||
311 | 338 | let debtorAssetCode = debtorAssetCfg[IdxDefoAssetCode] | |
312 | 339 | let lendedAmountByAssetCodeKey = keyLendedAmountByAssetCode(debtorAssetCode) | |
313 | 340 | let lendedAmt = valueOrErrorMessage(getInteger(this, lendedAmountByAssetCodeKey), ("No debts for " + debtorAssetCode)) | |
314 | - | if ((debtAssetId != debtPmtAsset0)) | |
315 | - | then throw(((("invalid debt asset id in the first paymet: expected=" + toBase58String(debtAssetId)) + " actual=") + toBase58String(debtPmtAsset0))) | |
316 | - | else if ((baseAssetId != basePmtAsset1)) | |
317 | - | then throw(((("invalid base asset id in the second payment: expected=" + toBase58String(baseAssetId)) + " actual=") + toBase58String(basePmtAsset1))) | |
318 | - | else if ((debtPmt0.amount != basePmt1.amount)) | |
319 | - | then throw("first payment amount doesn't match to the second payment amount") | |
320 | - | else if ((0 >= lendedAmt)) | |
321 | - | then throw(("lendedAmt is less then zero: lendedAmt=" + toString(lendedAmt))) | |
322 | - | else if ((minBasicBuyAmount >= debtPmt0.amount)) | |
323 | - | then throw(((("attached payment must be greater then minBasicBuyAmount: pmt0.amount=" + toString(debtPmt0.amount)) + " minBasicBuyAmount=") + toString(minBasicBuyAmount))) | |
324 | - | else if ((debtPmt0.amount > lendedAmt)) | |
325 | - | then throw(((("attached payment is grater than required: pmtAmount=" + toString(debtPmt0.amount)) + " lendedAmt=") + toString(lendedAmt))) | |
326 | - | else { | |
327 | - | let totalLendedAtOtherAccs = valueOrElse(getInteger(this, keyTotalLendedAtOtherAccs()), 0) | |
328 | - | let lendedAmtAfter = (lendedAmt - debtPmt0.amount) | |
341 | + | if (isBlocked) | |
342 | + | then throw("contract is blocked by EMERGENCY SHUTDOWN actions untill reactivation by emergency oracles") | |
343 | + | else if ((debtAssetId != debtPmtAsset0)) | |
344 | + | then throw(((("invalid debt asset id in the first paymet: expected=" + toBase58String(debtAssetId)) + " actual=") + toBase58String(debtPmtAsset0))) | |
345 | + | else if ((baseAssetId != basePmtAsset1)) | |
346 | + | then throw(((("invalid base asset id in the second payment: expected=" + toBase58String(baseAssetId)) + " actual=") + toBase58String(basePmtAsset1))) | |
347 | + | else if ((debtPmt0.amount != basePmt1.amount)) | |
348 | + | then throw("first payment amount doesn't match to the second payment amount") | |
349 | + | else if ((0 >= lendedAmt)) | |
350 | + | then throw(("lendedAmt is less then zero: lendedAmt=" + toString(lendedAmt))) | |
351 | + | else if (((100 * priceDecimals) >= debtPmt0.amount)) | |
352 | + | then throw(("attached payment must be greater then 100: pmt0.amount=" + toString(debtPmt0.amount))) | |
353 | + | else if ((debtPmt0.amount > lendedAmt)) | |
354 | + | then throw(((("attached payment is grater than required: pmtAmount=" + toString(debtPmt0.amount)) + " lendedAmt=") + toString(lendedAmt))) | |
355 | + | else { | |
356 | + | let totalLendedAtOtherAccs = valueOrElse(getInteger(this, keyTotalLendedAtOtherAccs()), 0) | |
357 | + | let lendedAmtAfter = (lendedAmt - debtPmt0.amount) | |
329 | 358 | [IntegerEntry(lendedAmountByAssetCodeKey, lendedAmtAfter), IntegerEntry(keyTotalLendedAtOtherAccs(), (totalLendedAtOtherAccs - debtPmt0.amount)), StringEntry(("%s%s__rebalanceTrace__" + toBase58String(i.transactionId)), assetDataRebalanceTrace(debtorAssetCode, debtPmt0, basePmt1, lendedAmt, lendedAmtAfter))] | |
330 | - | } | |
359 | + | } | |
331 | 360 | } | |
332 | 361 | ||
333 | 362 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 4 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | func keyAccumulatedFee () = "%s__accumulatedFee" | |
5 | 5 | ||
6 | 6 | ||
7 | 7 | func keyUcollateral () = "%s__ucollateral" | |
8 | 8 | ||
9 | 9 | ||
10 | 10 | func keyTotalLendedAtOtherAccs () = "%s__totalLendedAtOtherAccs" | |
11 | 11 | ||
12 | 12 | ||
13 | 13 | func keyAssetLockedTotal (assetId) = ("%s%s__assetLockedTotal__" + assetId) | |
14 | 14 | ||
15 | 15 | ||
16 | 16 | func keyAccountOperation (unlockHeight,address,status) = ((((("%s%s%d%s__defoAssetOperation__" + address) + "__") + toString(unlockHeight)) + "__") + status) | |
17 | 17 | ||
18 | 18 | ||
19 | 19 | func keyFactory () = "%s__factory" | |
20 | 20 | ||
21 | 21 | ||
22 | 22 | func keyLendedAmountByAssetCode (assetCode) = ("%s%s__lendedBaseAssetAmount__" + assetCode) | |
23 | 23 | ||
24 | 24 | ||
25 | 25 | func keyPrice (assetCode) = ("%s%s__price__" + assetCode) | |
26 | + | ||
27 | + | ||
28 | + | func keyControlLastHeight (assetCode) = ("%s%s__lastHeight__" + assetCode) | |
26 | 29 | ||
27 | 30 | ||
28 | 31 | let IdxOperationAmountIn = 1 | |
29 | 32 | ||
30 | 33 | let IdxOperationAssetIn = 2 | |
31 | 34 | ||
32 | 35 | let IdxOperationPrice = 3 | |
33 | 36 | ||
34 | 37 | let IdxOperationAmountOut = 4 | |
35 | 38 | ||
36 | 39 | let IdxOperationAssetOut = 5 | |
37 | 40 | ||
38 | 41 | func assetDataSwapOperation (amountIn,assetIn,price,amountOut,assetOut,bruttoAmount,feeAmount) = makeString(["%d%s%d%s%d%d%d", toString(amountIn), assetIn, toString(amountOut), assetOut, toString(price), toString(bruttoAmount), toString(feeAmount)], "__") | |
39 | 42 | ||
40 | 43 | ||
41 | 44 | func assetDataRebalanceTrace (debtorAssetCode,debtPmt,basePmt,lendedAmtBefore,lendedAmtAfter) = makeString(["%s%s%d%s%d%d%d", debtorAssetCode, toBase58String(value(debtPmt.assetId)), toString(debtPmt.amount), toBase58String(value(basePmt.assetId)), toString(basePmt.amount), toString(lendedAmtBefore), toString(lendedAmtAfter)], "__") | |
42 | 45 | ||
43 | 46 | ||
44 | 47 | func assetReadSwapDataArrayOrFail (accOperationKey) = { | |
45 | 48 | let accOperationDataStr = valueOrErrorMessage(getString(this, accOperationKey), ("There is no request for passed arguments: " + accOperationKey)) | |
46 | 49 | split(accOperationDataStr, "__") | |
47 | 50 | } | |
48 | 51 | ||
49 | 52 | ||
50 | 53 | let nullInt = -1 | |
51 | 54 | ||
52 | 55 | let nullStr = "NULL" | |
53 | 56 | ||
54 | 57 | let factoryAcc = addressFromStringValue(valueOrErrorMessage(getString(this, keyFactory()), ((("No config at this=" + toString(this)) + " for key=") + keyFactory()))) | |
55 | 58 | ||
56 | 59 | func keyFactoryDebtAssetId () = "%s%s__commonConfig__debtAssetId" | |
57 | 60 | ||
58 | 61 | ||
59 | 62 | func keyFactoryDebtAssetEtalonBalance () = "%s%s__commonConfig__debtAssetEtalonBalance" | |
60 | 63 | ||
61 | 64 | ||
62 | 65 | func keyFactoryAssetCfg (assetAddressStr) = (("%s%s%s__defoAsset__" + assetAddressStr) + "__config") | |
63 | 66 | ||
64 | 67 | ||
65 | 68 | func keyFactoryAssetCurrentPool (assetAccAddress) = (("%s%s%s__defoAsset__" + toString(assetAccAddress)) + "__currentPool") | |
66 | 69 | ||
67 | 70 | ||
68 | 71 | func keyFactoryDefoAddressByAssetCode (assetCode) = (("%s%s%s__defoAsset__" + assetCode) + "__addressByAssetCode") | |
69 | 72 | ||
70 | 73 | ||
71 | 74 | func keyFactoryAssetPoolMakers (assetAddress) = (("%s%s%s__defoAsset__" + assetAddress) + "__poolMakers") | |
72 | 75 | ||
73 | 76 | ||
74 | 77 | func keyFactoryDefoStakingPacemakerPub () = "%s%s__commonConfig__defoStakingPacemakerPub" | |
75 | 78 | ||
76 | 79 | ||
77 | 80 | func factoryReadDebtAssetId () = valueOrErrorMessage(getString(factoryAcc, keyFactoryDebtAssetId()), ((("No config at factory=" + toString(factoryAcc)) + " for key=") + keyFactoryDebtAssetId())) | |
78 | 81 | ||
79 | 82 | ||
80 | 83 | func factoryReadAssetCfgByAddress (assetAddressStr) = split(valueOrErrorMessage(getString(factoryAcc, keyFactoryAssetCfg(assetAddressStr)), ((("No config at factory=" + toString(factoryAcc)) + " for key=") + keyFactoryAssetCfg(assetAddressStr))), "__") | |
81 | 84 | ||
82 | 85 | ||
83 | 86 | func factoryReadAssetCfgByCode (assetCode) = { | |
84 | 87 | let assetAddressStr = valueOrErrorMessage(getString(factoryAcc, keyFactoryDefoAddressByAssetCode(assetCode)), ((("No config at factory=" + toString(factoryAcc)) + " for key=") + keyFactoryDefoAddressByAssetCode(assetCode))) | |
85 | 88 | $Tuple2(assetAddressStr, factoryReadAssetCfgByAddress(assetAddressStr)) | |
86 | 89 | } | |
87 | 90 | ||
88 | 91 | ||
89 | 92 | func factoryReadNextPoolMakerToDistributeFee (assetAddressStr) = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(factoryAcc, keyFactoryAssetPoolMakers(assetAddressStr)), ((("No config at factory=" + toString(factoryAcc)) + " for key=") + keyFactoryAssetPoolMakers(assetAddressStr)))), ("address extraction error for key=" + keyFactoryAssetPoolMakers(assetAddressStr))) | |
90 | 93 | ||
91 | 94 | ||
92 | 95 | func factoryReadDefoStakingPacemakerPub () = fromBase58String(valueOrErrorMessage(getString(factoryAcc, keyFactoryDefoStakingPacemakerPub()), ((("No config at factory=" + toString(factoryAcc)) + " for key=") + keyFactoryDefoStakingPacemakerPub()))) | |
93 | 96 | ||
94 | 97 | ||
95 | 98 | let IdxDefoAssetCode = 1 | |
96 | 99 | ||
97 | 100 | let IdxDefoAssetId = 2 | |
98 | 101 | ||
99 | 102 | let IdxDefoAssetStatus = 3 | |
100 | 103 | ||
101 | 104 | let IdxPriceDecimals = 4 | |
102 | 105 | ||
103 | 106 | let IdxBaseAssetId = 5 | |
104 | 107 | ||
105 | 108 | let IdxOverCollateralPercent = 6 | |
106 | 109 | ||
107 | 110 | let IdxMinInitPool = 7 | |
108 | 111 | ||
109 | 112 | let IdxPriceOracleAddress = 8 | |
110 | 113 | ||
111 | 114 | let IdxMinBuyPayment = 9 | |
112 | 115 | ||
113 | 116 | let IdxMinSellPayment = 10 | |
114 | 117 | ||
115 | 118 | let IdxBuyLockInterval = 11 | |
116 | 119 | ||
117 | 120 | let IdxSellLockInterval = 12 | |
118 | 121 | ||
119 | 122 | let IdxBuyFeePercent = 13 | |
120 | 123 | ||
121 | 124 | let IdxSellFeePercent = 14 | |
122 | 125 | ||
123 | 126 | let thisCfgArray = factoryReadAssetCfgByAddress(toString(this)) | |
124 | 127 | ||
125 | 128 | let defoAssetCode = thisCfgArray[IdxDefoAssetCode] | |
126 | 129 | ||
127 | 130 | let defoAssetIdStr = thisCfgArray[IdxDefoAssetId] | |
128 | 131 | ||
129 | 132 | let defoAssetId = fromBase58String(defoAssetIdStr) | |
130 | 133 | ||
131 | 134 | let priceOracleAcc = addressFromStringValue(thisCfgArray[IdxPriceOracleAddress]) | |
132 | 135 | ||
133 | 136 | let overCollateralPercent = parseIntValue(thisCfgArray[IdxOverCollateralPercent]) | |
134 | 137 | ||
135 | 138 | let baseAssetIdStr = thisCfgArray[IdxBaseAssetId] | |
136 | 139 | ||
137 | 140 | let baseAssetId = fromBase58String(baseAssetIdStr) | |
138 | 141 | ||
139 | 142 | let priceDecimals = parseIntValue(thisCfgArray[IdxPriceDecimals]) | |
140 | 143 | ||
141 | 144 | let minBasicBuyAmount = parseIntValue(thisCfgArray[IdxMinBuyPayment]) | |
142 | 145 | ||
143 | 146 | let minSynthSellAmount = parseIntValue(thisCfgArray[IdxMinSellPayment]) | |
144 | 147 | ||
145 | 148 | let buyLockInterval = parseIntValue(thisCfgArray[IdxBuyLockInterval]) | |
146 | 149 | ||
147 | 150 | let sellLockInterval = parseIntValue(thisCfgArray[IdxSellLockInterval]) | |
148 | 151 | ||
149 | 152 | let buyFeePercent = parseIntValue(thisCfgArray[IdxBuyFeePercent]) | |
150 | 153 | ||
151 | 154 | let sellFeePercent = parseIntValue(thisCfgArray[IdxSellFeePercent]) | |
152 | 155 | ||
156 | + | func keyIsBlocked () = "%s__isBlocked" | |
157 | + | ||
158 | + | ||
159 | + | let isBlocked = valueOrElse(getBoolean(priceOracleAcc, keyIsBlocked()), false) | |
160 | + | ||
153 | 161 | func controlAccReadPrice (assetCode) = valueOrErrorMessage(getInteger(priceOracleAcc, keyPrice(assetCode)), ((("No price at priceOracle=" + toString(priceOracleAcc)) + " for key=") + keyPrice(assetCode))) | |
162 | + | ||
163 | + | ||
164 | + | func controlAccReadLastHeight (assetCode) = valueOrErrorMessage(getInteger(priceOracleAcc, keyControlLastHeight(assetCode)), ((("No lastHeight at priceOracle=" + toString(priceOracleAcc)) + " for key=") + keyControlLastHeight(assetCode))) | |
154 | 165 | ||
155 | 166 | ||
156 | 167 | func controlAccReadCurrIdxOrFail () = valueOrErrorMessage(getInteger(priceOracleAcc, "currIdx"), ("No currIdx at controlAcc=" + toString(priceOracleAcc))) | |
157 | 168 | ||
158 | 169 | ||
159 | 170 | func controlAccReadIdxHeight (idx) = { | |
160 | 171 | let idxHeightKey = ("idxHeight_" + toString(idx)) | |
161 | 172 | valueOrElse(getInteger(priceOracleAcc, idxHeightKey), 0) | |
162 | 173 | } | |
163 | 174 | ||
164 | 175 | ||
165 | 176 | func controlAccReadPriceByHeight (priceHeight) = { | |
166 | 177 | let priceByHeightKey = ("price_" + toString(priceHeight)) | |
167 | 178 | valueOrErrorMessage(getInteger(priceOracleAcc, priceByHeightKey), ((("No " + priceByHeightKey) + " at controlAcc=") + toString(priceOracleAcc))) | |
168 | 179 | } | |
169 | 180 | ||
181 | + | ||
182 | + | let priceLastHeight = controlAccReadLastHeight(defoAssetCode) | |
183 | + | ||
184 | + | let isBlockedByLastHeight = ((priceLastHeight - priceLastHeight) > 5) | |
170 | 185 | ||
171 | 186 | let keyDefoStakingAddress = "%s%s__commonConfig__defoStakingAddress" | |
172 | 187 | ||
173 | 188 | let keyNeutrinoStakingAddress = "%s%s__commonConfig__neutrinoStakingAddress" | |
174 | 189 | ||
175 | 190 | func keyDefoStakingAssetBalance (assetId) = ("%s%s__stakingBalance__" + assetId) | |
176 | 191 | ||
177 | 192 | ||
178 | 193 | func keyNeutrinoStakingBalance () = ((("rpd_balance_" + baseAssetIdStr) + "_") + toString(this)) | |
179 | 194 | ||
180 | 195 | ||
181 | 196 | let defoStakingAcc = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(factoryAcc, keyDefoStakingAddress), ((("No config at factoryAcc" + toString(factoryAcc)) + " for key=") + keyDefoStakingAddress))), ("address extraction error for key=" + keyDefoStakingAddress)) | |
182 | 197 | ||
183 | 198 | let neutrinoStakingAcc = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(factoryAcc, keyNeutrinoStakingAddress), ((("No config at factoryAcc" + toString(factoryAcc)) + " for key=") + keyNeutrinoStakingAddress))), ("address extraction error for key=" + keyNeutrinoStakingAddress)) | |
184 | 199 | ||
185 | 200 | func getThisDefoStakingBalance () = valueOrElse(getInteger(defoStakingAcc, keyDefoStakingAssetBalance(defoAssetIdStr)), 0) | |
186 | 201 | ||
187 | 202 | ||
188 | 203 | func getThisNeutrinoStakingBalance () = valueOrElse(getInteger(neutrinoStakingAcc, keyNeutrinoStakingBalance()), 0) | |
189 | 204 | ||
190 | 205 | ||
191 | 206 | let ucollateral = valueOrElse(getInteger(this, keyUcollateral()), 0) | |
192 | 207 | ||
193 | 208 | let accumulatedFee = valueOrElse(getInteger(this, keyAccumulatedFee()), 0) | |
194 | 209 | ||
195 | 210 | let currPoolAmount = getIntegerValue(factoryAcc, keyFactoryAssetCurrentPool(this)) | |
196 | 211 | ||
197 | 212 | let debtAssetId = fromBase58String(factoryReadDebtAssetId()) | |
198 | 213 | ||
199 | 214 | let debtAssetEtalonBalance = getIntegerValue(factoryAcc, keyFactoryDebtAssetEtalonBalance()) | |
200 | 215 | ||
201 | 216 | let lendedOrDebtAmount = (debtAssetEtalonBalance - assetBalance(this, debtAssetId)) | |
202 | 217 | ||
203 | 218 | let currentBaseAssetBalance = ((assetBalance(this, baseAssetId) + getThisNeutrinoStakingBalance()) + lendedOrDebtAmount) | |
204 | 219 | ||
205 | 220 | let price = controlAccReadPrice(thisCfgArray[IdxDefoAssetCode]) | |
206 | 221 | ||
207 | 222 | let overPrice = (((priceDecimals + overCollateralPercent) * price) / priceDecimals) | |
208 | 223 | ||
209 | 224 | let emission = (value(assetInfo(defoAssetId)).quantity - assetBalance(this, defoAssetId)) | |
210 | 225 | ||
211 | 226 | func internalBuyAsset (sellerAddr,sellAmt,sellAssetId,minSellAmt,buy2sellPrice,feePercent) = { | |
212 | - | let availableDefoAssetInPool = (fraction(currentBaseAssetBalance, overPrice, priceDecimals) - emission) | |
213 | - | let defoAssetAmountNoPoolLimit = fraction(sellAmt, buy2sellPrice, priceDecimals) | |
214 | - | let defoAssetAmountGross = if ((defoAssetAmountNoPoolLimit > availableDefoAssetInPool)) | |
215 | - | then availableDefoAssetInPool | |
216 | - | else defoAssetAmountNoPoolLimit | |
227 | + | let defoAssetAmountGross = fraction(sellAmt, buy2sellPrice, priceDecimals) | |
217 | 228 | let defoAssetAmount = fraction((priceDecimals - feePercent), defoAssetAmountGross, priceDecimals) | |
218 | 229 | let feeAmount = (defoAssetAmountGross - defoAssetAmount) | |
219 | 230 | let requiredBasicAssetAmount = fraction(defoAssetAmountGross, priceDecimals, buy2sellPrice) | |
220 | 231 | let change = (sellAmt - requiredBasicAssetAmount) | |
221 | - | if ((0 >= availableDefoAssetInPool)) | |
222 | - | then throw((("impossible to issue new " + defoAssetCode) + ": not enough collateral")) | |
223 | - | else if (if ((minSellAmt > sellAmt)) | |
224 | - | then (toString(sellerAddr) != toString(defoStakingAcc)) | |
225 | - | else false) | |
226 | - | then throw(((((("impossible to issue new " + defoAssetCode) + ": payment=") + toString(sellAmt)) + "is less then min amount=") + toString(minSellAmt))) | |
227 | - | else $Tuple2([IntegerEntry(keyUcollateral(), (ucollateral + requiredBasicAssetAmount)), StringEntry(keyAccountOperation(height, toString(sellerAddr), "FINISHED"), assetDataSwapOperation(sellAmt, toBase58String(sellAssetId), price, defoAssetAmount, toBase58String(defoAssetId), defoAssetAmountGross, feeAmount)), Reissue(defoAssetId, (defoAssetAmount + feeAmount), true), ScriptTransfer(sellerAddr, defoAssetAmount, defoAssetId), ScriptTransfer(sellerAddr, change, sellAssetId), ScriptTransfer(factoryReadNextPoolMakerToDistributeFee(toString(this)), feeAmount, defoAssetId), IntegerEntry(keyAccumulatedFee(), (accumulatedFee + feeAmount))], change) | |
232 | + | if (if ((minSellAmt > sellAmt)) | |
233 | + | then (toString(sellerAddr) != toString(defoStakingAcc)) | |
234 | + | else false) | |
235 | + | then throw(((((("impossible to issue new " + defoAssetCode) + ": payment=") + toString(sellAmt)) + "is less then min amount=") + toString(minSellAmt))) | |
236 | + | else $Tuple2([IntegerEntry(keyUcollateral(), (ucollateral + requiredBasicAssetAmount)), StringEntry(keyAccountOperation(height, toString(sellerAddr), "FINISHED"), assetDataSwapOperation(sellAmt, toBase58String(sellAssetId), price, defoAssetAmount, toBase58String(defoAssetId), defoAssetAmountGross, feeAmount)), Reissue(defoAssetId, (defoAssetAmount + feeAmount), true), ScriptTransfer(sellerAddr, defoAssetAmount, defoAssetId), ScriptTransfer(sellerAddr, change, sellAssetId), ScriptTransfer(factoryReadNextPoolMakerToDistributeFee(toString(this)), feeAmount, defoAssetId), IntegerEntry(keyAccumulatedFee(), (accumulatedFee + feeAmount))], change) | |
228 | 237 | } | |
229 | 238 | ||
230 | 239 | ||
231 | 240 | @Callable(i) | |
232 | 241 | func buyAsset () = { | |
233 | 242 | let pmt = value(i.payments[0]) | |
234 | 243 | let pmtAssetId = value(pmt.assetId) | |
235 | - | if ((pmtAssetId != baseAssetId)) | |
236 | - | then throw(((("Payment asset id doesn't match basic asset: expected=" + toBase58String(baseAssetId)) + " actual=") + toBase58String(pmtAssetId))) | |
237 | - | else internalBuyAsset(i.caller, pmt.amount, pmtAssetId, minBasicBuyAmount, price, buyFeePercent)._1 | |
244 | + | if (isBlocked) | |
245 | + | then throw("contract is blocked by EMERGENCY SHUTDOWN actions untill reactivation by emergency oracles") | |
246 | + | else if (isBlockedByLastHeight) | |
247 | + | then throw(((("last price finalization has been more then 5 blocks ago: priceLastHeight=" + toString(priceLastHeight)) + " currHeight=") + toString(height))) | |
248 | + | else if ((pmtAssetId != baseAssetId)) | |
249 | + | then throw(((("Payment asset id doesn't match basic asset: expected=" + toBase58String(baseAssetId)) + " actual=") + toBase58String(pmtAssetId))) | |
250 | + | else internalBuyAsset(i.caller, pmt.amount, pmtAssetId, minBasicBuyAmount, price, buyFeePercent)._1 | |
238 | 251 | } | |
239 | 252 | ||
240 | 253 | ||
241 | 254 | ||
242 | 255 | @Callable(i) | |
243 | 256 | func sellAsset () = { | |
244 | 257 | let pmt = value(i.payments[0]) | |
245 | 258 | let pmtAsset = value(pmt.assetId) | |
246 | 259 | let callerAddress = toString(i.caller) | |
247 | - | if ((pmtAsset != defoAssetId)) | |
248 | - | then throw(((("Invalid payment asset id: expected=" + toBase58String(defoAssetId)) + " actual=") + toBase58String(pmtAsset))) | |
249 | - | else if ((minSynthSellAmount > pmt.amount)) | |
250 | - | then throw(((("Payment amount less then mininimal allowed: paymentAmount=" + toString(pmt.amount)) + " minAmount=") + toString(minSynthSellAmount))) | |
251 | - | else { | |
252 | - | let baseAssetAmountNoBalanceLimit = fraction(pmt.amount, priceDecimals, price) | |
253 | - | let baseAssetAmountAvailable = if ((baseAssetAmountNoBalanceLimit > currentBaseAssetBalance)) | |
254 | - | then currentBaseAssetBalance | |
255 | - | else baseAssetAmountNoBalanceLimit | |
256 | - | let soldDefoAssetAmountGross = fraction(baseAssetAmountAvailable, price, priceDecimals) | |
257 | - | let change = (pmt.amount - soldDefoAssetAmountGross) | |
258 | - | let defoAmountFee = fraction(sellFeePercent, soldDefoAssetAmountGross, priceDecimals) | |
259 | - | let soldDefoAssetAmount = (soldDefoAssetAmountGross - defoAmountFee) | |
260 | - | let baseAssetAmountToSend = fraction(soldDefoAssetAmount, priceDecimals, price) | |
260 | + | if (isBlocked) | |
261 | + | then throw("contract is blocked by EMERGENCY SHUTDOWN actions untill reactivation by emergency oracles") | |
262 | + | else if (isBlockedByLastHeight) | |
263 | + | then throw(((("last price finalization has been more then 5 blocks ago: priceLastHeight=" + toString(priceLastHeight)) + " currHeight=") + toString(height))) | |
264 | + | else if ((pmtAsset != defoAssetId)) | |
265 | + | then throw(((("Invalid payment asset id: expected=" + toBase58String(defoAssetId)) + " actual=") + toBase58String(pmtAsset))) | |
266 | + | else if ((minSynthSellAmount > pmt.amount)) | |
267 | + | then throw(((("Payment amount less then mininimal allowed: paymentAmount=" + toString(pmt.amount)) + " minAmount=") + toString(minSynthSellAmount))) | |
268 | + | else { | |
269 | + | let baseAssetAmountNoBalanceLimit = fraction(pmt.amount, priceDecimals, price) | |
270 | + | let baseAssetAmountAvailable = if ((baseAssetAmountNoBalanceLimit > currentBaseAssetBalance)) | |
271 | + | then currentBaseAssetBalance | |
272 | + | else baseAssetAmountNoBalanceLimit | |
273 | + | let soldDefoAssetAmountGross = fraction(baseAssetAmountAvailable, price, priceDecimals) | |
274 | + | let change = (pmt.amount - soldDefoAssetAmountGross) | |
275 | + | let defoAmountFee = fraction(sellFeePercent, soldDefoAssetAmountGross, priceDecimals) | |
276 | + | let soldDefoAssetAmount = (soldDefoAssetAmountGross - defoAmountFee) | |
277 | + | let baseAssetAmountToSend = fraction(soldDefoAssetAmount, priceDecimals, price) | |
261 | 278 | [IntegerEntry(keyUcollateral(), (ucollateral - baseAssetAmountToSend)), StringEntry(keyAccountOperation(height, callerAddress, "FINISHED"), assetDataSwapOperation(pmt.amount, toBase58String(pmtAsset), price, baseAssetAmountToSend, baseAssetIdStr, soldDefoAssetAmountGross, defoAmountFee)), Burn(defoAssetId, soldDefoAssetAmount), ScriptTransfer(i.caller, baseAssetAmountToSend, baseAssetId), ScriptTransfer(i.caller, change, defoAssetId), ScriptTransfer(factoryReadNextPoolMakerToDistributeFee(toString(this)), defoAmountFee, defoAssetId), IntegerEntry(keyAccumulatedFee(), (accumulatedFee + defoAmountFee))] | |
262 | - | } | |
279 | + | } | |
263 | 280 | } | |
264 | 281 | ||
265 | 282 | ||
266 | 283 | ||
267 | 284 | @Callable(i) | |
268 | 285 | func crossExchange (buyAssetCodeConfirm,sellAssetCodeConfirm) = { | |
269 | 286 | let pmt = value(i.payments[0]) | |
270 | 287 | let pmtAsset = value(pmt.assetId) | |
271 | 288 | let pmtAssetStr = toBase58String(pmtAsset) | |
272 | 289 | let pmtAmount = pmt.amount | |
273 | 290 | let callerAddress = toString(i.caller) | |
274 | 291 | let buyAssetCfg = thisCfgArray | |
275 | 292 | let sellAssetTuple = factoryReadAssetCfgByCode(sellAssetCodeConfirm) | |
276 | 293 | let sellAssetCfg = sellAssetTuple._2 | |
277 | 294 | let sellAssetAccAddress = valueOrErrorMessage(addressFromString(sellAssetTuple._1), ("couldn't parse address from string for assetCode=" + sellAssetCodeConfirm)) | |
278 | 295 | let minSellPmt = valueOrErrorMessage(parseInt(sellAssetCfg[IdxMinSellPayment]), ("minSellPmt parsing error: rawVal=" + sellAssetCfg[IdxMinSellPayment])) | |
279 | - | if ((thisCfgArray[IdxDefoAssetCode] != buyAssetCodeConfirm)) | |
280 | - | then throw(((("buyAsset confirmation failed: buyAssetIdConfirm=" + thisCfgArray[IdxDefoAssetCode]) + " BUT buyAssetId=") + buyAssetCodeConfirm)) | |
281 | - | else if ((sellAssetCfg[IdxDefoAssetId] != pmtAssetStr)) | |
282 | - | then throw(((("sellAsset confirmation failed: sellAssetIdConfirm=" + sellAssetCfg[IdxDefoAssetId]) + "BUT pmtAsset=") + pmtAssetStr)) | |
283 | - | else if ((thisCfgArray[IdxDefoAssetStatus] != "ISSUED")) | |
284 | - | then throw(((("toAsset has not been issued yet: buyAssetId=" + buyAssetCodeConfirm) + " BUT status=") + thisCfgArray[IdxDefoAssetStatus])) | |
285 | - | else if ((sellAssetCfg[IdxDefoAssetStatus] != "ISSUED")) | |
286 | - | then throw(((("fromAssetCfg has not been issued yet: sellAssetId=" + pmtAssetStr) + " BUT status=") + sellAssetCfg[IdxDefoAssetStatus])) | |
287 | - | else { | |
288 | - | let buyAssetUsdPrice = price | |
289 | - | let sellAssetUsdPrice = controlAccReadPrice(sellAssetCodeConfirm) | |
290 | - | let buy2sellPrice = fraction(buyAssetUsdPrice, priceDecimals, sellAssetUsdPrice) | |
291 | - | let usdnDebt = fraction(pmtAmount, priceDecimals, sellAssetUsdPrice) | |
292 | - | let totalLendedAtOtherAccs = valueOrElse(getInteger(this, keyTotalLendedAtOtherAccs()), 0) | |
293 | - | let lendedAmountByAssetCodeKey = keyLendedAmountByAssetCode(sellAssetCodeConfirm) | |
294 | - | let lendedAmtByAssetCode = valueOrElse(getInteger(this, lendedAmountByAssetCodeKey), 0) | |
295 | - | let sellAssetSellFeePercent = parseIntValue(sellAssetCfg[IdxSellFeePercent]) | |
296 | - | let buyAssetResult = internalBuyAsset(i.caller, pmtAmount, pmtAsset, minSellPmt, buy2sellPrice, fraction((buyFeePercent + sellAssetSellFeePercent), 75, 100)) | |
297 | - | ((((buyAssetResult._1 :+ ScriptTransfer(sellAssetAccAddress, usdnDebt, debtAssetId)) :+ ScriptTransfer(sellAssetAccAddress, (pmtAmount - buyAssetResult._2), pmtAsset)) :+ IntegerEntry(lendedAmountByAssetCodeKey, (lendedAmtByAssetCode + usdnDebt))) :+ IntegerEntry(keyTotalLendedAtOtherAccs(), (totalLendedAtOtherAccs + usdnDebt))) | |
298 | - | } | |
296 | + | let sellPriceLastHeight = controlAccReadLastHeight(sellAssetCodeConfirm) | |
297 | + | let isSellBlockedByLastHeight = ((sellPriceLastHeight - sellPriceLastHeight) > 5) | |
298 | + | if (isBlocked) | |
299 | + | then throw("contract is blocked by EMERGENCY SHUTDOWN actions untill reactivation by emergency oracles") | |
300 | + | else if ((sellAssetCfg[IdxDefoAssetCode] == "NGN")) | |
301 | + | then throw("crossExchange for NGN is temporary disabled") | |
302 | + | else if ((thisCfgArray[IdxDefoAssetCode] != buyAssetCodeConfirm)) | |
303 | + | then throw(((("buyAsset confirmation failed: buyAssetIdConfirm=" + thisCfgArray[IdxDefoAssetCode]) + " BUT buyAssetId=") + buyAssetCodeConfirm)) | |
304 | + | else if ((sellAssetCfg[IdxDefoAssetId] != pmtAssetStr)) | |
305 | + | then throw(((("sellAsset confirmation failed: sellAssetIdConfirm=" + sellAssetCfg[IdxDefoAssetId]) + "BUT pmtAsset=") + pmtAssetStr)) | |
306 | + | else if ((thisCfgArray[IdxDefoAssetStatus] != "ISSUED")) | |
307 | + | then throw(((("toAsset has not been issued yet: buyAssetId=" + buyAssetCodeConfirm) + " BUT status=") + thisCfgArray[IdxDefoAssetStatus])) | |
308 | + | else if ((sellAssetCfg[IdxDefoAssetStatus] != "ISSUED")) | |
309 | + | then throw(((("fromAssetCfg has not been issued yet: sellAssetId=" + pmtAssetStr) + " BUT status=") + sellAssetCfg[IdxDefoAssetStatus])) | |
310 | + | else if (isBlockedByLastHeight) | |
311 | + | then throw(((((("buy last price finalization has been more then 5 blocks ago: priceLastHeight=" + toString(priceLastHeight)) + " currHeight=") + toString(height)) + " buyCode=") + buyAssetCodeConfirm)) | |
312 | + | else if (isSellBlockedByLastHeight) | |
313 | + | then throw(((((("sell last price finalization has been more then 5 blocks ago: priceLastHeight=" + toString(priceLastHeight)) + " currHeight=") + toString(height)) + " sellCode=") + sellAssetCodeConfirm)) | |
314 | + | else { | |
315 | + | let buyAssetUsdPrice = price | |
316 | + | let sellAssetUsdPrice = controlAccReadPrice(sellAssetCodeConfirm) | |
317 | + | let buy2sellPrice = fraction(buyAssetUsdPrice, priceDecimals, sellAssetUsdPrice) | |
318 | + | let usdnDebt = fraction(pmtAmount, priceDecimals, sellAssetUsdPrice) | |
319 | + | let totalLendedAtOtherAccs = valueOrElse(getInteger(this, keyTotalLendedAtOtherAccs()), 0) | |
320 | + | let lendedAmountByAssetCodeKey = keyLendedAmountByAssetCode(sellAssetCodeConfirm) | |
321 | + | let lendedAmtByAssetCode = valueOrElse(getInteger(this, lendedAmountByAssetCodeKey), 0) | |
322 | + | let sellAssetSellFeePercent = parseIntValue(sellAssetCfg[IdxSellFeePercent]) | |
323 | + | let buyAssetResult = internalBuyAsset(i.caller, pmtAmount, pmtAsset, minSellPmt, buy2sellPrice, fraction((buyFeePercent + sellAssetSellFeePercent), 50, 100)) | |
324 | + | ((((buyAssetResult._1 :+ ScriptTransfer(sellAssetAccAddress, usdnDebt, debtAssetId)) :+ ScriptTransfer(sellAssetAccAddress, (pmtAmount - buyAssetResult._2), pmtAsset)) :+ IntegerEntry(lendedAmountByAssetCodeKey, (lendedAmtByAssetCode + usdnDebt))) :+ IntegerEntry(keyTotalLendedAtOtherAccs(), (totalLendedAtOtherAccs + usdnDebt))) | |
325 | + | } | |
299 | 326 | } | |
300 | 327 | ||
301 | 328 | ||
302 | 329 | ||
303 | 330 | @Callable(i) | |
304 | 331 | func rebalanceDebts () = { | |
305 | 332 | let debtPmt0 = value(i.payments[0]) | |
306 | 333 | let debtPmtAsset0 = value(debtPmt0.assetId) | |
307 | 334 | let basePmt1 = value(i.payments[1]) | |
308 | 335 | let basePmtAsset1 = value(basePmt1.assetId) | |
309 | 336 | let debtorAddress = toString(i.caller) | |
310 | 337 | let debtorAssetCfg = factoryReadAssetCfgByAddress(debtorAddress) | |
311 | 338 | let debtorAssetCode = debtorAssetCfg[IdxDefoAssetCode] | |
312 | 339 | let lendedAmountByAssetCodeKey = keyLendedAmountByAssetCode(debtorAssetCode) | |
313 | 340 | let lendedAmt = valueOrErrorMessage(getInteger(this, lendedAmountByAssetCodeKey), ("No debts for " + debtorAssetCode)) | |
314 | - | if ((debtAssetId != debtPmtAsset0)) | |
315 | - | then throw(((("invalid debt asset id in the first paymet: expected=" + toBase58String(debtAssetId)) + " actual=") + toBase58String(debtPmtAsset0))) | |
316 | - | else if ((baseAssetId != basePmtAsset1)) | |
317 | - | then throw(((("invalid base asset id in the second payment: expected=" + toBase58String(baseAssetId)) + " actual=") + toBase58String(basePmtAsset1))) | |
318 | - | else if ((debtPmt0.amount != basePmt1.amount)) | |
319 | - | then throw("first payment amount doesn't match to the second payment amount") | |
320 | - | else if ((0 >= lendedAmt)) | |
321 | - | then throw(("lendedAmt is less then zero: lendedAmt=" + toString(lendedAmt))) | |
322 | - | else if ((minBasicBuyAmount >= debtPmt0.amount)) | |
323 | - | then throw(((("attached payment must be greater then minBasicBuyAmount: pmt0.amount=" + toString(debtPmt0.amount)) + " minBasicBuyAmount=") + toString(minBasicBuyAmount))) | |
324 | - | else if ((debtPmt0.amount > lendedAmt)) | |
325 | - | then throw(((("attached payment is grater than required: pmtAmount=" + toString(debtPmt0.amount)) + " lendedAmt=") + toString(lendedAmt))) | |
326 | - | else { | |
327 | - | let totalLendedAtOtherAccs = valueOrElse(getInteger(this, keyTotalLendedAtOtherAccs()), 0) | |
328 | - | let lendedAmtAfter = (lendedAmt - debtPmt0.amount) | |
341 | + | if (isBlocked) | |
342 | + | then throw("contract is blocked by EMERGENCY SHUTDOWN actions untill reactivation by emergency oracles") | |
343 | + | else if ((debtAssetId != debtPmtAsset0)) | |
344 | + | then throw(((("invalid debt asset id in the first paymet: expected=" + toBase58String(debtAssetId)) + " actual=") + toBase58String(debtPmtAsset0))) | |
345 | + | else if ((baseAssetId != basePmtAsset1)) | |
346 | + | then throw(((("invalid base asset id in the second payment: expected=" + toBase58String(baseAssetId)) + " actual=") + toBase58String(basePmtAsset1))) | |
347 | + | else if ((debtPmt0.amount != basePmt1.amount)) | |
348 | + | then throw("first payment amount doesn't match to the second payment amount") | |
349 | + | else if ((0 >= lendedAmt)) | |
350 | + | then throw(("lendedAmt is less then zero: lendedAmt=" + toString(lendedAmt))) | |
351 | + | else if (((100 * priceDecimals) >= debtPmt0.amount)) | |
352 | + | then throw(("attached payment must be greater then 100: pmt0.amount=" + toString(debtPmt0.amount))) | |
353 | + | else if ((debtPmt0.amount > lendedAmt)) | |
354 | + | then throw(((("attached payment is grater than required: pmtAmount=" + toString(debtPmt0.amount)) + " lendedAmt=") + toString(lendedAmt))) | |
355 | + | else { | |
356 | + | let totalLendedAtOtherAccs = valueOrElse(getInteger(this, keyTotalLendedAtOtherAccs()), 0) | |
357 | + | let lendedAmtAfter = (lendedAmt - debtPmt0.amount) | |
329 | 358 | [IntegerEntry(lendedAmountByAssetCodeKey, lendedAmtAfter), IntegerEntry(keyTotalLendedAtOtherAccs(), (totalLendedAtOtherAccs - debtPmt0.amount)), StringEntry(("%s%s__rebalanceTrace__" + toBase58String(i.transactionId)), assetDataRebalanceTrace(debtorAssetCode, debtPmt0, basePmt1, lendedAmt, lendedAmtAfter))] | |
330 | - | } | |
359 | + | } | |
331 | 360 | } | |
332 | 361 | ||
333 | 362 | ||
334 | 363 | @Verifier(tx) | |
335 | 364 | func verify () = match tx { | |
336 | 365 | case inv: InvokeScriptTransaction => | |
337 | 366 | if ((inv.fee > (900 * 1000))) | |
338 | 367 | then throw(("fee amount is greater than max allowed: " + toString(inv.fee))) | |
339 | 368 | else if (isDefined(inv.feeAssetId)) | |
340 | 369 | then throw("only Waves is allowed as feeAssetId") | |
341 | 370 | else if ((inv.function == "rebalanceDebts")) | |
342 | 371 | then { | |
343 | 372 | let invDappAddress = toString(addressFromRecipient(inv.dApp)) | |
344 | 373 | if ((factoryReadAssetCfgByAddress(invDappAddress)[IdxDefoAssetStatus] != "ISSUED")) | |
345 | 374 | then throw("only defo dapp is allowed") | |
346 | 375 | else if ((invDappAddress == toString(this))) | |
347 | 376 | then throw("impossible to call self rebealnceDebt") | |
348 | 377 | else true | |
349 | 378 | } | |
350 | 379 | else if (if (if ((inv.function == "lockNeutrino")) | |
351 | 380 | then true | |
352 | 381 | else (inv.function == "lockNeutrinoSP")) | |
353 | 382 | then true | |
354 | 383 | else (inv.function == "unlockNeutrino")) | |
355 | 384 | then if ((toString(neutrinoStakingAcc) != toString(addressFromRecipient(inv.dApp)))) | |
356 | 385 | then throw("invalid neutrino staking dapp address") | |
357 | 386 | else sigVerify(tx.bodyBytes, tx.proofs[0], factoryReadDefoStakingPacemakerPub()) | |
358 | 387 | else throw("Not allowed invocation method calls") | |
359 | 388 | case _ => | |
360 | 389 | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
361 | 390 | } | |
362 | 391 |
github/deemru/w8io/026f985 86.18 ms ◑