tx · 9owH2PA3p7PBCapTvqHBTfMXtKhNNgqCNMCNWu4azLnS

3MwLW8P5yh5T2xML9QqFuVxkVkm9RXqnzXh:  -0.00900000 Waves

2022.12.01 18:45 [2341477] smart account 3MwLW8P5yh5T2xML9QqFuVxkVkm9RXqnzXh > SELF 0.00000000 Waves

{ "type": 13, "id": "9owH2PA3p7PBCapTvqHBTfMXtKhNNgqCNMCNWu4azLnS", "fee": 900000, "feeAssetId": null, "timestamp": 1669909628914, "version": 2, "chainId": 84, "sender": "3MwLW8P5yh5T2xML9QqFuVxkVkm9RXqnzXh", "senderPublicKey": "HscGVyJG5M3NMHWKfQbucCBsFLGPi8VmTxTAmcBbaWTa", "proofs": [ "5M6FzMWY5qTiSnov731vErZQPzRvwhzgE135MHG3qeavAt31e1meDKiTUMoMKLpPbha5rL2Kc4sHMXF3BUZMNTAG" ], "script": "base64:BgITCAISAwoBCBIDCgEIEgASAwoBARMABlNjYWxlNgDAhD0ABlNjYWxlOACAwtcvAAdTY2FsZTE2CQBoAgUGU2NhbGU4BQZTY2FsZTgACnZhbGlkYXRvcnMJAMwIAgIjM05BbXFHanhSQlJQb1JIWlVVcXZoaU5TNmF4bkdwaW5MSEMFA25pbAAHYXNzZXRJZAIsSEhtYUZRcFVvYndLeHpqejRFQ2FCUHRvRjY5a3VqS3dVMmNvemFVelRzZ3YAC3B1enpsZVBvb2xzCQDMCAICIzNONlN0SmRnbVRmQVJzUk5uOVh0NXJEWUVzM3ByNEtHeTF2BQNuaWwBCmdldEJhbGFuY2UBB2Fzc2V0SWQEByRtYXRjaDAFB2Fzc2V0SWQDCQABAgUHJG1hdGNoMAIEVW5pdAQBeAUHJG1hdGNoMAgJAO8HAQUEdGhpcwlhdmFpbGFibGUJAPAHAgUEdGhpcwkBBXZhbHVlAQUHYXNzZXRJZAEJdHJ5R2V0SW50AgdhZGRyZXNzA2tleQQHJG1hdGNoMAkAmggCBQdhZGRyZXNzBQNrZXkDCQABAgUHJG1hdGNoMAIDSW50BA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AQEdXNlcgkApQgBCAUBaQZjYWxsZXIEBmFtb3VudAgJAJEDAggFAWkIcGF5bWVudHMAAAZhbW91bnQEC2N1cnJlbnRQb29sCQEJdHJ5R2V0U3RyAgUEdGhpcwILY3VycmVudFBvb2wDAwkAZwIAAAUGYW1vdW50BgkBAiE9AggJAJEDAggFAWkIcGF5bWVudHMAAAdhc3NldElkCQDZBAEFB2Fzc2V0SWQJAAIBAhZpbnZhbGlkIHRva2VuIGF0dGFjaGVkAwkAAAIFC2N1cnJlbnRQb29sAgAJAAIBAhRQb29sIG5vdCBpbml0aWFsaXplZAkAzggCCQELc3Rha2VSZXN1bHQCBQR1c2VyBQZhbW91bnQJAQxzdXBwbHlSZXN1bHQBBQtjdXJyZW50UG9vbAFpAQd1bnN0YWtlAQZhbW91bnQEBHVzZXIJAKUIAQgFAWkGY2FsbGVyBAtjdXJyZW50UG9vbAkBCXRyeUdldFN0cgIFBHRoaXMCC2N1cnJlbnRQb29sBAJ0eAkBFndpdGhkcmF3RnJvbVB1enpsZVBvb2wCBQtjdXJyZW50UG9vbAUGYW1vdW50AwkAAAIFAnR4BQJ0eAkAzggCCQENdW5zdGFrZVJlc3VsdAIFBHVzZXIFBmFtb3VudAkAzAgCCQEOU2NyaXB0VHJhbnNmZXIDCAUBaQZjYWxsZXIFBmFtb3VudAkA2QQBBQdhc3NldElkBQNuaWwJAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4BAnR4AQZ2ZXJpZnkACQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwAACAUCdHgPc2VuZGVyUHVibGljS2V5U6Ufrw==", "height": 2341477, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 9R6erxBzUKkVB27ngEBAaafaT1pWM9JJMBou7jjts4fs Next: GQUPP2Pu1H1yxzXsa123npXeYvUbjTjNhzSFUA2wkq2U Diff:
OldNewDifferences
138138 }
139139
140140
141-@Callable(P)
141+func P (N,v) = {
142+ let O = fraction(v, b, y())
143+ let Q = j(this, (N + "_staked"))
144+ let R = if ((O > Q))
145+ then Q
146+ else O
147+ (F(-(O)) ++ [IntegerEntry((N + "_staked"), (Q - R))])
148+ }
149+
150+
151+@Callable(S)
142152 func init (q) = {
143153 let t = n(this, "currentPool")
144- if ((indexOf(d, toString(P.caller)) == unit))
154+ if ((indexOf(d, toString(S.caller)) == unit))
145155 then throw("Access denied")
146156 else if ((t == ""))
147157 then [StringEntry("currentPool", q)]
150160
151161
152162
153-@Callable(P)
163+@Callable(S)
154164 func rebalance (q) = {
155165 let t = n(this, "currentPool")
156- if ((indexOf(d, toString(P.caller)) == unit))
166+ if ((indexOf(d, toString(S.caller)) == unit))
157167 then throw("Access denied")
158168 else if ((t == q))
159169 then throw(("Already supplied to" + t))
167177
168178
169179
170-@Callable(P)
180+@Callable(S)
171181 func stake () = {
172- let N = toString(P.caller)
173- let v = P.payments[0].amount
182+ let N = toString(S.caller)
183+ let v = S.payments[0].amount
174184 let t = n(this, "currentPool")
175185 if (if ((0 >= v))
176186 then true
177- else (P.payments[0].assetId != fromBase58String(e)))
187+ else (S.payments[0].assetId != fromBase58String(e)))
178188 then throw("invalid token attached")
179189 else if ((t == ""))
180190 then throw("Pool not initialized")
182192 }
183193
184194
195+
196+@Callable(S)
197+func unstake (v) = {
198+ let N = toString(S.caller)
199+ let t = n(this, "currentPool")
200+ let L = u(t, v)
201+ if ((L == L))
202+ then (P(N, v) ++ [ScriptTransfer(S.caller, v, fromBase58String(e))])
203+ else throw("Strict value is not equal to itself.")
204+ }
205+
206+
185207 @Verifier(L)
186-func Q () = sigVerify(L.bodyBytes, L.proofs[0], L.senderPublicKey)
208+func T () = sigVerify(L.bodyBytes, L.proofs[0], L.senderPublicKey)
187209
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let a = 1000000
55
66 let b = 100000000
77
88 let c = (b * b)
99
1010 let d = ["3NAmqGjxRBRPoRHZUUqvhiNS6axnGpinLHC"]
1111
1212 let e = "HHmaFQpUobwKxzjz4ECaBPtoF69kujKwU2cozaUzTsgv"
1313
1414 let f = ["3N6StJdgmTfARsRNn9Xt5rDYEs3pr4KGy1v"]
1515
1616 func g (e) = {
1717 let h = e
1818 if ($isInstanceOf(h, "Unit"))
1919 then {
2020 let i = h
2121 wavesBalance(this).available
2222 }
2323 else assetBalance(this, value(e))
2424 }
2525
2626
2727 func j (k,l) = {
2828 let h = getInteger(k, l)
2929 if ($isInstanceOf(h, "Int"))
3030 then {
3131 let m = h
3232 m
3333 }
3434 else 0
3535 }
3636
3737
3838 func n (k,l) = {
3939 let h = getString(k, l)
4040 if ($isInstanceOf(h, "String"))
4141 then {
4242 let m = h
4343 m
4444 }
4545 else ""
4646 }
4747
4848
4949 func o (e) = {
5050 let h = e
5151 if ($isInstanceOf(h, "ByteVector"))
5252 then {
5353 let m = h
5454 toBase58String(m)
5555 }
5656 else "WAVES"
5757 }
5858
5959
6060 func p (q) = {
6161 let r = assetBalance(Address(fromBase58String(q)), fromBase58String(e))
6262 r
6363 }
6464
6565
6666 func s () = {
6767 let t = n(this, "currentPool")
6868 if ((t == ""))
6969 then throw(("Cannot find pool with id " + t))
7070 else p(t)
7171 }
7272
7373
7474 func u (q,v) = {
7575 let w = Address(fromBase58String(q))
7676 let x = if ((v > 0))
7777 then invoke(w, "withdraw", [e, v], nil)
7878 else ""
7979 if ((x == x))
8080 then x
8181 else throw("Strict value is not equal to itself.")
8282 }
8383
8484
8585 func y () = {
8686 let z = j(this, "global_lastCheckSRate")
8787 let A = j(this, "global_staked")
8888 let B = j(this, "global_lastCheckSRateHeight")
8989 let C = (height - B)
9090 let D = (s() - fraction(A, z, b))
9191 if ((A == 0))
9292 then b
9393 else {
9494 let E = (z + fraction((C * b), D, A))
9595 if ((b > E))
9696 then b
9797 else E
9898 }
9999 }
100100
101101
102102 func F (G) = {
103103 let A = j(this, "global_staked")
104104 let E = y()
105105 [IntegerEntry("global_staked", (A + G)), IntegerEntry("global_lastCheckSRate", E), IntegerEntry("global_lastCheckSRateHeight", height)]
106106 }
107107
108108
109109 func H (q) = if ((indexOf(f, q) == unit))
110110 then throw(("Unknown poolId " + q))
111111 else {
112112 let I = fromBase58String(e)
113113 let r = g(I)
114114 let J = invoke(Address(fromBase58String(q)), "supply", nil, [AttachedPayment(I, r)])
115115 if ((J == J))
116116 then [StringEntry("currentPool", q)]
117117 else throw("Strict value is not equal to itself.")
118118 }
119119
120120
121121 func K () = {
122122 let t = n(this, "currentPool")
123123 if ((t == ""))
124124 then throw(("Cannot find pool with id " + t))
125125 else {
126126 let v = p(t)
127127 let L = u(t, v)
128128 if ((L == L))
129129 then L
130130 else throw("Strict value is not equal to itself.")
131131 }
132132 }
133133
134134
135135 func M (N,v) = {
136136 let O = fraction(v, b, y())
137137 (F(O) ++ [IntegerEntry((N + "_staked"), (j(this, (N + "_staked")) + O))])
138138 }
139139
140140
141-@Callable(P)
141+func P (N,v) = {
142+ let O = fraction(v, b, y())
143+ let Q = j(this, (N + "_staked"))
144+ let R = if ((O > Q))
145+ then Q
146+ else O
147+ (F(-(O)) ++ [IntegerEntry((N + "_staked"), (Q - R))])
148+ }
149+
150+
151+@Callable(S)
142152 func init (q) = {
143153 let t = n(this, "currentPool")
144- if ((indexOf(d, toString(P.caller)) == unit))
154+ if ((indexOf(d, toString(S.caller)) == unit))
145155 then throw("Access denied")
146156 else if ((t == ""))
147157 then [StringEntry("currentPool", q)]
148158 else nil
149159 }
150160
151161
152162
153-@Callable(P)
163+@Callable(S)
154164 func rebalance (q) = {
155165 let t = n(this, "currentPool")
156- if ((indexOf(d, toString(P.caller)) == unit))
166+ if ((indexOf(d, toString(S.caller)) == unit))
157167 then throw("Access denied")
158168 else if ((t == q))
159169 then throw(("Already supplied to" + t))
160170 else {
161171 let x = K()
162172 if ((x == x))
163173 then (H(q) ++ F(0))
164174 else throw("Strict value is not equal to itself.")
165175 }
166176 }
167177
168178
169179
170-@Callable(P)
180+@Callable(S)
171181 func stake () = {
172- let N = toString(P.caller)
173- let v = P.payments[0].amount
182+ let N = toString(S.caller)
183+ let v = S.payments[0].amount
174184 let t = n(this, "currentPool")
175185 if (if ((0 >= v))
176186 then true
177- else (P.payments[0].assetId != fromBase58String(e)))
187+ else (S.payments[0].assetId != fromBase58String(e)))
178188 then throw("invalid token attached")
179189 else if ((t == ""))
180190 then throw("Pool not initialized")
181191 else (M(N, v) ++ H(t))
182192 }
183193
184194
195+
196+@Callable(S)
197+func unstake (v) = {
198+ let N = toString(S.caller)
199+ let t = n(this, "currentPool")
200+ let L = u(t, v)
201+ if ((L == L))
202+ then (P(N, v) ++ [ScriptTransfer(S.caller, v, fromBase58String(e))])
203+ else throw("Strict value is not equal to itself.")
204+ }
205+
206+
185207 @Verifier(L)
186-func Q () = sigVerify(L.bodyBytes, L.proofs[0], L.senderPublicKey)
208+func T () = sigVerify(L.bodyBytes, L.proofs[0], L.senderPublicKey)
187209

github/deemru/w8io/169f3d6 
40.49 ms