tx · H3Ps2DpcnSkvWMZwgPrUc7AH59fe5ZoA4KM1MTX6on4C

3MwLcJy3MSb2kq6dUaUR5uBgm8zCKZMjz2S:  -0.01400000 Waves

2021.04.03 20:52 [1466585] smart account 3MwLcJy3MSb2kq6dUaUR5uBgm8zCKZMjz2S > SELF 0.00000000 Waves

{ "type": 13, "id": "H3Ps2DpcnSkvWMZwgPrUc7AH59fe5ZoA4KM1MTX6on4C", "fee": 1400000, "feeAssetId": null, "timestamp": 1617472364134, "version": 2, "chainId": 84, "sender": "3MwLcJy3MSb2kq6dUaUR5uBgm8zCKZMjz2S", "senderPublicKey": "CgByewRUvLk7UtWSfRMLSYw4Ap2wT5dcdVYKideqDp9M", "proofs": [ "46FJDGJhUfGrUERF4brd5cVnWRGi94JivuTHoFGikr4cYXxdMLWq9kU1fGwPoK7gpP9xxAfFSJ5FJizg85CrjaiY" ], "script": "base64:AAIEAAAAAAAAAAYIAhIAEgAAAAAVAAAAABJ1c2RuRHl6QUJhbGFuY2VLZXkCAAAAGHVzZG5fZHl6X2FfYXNzZXRfYmFsYW5jZQAAAAASdXNkbkR5ekJCYWxhbmNlS2V5AgAAABh1c2RuX2R5el9iX2Fzc2V0X2JhbGFuY2UAAAAAEWV0aER5ekFCYWxhbmNlS2V5AgAAABdldGhfZHl6X2FfYXNzZXRfYmFsYW5jZQAAAAARZXRoRHl6QkJhbGFuY2VLZXkCAAAAF2V0aF9keXpfYl9hc3NldF9iYWxhbmNlAAAAABZ1c2RuRHl6UGFpcklzQWN0aXZlS2V5AgAAABJ1c2RuX2R5el9pc19hY3RpdmUAAAAAFWV0aER5elBhaXJJc0FjdGl2ZUtleQIAAAARZXRoX2R5el9pc19hY3RpdmUAAAAABmZlZUtleQIAAAADZmVlAAAAAA50b3RhbEZlZUV0aEtleQIAAAANdG90YWxfZmVlX2V0aAAAAAAOdG90YWxGZWVVc2RLZXkCAAAADXRvdGFsX2ZlZV91c2QAAAAAEnRvdGFsRmVlRHl6cmFwdEtleQIAA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QWRkcmVzcwUAAAAJZmVlQW1vdW50BQAAAAdhc3NldElkCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAAFpAAAABmNhbGxlcgUAAAAHckFtb3VudAUAAAAIckFzc2V0SWQFAAAAA25pbAAAAADm6rN6", "height": 1466585, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 4dfpS3GLNgEQDED9XT9LX6zYJ2u1mggW8XRWXmU81PSn Next: 2oQ3QJHoAg5mVsXyP6N3VMg76M81bCkePLi3KJ1oU9KX Diff:
OldNewDifferences
1515
1616 let feeKey = "fee"
1717
18+let totalFeeEthKey = "total_fee_eth"
19+
20+let totalFeeUsdKey = "total_fee_usd"
21+
22+let totalFeeDyzraptKey = "total_fee_dyzrapt"
23+
1824 let dyzraptAssetId = base58'Bi4jxKEFjjYG2emeyxZfpkVMS88N7uAogHNsi1urkoJA'
1925
2026 let ethAssetId = base58'3JJkzB4pFXcqdJvC9TcV8ys1FLgesr5SxbhmykkpceQp'
3137 }
3238
3339
40+func getIntKeyData (key) = {
41+ let v = valueOrElse(getInteger(this, key), 0)
42+ v
43+ }
44+
45+
46+func getTotalFeeByKey (key) = getIntKeyData(key)
47+
48+
3449 func getFeeAmount (amount) = {
3550 let fee = getIntKeyDataOrError(feeKey)
3651 let feeAmount = fraction(amount, fee, 10000)
3752 feeAmount
3853 }
54+
55+
56+func getFeeKeyByAssetId (assetId) = if ((assetId == usdnAssetId))
57+ then totalFeeUsdKey
58+ else if ((assetId == ethAssetId))
59+ then totalFeeEthKey
60+ else if ((assetId == dyzraptAssetId))
61+ then totalFeeDyzraptKey
62+ else throw("Incorrect asset attached")
3963
4064
4165 func getUsdnDyzAmount (assetId,amount) = {
4670 if ((assetId == usdnAssetId))
4771 then {
4872 let rAmount = fraction(balanceB, amountWithoutFee, (amountWithoutFee + balanceA))
49- throw(("usdn" + toString(rAmount)))
73+ let rAssetId = dyzraptAssetId
74+ let newBalanceA = (amountWithoutFee + balanceA)
75+ let newBalanceB = (balanceB - rAmount)
76+ $Tuple5(feeAmount, rAmount, rAssetId, newBalanceA, newBalanceB)
5077 }
5178 else if ((assetId == dyzraptAssetId))
5279 then {
5380 let rAmount = fraction(balanceA, amountWithoutFee, (amountWithoutFee + balanceB))
54- throw(("dyzrupt " + toString(rAmount)))
81+ let rAssetId = usdnAssetId
82+ let newBalanceA = (balanceA - rAmount)
83+ let newBalanceB = (balanceB + amountWithoutFee)
84+ $Tuple5(feeAmount, rAmount, rAssetId, newBalanceA, newBalanceB)
5585 }
5686 else throw("Incorrect asset attached")
5787 }
6393 else if ((i.callerPublicKey != adminPublicKey))
6494 then throw("Only admin can activate pair")
6595 else {
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
96+ let $t029753052 = $Tuple2(i.payments[0].amount, i.payments[0].assetId)
97+ let pmtAmountA = $t029753052._1
98+ let pmtAssetIdA = $t029753052._2
99+ let $t030613138 = $Tuple2(i.payments[1].amount, i.payments[1].assetId)
100+ let pmtAmountB = $t030613138._1
101+ let pmtAssetIdB = $t030613138._2
72102 if ((pmtAssetIdA != usdnAssetId))
73103 then throw("A asset is not a usdn")
74104 else if ((pmtAssetIdB != dyzraptAssetId))
90120 else false)
91121 then throw("Only usdn and dyzrupt are supporting")
92122 else {
93- let rAmount = getUsdnDyzAmount(assetId, amount)
94- throw(rAmount)
123+ let $t040204116 = getUsdnDyzAmount(assetId, amount)
124+ let feeAmount = $t040204116._1
125+ let rAmount = $t040204116._2
126+ let rAssetId = $t040204116._3
127+ let newBalanceA = $t040204116._4
128+ let newBalanceB = $t040204116._5
129+ let totalFeeKey = getFeeKeyByAssetId(assetId)
130+ let totalFee = (getTotalFeeByKey(totalFeeKey) + feeAmount)
131+[IntegerEntry(usdnDyzABalanceKey, newBalanceA), IntegerEntry(usdnDyzBBalanceKey, newBalanceB), IntegerEntry(totalFeeKey, totalFee), ScriptTransfer(feeAddress, feeAmount, assetId), ScriptTransfer(i.caller, rAmount, rAssetId)]
95132 }
96133 }
97134
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
18+let totalFeeEthKey = "total_fee_eth"
19+
20+let totalFeeUsdKey = "total_fee_usd"
21+
22+let totalFeeDyzraptKey = "total_fee_dyzrapt"
23+
1824 let dyzraptAssetId = base58'Bi4jxKEFjjYG2emeyxZfpkVMS88N7uAogHNsi1urkoJA'
1925
2026 let ethAssetId = base58'3JJkzB4pFXcqdJvC9TcV8ys1FLgesr5SxbhmykkpceQp'
2127
2228 let usdnAssetId = base58'9Nf5wpj6jds3VRZKDryp6Dtf3R9d8MdbjNhencLogCr5'
2329
2430 let adminPublicKey = base58'7zDUSbBXZtec3E333b1fC2wR2MPrnzh69ZrH3rwpQj9S'
2531
2632 let feeAddress = Address(base58'3N7G2kVtBTh94aEnDHQ9dpi4EdsDxAiDXjB')
2733
2834 func getIntKeyDataOrError (key) = {
2935 let v = valueOrErrorMessage(getInteger(this, key), "unable to read key")
3036 v
3137 }
3238
3339
40+func getIntKeyData (key) = {
41+ let v = valueOrElse(getInteger(this, key), 0)
42+ v
43+ }
44+
45+
46+func getTotalFeeByKey (key) = getIntKeyData(key)
47+
48+
3449 func getFeeAmount (amount) = {
3550 let fee = getIntKeyDataOrError(feeKey)
3651 let feeAmount = fraction(amount, fee, 10000)
3752 feeAmount
3853 }
54+
55+
56+func getFeeKeyByAssetId (assetId) = if ((assetId == usdnAssetId))
57+ then totalFeeUsdKey
58+ else if ((assetId == ethAssetId))
59+ then totalFeeEthKey
60+ else if ((assetId == dyzraptAssetId))
61+ then totalFeeDyzraptKey
62+ else throw("Incorrect asset attached")
3963
4064
4165 func getUsdnDyzAmount (assetId,amount) = {
4266 let feeAmount = getFeeAmount(amount)
4367 let amountWithoutFee = (amount - feeAmount)
4468 let balanceA = getIntegerValue(this, usdnDyzABalanceKey)
4569 let balanceB = getIntegerValue(this, usdnDyzBBalanceKey)
4670 if ((assetId == usdnAssetId))
4771 then {
4872 let rAmount = fraction(balanceB, amountWithoutFee, (amountWithoutFee + balanceA))
49- throw(("usdn" + toString(rAmount)))
73+ let rAssetId = dyzraptAssetId
74+ let newBalanceA = (amountWithoutFee + balanceA)
75+ let newBalanceB = (balanceB - rAmount)
76+ $Tuple5(feeAmount, rAmount, rAssetId, newBalanceA, newBalanceB)
5077 }
5178 else if ((assetId == dyzraptAssetId))
5279 then {
5380 let rAmount = fraction(balanceA, amountWithoutFee, (amountWithoutFee + balanceB))
54- throw(("dyzrupt " + toString(rAmount)))
81+ let rAssetId = usdnAssetId
82+ let newBalanceA = (balanceA - rAmount)
83+ let newBalanceB = (balanceB + amountWithoutFee)
84+ $Tuple5(feeAmount, rAmount, rAssetId, newBalanceA, newBalanceB)
5585 }
5686 else throw("Incorrect asset attached")
5787 }
5888
5989
6090 @Callable(i)
6191 func initUsdnDyzPair () = if (isDefined(getBoolean(this, usdnDyzPairIsActiveKey)))
6292 then throw("Pair is already active")
6393 else if ((i.callerPublicKey != adminPublicKey))
6494 then throw("Only admin can activate pair")
6595 else {
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
96+ let $t029753052 = $Tuple2(i.payments[0].amount, i.payments[0].assetId)
97+ let pmtAmountA = $t029753052._1
98+ let pmtAssetIdA = $t029753052._2
99+ let $t030613138 = $Tuple2(i.payments[1].amount, i.payments[1].assetId)
100+ let pmtAmountB = $t030613138._1
101+ let pmtAssetIdB = $t030613138._2
72102 if ((pmtAssetIdA != usdnAssetId))
73103 then throw("A asset is not a usdn")
74104 else if ((pmtAssetIdB != dyzraptAssetId))
75105 then throw("B asset is not a dyzrupt")
76106 else [BooleanEntry(usdnDyzPairIsActiveKey, true), IntegerEntry(usdnDyzABalanceKey, pmtAmountA), IntegerEntry(usdnDyzBBalanceKey, pmtAmountB), IntegerEntry(feeKey, 300)]
77107 }
78108
79109
80110
81111 @Callable(i)
82112 func exchangeUsdnDyz () = if (!(isDefined(getBoolean(this, usdnDyzPairIsActiveKey))))
83113 then throw("Pair is not active")
84114 else {
85115 let pmt = value(i.payments[0])
86116 let assetId = pmt.assetId
87117 let amount = pmt.amount
88118 if (if ((assetId != usdnAssetId))
89119 then (assetId != dyzraptAssetId)
90120 else false)
91121 then throw("Only usdn and dyzrupt are supporting")
92122 else {
93- let rAmount = getUsdnDyzAmount(assetId, amount)
94- throw(rAmount)
123+ let $t040204116 = getUsdnDyzAmount(assetId, amount)
124+ let feeAmount = $t040204116._1
125+ let rAmount = $t040204116._2
126+ let rAssetId = $t040204116._3
127+ let newBalanceA = $t040204116._4
128+ let newBalanceB = $t040204116._5
129+ let totalFeeKey = getFeeKeyByAssetId(assetId)
130+ let totalFee = (getTotalFeeByKey(totalFeeKey) + feeAmount)
131+[IntegerEntry(usdnDyzABalanceKey, newBalanceA), IntegerEntry(usdnDyzBBalanceKey, newBalanceB), IntegerEntry(totalFeeKey, totalFee), ScriptTransfer(feeAddress, feeAmount, assetId), ScriptTransfer(i.caller, rAmount, rAssetId)]
95132 }
96133 }
97134
98135

github/deemru/w8io/169f3d6 
24.26 ms