tx · CBLvu4R4BUZniPFxXFcKmH9pimLQoJjnAP8wAyVXyHtC

3MwLW8P5yh5T2xML9QqFuVxkVkm9RXqnzXh:  -0.00900000 Waves

2022.12.06 23:22 [2348954] smart account 3MwLW8P5yh5T2xML9QqFuVxkVkm9RXqnzXh > SELF 0.00000000 Waves

{ "type": 13, "id": "CBLvu4R4BUZniPFxXFcKmH9pimLQoJjnAP8wAyVXyHtC", "fee": 900000, "feeAssetId": null, "timestamp": 1670358243290, "version": 2, "chainId": 84, "sender": "3MwLW8P5yh5T2xML9QqFuVxkVkm9RXqnzXh", "senderPublicKey": "HscGVyJG5M3NMHWKfQbucCBsFLGPi8VmTxTAmcBbaWTa", "proofs": [ "3tXkH4Z7PD7P7R3GNzLoDYH1dKGFWgFoNBZATgX4JVf2j57PW7WQK4cMTT7ePWshdv5HjY8sPVFj8YeaRrzycNdK" ], "script": "base64:BgITCAISAwoBCBIDCgEIEgASAwoBARUABlNjYWxlNgDAhD0ABlNjYWxlOACAwtcvAAdTY2FsZTE2CQBoAgUGU2NhbGU4BQZTY2FsZTgACnZhbGlkYXRvcnMJAMwIAgIjM05BbXFHanhSQlJQb1JIWlVVcXZoaU5TNmF4bkdwaW5MSEMFA25pbAAPbW9uZXlCb3hBZGRyZXNzCQEHQWRkcmVzcwEBGgFUZKnP467xWXotJQOt2k8QiNBvrQpHH8SpAAdhc3NldElkAixISG1hRlFwVW9id0t4emp6NEVDYUJQdG9GNjlrdWpLd1UyY296YVV6VHNndgALcHV6emxlUG9vbHMJAMwIAgIjM042U3RKZGdtVGZBUnNSTm45WHQ1ckRZRXMzcHI0S0d5MXYFA25pbAEKZ2V0QmFsYW5jZQEHYXNzZXRJZAQHJG1hdGNoMAUHYXNzZXRJZAMJAAECBQckbWF0Y2gwAgRVbml0BAF4BQckbWF0Y2gwCAkA7wcBBQR0aGlzCWF2YWlsYWJsZQkA8AcCBQR0aGlzCQEFdmFsdWUBBQdhc3NldElkAQl0cnlHZXRJbnQCB2FkZHJl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vuc3Rha2UBBmFtb3VudAQEdXNlcgkApQgBCAUBaQZjYWxsZXIEC2N1cnJlbnRQb29sCQEJdHJ5R2V0U3RyAgUEdGhpcwILY3VycmVudFBvb2wEA2ZlZQkBB2NhbGNGZWUABAFhAwkAAAIFA2ZlZQD///////////8BAgAJAAIBCQCsAgICBUZlZTogCQCkAwEFA2ZlZQMJAAACBQFhBQFhBAVhc3NldAkA2QQBBQdhc3NldElkBAJ0eAkBFndpdGhkcmF3RnJvbVB1enpsZVBvb2wCBQtjdXJyZW50UG9vbAkAZAIFBmFtb3VudAUDZmVlAwkAAAIFAnR4BQJ0eAkAzggCCQENdW5zdGFrZVJlc3VsdAIFBHVzZXIFBmFtb3VudAkAzAgCCQEOU2NyaXB0VHJhbnNmZXIDCAUBaQZjYWxsZXIFBmFtb3VudAUFYXNzZXQJAMwIAgkBDlNjcmlwdFRyYW5zZmVyAwUPbW9uZXlCb3hBZGRyZXNzBQNmZWUFBWFzc2V0BQNuaWwJAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4JAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4BAnR4AQZ2ZXJpZnkACQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwAACAUCdHgPc2VuZGVyUHVibGljS2V56xIDEA==", "height": 2348954, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 5bSwgFi9KbYrRSbZLEPYM3UiNpCTj3d9Wxd6KTXimagH Next: HRYhJbQJiJqXikrbQ2WoCBocV85MU9zx6BPbwrUtGyps Diff:
OldNewDifferences
209209 let user = toString(i.caller)
210210 let currentPool = tryGetStr(this, "currentPool")
211211 let fee = calcFee()
212- let asset = fromBase58String(assetId)
213- let tx = withdrawFromPuzzlePool(currentPool, (amount + fee))
214- if ((tx == tx))
215- then (unstakeResult(user, amount) ++ [ScriptTransfer(i.caller, amount, asset), ScriptTransfer(moneyBoxAddress, fee, asset)])
212+ let a = if ((fee == -1))
213+ then ""
214+ else throw(("Fee: " + toString(fee)))
215+ if ((a == a))
216+ then {
217+ let asset = fromBase58String(assetId)
218+ let tx = withdrawFromPuzzlePool(currentPool, (amount + fee))
219+ if ((tx == tx))
220+ then (unstakeResult(user, amount) ++ [ScriptTransfer(i.caller, amount, asset), ScriptTransfer(moneyBoxAddress, fee, asset)])
221+ else throw("Strict value is not equal to itself.")
222+ }
216223 else throw("Strict value is not equal to itself.")
217224 }
218225
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 moneyBoxAddress = Address(base58'3My6LmrRSRvJ73T14oT5k53SGPavGFoacWc')
1313
1414 let assetId = "HHmaFQpUobwKxzjz4ECaBPtoF69kujKwU2cozaUzTsgv"
1515
1616 let puzzlePools = ["3N6StJdgmTfARsRNn9Xt5rDYEs3pr4KGy1v"]
1717
1818 func getBalance (assetId) = match assetId {
1919 case x: Unit =>
2020 wavesBalance(this).available
2121 case _ =>
2222 assetBalance(this, value(assetId))
2323 }
2424
2525
2626 func tryGetInt (address,key) = match getInteger(address, key) {
2727 case b: Int =>
2828 b
2929 case _ =>
3030 0
3131 }
3232
3333
3434 func tryGetStr (address,key) = match getString(address, key) {
3535 case b: String =>
3636 b
3737 case _ =>
3838 ""
3939 }
4040
4141
4242 func getAssetString (assetId) = match assetId {
4343 case b: ByteVector =>
4444 toBase58String(b)
4545 case _ =>
4646 "WAVES"
4747 }
4848
4949
5050 func getPuzzlePoolSuppliedAmount (poolId) = {
5151 let balance = assetBalance(Address(fromBase58String(poolId)), fromBase58String(assetId))
5252 balance
5353 }
5454
5555
5656 func getTotalSuppliedAmount () = {
5757 let currentPool = tryGetStr(this, "currentPool")
5858 if ((currentPool == ""))
5959 then throw(("Cannot find pool with id " + currentPool))
6060 else getPuzzlePoolSuppliedAmount(currentPool)
6161 }
6262
6363
6464 func withdrawFromPuzzlePool (poolId,amount) = {
6565 let poolAddress = Address(fromBase58String(poolId))
6666 let withdrawTx = if ((amount > 0))
6767 then invoke(poolAddress, "withdraw", [assetId, amount], nil)
6868 else ""
6969 if ((withdrawTx == withdrawTx))
7070 then withdrawTx
7171 else throw("Strict value is not equal to itself.")
7272 }
7373
7474
7575 func calcFee () = {
7676 let stakedAmount = tryGetInt(this, "global_staked")
7777 let lastSRate = tryGetInt(this, "global_lastCheckSRate")
7878 let sAmount = fraction(stakedAmount, lastSRate, Scale8)
7979 let totalSupplied = getTotalSuppliedAmount()
8080 let diff = (totalSupplied - sAmount)
8181 let fee = fraction(diff, 5000000, Scale8)
8282 if ((fee > 0))
8383 then fee
8484 else 0
8585 }
8686
8787
8888 func calculateSRate () = {
8989 let lastCheckSRate = tryGetInt(this, "global_lastCheckSRate")
9090 let stakedAmount = tryGetInt(this, "global_staked")
9191 let lastCheckSAmounut = fraction(stakedAmount, lastCheckSRate, Scale8)
9292 if ((lastCheckSRate == 0))
9393 then Scale8
9494 else if ((lastCheckSAmounut == 0))
9595 then lastCheckSRate
9696 else {
9797 let sRate = fraction(lastCheckSRate, (fraction((fraction(getTotalSuppliedAmount(), Scale6, lastCheckSAmounut) - Scale6), (Scale8 - 5000000), Scale8) + Scale6), Scale6)
9898 if ((Scale8 > sRate))
9999 then lastCheckSRate
100100 else sRate
101101 }
102102 }
103103
104104
105105 func recalcResult (stakedChange) = {
106106 let stakedAmount = tryGetInt(this, "global_staked")
107107 let sRate = calculateSRate()
108108 [IntegerEntry("global_staked", (stakedAmount + stakedChange)), IntegerEntry("global_lastCheckSRate", sRate)]
109109 }
110110
111111
112112 func supplyResult (poolId,fee) = if ((indexOf(puzzlePools, poolId) == unit))
113113 then throw(("Unknown poolId " + poolId))
114114 else {
115115 let assetBytes = fromBase58String(assetId)
116116 let balance = getBalance(assetBytes)
117117 let supplyTx = invoke(Address(fromBase58String(poolId)), "supply", nil, [AttachedPayment(assetBytes, balance)])
118118 if ((supplyTx == supplyTx))
119119 then {
120120 let withdrawFeeTx = withdrawFromPuzzlePool(poolId, fee)
121121 if ((withdrawFeeTx == withdrawFeeTx))
122122 then [StringEntry("currentPool", poolId), ScriptTransfer(moneyBoxAddress, fee, fromBase58String(assetId))]
123123 else throw("Strict value is not equal to itself.")
124124 }
125125 else throw("Strict value is not equal to itself.")
126126 }
127127
128128
129129 func withdrawResult () = {
130130 let currentPool = tryGetStr(this, "currentPool")
131131 if ((currentPool == ""))
132132 then throw(("Cannot find pool with id " + currentPool))
133133 else {
134134 let amount = getPuzzlePoolSuppliedAmount(currentPool)
135135 let tx = withdrawFromPuzzlePool(currentPool, amount)
136136 if ((tx == tx))
137137 then tx
138138 else throw("Strict value is not equal to itself.")
139139 }
140140 }
141141
142142
143143 func stakeResult (user,amount) = {
144144 let sAmount = fraction(amount, Scale8, calculateSRate())
145145 (recalcResult(sAmount) ++ [IntegerEntry((user + "_staked"), (tryGetInt(this, (user + "_staked")) + sAmount))])
146146 }
147147
148148
149149 func unstakeResult (user,amount) = {
150150 let sAmount = fraction(amount, Scale8, calculateSRate())
151151 let userStaked = tryGetInt(this, (user + "_staked"))
152152 let unstakeAmount = if ((sAmount > userStaked))
153153 then userStaked
154154 else sAmount
155155 (recalcResult(-(unstakeAmount)) ++ [IntegerEntry((user + "_staked"), (userStaked - unstakeAmount))])
156156 }
157157
158158
159159 @Callable(i)
160160 func init (poolId) = {
161161 let currentPool = tryGetStr(this, "currentPool")
162162 if ((indexOf(validators, toString(i.caller)) == unit))
163163 then throw("Access denied")
164164 else if ((currentPool == ""))
165165 then [StringEntry("currentPool", poolId)]
166166 else nil
167167 }
168168
169169
170170
171171 @Callable(i)
172172 func rebalance (poolId) = {
173173 let currentPool = tryGetStr(this, "currentPool")
174174 if ((indexOf(validators, toString(i.caller)) == unit))
175175 then throw("Access denied")
176176 else if ((currentPool == poolId))
177177 then throw(("Already supplied to" + currentPool))
178178 else {
179179 let withdrawTx = withdrawResult()
180180 if ((withdrawTx == withdrawTx))
181181 then (supplyResult(poolId, 0) ++ recalcResult(0))
182182 else throw("Strict value is not equal to itself.")
183183 }
184184 }
185185
186186
187187
188188 @Callable(i)
189189 func stake () = {
190190 let user = toString(i.caller)
191191 let amount = i.payments[0].amount
192192 let currentPool = tryGetStr(this, "currentPool")
193193 if (if ((0 >= amount))
194194 then true
195195 else (i.payments[0].assetId != fromBase58String(assetId)))
196196 then throw("invalid token attached")
197197 else if ((currentPool == ""))
198198 then throw("Pool not initialized")
199199 else {
200200 let fee = calcFee()
201201 (stakeResult(user, amount) ++ supplyResult(currentPool, fee))
202202 }
203203 }
204204
205205
206206
207207 @Callable(i)
208208 func unstake (amount) = {
209209 let user = toString(i.caller)
210210 let currentPool = tryGetStr(this, "currentPool")
211211 let fee = calcFee()
212- let asset = fromBase58String(assetId)
213- let tx = withdrawFromPuzzlePool(currentPool, (amount + fee))
214- if ((tx == tx))
215- then (unstakeResult(user, amount) ++ [ScriptTransfer(i.caller, amount, asset), ScriptTransfer(moneyBoxAddress, fee, asset)])
212+ let a = if ((fee == -1))
213+ then ""
214+ else throw(("Fee: " + toString(fee)))
215+ if ((a == a))
216+ then {
217+ let asset = fromBase58String(assetId)
218+ let tx = withdrawFromPuzzlePool(currentPool, (amount + fee))
219+ if ((tx == tx))
220+ then (unstakeResult(user, amount) ++ [ScriptTransfer(i.caller, amount, asset), ScriptTransfer(moneyBoxAddress, fee, asset)])
221+ else throw("Strict value is not equal to itself.")
222+ }
216223 else throw("Strict value is not equal to itself.")
217224 }
218225
219226
220227 @Verifier(tx)
221228 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
222229

github/deemru/w8io/026f985 
38.45 ms