tx · 4CuLC9CLa76mqGzE5JGsAFmXKDGJf9Xr6ThwyGB3G6V5

3MwLW8P5yh5T2xML9QqFuVxkVkm9RXqnzXh:  -0.00900000 Waves

2022.12.01 22:21 [2341679] smart account 3MwLW8P5yh5T2xML9QqFuVxkVkm9RXqnzXh > SELF 0.00000000 Waves

{ "type": 13, "id": "4CuLC9CLa76mqGzE5JGsAFmXKDGJf9Xr6ThwyGB3G6V5", "fee": 900000, "feeAssetId": null, "timestamp": 1669922581119, "version": 2, "chainId": 84, "sender": "3MwLW8P5yh5T2xML9QqFuVxkVkm9RXqnzXh", "senderPublicKey": "HscGVyJG5M3NMHWKfQbucCBsFLGPi8VmTxTAmcBbaWTa", "proofs": [ "2yPrkrnBkyuKMBgLVRSDMLX1XAxW3M1dzqDPHeA49249Nfnsd1GRhAiMeirvx8XXr2WdokACTDJqLaDV7jgbFpw2" ], "script": "base64:BgITCAISAwoBCBIDCgEIEgASAwoBARMABlNjYWxlNgDAhD0ABlNjYWxlOACAwtcvAAdTY2FsZTE2CQBoAgUGU2NhbGU4BQZTY2FsZTgACnZhbGlkYXRvcnMJAMwIAgIjM05BbXFHanhSQlJQb1JIWlVVcXZoaU5TNmF4bkdwaW5MSEMFA25pbAAHYXNzZXRJZAIsSEhtYUZRcFVvYndLeHpqejRFQ2FCUHRvRjY5a3VqS3dVMmNvemFVelRzZ3YAC3B1enpsZVBvb2xzCQDMCAICIzNONlN0SmRnbVRmQVJzUk5uOVh0NXJEWUVzM3ByNEtHeTF2BQNuaWwBCmdldEJhbGFuY2UBB2Fzc2V0SWQEByRtYXRjaDAFB2Fzc2V0SWQDCQABAgUHJG1hdGNoMAIEVW5pdAQBeAUHJG1hdGNoMAgJAO8HAQUEdGhpcwlhdmFpbGFibGUJAPAHAgUEdGhpcwkBBXZhbHVlAQUHYXNzZXRJZAEJdHJ5R2V0SW50AgdhZGRyZXNzA2tleQQHJG1hdGNoMAkAmggCBQdhZGRyZXNzBQNrZXkDCQABAgUHJG1hdGN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mVudFBvb2wCAAkAAgECFFBvb2wgbm90IGluaXRpYWxpemVkCQDOCAIJAQtzdGFrZVJlc3VsdAIFBHVzZXIFBmFtb3VudAkBDHN1cHBseVJlc3VsdAEFC2N1cnJlbnRQb29sAWkBB3Vuc3Rha2UBBmFtb3VudAQEdXNlcgkApQgBCAUBaQZjYWxsZXIEC2N1cnJlbnRQb29sCQEJdHJ5R2V0U3RyAgUEdGhpcwILY3VycmVudFBvb2wEAnR4CQEWd2l0aGRyYXdGcm9tUHV6emxlUG9vbAIFC2N1cnJlbnRQb29sBQZhbW91bnQDCQAAAgUCdHgFAnR4CQDOCAIJAQ11bnN0YWtlUmVzdWx0AgUEdXNlcgUGYW1vdW50CQDMCAIJAQ5TY3JpcHRUcmFuc2ZlcgMIBQFpBmNhbGxlcgUGYW1vdW50CQDZBAEFB2Fzc2V0SWQFA25pbAkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgECdHgBBnZlcmlmeQAJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAIBQJ0eA9zZW5kZXJQdWJsaWNLZXlkpqDV", "height": 2341679, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: ALUPCoxYdG6XSME6xfy1pfkNe8T9vpxsPtZUjpVU1rwz Next: ChtSv1AseKpKtu36yP5ZvmQnnUXbfv1EekzVwjGGh36e Diff:
OldNewDifferences
8888 func recalcResult (stakedChange) = {
8989 let stakedAmount = tryGetInt(this, "global_staked")
9090 let sRate = calculateSRate()
91-[IntegerEntry("global_staked", (stakedAmount + stakedChange)), IntegerEntry("global_lastCheckSRate", sRate), IntegerEntry("global_lastCheckSRateHeight", height)]
91+[IntegerEntry("global_staked", (stakedAmount + stakedChange)), IntegerEntry("global_lastCheckSRate", sRate)]
9292 }
9393
9494
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let Scale6 = 1000000
55
66 let Scale8 = 100000000
77
88 let Scale16 = (Scale8 * Scale8)
99
1010 let validators = ["3NAmqGjxRBRPoRHZUUqvhiNS6axnGpinLHC"]
1111
1212 let assetId = "HHmaFQpUobwKxzjz4ECaBPtoF69kujKwU2cozaUzTsgv"
1313
1414 let puzzlePools = ["3N6StJdgmTfARsRNn9Xt5rDYEs3pr4KGy1v"]
1515
1616 func getBalance (assetId) = match assetId {
1717 case x: Unit =>
1818 wavesBalance(this).available
1919 case _ =>
2020 assetBalance(this, value(assetId))
2121 }
2222
2323
2424 func tryGetInt (address,key) = match getInteger(address, key) {
2525 case b: Int =>
2626 b
2727 case _ =>
2828 0
2929 }
3030
3131
3232 func tryGetStr (address,key) = match getString(address, key) {
3333 case b: String =>
3434 b
3535 case _ =>
3636 ""
3737 }
3838
3939
4040 func getAssetString (assetId) = match assetId {
4141 case b: ByteVector =>
4242 toBase58String(b)
4343 case _ =>
4444 "WAVES"
4545 }
4646
4747
4848 func getPuzzlePoolSuppliedAmount (poolId) = {
4949 let balance = assetBalance(Address(fromBase58String(poolId)), fromBase58String(assetId))
5050 balance
5151 }
5252
5353
5454 func getTotalSuppliedAmount () = {
5555 let currentPool = tryGetStr(this, "currentPool")
5656 if ((currentPool == ""))
5757 then throw(("Cannot find pool with id " + currentPool))
5858 else getPuzzlePoolSuppliedAmount(currentPool)
5959 }
6060
6161
6262 func withdrawFromPuzzlePool (poolId,amount) = {
6363 let poolAddress = Address(fromBase58String(poolId))
6464 let withdrawTx = if ((amount > 0))
6565 then invoke(poolAddress, "withdraw", [assetId, amount], nil)
6666 else ""
6767 if ((withdrawTx == withdrawTx))
6868 then withdrawTx
6969 else throw("Strict value is not equal to itself.")
7070 }
7171
7272
7373 func calculateSRate () = {
7474 let lastCheckSRate = tryGetInt(this, "global_lastCheckSRate")
7575 let stakedAmount = tryGetInt(this, "global_staked")
7676 let lastCheckSAmounut = fraction(stakedAmount, lastCheckSRate, Scale8)
7777 if ((lastCheckSAmounut == 0))
7878 then Scale8
7979 else {
8080 let sRate = fraction(lastCheckSRate, getTotalSuppliedAmount(), lastCheckSAmounut)
8181 if ((Scale8 > sRate))
8282 then Scale8
8383 else sRate
8484 }
8585 }
8686
8787
8888 func recalcResult (stakedChange) = {
8989 let stakedAmount = tryGetInt(this, "global_staked")
9090 let sRate = calculateSRate()
91-[IntegerEntry("global_staked", (stakedAmount + stakedChange)), IntegerEntry("global_lastCheckSRate", sRate), IntegerEntry("global_lastCheckSRateHeight", height)]
91+[IntegerEntry("global_staked", (stakedAmount + stakedChange)), IntegerEntry("global_lastCheckSRate", sRate)]
9292 }
9393
9494
9595 func supplyResult (poolId) = if ((indexOf(puzzlePools, poolId) == unit))
9696 then throw(("Unknown poolId " + poolId))
9797 else {
9898 let assetBytes = fromBase58String(assetId)
9999 let balance = getBalance(assetBytes)
100100 let inv = invoke(Address(fromBase58String(poolId)), "supply", nil, [AttachedPayment(assetBytes, balance)])
101101 if ((inv == inv))
102102 then [StringEntry("currentPool", poolId)]
103103 else throw("Strict value is not equal to itself.")
104104 }
105105
106106
107107 func withdrawResult () = {
108108 let currentPool = tryGetStr(this, "currentPool")
109109 if ((currentPool == ""))
110110 then throw(("Cannot find pool with id " + currentPool))
111111 else {
112112 let amount = getPuzzlePoolSuppliedAmount(currentPool)
113113 let tx = withdrawFromPuzzlePool(currentPool, amount)
114114 if ((tx == tx))
115115 then tx
116116 else throw("Strict value is not equal to itself.")
117117 }
118118 }
119119
120120
121121 func stakeResult (user,amount) = {
122122 let sAmount = fraction(amount, Scale8, calculateSRate())
123123 (recalcResult(sAmount) ++ [IntegerEntry((user + "_staked"), (tryGetInt(this, (user + "_staked")) + sAmount))])
124124 }
125125
126126
127127 func unstakeResult (user,amount) = {
128128 let sAmount = fraction(amount, Scale8, calculateSRate())
129129 let userStaked = tryGetInt(this, (user + "_staked"))
130130 let unstakeAmount = if ((sAmount > userStaked))
131131 then userStaked
132132 else sAmount
133133 (recalcResult(-(sAmount)) ++ [IntegerEntry((user + "_staked"), (userStaked - unstakeAmount))])
134134 }
135135
136136
137137 @Callable(i)
138138 func init (poolId) = {
139139 let currentPool = tryGetStr(this, "currentPool")
140140 if ((indexOf(validators, toString(i.caller)) == unit))
141141 then throw("Access denied")
142142 else if ((currentPool == ""))
143143 then [StringEntry("currentPool", poolId)]
144144 else nil
145145 }
146146
147147
148148
149149 @Callable(i)
150150 func rebalance (poolId) = {
151151 let currentPool = tryGetStr(this, "currentPool")
152152 if ((indexOf(validators, toString(i.caller)) == unit))
153153 then throw("Access denied")
154154 else if ((currentPool == poolId))
155155 then throw(("Already supplied to" + currentPool))
156156 else {
157157 let withdrawTx = withdrawResult()
158158 if ((withdrawTx == withdrawTx))
159159 then (supplyResult(poolId) ++ recalcResult(0))
160160 else throw("Strict value is not equal to itself.")
161161 }
162162 }
163163
164164
165165
166166 @Callable(i)
167167 func stake () = {
168168 let user = toString(i.caller)
169169 let amount = i.payments[0].amount
170170 let currentPool = tryGetStr(this, "currentPool")
171171 if (if ((0 >= amount))
172172 then true
173173 else (i.payments[0].assetId != fromBase58String(assetId)))
174174 then throw("invalid token attached")
175175 else if ((currentPool == ""))
176176 then throw("Pool not initialized")
177177 else (stakeResult(user, amount) ++ supplyResult(currentPool))
178178 }
179179
180180
181181
182182 @Callable(i)
183183 func unstake (amount) = {
184184 let user = toString(i.caller)
185185 let currentPool = tryGetStr(this, "currentPool")
186186 let tx = withdrawFromPuzzlePool(currentPool, amount)
187187 if ((tx == tx))
188188 then (unstakeResult(user, amount) ++ [ScriptTransfer(i.caller, amount, fromBase58String(assetId))])
189189 else throw("Strict value is not equal to itself.")
190190 }
191191
192192
193193 @Verifier(tx)
194194 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
195195

github/deemru/w8io/026f985 
45.70 ms