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