tx · 2oQ3QJHoAg5mVsXyP6N3VMg76M81bCkePLi3KJ1oU9KX

3MwLcJy3MSb2kq6dUaUR5uBgm8zCKZMjz2S:  -0.01400000 Waves

2021.04.03 22:04 [1466659] smart account 3MwLcJy3MSb2kq6dUaUR5uBgm8zCKZMjz2S > SELF 0.00000000 Waves

{ "type": 13, "id": "2oQ3QJHoAg5mVsXyP6N3VMg76M81bCkePLi3KJ1oU9KX", "fee": 1400000, "feeAssetId": null, "timestamp": 1617476764833, "version": 2, "chainId": 84, "sender": "3MwLcJy3MSb2kq6dUaUR5uBgm8zCKZMjz2S", "senderPublicKey": "CgByewRUvLk7UtWSfRMLSYw4Ap2wT5dcdVYKideqDp9M", "proofs": [ "2U2eDatNBrE8BcuvfDrERYMDt98BSR9PZWCf6B5Lf9kHHn4YCr5C14n6GARJz1rfnwppMvzDUPgpf9Mv2AjYm8nH" ], "script": "base64:AAIEAAAAAAAAAAsIAhIAEgMKAQESAAAAABUAAAAAEnVzZG5EeXpBQmFsYW5jZUtleQIAAAAYdXNkbl9keXpfYV9hc3NldF9iYWxhbmNlAAAAABJ1c2RuRHl6QkJhbGFuY2VLZXkCAAAAGHVzZG5fZHl6X2JfYXNzZXRfYmFsYW5jZQAAAAARZXRoRHl6QUJhbGFuY2VLZXkCAAAAF2V0aF9keXpfYV9hc3NldF9iYWxhbmNlAAAAABFldGhEeXpCQmFsYW5jZUtleQIAAAAXZXRoX2R5el9iX2Fzc2V0X2JhbGFuY2UAAAAAFnVzZG5EeXpQYWlySXNBY3RpdmVLZXkCAAAAEnVzZG5fZHl6X2lzX2FjdGl2ZQAAAAAVZXRoRHl6UGFpcklzQWN0aXZlS2V5AgAAABFldGhfZHl6X2lzX2FjdGl2ZQAAAAAGZmVlS2V5AgAAAANmZWUAAAAADnRvdGFsRmVlRXRoS2V5AgAAAA10b3RhbF9mZWVfZXRoAAAAAA50b3RhbEZlZVVzZEtleQIAAAANdG90YWxfZmVlX3VzZAAAAAASdG90YWxGZWVEeXp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tdEFtb3VudEIIBQAAAAskdDA1MTE5NTE5NgAAAAJfMQQAAAALcG10QXNzZXRJZEIIBQAAAAskdDA1MTE5NTE5NgAAAAJfMgMJAQAAAAIhPQAAAAIFAAAAC3BtdEFzc2V0SWRBBQAAAAt1c2RuQXNzZXRJZAkAAAIAAAABAgAAABVBIGFzc2V0IGlzIG5vdCBhIHVzZG4DCQEAAAACIT0AAAACBQAAAAtwbXRBc3NldElkQgUAAAAOZHl6cmFwdEFzc2V0SWQJAAACAAAAAQIAAAAZQiAgYXNzZXQgaXMgbm90IGEgZHl6cnVwdAQAAAAIYmFsYW5jZUEJAQAAAA1nZXRJbnRLZXlEYXRhAAAAAQUAAAASdXNkbkR5ekFCYWxhbmNlS2V5BAAAAAhiYWxhbmNlQgkBAAAADWdldEludEtleURhdGEAAAABBQAAABJ1c2RuRHl6QkJhbGFuY2VLZXkEAAAAC3Rva2VuUmF0aW8xCQAAawAAAAMJAABrAAAAAwUAAAAIYmFsYW5jZUEAAAAAAAX14QAFAAAACnBtdEFtb3VudEEAAAAAAAAAAAEJAABrAAAAAwUAAAAIYmFsYW5jZUIAAAAAAAX14QAFAAAACnBtdEFtb3VudEIEAAAAC3Rva2VuUmF0aW8yCQAAawAAAAMJAABrAAAAAwUAAAAIYmFsYW5jZUEAAAAAAAX14QAFAAAACnBtdEFtb3VudEEAAAAAAAAAA+gJAABrAAAAAwUAAAAIYmFsYW5jZUIAAAAAAAX14QAFAAAACnBtdEFtb3VudEIJAAACAAAAAQkAASwAAAACCQABLAAAAAIJAAGkAAAAAQUAAAALdG9rZW5SYXRpbzECAAAAASAJAAGkAAAAAQUAAAALdG9rZW5SYXRpbzIAAAAASClBFA==", "height": 1466659, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: H3Ps2DpcnSkvWMZwgPrUc7AH59fe5ZoA4KM1MTX6on4C Next: 4SY8U1pLgFKAZGVqa64guqVYx2M5oMsChvamFBFA2Pt6 Diff:
OldNewDifferences
109109
110110
111111 @Callable(I)
112-func exchangeUsdnDyz () = if (!(isDefined(getBoolean(this, e))))
112+func exchangeUsdnDyz (P) = if (!(isDefined(getBoolean(this, e))))
113113 then throw("Pair is not active")
114114 else {
115- let P = value(I.payments[0])
116- let z = P.assetId
117- let v = P.amount
115+ let Q = value(I.payments[0])
116+ let z = Q.assetId
117+ let v = Q.amount
118118 if (if ((z != m))
119119 then (z != k)
120120 else false)
121121 then throw("Only usdn and dyzrupt are supporting")
122122 else {
123- let Q = A(z, v)
124- let x = Q._1
125- let E = Q._2
126- let F = Q._3
127- let G = Q._4
128- let H = Q._5
129- let R = y(z)
130- let S = (t(R) + x)
131-[IntegerEntry(a, G), IntegerEntry(b, H), IntegerEntry(R, S), ScriptTransfer(o, x, z), ScriptTransfer(I.caller, E, F)]
123+ let R = A(z, v)
124+ let x = R._1
125+ let E = R._2
126+ let F = R._3
127+ let G = R._4
128+ let H = R._5
129+ if ((P > E))
130+ then throw("Calculated amount to receive is less than specified minimum")
131+ else {
132+ let S = y(z)
133+ let T = (t(S) + x)
134+[IntegerEntry(a, G), IntegerEntry(b, H), IntegerEntry(S, T), ScriptTransfer(o, x, z), ScriptTransfer(I.caller, E, F)]
135+ }
132136 }
133137 }
138+
139+
140+
141+@Callable(I)
142+func addLiquidToUsdnDyz () = if (!(isDefined(getBoolean(this, e))))
143+ then throw("Pair is not active")
144+ else if ((I.callerPublicKey != n))
145+ then throw("Only admin can add liquid")
146+ else {
147+ let U = $Tuple2(I.payments[0].amount, I.payments[0].assetId)
148+ let K = U._1
149+ let L = U._2
150+ let V = $Tuple2(I.payments[1].amount, I.payments[1].assetId)
151+ let N = V._1
152+ let O = V._2
153+ if ((L != m))
154+ then throw("A asset is not a usdn")
155+ else if ((O != k))
156+ then throw("B asset is not a dyzrupt")
157+ else {
158+ let C = s(a)
159+ let D = s(b)
160+ let W = fraction(fraction(C, 100000000, K), 1, fraction(D, 100000000, N))
161+ let X = fraction(fraction(C, 100000000, K), 1000, fraction(D, 100000000, N))
162+ throw(((toString(W) + " ") + toString(X)))
163+ }
164+ }
134165
135166
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 4 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let a = "usdn_dyz_a_asset_balance"
55
66 let b = "usdn_dyz_b_asset_balance"
77
88 let c = "eth_dyz_a_asset_balance"
99
1010 let d = "eth_dyz_b_asset_balance"
1111
1212 let e = "usdn_dyz_is_active"
1313
1414 let f = "eth_dyz_is_active"
1515
1616 let g = "fee"
1717
1818 let h = "total_fee_eth"
1919
2020 let i = "total_fee_usd"
2121
2222 let j = "total_fee_dyzrapt"
2323
2424 let k = base58'Bi4jxKEFjjYG2emeyxZfpkVMS88N7uAogHNsi1urkoJA'
2525
2626 let l = base58'3JJkzB4pFXcqdJvC9TcV8ys1FLgesr5SxbhmykkpceQp'
2727
2828 let m = base58'9Nf5wpj6jds3VRZKDryp6Dtf3R9d8MdbjNhencLogCr5'
2929
3030 let n = base58'7zDUSbBXZtec3E333b1fC2wR2MPrnzh69ZrH3rwpQj9S'
3131
3232 let o = Address(base58'3N7G2kVtBTh94aEnDHQ9dpi4EdsDxAiDXjB')
3333
3434 func p (q) = {
3535 let r = valueOrErrorMessage(getInteger(this, q), "unable to read key")
3636 r
3737 }
3838
3939
4040 func s (q) = {
4141 let r = valueOrElse(getInteger(this, q), 0)
4242 r
4343 }
4444
4545
4646 func t (q) = s(q)
4747
4848
4949 func u (v) = {
5050 let w = p(g)
5151 let x = fraction(v, w, 10000)
5252 x
5353 }
5454
5555
5656 func y (z) = if ((z == m))
5757 then i
5858 else if ((z == l))
5959 then h
6060 else if ((z == k))
6161 then j
6262 else throw("Incorrect asset attached")
6363
6464
6565 func A (z,v) = {
6666 let x = u(v)
6767 let B = (v - x)
6868 let C = getIntegerValue(this, a)
6969 let D = getIntegerValue(this, b)
7070 if ((z == m))
7171 then {
7272 let E = fraction(D, B, (B + C))
7373 let F = k
7474 let G = (B + C)
7575 let H = (D - E)
7676 $Tuple5(x, E, F, G, H)
7777 }
7878 else if ((z == k))
7979 then {
8080 let E = fraction(C, B, (B + D))
8181 let F = m
8282 let G = (C - E)
8383 let H = (D + B)
8484 $Tuple5(x, E, F, G, H)
8585 }
8686 else throw("Incorrect asset attached")
8787 }
8888
8989
9090 @Callable(I)
9191 func initUsdnDyzPair () = if (isDefined(getBoolean(this, e)))
9292 then throw("Pair is already active")
9393 else if ((I.callerPublicKey != n))
9494 then throw("Only admin can activate pair")
9595 else {
9696 let J = $Tuple2(I.payments[0].amount, I.payments[0].assetId)
9797 let K = J._1
9898 let L = J._2
9999 let M = $Tuple2(I.payments[1].amount, I.payments[1].assetId)
100100 let N = M._1
101101 let O = M._2
102102 if ((L != m))
103103 then throw("A asset is not a usdn")
104104 else if ((O != k))
105105 then throw("B asset is not a dyzrupt")
106106 else [BooleanEntry(e, true), IntegerEntry(a, K), IntegerEntry(b, N), IntegerEntry(g, 300)]
107107 }
108108
109109
110110
111111 @Callable(I)
112-func exchangeUsdnDyz () = if (!(isDefined(getBoolean(this, e))))
112+func exchangeUsdnDyz (P) = if (!(isDefined(getBoolean(this, e))))
113113 then throw("Pair is not active")
114114 else {
115- let P = value(I.payments[0])
116- let z = P.assetId
117- let v = P.amount
115+ let Q = value(I.payments[0])
116+ let z = Q.assetId
117+ let v = Q.amount
118118 if (if ((z != m))
119119 then (z != k)
120120 else false)
121121 then throw("Only usdn and dyzrupt are supporting")
122122 else {
123- let Q = A(z, v)
124- let x = Q._1
125- let E = Q._2
126- let F = Q._3
127- let G = Q._4
128- let H = Q._5
129- let R = y(z)
130- let S = (t(R) + x)
131-[IntegerEntry(a, G), IntegerEntry(b, H), IntegerEntry(R, S), ScriptTransfer(o, x, z), ScriptTransfer(I.caller, E, F)]
123+ let R = A(z, v)
124+ let x = R._1
125+ let E = R._2
126+ let F = R._3
127+ let G = R._4
128+ let H = R._5
129+ if ((P > E))
130+ then throw("Calculated amount to receive is less than specified minimum")
131+ else {
132+ let S = y(z)
133+ let T = (t(S) + x)
134+[IntegerEntry(a, G), IntegerEntry(b, H), IntegerEntry(S, T), ScriptTransfer(o, x, z), ScriptTransfer(I.caller, E, F)]
135+ }
132136 }
133137 }
138+
139+
140+
141+@Callable(I)
142+func addLiquidToUsdnDyz () = if (!(isDefined(getBoolean(this, e))))
143+ then throw("Pair is not active")
144+ else if ((I.callerPublicKey != n))
145+ then throw("Only admin can add liquid")
146+ else {
147+ let U = $Tuple2(I.payments[0].amount, I.payments[0].assetId)
148+ let K = U._1
149+ let L = U._2
150+ let V = $Tuple2(I.payments[1].amount, I.payments[1].assetId)
151+ let N = V._1
152+ let O = V._2
153+ if ((L != m))
154+ then throw("A asset is not a usdn")
155+ else if ((O != k))
156+ then throw("B asset is not a dyzrupt")
157+ else {
158+ let C = s(a)
159+ let D = s(b)
160+ let W = fraction(fraction(C, 100000000, K), 1, fraction(D, 100000000, N))
161+ let X = fraction(fraction(C, 100000000, K), 1000, fraction(D, 100000000, N))
162+ throw(((toString(W) + " ") + toString(X)))
163+ }
164+ }
134165
135166

github/deemru/w8io/169f3d6 
46.99 ms