tx · AXswYCqiUSgcsNMo7V3gYSxWCSwm4ubtQJrvWrL8yYiu

3MwLcJy3MSb2kq6dUaUR5uBgm8zCKZMjz2S:  -0.01400000 Waves

2021.04.03 09:43 [1465918] smart account 3MwLcJy3MSb2kq6dUaUR5uBgm8zCKZMjz2S > SELF 0.00000000 Waves

{ "type": 13, "id": "AXswYCqiUSgcsNMo7V3gYSxWCSwm4ubtQJrvWrL8yYiu", "fee": 1400000, "feeAssetId": null, "timestamp": 1617432226870, "version": 2, "chainId": 84, "sender": "3MwLcJy3MSb2kq6dUaUR5uBgm8zCKZMjz2S", "senderPublicKey": "CgByewRUvLk7UtWSfRMLSYw4Ap2wT5dcdVYKideqDp9M", "proofs": [ "5WHeex7FzkQL1fZdSULYjujgmaApQc11Wp4EGCG67ocyEDhvoB8eqH1sTjAozBWkkaifvHP1ATNVKhqJ9bYA3gN4" ], "script": "base64:AAIEAAAAAAAAAAwIAhIAEgASABIAEgAAAAAQAAAAAA50b3RhbEZlZUV0aEtleQIAAAANdG90YWxfZmVlX2V0aAAAAAAOdG90YWxGZWVVc2RLZXkCAAAADXRvdGFsX2ZlZV91c2QAAAAAEnRvdGFsRmVlRHl6cmFwdEtleQIAAAARdG90YWxfZmVlX2R5enJhcHQAAAAAEXByaWNlT2ZEeXpyYXB0S2V5AgAAAANkeXoAAAAADXByaWNlT2ZFdGhLZXkCAAAAA2V0aAAAAAANb3JhY2xlQWRkcmVzcwkBAAAAB0FkZHJlc3MAAAABAQAAABoBVL4/7s2JD7wFpgWNJdKO/aqFvcIdJFtzlgAAAAAOZHl6cmFwdEFzc2V0SWQBAAAAIJ8Z6XPZJu9QR4hmGj9/o7LyMJ48jRPQD0CePJOEpwQjAAAAAApldGhBc3NldElkAQAAACAiJlO6kpv9VYDdwqxzfY0rRQ9rtHAOIBs/eo3GguMLoQAAAAALdXNkbkFzc2V0SWQBAAAAIHxpwWtkcIB0JFIbiNXtI38nVRmozWmXoaigru9h4HfCAQAAAAxnZXRGZWVBbW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wkBAAAAAiE9AAAAAgUAAAAHYXNzZXRJZAUAAAAOZHl6cmFwdEFzc2V0SWQJAAACAAAAAQIAAAAsT25seSBEWVpSQVBUIHRva2VucyBhcmUgYWxsb3dlZCBmb3Igc3dhcHBpbmcEAAAAA2ZlZQkBAAAADGdldEZlZUFtb3VudAAAAAEFAAAAC3RvdGFsQW1vdW50BAAAAAZhbW91bnQJAABlAAAAAgUAAAALdG90YWxBbW91bnQFAAAAA2ZlZQQAAAAKdXNkbkFtb3VudAkBAAAADWR5enJhcHRUb1VzZG4AAAABBQAAAAZhbW91bnQEAAAACGV0aFByaWNlCQEAAAATdmFsdWVPckVycm9yTWVzc2FnZQAAAAIJAAQaAAAAAgUAAAANb3JhY2xlQWRkcmVzcwUAAAANcHJpY2VPZkV0aEtleQIAAAAUVW5hYmxlIHRvIGxvYWQgcHJpY2UEAAAACWV0aEFtb3VudAkAAGsAAAADBQAAAAp1c2RuQW1vdW50AAAAAAAAACcQBQAAAAhldGhQcmljZQQAAAAIc2F2ZWRGZWUJAQAAABJnZXRUb3RhbEZlZUR5enJhcHQAAAAABAAAAAh0b3RhbEZlZQkAAGQAAAACBQAAAAhzYXZlZEZlZQUAAAADZmVlCQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAAACBQAAABJ0b3RhbEZlZUR5enJhcHRLZXkFAAAACHRvdGFsRmVlCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAAFpAAAABmNhbGxlcgUAAAAJZXRoQW1vdW50BQAAAApldGhBc3NldElkBQAAAANuaWwAAAAAePIwhw==", "height": 1465918, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 7f6YdXZ6iZt2Wh1sF2ZXYe5rRqCAasqoZ6RpExkGM423 Next: 7SLtRq6DWjUvBpCPkKddSz5u1vFwmFezZFTYvrXvJ2o Full:
OldNewDifferences
11 {-# STDLIB_VERSION 4 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let totalFeeEthKey = "total_fee_eth"
55
66 let totalFeeUsdKey = "total_fee_usd"
77
88 let totalFeeDyzraptKey = "total_fee_dyzrapt"
99
1010 let priceOfDyzraptKey = "dyz"
1111
1212 let priceOfEthKey = "eth"
1313
1414 let oracleAddress = Address(base58'3N7G2kVtBTh94aEnDHQ9dpi4EdsDxAiDXjB')
1515
1616 let dyzraptAssetId = base58'Bi4jxKEFjjYG2emeyxZfpkVMS88N7uAogHNsi1urkoJA'
1717
1818 let ethAssetId = base58'3JJkzB4pFXcqdJvC9TcV8ys1FLgesr5SxbhmykkpceQp'
1919
2020 let usdnAssetId = base58'9Nf5wpj6jds3VRZKDryp6Dtf3R9d8MdbjNhencLogCr5'
2121
2222 func getFeeAmount (amount) = {
2323 let fee = fraction(amount, 3, 100)
2424 fee
2525 }
2626
2727
2828 func getIntKeyData (key) = {
2929 let v = valueOrElse(getInteger(this, key), 0)
3030 v
3131 }
3232
3333
3434 func getTotalFeeEth () = getIntKeyData(totalFeeEthKey)
3535
3636
3737 func getTotalFeeUsd () = getIntKeyData(totalFeeUsdKey)
3838
3939
4040 func getTotalFeeDyzrapt () = getIntKeyData(totalFeeDyzraptKey)
4141
4242
4343 func usdnToDyzrapt (amount) = {
4444 let dyzraptPrice = valueOrErrorMessage(getInteger(oracleAddress, priceOfDyzraptKey), "Unable to load price")
4545 fraction(amount, 10000, dyzraptPrice)
4646 }
4747
4848
4949 func dyzraptToUsdn (amount) = {
5050 let dyzraptPrice = valueOrErrorMessage(getInteger(oracleAddress, priceOfDyzraptKey), "Unable to load price")
5151 fraction(amount, dyzraptPrice, 10000)
5252 }
5353
5454
5555 @Callable(i)
5656 func test () = {
5757 let pmt = value(i.payments[0])
5858 let assetId = pmt.assetId
5959 let amount = pmt.amount
6060 if ((assetId == dyzraptAssetId))
6161 then throw(("its a dyzrapt. Amount=" + toString(amount)))
6262 else throw("its not a dyzrapt")
6363 }
6464
6565
6666
6767 @Callable(i)
6868 func swapUsdnToDyzrapt () = {
6969 let pmt = value(i.payments[0])
7070 let assetId = pmt.assetId
7171 let totalAmount = pmt.amount
7272 if ((assetId != usdnAssetId))
7373 then throw("Only USDN tokens are allowed for swapping")
7474 else {
7575 let fee = getFeeAmount(totalAmount)
7676 let amount = (totalAmount - fee)
7777 let dyzraptAmount = usdnToDyzrapt(amount)
7878 let savedFee = getTotalFeeUsd()
7979 let totalFee = (savedFee + fee)
8080 [IntegerEntry(totalFeeUsdKey, totalFee), ScriptTransfer(i.caller, dyzraptAmount, dyzraptAssetId)]
8181 }
8282 }
8383
8484
8585
8686 @Callable(i)
8787 func swapEthToDyzrapt () = {
8888 let pmt = value(i.payments[0])
8989 let assetId = pmt.assetId
9090 let totalAmount = pmt.amount
9191 if ((assetId != ethAssetId))
9292 then throw("Only WETH tokens are allowed for swapping")
9393 else {
9494 let fee = getFeeAmount(totalAmount)
9595 let amount = (totalAmount - fee)
9696 let ethPrice = valueOrErrorMessage(getInteger(oracleAddress, priceOfEthKey), "Unable to load price")
9797 let usdnAmount = fraction(amount, ethPrice, 10000)
9898 let dyzraptAmount = usdnToDyzrapt(usdnAmount)
9999 let savedFee = getTotalFeeEth()
100100 let totalFee = (savedFee + fee)
101101 [IntegerEntry(totalFeeEthKey, totalFee), ScriptTransfer(i.caller, dyzraptAmount, dyzraptAssetId)]
102102 }
103103 }
104104
105105
106106
107107 @Callable(i)
108108 func swapDyzraptToUsdn () = {
109109 let pmt = value(i.payments[0])
110110 let assetId = pmt.assetId
111111 let totalAmount = pmt.amount
112112 if ((assetId != dyzraptAssetId))
113113 then throw("Only DYZRAPT tokens are allowed for swapping")
114114 else {
115115 let fee = getFeeAmount(totalAmount)
116116 let amount = (totalAmount - fee)
117117 let usdnAmount = dyzraptToUsdn(amount)
118118 let savedFee = getTotalFeeDyzrapt()
119119 let totalFee = (savedFee + fee)
120120 [IntegerEntry(totalFeeDyzraptKey, totalFee), ScriptTransfer(i.caller, usdnAmount, usdnAssetId)]
121121 }
122122 }
123123
124124
125125
126126 @Callable(i)
127127 func swapDyzraptToEth () = {
128128 let pmt = value(i.payments[0])
129129 let assetId = pmt.assetId
130130 let totalAmount = pmt.amount
131131 if ((assetId != dyzraptAssetId))
132132 then throw("Only DYZRAPT tokens are allowed for swapping")
133133 else {
134134 let fee = getFeeAmount(totalAmount)
135135 let amount = (totalAmount - fee)
136136 let usdnAmount = dyzraptToUsdn(amount)
137137 let ethPrice = valueOrErrorMessage(getInteger(oracleAddress, priceOfEthKey), "Unable to load price")
138138 let ethAmount = fraction(usdnAmount, 10000, ethPrice)
139139 let savedFee = getTotalFeeDyzrapt()
140140 let totalFee = (savedFee + fee)
141141 [IntegerEntry(totalFeeDyzraptKey, totalFee), ScriptTransfer(i.caller, ethAmount, ethAssetId)]
142142 }
143143 }
144144
145145

github/deemru/w8io/026f985 
31.84 ms