tx · BMBcHomCA5AhTqbtq7tBL72uqkESVxPCfg6he5HQM8HD

3MwLcJy3MSb2kq6dUaUR5uBgm8zCKZMjz2S:  -0.01400000 Waves

2021.03.26 22:40 [1455145] smart account 3MwLcJy3MSb2kq6dUaUR5uBgm8zCKZMjz2S > SELF 0.00000000 Waves

{ "type": 13, "id": "BMBcHomCA5AhTqbtq7tBL72uqkESVxPCfg6he5HQM8HD", "fee": 1400000, "feeAssetId": null, "timestamp": 1616787653711, "version": 2, "chainId": 84, "sender": "3MwLcJy3MSb2kq6dUaUR5uBgm8zCKZMjz2S", "senderPublicKey": "CgByewRUvLk7UtWSfRMLSYw4Ap2wT5dcdVYKideqDp9M", "proofs": [ "42SFdnTikbDfxfRRcS1taPfiePFa6DdtL8hMFmjaJ1qVMK7nGiSwBpkL4h7SD4SsgvTMVDx4eUqKgBhSz42ANaMY" ], "script": "base64:AAIEAAAAAAAAAAYIAhIAEgAAAAAOAAAAAA50b3RhbEZlZUV0aEtleQIAAAANdG90YWxfZmVlX2V0aAAAAAAOdG90YWxGZWVVc2RLZXkCAAAADXRvdGFsX2ZlZV91c2QAAAAAEnRvdGFsRmVlRHl6cmFwdEtleQIAAAARdG90YWxfZmVlX2R5enJhcHQAAAAADnByaWNlT2ZEeXpyYXB0AgAAAANkeXoAAAAACnByaWNlT2ZFdGgCAAAAA2V0aAAAAAANb3JhY2xlQWRkcmVzcwkBAAAAB0FkZHJlc3MAAAABAQAAABoBVL4/7s2JD7wFpgWNJdKO/aqFvcIdJFtzlgAAAAAOZHl6cmFwdEFzc2V0SWQBAAAAIJ8Z6XPZJu9QR4hmGj9/o7LyMJ48jRPQD0CePJOEpwQjAAAAAApldGhBc3NldElkAQAAACAiJlO6kpv9VYDdwqxzfY0rRQ9rtHAOIBs/eo3GguMLoQAAAAALdXNkbkFzc2V0SWQBAAAAIHxpwWtkcIB0JFIbiNXtI38nVRmozWmXoaigru9h4HfCAQAAAAxnZXRGZWVBbW91bnQAAAABAAAABmFtb3Vud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c2RuQXNzZXRJZAkAAAIAAAABAgAAAClPbmx5IHVzZG4gdG9rZW5zIGFyZSBhbGxvd2VkIGZvciBzd2FwcGluZwQAAAADZmVlCQEAAAAMZ2V0RmVlQW1vdW50AAAAAQUAAAALdG90YWxBbW91bnQEAAAABmFtb3VudAkAAGUAAAACBQAAAAt0b3RhbEFtb3VudAUAAAADZmVlBAAAAAxkeXpyYXB0UHJpY2UJAQAAABN2YWx1ZU9yRXJyb3JNZXNzYWdlAAAAAgkABBoAAAACBQAAAA1vcmFjbGVBZGRyZXNzAgAAAANkeXoCAAAAFFVuYWJsZSB0byBsb2FkIHByaWNlCQAAAgAAAAEJAAGkAAAAAQUAAAAMZHl6cmFwdFByaWNlAAAAAI47sS0=", "height": 1455145, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 5BnAhGPLt9iSQAhg5JcghChrtYMmwh7BL53yFLQJBdPj Next: 6wG5C4uHb58SdVvwbqPqF4YGmw34DFZh7JP1XXTJNoaz Diff:
OldNewDifferences
66 let totalFeeUsdKey = "total_fee_usd"
77
88 let totalFeeDyzraptKey = "total_fee_dyzrapt"
9+
10+let priceOfDyzrapt = "dyz"
11+
12+let priceOfEth = "eth"
913
1014 let oracleAddress = Address(base58'3N7G2kVtBTh94aEnDHQ9dpi4EdsDxAiDXjB')
1115
4751 }
4852
4953
54+
55+@Callable(i)
56+func swapUsdnToDyzrapt () = {
57+ let pmt = value(i.payments[0])
58+ let assetId = pmt.assetId
59+ let totalAmount = pmt.amount
60+ if ((assetId != usdnAssetId))
61+ then throw("Only usdn tokens are allowed for swapping")
62+ else {
63+ let fee = getFeeAmount(totalAmount)
64+ let amount = (totalAmount - fee)
65+ let dyzraptPrice = valueOrErrorMessage(getInteger(oracleAddress, "dyz"), "Unable to load price")
66+ throw(toString(dyzraptPrice))
67+ }
68+ }
69+
70+
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"
9+
10+let priceOfDyzrapt = "dyz"
11+
12+let priceOfEth = "eth"
913
1014 let oracleAddress = Address(base58'3N7G2kVtBTh94aEnDHQ9dpi4EdsDxAiDXjB')
1115
1216 let dyzraptAssetId = base58'Bi4jxKEFjjYG2emeyxZfpkVMS88N7uAogHNsi1urkoJA'
1317
1418 let ethAssetId = base58'3JJkzB4pFXcqdJvC9TcV8ys1FLgesr5SxbhmykkpceQp'
1519
1620 let usdnAssetId = base58'9Nf5wpj6jds3VRZKDryp6Dtf3R9d8MdbjNhencLogCr5'
1721
1822 func getFeeAmount (amount) = {
1923 let fee = fraction(amount, 3, 100)
2024 fee
2125 }
2226
2327
2428 func getIntKeyData (key) = {
2529 let v = valueOrElse(getInteger(this, key), 0)
2630 v
2731 }
2832
2933
3034 func getTotalFeeEth () = getIntKeyData(totalFeeEthKey)
3135
3236
3337 func getTotalFeeUsd () = getIntKeyData(totalFeeUsdKey)
3438
3539
3640 func getTotalFeeDyzrapt () = getIntKeyData(totalFeeDyzraptKey)
3741
3842
3943 @Callable(i)
4044 func test () = {
4145 let pmt = value(i.payments[0])
4246 let assetId = pmt.assetId
4347 let amount = pmt.amount
4448 if ((assetId == dyzraptAssetId))
4549 then throw(("its a dyzrapt. Amount=" + toString(amount)))
4650 else throw("its not a dyzrapt")
4751 }
4852
4953
54+
55+@Callable(i)
56+func swapUsdnToDyzrapt () = {
57+ let pmt = value(i.payments[0])
58+ let assetId = pmt.assetId
59+ let totalAmount = pmt.amount
60+ if ((assetId != usdnAssetId))
61+ then throw("Only usdn tokens are allowed for swapping")
62+ else {
63+ let fee = getFeeAmount(totalAmount)
64+ let amount = (totalAmount - fee)
65+ let dyzraptPrice = valueOrErrorMessage(getInteger(oracleAddress, "dyz"), "Unable to load price")
66+ throw(toString(dyzraptPrice))
67+ }
68+ }
69+
70+

github/deemru/w8io/169f3d6 
25.89 ms