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