tx · 7SLtRq6DWjUvBpCPkKddSz5u1vFwmFezZFTYvrXvJ2o

3MwLcJy3MSb2kq6dUaUR5uBgm8zCKZMjz2S:  -0.01400000 Waves

2021.04.03 09:44 [1465919] smart account 3MwLcJy3MSb2kq6dUaUR5uBgm8zCKZMjz2S > SELF 0.00000000 Waves

{ "type": 13, "id": "7SLtRq6DWjUvBpCPkKddSz5u1vFwmFezZFTYvrXvJ2o", "fee": 1400000, "feeAssetId": null, "timestamp": 1617432323224, "version": 2, "chainId": 84, "sender": "3MwLcJy3MSb2kq6dUaUR5uBgm8zCKZMjz2S", "senderPublicKey": "CgByewRUvLk7UtWSfRMLSYw4Ap2wT5dcdVYKideqDp9M", "proofs": [ "2tgL4bmH8JCy5A5m8jyUpcrpLqX2mVcXV8d4rQ2fA4iUUBuwkYp1Me86VBNTJF3t3vgP7QLjMq76p5oZTugXACuB" ], "script": "base64:AAIEAAAAAAAAAAQIAhIAAAAACgAAAAASdXNkbkR5ekFCYWxhbmNlS2V5AgAAABh1c2RuX2R5el9hX2Fzc2V0X2JhbGFuY2UAAAAAEnVzZG5EeXpCQmFsYW5jZUtleQIAAAAYdXNkbl9keXpfYl9hc3NldF9iYWxhbmNlAAAAABFldGhEeXpBQmFsYW5jZUtleQIAAAAXZXRoX2R5el9hX2Fzc2V0X2JhbGFuY2UAAAAAEWV0aER5ekJCYWxhbmNlS2V5AgAAABdldGhfZHl6X2JfYXNzZXRfYmFsYW5jZQAAAAAWdXNkbkR5elBhaXJJc0FjdGl2ZUtleQIAAAASdXNkbl9keXpfaXNfYWN0aXZlAAAAABVldGhEeXpQYWlySXNBY3RpdmVLZXkCAAAAEWV0aF9keXpfaXNfYWN0aXZlAAAAAA5keXpyYXB0QXNzZXRJZAEAAAAgnxnpc9km71BHiGYaP3+jsvIwnjyNE9APQJ48k4SnBCMAAAAACmV0aEFzc2V0SWQBAAAAICImU7qSm/1VgN3CrHN9jStFD2u0cA4gGz96jcaC4wuhAAAAAAt1c2RuQXNzZX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EFzc2V0SWRCBQAAAA5keXpyYXB0QXNzZXRJZAkAAAIAAAABAgAAABlCICBhc3NldCBpcyBub3QgYSBkeXpydXB0CQAAAgAAAAECAAAABWhlbGxvAAAAAAoORZk=", "height": 1465919, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: AXswYCqiUSgcsNMo7V3gYSxWCSwm4ubtQJrvWrL8yYiu Next: DNeFe6dQefHNtjr2TMwcKqeTMJyXSEa8zPRP53tLTsDU Diff:
OldNewDifferences
11 {-# STDLIB_VERSION 4 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let totalFeeEthKey = "total_fee_eth"
4+let usdnDyzABalanceKey = "usdn_dyz_a_asset_balance"
55
6-let totalFeeUsdKey = "total_fee_usd"
6+let usdnDyzBBalanceKey = "usdn_dyz_b_asset_balance"
77
8-let totalFeeDyzraptKey = "total_fee_dyzrapt"
8+let ethDyzABalanceKey = "eth_dyz_a_asset_balance"
99
10-let priceOfDyzraptKey = "dyz"
10+let ethDyzBBalanceKey = "eth_dyz_b_asset_balance"
1111
12-let priceOfEthKey = "eth"
12+let usdnDyzPairIsActiveKey = "usdn_dyz_is_active"
1313
14-let oracleAddress = Address(base58'3N7G2kVtBTh94aEnDHQ9dpi4EdsDxAiDXjB')
14+let ethDyzPairIsActiveKey = "eth_dyz_is_active"
1515
1616 let dyzraptAssetId = base58'Bi4jxKEFjjYG2emeyxZfpkVMS88N7uAogHNsi1urkoJA'
1717
1919
2020 let usdnAssetId = base58'9Nf5wpj6jds3VRZKDryp6Dtf3R9d8MdbjNhencLogCr5'
2121
22-func getFeeAmount (amount) = {
23- let fee = fraction(amount, 3, 100)
24- fee
25- }
26-
27-
28-func getIntKeyData (key) = {
29- let v = valueOrElse(getInteger(this, key), 0)
30- v
31- }
32-
33-
34-func getTotalFeeEth () = getIntKeyData(totalFeeEthKey)
35-
36-
37-func getTotalFeeUsd () = getIntKeyData(totalFeeUsdKey)
38-
39-
40-func getTotalFeeDyzrapt () = getIntKeyData(totalFeeDyzraptKey)
41-
42-
43-func usdnToDyzrapt (amount) = {
44- let dyzraptPrice = valueOrErrorMessage(getInteger(oracleAddress, priceOfDyzraptKey), "Unable to load price")
45- fraction(amount, 10000, dyzraptPrice)
46- }
47-
48-
49-func dyzraptToUsdn (amount) = {
50- let dyzraptPrice = valueOrErrorMessage(getInteger(oracleAddress, priceOfDyzraptKey), "Unable to load price")
51- fraction(amount, dyzraptPrice, 10000)
52- }
53-
22+let adminPublicKey = base58'CgByewRUvLk7UtWSfRMLSYw4Ap2wT5dcdVYKideqDp9M'
5423
5524 @Callable(i)
56-func test () = {
57- let pmt = value(i.payments[0])
58- let assetId = pmt.assetId
59- let amount = pmt.amount
60- if ((assetId == dyzraptAssetId))
61- then throw(("its a dyzrapt. Amount=" + toString(amount)))
62- else throw("its not a dyzrapt")
63- }
64-
65-
66-
67-@Callable(i)
68-func swapUsdnToDyzrapt () = {
69- let pmt = value(i.payments[0])
70- let assetId = pmt.assetId
71- let totalAmount = pmt.amount
72- if ((assetId != usdnAssetId))
73- then throw("Only USDN tokens are allowed for swapping")
25+func initUsdnDyzPair () = if (isDefined(getBoolean(this, usdnDyzPairIsActiveKey)))
26+ then throw("Pair is already active")
27+ else if ((i.callerPublicKey != adminPublicKey))
28+ then throw("Only admin can activate pair")
7429 else {
75- let fee = getFeeAmount(totalAmount)
76- let amount = (totalAmount - fee)
77- let dyzraptAmount = usdnToDyzrapt(amount)
78- let savedFee = getTotalFeeUsd()
79- let totalFee = (savedFee + fee)
80-[IntegerEntry(totalFeeUsdKey, totalFee), ScriptTransfer(i.caller, dyzraptAmount, dyzraptAssetId)]
30+ let $t09381015 = $Tuple2(i.payments[0].amount, i.payments[0].assetId)
31+ let pmtAmountA = $t09381015._1
32+ let pmtAssetIdA = $t09381015._2
33+ let $t010241101 = $Tuple2(i.payments[1].amount, i.payments[1].assetId)
34+ let pmtAmountB = $t010241101._1
35+ let pmtAssetIdB = $t010241101._2
36+ if ((pmtAssetIdA != usdnAssetId))
37+ then throw("A asset is not a usdn")
38+ else if ((pmtAssetIdB != dyzraptAssetId))
39+ then throw("B asset is not a dyzrupt")
40+ else throw("hello")
8141 }
82- }
83-
84-
85-
86-@Callable(i)
87-func swapEthToDyzrapt () = {
88- let pmt = value(i.payments[0])
89- let assetId = pmt.assetId
90- let totalAmount = pmt.amount
91- if ((assetId != ethAssetId))
92- then throw("Only WETH tokens are allowed for swapping")
93- else {
94- let fee = getFeeAmount(totalAmount)
95- let amount = (totalAmount - fee)
96- let ethPrice = valueOrErrorMessage(getInteger(oracleAddress, priceOfEthKey), "Unable to load price")
97- let usdnAmount = fraction(amount, ethPrice, 10000)
98- let dyzraptAmount = usdnToDyzrapt(usdnAmount)
99- let savedFee = getTotalFeeEth()
100- let totalFee = (savedFee + fee)
101-[IntegerEntry(totalFeeEthKey, totalFee), ScriptTransfer(i.caller, dyzraptAmount, dyzraptAssetId)]
102- }
103- }
104-
105-
106-
107-@Callable(i)
108-func swapDyzraptToUsdn () = {
109- let pmt = value(i.payments[0])
110- let assetId = pmt.assetId
111- let totalAmount = pmt.amount
112- if ((assetId != dyzraptAssetId))
113- then throw("Only DYZRAPT tokens are allowed for swapping")
114- else {
115- let fee = getFeeAmount(totalAmount)
116- let amount = (totalAmount - fee)
117- let usdnAmount = dyzraptToUsdn(amount)
118- let savedFee = getTotalFeeDyzrapt()
119- let totalFee = (savedFee + fee)
120-[IntegerEntry(totalFeeDyzraptKey, totalFee), ScriptTransfer(i.caller, usdnAmount, usdnAssetId)]
121- }
122- }
123-
124-
125-
126-@Callable(i)
127-func swapDyzraptToEth () = {
128- let pmt = value(i.payments[0])
129- let assetId = pmt.assetId
130- let totalAmount = pmt.amount
131- if ((assetId != dyzraptAssetId))
132- then throw("Only DYZRAPT tokens are allowed for swapping")
133- else {
134- let fee = getFeeAmount(totalAmount)
135- let amount = (totalAmount - fee)
136- let usdnAmount = dyzraptToUsdn(amount)
137- let ethPrice = valueOrErrorMessage(getInteger(oracleAddress, priceOfEthKey), "Unable to load price")
138- let ethAmount = fraction(usdnAmount, 10000, ethPrice)
139- let savedFee = getTotalFeeDyzrapt()
140- let totalFee = (savedFee + fee)
141-[IntegerEntry(totalFeeDyzraptKey, totalFee), ScriptTransfer(i.caller, ethAmount, ethAssetId)]
142- }
143- }
14442
14543
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 4 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let totalFeeEthKey = "total_fee_eth"
4+let usdnDyzABalanceKey = "usdn_dyz_a_asset_balance"
55
6-let totalFeeUsdKey = "total_fee_usd"
6+let usdnDyzBBalanceKey = "usdn_dyz_b_asset_balance"
77
8-let totalFeeDyzraptKey = "total_fee_dyzrapt"
8+let ethDyzABalanceKey = "eth_dyz_a_asset_balance"
99
10-let priceOfDyzraptKey = "dyz"
10+let ethDyzBBalanceKey = "eth_dyz_b_asset_balance"
1111
12-let priceOfEthKey = "eth"
12+let usdnDyzPairIsActiveKey = "usdn_dyz_is_active"
1313
14-let oracleAddress = Address(base58'3N7G2kVtBTh94aEnDHQ9dpi4EdsDxAiDXjB')
14+let ethDyzPairIsActiveKey = "eth_dyz_is_active"
1515
1616 let dyzraptAssetId = base58'Bi4jxKEFjjYG2emeyxZfpkVMS88N7uAogHNsi1urkoJA'
1717
1818 let ethAssetId = base58'3JJkzB4pFXcqdJvC9TcV8ys1FLgesr5SxbhmykkpceQp'
1919
2020 let usdnAssetId = base58'9Nf5wpj6jds3VRZKDryp6Dtf3R9d8MdbjNhencLogCr5'
2121
22-func getFeeAmount (amount) = {
23- let fee = fraction(amount, 3, 100)
24- fee
25- }
26-
27-
28-func getIntKeyData (key) = {
29- let v = valueOrElse(getInteger(this, key), 0)
30- v
31- }
32-
33-
34-func getTotalFeeEth () = getIntKeyData(totalFeeEthKey)
35-
36-
37-func getTotalFeeUsd () = getIntKeyData(totalFeeUsdKey)
38-
39-
40-func getTotalFeeDyzrapt () = getIntKeyData(totalFeeDyzraptKey)
41-
42-
43-func usdnToDyzrapt (amount) = {
44- let dyzraptPrice = valueOrErrorMessage(getInteger(oracleAddress, priceOfDyzraptKey), "Unable to load price")
45- fraction(amount, 10000, dyzraptPrice)
46- }
47-
48-
49-func dyzraptToUsdn (amount) = {
50- let dyzraptPrice = valueOrErrorMessage(getInteger(oracleAddress, priceOfDyzraptKey), "Unable to load price")
51- fraction(amount, dyzraptPrice, 10000)
52- }
53-
22+let adminPublicKey = base58'CgByewRUvLk7UtWSfRMLSYw4Ap2wT5dcdVYKideqDp9M'
5423
5524 @Callable(i)
56-func test () = {
57- let pmt = value(i.payments[0])
58- let assetId = pmt.assetId
59- let amount = pmt.amount
60- if ((assetId == dyzraptAssetId))
61- then throw(("its a dyzrapt. Amount=" + toString(amount)))
62- else throw("its not a dyzrapt")
63- }
64-
65-
66-
67-@Callable(i)
68-func swapUsdnToDyzrapt () = {
69- let pmt = value(i.payments[0])
70- let assetId = pmt.assetId
71- let totalAmount = pmt.amount
72- if ((assetId != usdnAssetId))
73- then throw("Only USDN tokens are allowed for swapping")
25+func initUsdnDyzPair () = if (isDefined(getBoolean(this, usdnDyzPairIsActiveKey)))
26+ then throw("Pair is already active")
27+ else if ((i.callerPublicKey != adminPublicKey))
28+ then throw("Only admin can activate pair")
7429 else {
75- let fee = getFeeAmount(totalAmount)
76- let amount = (totalAmount - fee)
77- let dyzraptAmount = usdnToDyzrapt(amount)
78- let savedFee = getTotalFeeUsd()
79- let totalFee = (savedFee + fee)
80-[IntegerEntry(totalFeeUsdKey, totalFee), ScriptTransfer(i.caller, dyzraptAmount, dyzraptAssetId)]
30+ let $t09381015 = $Tuple2(i.payments[0].amount, i.payments[0].assetId)
31+ let pmtAmountA = $t09381015._1
32+ let pmtAssetIdA = $t09381015._2
33+ let $t010241101 = $Tuple2(i.payments[1].amount, i.payments[1].assetId)
34+ let pmtAmountB = $t010241101._1
35+ let pmtAssetIdB = $t010241101._2
36+ if ((pmtAssetIdA != usdnAssetId))
37+ then throw("A asset is not a usdn")
38+ else if ((pmtAssetIdB != dyzraptAssetId))
39+ then throw("B asset is not a dyzrupt")
40+ else throw("hello")
8141 }
82- }
83-
84-
85-
86-@Callable(i)
87-func swapEthToDyzrapt () = {
88- let pmt = value(i.payments[0])
89- let assetId = pmt.assetId
90- let totalAmount = pmt.amount
91- if ((assetId != ethAssetId))
92- then throw("Only WETH tokens are allowed for swapping")
93- else {
94- let fee = getFeeAmount(totalAmount)
95- let amount = (totalAmount - fee)
96- let ethPrice = valueOrErrorMessage(getInteger(oracleAddress, priceOfEthKey), "Unable to load price")
97- let usdnAmount = fraction(amount, ethPrice, 10000)
98- let dyzraptAmount = usdnToDyzrapt(usdnAmount)
99- let savedFee = getTotalFeeEth()
100- let totalFee = (savedFee + fee)
101-[IntegerEntry(totalFeeEthKey, totalFee), ScriptTransfer(i.caller, dyzraptAmount, dyzraptAssetId)]
102- }
103- }
104-
105-
106-
107-@Callable(i)
108-func swapDyzraptToUsdn () = {
109- let pmt = value(i.payments[0])
110- let assetId = pmt.assetId
111- let totalAmount = pmt.amount
112- if ((assetId != dyzraptAssetId))
113- then throw("Only DYZRAPT tokens are allowed for swapping")
114- else {
115- let fee = getFeeAmount(totalAmount)
116- let amount = (totalAmount - fee)
117- let usdnAmount = dyzraptToUsdn(amount)
118- let savedFee = getTotalFeeDyzrapt()
119- let totalFee = (savedFee + fee)
120-[IntegerEntry(totalFeeDyzraptKey, totalFee), ScriptTransfer(i.caller, usdnAmount, usdnAssetId)]
121- }
122- }
123-
124-
125-
126-@Callable(i)
127-func swapDyzraptToEth () = {
128- let pmt = value(i.payments[0])
129- let assetId = pmt.assetId
130- let totalAmount = pmt.amount
131- if ((assetId != dyzraptAssetId))
132- then throw("Only DYZRAPT tokens are allowed for swapping")
133- else {
134- let fee = getFeeAmount(totalAmount)
135- let amount = (totalAmount - fee)
136- let usdnAmount = dyzraptToUsdn(amount)
137- let ethPrice = valueOrErrorMessage(getInteger(oracleAddress, priceOfEthKey), "Unable to load price")
138- let ethAmount = fraction(usdnAmount, 10000, ethPrice)
139- let savedFee = getTotalFeeDyzrapt()
140- let totalFee = (savedFee + fee)
141-[IntegerEntry(totalFeeDyzraptKey, totalFee), ScriptTransfer(i.caller, ethAmount, ethAssetId)]
142- }
143- }
14442
14543

github/deemru/w8io/169f3d6 
57.61 ms