tx · D122vmEdqLmEQaJcHC6PD8NFyvaLVFECSTjr5sA6FNL2

3MwLW8P5yh5T2xML9QqFuVxkVkm9RXqnzXh:  -0.01000000 Waves

2022.12.07 03:26 [2349211] smart account 3MwLW8P5yh5T2xML9QqFuVxkVkm9RXqnzXh > SELF 0.00000000 Waves

{ "type": 13, "id": "D122vmEdqLmEQaJcHC6PD8NFyvaLVFECSTjr5sA6FNL2", "fee": 1000000, "feeAssetId": null, "timestamp": 1670372865188, "version": 2, "chainId": 84, "sender": "3MwLW8P5yh5T2xML9QqFuVxkVkm9RXqnzXh", "senderPublicKey": "HscGVyJG5M3NMHWKfQbucCBsFLGPi8VmTxTAmcBbaWTa", "proofs": [ "63xE7MGLgXGA68C4uFd87SLt9YNykKA1vjTJiyrvnNTkNRmy7HvVhzcYHGEhA8G8cZicZedkJUGtwynMRK6H4qQ2" ], "script": "base64:BgITCAISAwoBCBIDCgEIEgASAwoBARcABlNjYWxlNgDAhD0ABlNjYWxlOACAwtcvAAdTY2FsZTE2CQBoAgUGU2NhbGU4BQZTY2FsZTgACnZhbGlkYXRvcnMJAMwIAgIjM05BbXFHanhSQlJQb1JIWlVVcXZoaU5TNmF4bkdwaW5MSEMFA25pbAAPbW9uZXlCb3hBZGRyZXNzCQEHQWRkcmVzcwEBGgFUZKnP467xWXotJQOt2k8QiNBvrQpHH8SpAAdhc3NldElkAixISG1hRlFwVW9id0t4emp6NEVDYUJQdG9GNjlrdWpLd1UyY296YVV6VHNndgALcHV6emxlUG9vbHMJAMwIAgIjM042U3RKZGdtVGZBUnNSTm45WHQ1ckRZRXMzcHI0S0d5MXYJAMwIAgIjM014RFREUXRuUjd6cEx1SHlneGdGenJxS1oyQlN3emNqeWEFA25pbAEKZ2V0QmFsYW5jZQEHYXNzZXRJZAQHJG1hdGNoMAUHYXNzZXRJZAMJAAECBQckbWF0Y2gwAgRVbml0BAF4BQckbWF0Y2gwCAkA7wcBBQR0aGlzCWF2YWlsYWJsZQkA8AcCBQR0aGlz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prev: 38LLYjrH2aafmNSn1s467uEpumUUoQxxsjnrs13fQ2Fy Next: 97kHeeMZRJKL9B56kwhMBxvdh87ycc4CazKJX4QJrVHK Diff:
OldNewDifferences
1313
1414 let assetId = "HHmaFQpUobwKxzjz4ECaBPtoF69kujKwU2cozaUzTsgv"
1515
16-let puzzlePools = ["3N6StJdgmTfARsRNn9Xt5rDYEs3pr4KGy1v"]
16+let puzzlePools = ["3N6StJdgmTfARsRNn9Xt5rDYEs3pr4KGy1v", "3MxDTDQtnR7zpLuHygxgFzrqKZ2BSwzcjya"]
1717
1818 func getBalance (assetId) = match assetId {
1919 case x: Unit =>
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
16-let puzzlePools = ["3N6StJdgmTfARsRNn9Xt5rDYEs3pr4KGy1v"]
16+let puzzlePools = ["3N6StJdgmTfARsRNn9Xt5rDYEs3pr4KGy1v", "3MxDTDQtnR7zpLuHygxgFzrqKZ2BSwzcjya"]
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 calculateFee () = {
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) = 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 inv = invoke(Address(fromBase58String(poolId)), "supply", nil, [AttachedPayment(assetBytes, balance)])
118118 if ((inv == inv))
119119 then [StringEntry("currentPool", poolId)]
120120 else throw("Strict value is not equal to itself.")
121121 }
122122
123123
124124 func chargeFeeResult (poolId,fee) = {
125125 let withdrawFeeTx = withdrawFromPuzzlePool(poolId, fee)
126126 if ((withdrawFeeTx == withdrawFeeTx))
127127 then [ScriptTransfer(moneyBoxAddress, fee, fromBase58String(assetId))]
128128 else throw("Strict value is not equal to itself.")
129129 }
130130
131131
132132 func withdrawResult () = {
133133 let currentPool = tryGetStr(this, "currentPool")
134134 if ((currentPool == ""))
135135 then throw(("Cannot find pool with id " + currentPool))
136136 else {
137137 let amount = getPuzzlePoolSuppliedAmount(currentPool)
138138 let tx = withdrawFromPuzzlePool(currentPool, amount)
139139 if ((tx == tx))
140140 then tx
141141 else throw("Strict value is not equal to itself.")
142142 }
143143 }
144144
145145
146146 func stakeResult (user,amount) = {
147147 let sAmount = fraction(amount, Scale8, calculateSRate())
148148 (recalcResult(sAmount) ++ [IntegerEntry((user + "_staked"), (tryGetInt(this, (user + "_staked")) + sAmount))])
149149 }
150150
151151
152152 func unstakeResult (user,amount) = {
153153 let sAmount = fraction(amount, Scale8, calculateSRate())
154154 let userStaked = tryGetInt(this, (user + "_staked"))
155155 let unstakeAmount = if ((sAmount > userStaked))
156156 then userStaked
157157 else sAmount
158158 (recalcResult(-(unstakeAmount)) ++ [IntegerEntry((user + "_staked"), (userStaked - unstakeAmount))])
159159 }
160160
161161
162162 func withdrawAndTransferResult (currentPool,caller,amount) = {
163163 let tx = withdrawFromPuzzlePool(currentPool, amount)
164164 if ((tx == tx))
165165 then [ScriptTransfer(caller, amount, fromBase58String(assetId))]
166166 else throw("Strict value is not equal to itself.")
167167 }
168168
169169
170170 @Callable(i)
171171 func init (poolId) = {
172172 let currentPool = tryGetStr(this, "currentPool")
173173 if ((indexOf(validators, toString(i.caller)) == unit))
174174 then throw("Access denied")
175175 else if ((currentPool == ""))
176176 then [StringEntry("currentPool", poolId)]
177177 else nil
178178 }
179179
180180
181181
182182 @Callable(i)
183183 func rebalance (poolId) = {
184184 let currentPool = tryGetStr(this, "currentPool")
185185 if ((indexOf(validators, toString(i.caller)) == unit))
186186 then throw("Access denied")
187187 else if ((currentPool == poolId))
188188 then throw(("Already supplied to" + currentPool))
189189 else {
190190 let withdrawTx = withdrawResult()
191191 if ((withdrawTx == withdrawTx))
192192 then supplyResult(poolId)
193193 else throw("Strict value is not equal to itself.")
194194 }
195195 }
196196
197197
198198
199199 @Callable(i)
200200 func stake () = {
201201 let user = toString(i.caller)
202202 let amount = i.payments[0].amount
203203 let currentPool = tryGetStr(this, "currentPool")
204204 if (if ((0 >= amount))
205205 then true
206206 else (i.payments[0].assetId != fromBase58String(assetId)))
207207 then throw("invalid token attached")
208208 else if ((currentPool == ""))
209209 then throw("Pool not initialized")
210210 else {
211211 let fee = calculateFee()
212212 if ((fee == fee))
213213 then ((stakeResult(user, amount) ++ supplyResult(currentPool)) ++ chargeFeeResult(currentPool, fee))
214214 else throw("Strict value is not equal to itself.")
215215 }
216216 }
217217
218218
219219
220220 @Callable(i)
221221 func unstake (amount) = {
222222 let user = toString(i.caller)
223223 let currentPool = tryGetStr(this, "currentPool")
224224 let asset = fromBase58String(assetId)
225225 let fee = calculateFee()
226226 if ((fee == fee))
227227 then ((unstakeResult(user, amount) ++ withdrawAndTransferResult(currentPool, i.caller, amount)) ++ chargeFeeResult(currentPool, fee))
228228 else throw("Strict value is not equal to itself.")
229229 }
230230
231231
232232 @Verifier(tx)
233233 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
234234

github/deemru/w8io/026f985 
39.41 ms