tx · 9Qg4aBQJM14m52ctZ1MorguHHCEiygA3CeFTXcXQcrmj 3MvGMtmdY1eSW4iY922zj5bx8hBfyP1qgHo: -0.04000000 Waves 2021.09.06 20:53 [1691520] smart account 3MvGMtmdY1eSW4iY922zj5bx8hBfyP1qgHo > SELF 0.00000000 Waves
{ "type": 13, "id": "9Qg4aBQJM14m52ctZ1MorguHHCEiygA3CeFTXcXQcrmj", "fee": 4000000, "feeAssetId": null, "timestamp": 1630950844621, "version": 2, "chainId": 84, "sender": "3MvGMtmdY1eSW4iY922zj5bx8hBfyP1qgHo", "senderPublicKey": "CD4N2SBeZVBUwmtsqwfmQ3ZKnBP3AxpZCvJ5QkHytUed", "proofs": [ "3Hywj8Zn8tzciBCUMw6J3zJfKAnzWa8rBsrpeMoJiazp3HjWpCZvawawJzpV3zBQCk9eyZzZoFk7U8moCSW1PXE9" ], "script": "base64:AAIFAAAAAAAAADwIAhIAEgQKAggYEgMKAQgSAwoBCBIECgIIBBIDCgEIEgMKAQgSBQoDCAgBEgMKAQgSBQoDCAgBEgMKAQgAAAAOAAAAAAZjb25maWcJAQAAAAt2YWx1ZU9yRWxzZQAAAAIJAQAAABFAZXh0ck5hdGl2ZSgxMDUzKQAAAAIFAAAABHRoaXMCAAAABmNvbmZpZwIAAAAAAAAAAAVhZG1pbgkBAAAAC3ZhbHVlT3JFbHNlAAAAAgkBAAAAEUBleHRyTmF0aXZlKDEwNTMpAAAAAgkBAAAAEUBleHRyTmF0aXZlKDEwNjIpAAAAAQUAAAAGY29uZmlnAgAAAAVhZG1pbgIAAAAAAAAAAAVwb29scwkBAAAAC3ZhbHVlT3JFbHNlAAAAAgkBAAAAEUBleHRyTmF0aXZlKDEwNTMpAAAAAgUAAAAEdGhpcwIAAAAFcG9vbHMCAAAAAAEAAAAHaXNBZG1pbgAAAAEAAAANY2FsbGVyQWRkcmVzcwMJAAAAAAAAAgUAAAANY2FsbGVyQWRkcmVzcwkBAAAAEUBleHRyTmF0aXZlKDEwNjIpA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QAAAAFpAAAABmNhbGxlcgUAAAABdAkAAlkAAAABBQAAAAd0b2tlbklkBQAAAANuaWwDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABlN0cmluZwQAAAABdAUAAAAHJG1hdGNoMAUAAAADbmlsCQAAAgAAAAECAAAAGEluY29ycmVjdCBpbnZva2UgcmVzdWx0IQkAAAIAAAABAgAAACRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4JAAACAAAAAQIAAAAbQm9ycm93IGV4Y2VlZHMgdXNlciBoZWFsdGghCQAAAgAAAAECAAAAF0Fzc2V0SWRzIGRvZXMgbm90IG1hdGNoCQAAAgAAAAECAAAAF1Bvb2wgYWRkcmVzcyBub3QgZm91bmQhAAAAAWkBAAAACmRlbGV0ZURhdGEAAAABAAAABG5hbWUJAARMAAAAAgkBAAAAC0RlbGV0ZUVudHJ5AAAAAQUAAAAEbmFtZQUAAAADbmlsAAAAAHgdqco=", "height": 1691520, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: CAm1n28teAFVHR9ppPjewXETEf949mbNK1JqDAKAPnu2 Next: 59iroGMSmdiPPrq3WA3euMj4yabWeyG5ij8cPhQVfgTd Diff:
Old | New | Differences | |
---|---|---|---|
117 | 117 | } | |
118 | 118 | else throw("AssetIds do not match!") | |
119 | 119 | } | |
120 | + | ||
121 | + | ||
122 | + | @Callable(i) | |
123 | + | func checkUserHealthTest () = { | |
124 | + | let user = toBase58String(i.caller.bytes) | |
125 | + | let bcBcu = calcBorrowCBorrowCU(user, 0, "", 0, "") | |
126 | + | let userHealth = calcHealthFactor(bcBcu._1, bcBcu._2) | |
127 | + | [writeInteger((user + "_health"), userHealth)] | |
128 | + | } | |
129 | + | ||
120 | 130 | ||
121 | 131 | ||
122 | 132 | @Callable(i) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let config = valueOrElse(getStringValue(this, "config"), "") | |
5 | 5 | ||
6 | 6 | let admin = valueOrElse(getStringValue(addressFromStringValue(config), "admin"), "") | |
7 | 7 | ||
8 | 8 | let pools = valueOrElse(getStringValue(this, "pools"), "") | |
9 | 9 | ||
10 | 10 | func isAdmin (callerAddress) = if ((callerAddress == addressFromStringValue(admin))) | |
11 | 11 | then true | |
12 | 12 | else false | |
13 | 13 | ||
14 | 14 | ||
15 | 15 | func checkPool (poolAdd) = if (contains(pools, poolAdd)) | |
16 | 16 | then true | |
17 | 17 | else false | |
18 | 18 | ||
19 | 19 | ||
20 | 20 | func writeString (key,stringValue) = StringEntry(key, stringValue) | |
21 | 21 | ||
22 | 22 | ||
23 | 23 | func writeInteger (key,integerValue) = IntegerEntry(key, integerValue) | |
24 | 24 | ||
25 | 25 | ||
26 | 26 | func checkPoolLiquidity (poolAddress,amount) = { | |
27 | 27 | let totalSupply = getIntegerValue(addressFromStringValue(poolAddress), "totalSupply") | |
28 | 28 | let totalBorrow = getIntegerValue(addressFromStringValue(poolAddress), "totalBorrow") | |
29 | 29 | let availableLiquidity = (totalSupply - totalBorrow) | |
30 | 30 | if ((availableLiquidity >= amount)) | |
31 | 31 | then true | |
32 | 32 | else false | |
33 | 33 | } | |
34 | 34 | ||
35 | 35 | ||
36 | 36 | func getHealthParameter (user,poolAddress,newDebtAmount,newDebtId,collateralAmount,collateralId) = { | |
37 | 37 | let result = invoke(addressFromStringValue(poolAddress), "getUserHealthParameter", [user, collateralAmount, collateralId, newDebtAmount, newDebtId], nil) | |
38 | 38 | match result { | |
39 | 39 | case t: (Int, Int) => | |
40 | 40 | t | |
41 | 41 | case _ => | |
42 | 42 | throw("Return value has the wrong data type") | |
43 | 43 | } | |
44 | 44 | } | |
45 | 45 | ||
46 | 46 | ||
47 | 47 | func calcHealthFactor (borrowCapacity,borrowCapacityUsed) = if ((borrowCapacity > 0)) | |
48 | 48 | then fraction((borrowCapacity - borrowCapacityUsed), 1000, borrowCapacity) | |
49 | 49 | else 0 | |
50 | 50 | ||
51 | 51 | ||
52 | 52 | func calcBorrowCBorrowCU (user,newDebtAmount,newDebtId,collateralAmount,collateralId) = { | |
53 | 53 | let poolList = split(pools, ";") | |
54 | 54 | let listSize = size(poolList) | |
55 | 55 | func foldPools (accum,next) = { | |
56 | 56 | let healthParams = getHealthParameter(user, next, newDebtAmount, newDebtId, collateralAmount, collateralId) | |
57 | 57 | match healthParams { | |
58 | 58 | case t: (Int, Int) => | |
59 | 59 | $Tuple2((accum._1 + healthParams._1), (accum._2 + healthParams._2)) | |
60 | 60 | case e => | |
61 | 61 | throw("Test") | |
62 | 62 | } | |
63 | 63 | } | |
64 | 64 | ||
65 | 65 | let $list23672401 = poolList | |
66 | 66 | let $size23672401 = size($list23672401) | |
67 | 67 | let $acc023672401 = $Tuple2(0, 0) | |
68 | 68 | if (($size23672401 == 0)) | |
69 | 69 | then $acc023672401 | |
70 | 70 | else { | |
71 | 71 | let $acc123672401 = foldPools($acc023672401, $list23672401[0]) | |
72 | 72 | if (($size23672401 == 1)) | |
73 | 73 | then $acc123672401 | |
74 | 74 | else { | |
75 | 75 | let $acc223672401 = foldPools($acc123672401, $list23672401[1]) | |
76 | 76 | if (($size23672401 == 2)) | |
77 | 77 | then $acc223672401 | |
78 | 78 | else { | |
79 | 79 | let $acc323672401 = foldPools($acc223672401, $list23672401[2]) | |
80 | 80 | throw("List size exceed 2") | |
81 | 81 | } | |
82 | 82 | } | |
83 | 83 | } | |
84 | 84 | } | |
85 | 85 | ||
86 | 86 | ||
87 | 87 | func checkUserHealth (user,newDebtAmount,newDebtId,collateralAmount,collateralId) = { | |
88 | 88 | let bcBcu = calcBorrowCBorrowCU(user, newDebtAmount, newDebtId, collateralAmount, collateralId) | |
89 | 89 | let userHealth = calcHealthFactor(bcBcu._1, bcBcu._2) | |
90 | 90 | if ((userHealth >= 0)) | |
91 | 91 | then true | |
92 | 92 | else false | |
93 | 93 | } | |
94 | 94 | ||
95 | 95 | ||
96 | 96 | func userHasBorrow (user,poolAddress,borrowAsset) = { | |
97 | 97 | let poolAsset = getString(addressFromStringValue(poolAddress), "assetId") | |
98 | 98 | if ((poolAsset == borrowAsset)) | |
99 | 99 | then { | |
100 | 100 | let userBorrow = valueOrElse(getInteger(addressFromStringValue(poolAddress), (user + "_borrow")), 0) | |
101 | 101 | if ((userBorrow > 0)) | |
102 | 102 | then true | |
103 | 103 | else false | |
104 | 104 | } | |
105 | 105 | else throw("AssetIds do not match!") | |
106 | 106 | } | |
107 | 107 | ||
108 | 108 | ||
109 | 109 | func userHasCollateral (user,poolAddress,CollateralAsset) = { | |
110 | 110 | let poolAsset = getString(addressFromStringValue(poolAddress), "assetId") | |
111 | 111 | if ((poolAsset == CollateralAsset)) | |
112 | 112 | then { | |
113 | 113 | let userCollateral = valueOrElse(getInteger(addressFromStringValue(poolAddress), (user + "_locked")), 0) | |
114 | 114 | if ((userCollateral > 0)) | |
115 | 115 | then true | |
116 | 116 | else false | |
117 | 117 | } | |
118 | 118 | else throw("AssetIds do not match!") | |
119 | 119 | } | |
120 | + | ||
121 | + | ||
122 | + | @Callable(i) | |
123 | + | func checkUserHealthTest () = { | |
124 | + | let user = toBase58String(i.caller.bytes) | |
125 | + | let bcBcu = calcBorrowCBorrowCU(user, 0, "", 0, "") | |
126 | + | let userHealth = calcHealthFactor(bcBcu._1, bcBcu._2) | |
127 | + | [writeInteger((user + "_health"), userHealth)] | |
128 | + | } | |
129 | + | ||
120 | 130 | ||
121 | 131 | ||
122 | 132 | @Callable(i) | |
123 | 133 | func setup (configAddress,pools) = if (if (!(isDefined(getString(this, "config")))) | |
124 | 134 | then !(isDefined(getString(this, "pools"))) | |
125 | 135 | else false) | |
126 | 136 | then [writeString("config", configAddress), writeString("pools", makeString(pools, ";"))] | |
127 | 137 | else throw("Admin and config address already definied!") | |
128 | 138 | ||
129 | 139 | ||
130 | 140 | ||
131 | 141 | @Callable(i) | |
132 | 142 | func addPool (poolAddress) = if (isAdmin(i.caller)) | |
133 | 143 | then { | |
134 | 144 | let poolList = split(pools, ";") | |
135 | 145 | if ((containsElement(poolList, poolAddress) == false)) | |
136 | 146 | then { | |
137 | 147 | let newPools = (poolList :+ poolAddress) | |
138 | 148 | [writeString("pools", makeString(newPools, ";"))] | |
139 | 149 | } | |
140 | 150 | else throw("Pool already exists!") | |
141 | 151 | } | |
142 | 152 | else throw("Address does not match with admin address!") | |
143 | 153 | ||
144 | 154 | ||
145 | 155 | ||
146 | 156 | @Callable(i) | |
147 | 157 | func updateConfig (configAddress) = if (isAdmin(i.caller)) | |
148 | 158 | then [writeString("config", configAddress)] | |
149 | 159 | else throw("Address does not match with admin address!") | |
150 | 160 | ||
151 | 161 | ||
152 | 162 | ||
153 | 163 | @Callable(i) | |
154 | 164 | func depositAt (poolAddress,isCollateral) = if (checkPool(poolAddress)) | |
155 | 165 | then if ((size(i.payments) > 0)) | |
156 | 166 | then { | |
157 | 167 | let user = toBase58String(i.caller.bytes) | |
158 | 168 | let tokenAmount = invoke(addressFromStringValue(poolAddress), "deposit", [user, isCollateral], i.payments) | |
159 | 169 | if ((tokenAmount == tokenAmount)) | |
160 | 170 | then { | |
161 | 171 | let tokenId = getStringValue(addressFromStringValue(poolAddress), "dTokenId") | |
162 | 172 | match tokenAmount { | |
163 | 173 | case t: Int => | |
164 | 174 | [ScriptTransfer(i.caller, t, fromBase58String(tokenId))] | |
165 | 175 | case t: String => | |
166 | 176 | nil | |
167 | 177 | case _ => | |
168 | 178 | throw("Incorrect invoke result!") | |
169 | 179 | } | |
170 | 180 | } | |
171 | 181 | else throw("Strict value is not equal to itself.") | |
172 | 182 | } | |
173 | 183 | else throw("No payment attached!") | |
174 | 184 | else throw("Pool address not found!") | |
175 | 185 | ||
176 | 186 | ||
177 | 187 | ||
178 | 188 | @Callable(i) | |
179 | 189 | func withdrawFrom (poolAddress) = if (checkPool(poolAddress)) | |
180 | 190 | then { | |
181 | 191 | let dTokenId = getStringValue(addressFromStringValue(poolAddress), "dTokenId") | |
182 | 192 | if ((fromBase58String(dTokenId) == i.payments[0].assetId)) | |
183 | 193 | then if ((size(i.payments) > 0)) | |
184 | 194 | then { | |
185 | 195 | let user = toBase58String(i.caller.bytes) | |
186 | 196 | let tokenAmount = invoke(addressFromStringValue(poolAddress), "withdraw", [user], i.payments) | |
187 | 197 | if ((tokenAmount == tokenAmount)) | |
188 | 198 | then { | |
189 | 199 | let tokenId = getStringValue(addressFromStringValue(poolAddress), "assetId") | |
190 | 200 | match tokenAmount { | |
191 | 201 | case t: Int => | |
192 | 202 | if ((tokenId == "WAVES")) | |
193 | 203 | then [ScriptTransfer(i.caller, t, unit)] | |
194 | 204 | else [ScriptTransfer(i.caller, t, fromBase58String(tokenId))] | |
195 | 205 | case t: String => | |
196 | 206 | nil | |
197 | 207 | case _ => | |
198 | 208 | throw("Incorrect invoke result!") | |
199 | 209 | } | |
200 | 210 | } | |
201 | 211 | else throw("Strict value is not equal to itself.") | |
202 | 212 | } | |
203 | 213 | else throw("No payment attached!") | |
204 | 214 | else throw("AssetIds does not match") | |
205 | 215 | } | |
206 | 216 | else throw("Pool address not found!") | |
207 | 217 | ||
208 | 218 | ||
209 | 219 | ||
210 | 220 | @Callable(i) | |
211 | 221 | func repayTo (poolAddress) = if (checkPool(poolAddress)) | |
212 | 222 | then { | |
213 | 223 | let poolAsset = getStringValue(addressFromStringValue(poolAddress), "assetId") | |
214 | 224 | if ((fromBase58String(poolAsset) == i.payments[0].assetId)) | |
215 | 225 | then if ((size(i.payments) > 0)) | |
216 | 226 | then { | |
217 | 227 | let user = toBase58String(i.caller.bytes) | |
218 | 228 | let amount = invoke(addressFromStringValue(poolAddress), "repay", [user], i.payments) | |
219 | 229 | if ((amount == amount)) | |
220 | 230 | then { | |
221 | 231 | let assetId = getStringValue(addressFromStringValue(poolAddress), "assetId") | |
222 | 232 | match amount { | |
223 | 233 | case t: Int => | |
224 | 234 | if ((assetId == "WAVES")) | |
225 | 235 | then [ScriptTransfer(i.caller, t, unit)] | |
226 | 236 | else [ScriptTransfer(i.caller, t, fromBase58String(assetId))] | |
227 | 237 | case t: String => | |
228 | 238 | nil | |
229 | 239 | case _ => | |
230 | 240 | throw("Incorrect invoke result!") | |
231 | 241 | } | |
232 | 242 | } | |
233 | 243 | else throw("Strict value is not equal to itself.") | |
234 | 244 | } | |
235 | 245 | else throw("No payment attached!") | |
236 | 246 | else throw("AssetIds does not match") | |
237 | 247 | } | |
238 | 248 | else throw("Pool address not found!") | |
239 | 249 | ||
240 | 250 | ||
241 | 251 | ||
242 | 252 | @Callable(i) | |
243 | 253 | func borrowFrom (poolAddress,assetId,amount) = if (checkPool(poolAddress)) | |
244 | 254 | then { | |
245 | 255 | let poolAsset = getStringValue(addressFromStringValue(poolAddress), "assetId") | |
246 | 256 | if ((poolAsset == assetId)) | |
247 | 257 | then if (checkPoolLiquidity(poolAddress, amount)) | |
248 | 258 | then { | |
249 | 259 | let user = toBase58String(i.caller.bytes) | |
250 | 260 | if ((checkUserHealth(user, amount, assetId, 0, "") == true)) | |
251 | 261 | then { | |
252 | 262 | let tokenAmount = invoke(addressFromStringValue(poolAddress), "borrow", [user, amount], nil) | |
253 | 263 | if ((tokenAmount == tokenAmount)) | |
254 | 264 | then match tokenAmount { | |
255 | 265 | case t: Int => | |
256 | 266 | if ((poolAsset == "WAVES")) | |
257 | 267 | then [ScriptTransfer(i.caller, t, unit)] | |
258 | 268 | else [ScriptTransfer(i.caller, t, fromBase58String(poolAsset))] | |
259 | 269 | case t: String => | |
260 | 270 | nil | |
261 | 271 | case _ => | |
262 | 272 | throw("Incorrect invoke result!") | |
263 | 273 | } | |
264 | 274 | else throw("Strict value is not equal to itself.") | |
265 | 275 | } | |
266 | 276 | else throw("Borrow exceeds user health!") | |
267 | 277 | } | |
268 | 278 | else throw("Pool liquidity is not sufficient!") | |
269 | 279 | else throw("AssetIds does not match") | |
270 | 280 | } | |
271 | 281 | else throw("Pool address not found!") | |
272 | 282 | ||
273 | 283 | ||
274 | 284 | ||
275 | 285 | @Callable(i) | |
276 | 286 | func lockAsCollateralAt (poolAddress) = if (checkPool(poolAddress)) | |
277 | 287 | then { | |
278 | 288 | let dTokenId = getStringValue(addressFromStringValue(poolAddress), "dTokenId") | |
279 | 289 | if ((fromBase58String(dTokenId) == i.payments[0].assetId)) | |
280 | 290 | then if ((size(i.payments) > 0)) | |
281 | 291 | then { | |
282 | 292 | let user = toBase58String(i.caller.bytes) | |
283 | 293 | let msg = invoke(addressFromStringValue(poolAddress), "lockAsCollateral", [user], i.payments) | |
284 | 294 | if ((msg == msg)) | |
285 | 295 | then match msg { | |
286 | 296 | case t: String => | |
287 | 297 | nil | |
288 | 298 | case _ => | |
289 | 299 | throw("Incorrect invoke result!") | |
290 | 300 | } | |
291 | 301 | else throw("Strict value is not equal to itself.") | |
292 | 302 | } | |
293 | 303 | else throw("No payment attached!") | |
294 | 304 | else throw("AssetIds does not match") | |
295 | 305 | } | |
296 | 306 | else throw("Pool address not found!") | |
297 | 307 | ||
298 | 308 | ||
299 | 309 | ||
300 | 310 | @Callable(i) | |
301 | 311 | func redeemCollateralFrom (poolAddress,dtokeId,amount) = if (checkPool(poolAddress)) | |
302 | 312 | then { | |
303 | 313 | let poolDTokenId = getStringValue(addressFromStringValue(poolAddress), "dTokenId") | |
304 | 314 | if ((poolDTokenId == dtokeId)) | |
305 | 315 | then { | |
306 | 316 | let user = toBase58String(i.caller.bytes) | |
307 | 317 | if ((checkUserHealth(user, 0, "", amount, dtokeId) == true)) | |
308 | 318 | then { | |
309 | 319 | let tokenAmount = invoke(addressFromStringValue(poolAddress), "redeemCollateral", [user, amount], nil) | |
310 | 320 | if ((tokenAmount == tokenAmount)) | |
311 | 321 | then { | |
312 | 322 | let tokenId = getStringValue(addressFromStringValue(poolAddress), "dTokenId") | |
313 | 323 | match tokenAmount { | |
314 | 324 | case t: Int => | |
315 | 325 | [ScriptTransfer(i.caller, t, fromBase58String(tokenId))] | |
316 | 326 | case t: String => | |
317 | 327 | nil | |
318 | 328 | case _ => | |
319 | 329 | throw("Incorrect invoke result!") | |
320 | 330 | } | |
321 | 331 | } | |
322 | 332 | else throw("Strict value is not equal to itself.") | |
323 | 333 | } | |
324 | 334 | else throw("Borrow exceeds user health!") | |
325 | 335 | } | |
326 | 336 | else throw("AssetIds does not match") | |
327 | 337 | } | |
328 | 338 | else throw("Pool address not found!") | |
329 | 339 | ||
330 | 340 | ||
331 | 341 | ||
332 | 342 | @Callable(i) | |
333 | 343 | func deleteData (name) = [DeleteEntry(name)] | |
334 | 344 | ||
335 | 345 |
github/deemru/w8io/169f3d6 44.33 ms ◑