tx · GZJtPLfkmezPNLnrCvrWcj8Z6WeJdnDEkSzi6T6q7ef3

3MwLcJy3MSb2kq6dUaUR5uBgm8zCKZMjz2S:  -0.01400000 Waves

2021.04.03 20:23 [1466555] smart account 3MwLcJy3MSb2kq6dUaUR5uBgm8zCKZMjz2S > SELF 0.00000000 Waves

{ "type": 13, "id": "GZJtPLfkmezPNLnrCvrWcj8Z6WeJdnDEkSzi6T6q7ef3", "fee": 1400000, "feeAssetId": null, "timestamp": 1617470645322, "version": 2, "chainId": 84, "sender": "3MwLcJy3MSb2kq6dUaUR5uBgm8zCKZMjz2S", "senderPublicKey": "CgByewRUvLk7UtWSfRMLSYw4Ap2wT5dcdVYKideqDp9M", "proofs": [ "4ArbArRvoKfbsNLWmMEGQwA9Wgz1RX6th2FBYiwmxHmuzoXADjyjaa4voVjjAgZmnttqLvCnkjtaAABX3quQbBQm" ], "script": "base64:AAIEAAAAAAAAAAYIAhIAEgAAAAAPAAAAABJ1c2RuRHl6QUJhbGFuY2VLZXkCAAAAGHVzZG5fZHl6X2FfYXNzZXRfYmFsYW5jZQAAAAASdXNkbkR5ekJCYWxhbmNlS2V5AgAAABh1c2RuX2R5el9iX2Fzc2V0X2JhbGFuY2UAAAAAEWV0aER5ekFCYWxhbmNlS2V5AgAAABdldGhfZHl6X2FfYXNzZXRfYmFsYW5jZQAAAAARZXRoRHl6QkJhbGFuY2VLZXkCAAAAF2V0aF9keXpfYl9hc3NldF9iYWxhbmNlAAAAABZ1c2RuRHl6UGFpcklzQWN0aXZlS2V5AgAAABJ1c2RuX2R5el9pc19hY3RpdmUAAAAAFWV0aER5elBhaXJJc0FjdGl2ZUtleQIAAAARZXRoX2R5el9pc19hY3RpdmUAAAAABmZlZUtleQIAAAADZmVlAAAAAA5keXpyYXB0QXNzZXRJZAEAAAAgnxnpc9km71BHiGYaP3+jsvIwnjyNE9APQJ48k4SnBCMAAAAACmV0aEFzc2V0SWQBAAAAICImU7qSm/1VgN3CrHN9jStFD2u0cA4gG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AAACIT0AAAACBQAAAAdhc3NldElkBQAAAAt1c2RuQXNzZXRJZAkBAAAAAiE9AAAAAgUAAAAHYXNzZXRJZAUAAAAOZHl6cmFwdEFzc2V0SWQHCQAAAgAAAAECAAAAJE9ubHkgdXNkbiBhbmQgZHl6cnVwdCBhcmUgc3VwcG9ydGluZwQAAAAHckFtb3VudAkBAAAAEGdldFVzZG5EeXpBbW91bnQAAAACBQAAAAdhc3NldElkBQAAAAZhbW91bnQJAAACAAAAAQUAAAAHckFtb3VudAAAAADQwrde", "height": 1466555, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: FyEfyVzg2ffK64ffNpEiudok6aLdVezcfYKSJWTrZRtL Next: 4dfpS3GLNgEQDED9XT9LX6zYJ2u1mggW8XRWXmU81PSn Diff:
OldNewDifferences
4141 func getUsdnDyzAmount (assetId,amount) = {
4242 let feeAmount = getFeeAmount(amount)
4343 let amountWithoutFee = (amount - feeAmount)
44- throw(toString(amountWithoutFee))
44+ let balanceA = getIntegerValue(this, usdnDyzABalanceKey)
45+ let balanceB = getIntegerValue(this, usdnDyzBBalanceKey)
46+ if ((assetId == usdnAssetId))
47+ then {
48+ let rAmount = fraction(balanceB, amountWithoutFee, (amountWithoutFee + balanceA))
49+ throw(("usdn" + toString(rAmount)))
50+ }
51+ else if ((assetId == dyzraptAssetId))
52+ then {
53+ let rAmount = fraction(balanceA, amountWithoutFee, (amountWithoutFee + balanceB))
54+ throw(("dyzrupt " + toString(rAmount)))
55+ }
56+ else throw("Incorrect asset attached")
4557 }
4658
4759
5163 else if ((i.callerPublicKey != adminPublicKey))
5264 then throw("Only admin can activate pair")
5365 else {
54- let $t014931570 = $Tuple2(i.payments[0].amount, i.payments[0].assetId)
55- let pmtAmountA = $t014931570._1
56- let pmtAssetIdA = $t014931570._2
57- let $t015791656 = $Tuple2(i.payments[1].amount, i.payments[1].assetId)
58- let pmtAmountB = $t015791656._1
59- let pmtAssetIdB = $t015791656._2
66+ let $t019632040 = $Tuple2(i.payments[0].amount, i.payments[0].assetId)
67+ let pmtAmountA = $t019632040._1
68+ let pmtAssetIdA = $t019632040._2
69+ let $t020492126 = $Tuple2(i.payments[1].amount, i.payments[1].assetId)
70+ let pmtAmountB = $t020492126._1
71+ let pmtAssetIdB = $t020492126._2
6072 if ((pmtAssetIdA != usdnAssetId))
6173 then throw("A asset is not a usdn")
6274 else if ((pmtAssetIdB != dyzraptAssetId))
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 4 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let usdnDyzABalanceKey = "usdn_dyz_a_asset_balance"
55
66 let usdnDyzBBalanceKey = "usdn_dyz_b_asset_balance"
77
88 let ethDyzABalanceKey = "eth_dyz_a_asset_balance"
99
1010 let ethDyzBBalanceKey = "eth_dyz_b_asset_balance"
1111
1212 let usdnDyzPairIsActiveKey = "usdn_dyz_is_active"
1313
1414 let ethDyzPairIsActiveKey = "eth_dyz_is_active"
1515
1616 let feeKey = "fee"
1717
1818 let dyzraptAssetId = base58'Bi4jxKEFjjYG2emeyxZfpkVMS88N7uAogHNsi1urkoJA'
1919
2020 let ethAssetId = base58'3JJkzB4pFXcqdJvC9TcV8ys1FLgesr5SxbhmykkpceQp'
2121
2222 let usdnAssetId = base58'9Nf5wpj6jds3VRZKDryp6Dtf3R9d8MdbjNhencLogCr5'
2323
2424 let adminPublicKey = base58'7zDUSbBXZtec3E333b1fC2wR2MPrnzh69ZrH3rwpQj9S'
2525
2626 let feeAddress = Address(base58'3N7G2kVtBTh94aEnDHQ9dpi4EdsDxAiDXjB')
2727
2828 func getIntKeyDataOrError (key) = {
2929 let v = valueOrErrorMessage(getInteger(this, key), "unable to read key")
3030 v
3131 }
3232
3333
3434 func getFeeAmount (amount) = {
3535 let fee = getIntKeyDataOrError(feeKey)
3636 let feeAmount = fraction(amount, fee, 10000)
3737 feeAmount
3838 }
3939
4040
4141 func getUsdnDyzAmount (assetId,amount) = {
4242 let feeAmount = getFeeAmount(amount)
4343 let amountWithoutFee = (amount - feeAmount)
44- throw(toString(amountWithoutFee))
44+ let balanceA = getIntegerValue(this, usdnDyzABalanceKey)
45+ let balanceB = getIntegerValue(this, usdnDyzBBalanceKey)
46+ if ((assetId == usdnAssetId))
47+ then {
48+ let rAmount = fraction(balanceB, amountWithoutFee, (amountWithoutFee + balanceA))
49+ throw(("usdn" + toString(rAmount)))
50+ }
51+ else if ((assetId == dyzraptAssetId))
52+ then {
53+ let rAmount = fraction(balanceA, amountWithoutFee, (amountWithoutFee + balanceB))
54+ throw(("dyzrupt " + toString(rAmount)))
55+ }
56+ else throw("Incorrect asset attached")
4557 }
4658
4759
4860 @Callable(i)
4961 func initUsdnDyzPair () = if (isDefined(getBoolean(this, usdnDyzPairIsActiveKey)))
5062 then throw("Pair is already active")
5163 else if ((i.callerPublicKey != adminPublicKey))
5264 then throw("Only admin can activate pair")
5365 else {
54- let $t014931570 = $Tuple2(i.payments[0].amount, i.payments[0].assetId)
55- let pmtAmountA = $t014931570._1
56- let pmtAssetIdA = $t014931570._2
57- let $t015791656 = $Tuple2(i.payments[1].amount, i.payments[1].assetId)
58- let pmtAmountB = $t015791656._1
59- let pmtAssetIdB = $t015791656._2
66+ let $t019632040 = $Tuple2(i.payments[0].amount, i.payments[0].assetId)
67+ let pmtAmountA = $t019632040._1
68+ let pmtAssetIdA = $t019632040._2
69+ let $t020492126 = $Tuple2(i.payments[1].amount, i.payments[1].assetId)
70+ let pmtAmountB = $t020492126._1
71+ let pmtAssetIdB = $t020492126._2
6072 if ((pmtAssetIdA != usdnAssetId))
6173 then throw("A asset is not a usdn")
6274 else if ((pmtAssetIdB != dyzraptAssetId))
6375 then throw("B asset is not a dyzrupt")
6476 else [BooleanEntry(usdnDyzPairIsActiveKey, true), IntegerEntry(usdnDyzABalanceKey, pmtAmountA), IntegerEntry(usdnDyzBBalanceKey, pmtAmountB), IntegerEntry(feeKey, 300)]
6577 }
6678
6779
6880
6981 @Callable(i)
7082 func exchangeUsdnDyz () = if (!(isDefined(getBoolean(this, usdnDyzPairIsActiveKey))))
7183 then throw("Pair is not active")
7284 else {
7385 let pmt = value(i.payments[0])
7486 let assetId = pmt.assetId
7587 let amount = pmt.amount
7688 if (if ((assetId != usdnAssetId))
7789 then (assetId != dyzraptAssetId)
7890 else false)
7991 then throw("Only usdn and dyzrupt are supporting")
8092 else {
8193 let rAmount = getUsdnDyzAmount(assetId, amount)
8294 throw(rAmount)
8395 }
8496 }
8597
8698

github/deemru/w8io/169f3d6 
24.11 ms