tx · 59iroGMSmdiPPrq3WA3euMj4yabWeyG5ij8cPhQVfgTd

3MvGMtmdY1eSW4iY922zj5bx8hBfyP1qgHo:  -0.04000000 Waves

2021.09.07 00:56 [1691754] smart account 3MvGMtmdY1eSW4iY922zj5bx8hBfyP1qgHo > SELF 0.00000000 Waves

{ "type": 13, "id": "59iroGMSmdiPPrq3WA3euMj4yabWeyG5ij8cPhQVfgTd", "fee": 4000000, "feeAssetId": null, "timestamp": 1630965393274, "version": 2, "chainId": 84, "sender": "3MvGMtmdY1eSW4iY922zj5bx8hBfyP1qgHo", "senderPublicKey": "CD4N2SBeZVBUwmtsqwfmQ3ZKnBP3AxpZCvJ5QkHytUed", "proofs": [ "5NDUM2bpF4Siow4F8YDcrPdFTga8Sjh7qYdyKMU22cu89mvfBNLHzLG9jSP8kgE9kaU9sTKsJ5ZQTBEgs69UnLNa" ], "script": "base64:AAIFAAAAAAAAAEQIAhIAEgQKAggYEgMKAQgSAwoBCBIECgIIBBIDCgEIEgMKAQgSBgoECAgICBIFCgMICAESAwoBCBIFCgMICAESAwoBCAAAAA8AAAAABmNvbmZpZwkBAAAAC3ZhbHVlT3JFbHNlAAAAAgkBAAAAEUBleHRyTmF0aXZlKDEwNTMpAAAAAgUAAAAEdGhpcwIAAAAGY29uZmlnAgAAAAAAAAAABWFkbWluCQEAAAALdmFsdWVPckVsc2UAAAACCQEAAAARQGV4dHJOYXRpdmUoMTA1MykAAAACCQEAAAARQGV4dHJOYXRpdmUoMTA2MikAAAABBQAAAAZjb25maWcCAAAABWFkbWluAgAAAAAAAAAABXBvb2xzCQEAAAALdmFsdWVPckVsc2UAAAACCQEAAAARQGV4dHJOYXRpdmUoMTA1MykAAAACBQAAAAR0aGlzAgAAAAVwb29scwIAAAAAAQAAAAdpc0FkbWluAAAAAQAAAA1jYWxsZXJBZGRyZXNzAwkAAAAAAAACBQAAAA1jYWxsZXJBZGRyZXNzCQEAAAARQGV4dHJOYXRpdmUoMTA2MikAAAABBQAAAAVhZG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AAAZTdHJpbmcEAAAAAXQFAAAAByRtYXRjaDAFAAAAA25pbAkAAAIAAAABAgAAABhJbmNvcnJlY3QgaW52b2tlIHJlc3VsdCEJAAACAAAAAQIAAAAkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuCQAAAgAAAAECAAAAG0JvcnJvdyBleGNlZWRzIHVzZXIgaGVhbHRoIQkAAAIAAAABAgAAABdBc3NldElkcyBkb2VzIG5vdCBtYXRjaAkAAAIAAAABAgAAABdQb29sIGFkZHJlc3Mgbm90IGZvdW5kIQAAAAFpAQAAAApkZWxldGVEYXRhAAAAAQAAAARuYW1lCQAETAAAAAIJAQAAAAtEZWxldGVFbnRyeQAAAAEFAAAABG5hbWUFAAAAA25pbAAAAADhlnHM", "height": 1691754, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 9Qg4aBQJM14m52ctZ1MorguHHCEiygA3CeFTXcXQcrmj Next: 58S5VFz1Fvx81Ufu1dckojkxjLNBcHvcMx2Gx9ZTVwvk Diff:
OldNewDifferences
6262 }
6363 }
6464
65- let $list23672401 = poolList
66- let $size23672401 = size($list23672401)
67- let $acc023672401 = $Tuple2(0, 0)
68- if (($size23672401 == 0))
69- then $acc023672401
65+ let $list23512385 = poolList
66+ let $size23512385 = size($list23512385)
67+ let $acc023512385 = $Tuple2(0, 0)
68+ if (($size23512385 == 0))
69+ then $acc023512385
7070 else {
71- let $acc123672401 = foldPools($acc023672401, $list23672401[0])
72- if (($size23672401 == 1))
73- then $acc123672401
71+ let $acc123512385 = foldPools($acc023512385, $list23512385[0])
72+ if (($size23512385 == 1))
73+ then $acc123512385
7474 else {
75- let $acc223672401 = foldPools($acc123672401, $list23672401[1])
76- if (($size23672401 == 2))
77- then $acc223672401
75+ let $acc223512385 = foldPools($acc123512385, $list23512385[1])
76+ if (($size23512385 == 2))
77+ then $acc223512385
7878 else {
79- let $acc323672401 = foldPools($acc223672401, $list23672401[2])
79+ let $acc323512385 = foldPools($acc223512385, $list23512385[2])
8080 throw("List size exceed 2")
8181 }
8282 }
9393 }
9494
9595
96-func userHasBorrow (user,poolAddress,borrowAsset) = {
96+func checkUserBorrow (user,poolAddress,borrowAsset) = {
9797 let poolAsset = getString(addressFromStringValue(poolAddress), "assetId")
9898 if ((poolAsset == borrowAsset))
9999 then {
106106 }
107107
108108
109-func userHasCollateral (user,poolAddress,CollateralAsset) = {
110- let poolAsset = getString(addressFromStringValue(poolAddress), "assetId")
111- if ((poolAsset == CollateralAsset))
112- then {
113- let userCollateral = valueOrElse(getInteger(addressFromStringValue(poolAddress), (user + "_locked")), 0)
114- if ((userCollateral > 0))
115- then true
116- else false
117- }
118- else throw("AssetIds do not match!")
109+func checkUserCollateral (user,poolAddress) = {
110+ let userCollateral = valueOrElse(getInteger(addressFromStringValue(poolAddress), (user + "_locked")), 0)
111+ if ((userCollateral > 0))
112+ then true
113+ else false
114+ }
115+
116+
117+func calcEqualCollateral (liquidationAmount,liquidationPrice,liquidationMantissa,collateralPrice,collateralMantissa,penalty) = {
118+ let baseFactor = 1000
119+ let liquidationUSD = fraction(liquidationAmount, liquidationPrice, liquidationMantissa)
120+ let penaltyUSD = fraction(liquidationUSD, penalty, baseFactor)
121+ fraction((liquidationUSD + penaltyUSD), collateralMantissa, collateralPrice)
119122 }
120123
121124
250253
251254
252255 @Callable(i)
256+func liquidateAt (userToLiquidate,liquidationPool,collateralPool,collateralAsset) = {
257+ let closeFactor = getIntegerValue(addressFromStringValue(config), "closeFactor")
258+ let penalty = getIntegerValue(addressFromStringValue(config), (collateralAsset + "_Penalty"))
259+ let liquidationAmount = i.payments[0].amount
260+ if ((checkUserHealth(userToLiquidate, 0, "", 0, "") == false))
261+ then {
262+ let borrowAsset = match i.payments[0].assetId {
263+ case t: ByteVector =>
264+ toBase58String(t)
265+ case _ =>
266+ throw("AssetId is not a String")
267+ }
268+ if (if (checkUserBorrow(userToLiquidate, liquidationPool, borrowAsset))
269+ then checkUserCollateral(userToLiquidate, collateralPool)
270+ else false)
271+ then {
272+ let result = invoke(addressFromStringValue(liquidationPool), "getBorrowUSD", [userToLiquidate], nil)
273+ if ((result == result))
274+ then {
275+ let userBorrow = match result {
276+ case t: (Int, Int, Int) =>
277+ t
278+ case _ =>
279+ throw("unexpected return value type")
280+ }
281+ let collateralResult = invoke(addressFromStringValue(collateralPool), "getCollateralUSD", [userToLiquidate], nil)
282+ if ((collateralResult == collateralResult))
283+ then {
284+ let userCollateral = match collateralResult {
285+ case a: (Int, Int, Int) =>
286+ a
287+ case _ =>
288+ throw("unexpected return value type")
289+ }
290+ if ((fraction(userBorrow._1, closeFactor, 1000) >= liquidationAmount))
291+ then {
292+ let collateralAmount = calcEqualCollateral(liquidationAmount, userBorrow._2, userBorrow._3, userCollateral._2, userCollateral._3, penalty)
293+ let repay = invoke(addressFromStringValue(liquidationPool), "repay", [userToLiquidate], i.payments)
294+ if ((repay == repay))
295+ then {
296+ let amount = invoke(addressFromStringValue(collateralPool), "payoutPenalty", [userToLiquidate, collateralAmount], nil)
297+ if ((amount == amount))
298+ then {
299+ let assetId = getStringValue(addressFromStringValue(collateralPool), "assetId")
300+ match amount {
301+ case t: Int =>
302+ if ((assetId == "WAVES"))
303+ then [ScriptTransfer(i.caller, t, unit)]
304+ else [ScriptTransfer(i.caller, t, fromBase58String(assetId))]
305+ case t: String =>
306+ nil
307+ case _ =>
308+ throw("Incorrect invoke result!")
309+ }
310+ }
311+ else throw("Strict value is not equal to itself.")
312+ }
313+ else throw("Strict value is not equal to itself.")
314+ }
315+ else throw("Liquidation amount exceeds closefactor!")
316+ }
317+ else throw("Strict value is not equal to itself.")
318+ }
319+ else throw("Strict value is not equal to itself.")
320+ }
321+ else throw("User does not have the required assets!")
322+ }
323+ else throw("Only unhealthy accounts can be liquidated!")
324+ }
325+
326+
327+
328+@Callable(i)
253329 func borrowFrom (poolAddress,assetId,amount) = if (checkPool(poolAddress))
254330 then {
255331 let poolAsset = getStringValue(addressFromStringValue(poolAddress), "assetId")
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let config = valueOrElse(getStringValue(this, "config"), "")
55
66 let admin = valueOrElse(getStringValue(addressFromStringValue(config), "admin"), "")
77
88 let pools = valueOrElse(getStringValue(this, "pools"), "")
99
1010 func isAdmin (callerAddress) = if ((callerAddress == addressFromStringValue(admin)))
1111 then true
1212 else false
1313
1414
1515 func checkPool (poolAdd) = if (contains(pools, poolAdd))
1616 then true
1717 else false
1818
1919
2020 func writeString (key,stringValue) = StringEntry(key, stringValue)
2121
2222
2323 func writeInteger (key,integerValue) = IntegerEntry(key, integerValue)
2424
2525
2626 func checkPoolLiquidity (poolAddress,amount) = {
2727 let totalSupply = getIntegerValue(addressFromStringValue(poolAddress), "totalSupply")
2828 let totalBorrow = getIntegerValue(addressFromStringValue(poolAddress), "totalBorrow")
2929 let availableLiquidity = (totalSupply - totalBorrow)
3030 if ((availableLiquidity >= amount))
3131 then true
3232 else false
3333 }
3434
3535
3636 func getHealthParameter (user,poolAddress,newDebtAmount,newDebtId,collateralAmount,collateralId) = {
3737 let result = invoke(addressFromStringValue(poolAddress), "getUserHealthParameter", [user, collateralAmount, collateralId, newDebtAmount, newDebtId], nil)
3838 match result {
3939 case t: (Int, Int) =>
4040 t
4141 case _ =>
4242 throw("Return value has the wrong data type")
4343 }
4444 }
4545
4646
4747 func calcHealthFactor (borrowCapacity,borrowCapacityUsed) = if ((borrowCapacity > 0))
4848 then fraction((borrowCapacity - borrowCapacityUsed), 1000, borrowCapacity)
4949 else 0
5050
5151
5252 func calcBorrowCBorrowCU (user,newDebtAmount,newDebtId,collateralAmount,collateralId) = {
5353 let poolList = split(pools, ";")
5454 let listSize = size(poolList)
5555 func foldPools (accum,next) = {
5656 let healthParams = getHealthParameter(user, next, newDebtAmount, newDebtId, collateralAmount, collateralId)
5757 match healthParams {
5858 case t: (Int, Int) =>
5959 $Tuple2((accum._1 + healthParams._1), (accum._2 + healthParams._2))
6060 case e =>
6161 throw("Test")
6262 }
6363 }
6464
65- let $list23672401 = poolList
66- let $size23672401 = size($list23672401)
67- let $acc023672401 = $Tuple2(0, 0)
68- if (($size23672401 == 0))
69- then $acc023672401
65+ let $list23512385 = poolList
66+ let $size23512385 = size($list23512385)
67+ let $acc023512385 = $Tuple2(0, 0)
68+ if (($size23512385 == 0))
69+ then $acc023512385
7070 else {
71- let $acc123672401 = foldPools($acc023672401, $list23672401[0])
72- if (($size23672401 == 1))
73- then $acc123672401
71+ let $acc123512385 = foldPools($acc023512385, $list23512385[0])
72+ if (($size23512385 == 1))
73+ then $acc123512385
7474 else {
75- let $acc223672401 = foldPools($acc123672401, $list23672401[1])
76- if (($size23672401 == 2))
77- then $acc223672401
75+ let $acc223512385 = foldPools($acc123512385, $list23512385[1])
76+ if (($size23512385 == 2))
77+ then $acc223512385
7878 else {
79- let $acc323672401 = foldPools($acc223672401, $list23672401[2])
79+ let $acc323512385 = foldPools($acc223512385, $list23512385[2])
8080 throw("List size exceed 2")
8181 }
8282 }
8383 }
8484 }
8585
8686
8787 func checkUserHealth (user,newDebtAmount,newDebtId,collateralAmount,collateralId) = {
8888 let bcBcu = calcBorrowCBorrowCU(user, newDebtAmount, newDebtId, collateralAmount, collateralId)
8989 let userHealth = calcHealthFactor(bcBcu._1, bcBcu._2)
9090 if ((userHealth >= 0))
9191 then true
9292 else false
9393 }
9494
9595
96-func userHasBorrow (user,poolAddress,borrowAsset) = {
96+func checkUserBorrow (user,poolAddress,borrowAsset) = {
9797 let poolAsset = getString(addressFromStringValue(poolAddress), "assetId")
9898 if ((poolAsset == borrowAsset))
9999 then {
100100 let userBorrow = valueOrElse(getInteger(addressFromStringValue(poolAddress), (user + "_borrow")), 0)
101101 if ((userBorrow > 0))
102102 then true
103103 else false
104104 }
105105 else throw("AssetIds do not match!")
106106 }
107107
108108
109-func userHasCollateral (user,poolAddress,CollateralAsset) = {
110- let poolAsset = getString(addressFromStringValue(poolAddress), "assetId")
111- if ((poolAsset == CollateralAsset))
112- then {
113- let userCollateral = valueOrElse(getInteger(addressFromStringValue(poolAddress), (user + "_locked")), 0)
114- if ((userCollateral > 0))
115- then true
116- else false
117- }
118- else throw("AssetIds do not match!")
109+func checkUserCollateral (user,poolAddress) = {
110+ let userCollateral = valueOrElse(getInteger(addressFromStringValue(poolAddress), (user + "_locked")), 0)
111+ if ((userCollateral > 0))
112+ then true
113+ else false
114+ }
115+
116+
117+func calcEqualCollateral (liquidationAmount,liquidationPrice,liquidationMantissa,collateralPrice,collateralMantissa,penalty) = {
118+ let baseFactor = 1000
119+ let liquidationUSD = fraction(liquidationAmount, liquidationPrice, liquidationMantissa)
120+ let penaltyUSD = fraction(liquidationUSD, penalty, baseFactor)
121+ fraction((liquidationUSD + penaltyUSD), collateralMantissa, collateralPrice)
119122 }
120123
121124
122125 @Callable(i)
123126 func checkUserHealthTest () = {
124127 let user = toBase58String(i.caller.bytes)
125128 let bcBcu = calcBorrowCBorrowCU(user, 0, "", 0, "")
126129 let userHealth = calcHealthFactor(bcBcu._1, bcBcu._2)
127130 [writeInteger((user + "_health"), userHealth)]
128131 }
129132
130133
131134
132135 @Callable(i)
133136 func setup (configAddress,pools) = if (if (!(isDefined(getString(this, "config"))))
134137 then !(isDefined(getString(this, "pools")))
135138 else false)
136139 then [writeString("config", configAddress), writeString("pools", makeString(pools, ";"))]
137140 else throw("Admin and config address already definied!")
138141
139142
140143
141144 @Callable(i)
142145 func addPool (poolAddress) = if (isAdmin(i.caller))
143146 then {
144147 let poolList = split(pools, ";")
145148 if ((containsElement(poolList, poolAddress) == false))
146149 then {
147150 let newPools = (poolList :+ poolAddress)
148151 [writeString("pools", makeString(newPools, ";"))]
149152 }
150153 else throw("Pool already exists!")
151154 }
152155 else throw("Address does not match with admin address!")
153156
154157
155158
156159 @Callable(i)
157160 func updateConfig (configAddress) = if (isAdmin(i.caller))
158161 then [writeString("config", configAddress)]
159162 else throw("Address does not match with admin address!")
160163
161164
162165
163166 @Callable(i)
164167 func depositAt (poolAddress,isCollateral) = if (checkPool(poolAddress))
165168 then if ((size(i.payments) > 0))
166169 then {
167170 let user = toBase58String(i.caller.bytes)
168171 let tokenAmount = invoke(addressFromStringValue(poolAddress), "deposit", [user, isCollateral], i.payments)
169172 if ((tokenAmount == tokenAmount))
170173 then {
171174 let tokenId = getStringValue(addressFromStringValue(poolAddress), "dTokenId")
172175 match tokenAmount {
173176 case t: Int =>
174177 [ScriptTransfer(i.caller, t, fromBase58String(tokenId))]
175178 case t: String =>
176179 nil
177180 case _ =>
178181 throw("Incorrect invoke result!")
179182 }
180183 }
181184 else throw("Strict value is not equal to itself.")
182185 }
183186 else throw("No payment attached!")
184187 else throw("Pool address not found!")
185188
186189
187190
188191 @Callable(i)
189192 func withdrawFrom (poolAddress) = if (checkPool(poolAddress))
190193 then {
191194 let dTokenId = getStringValue(addressFromStringValue(poolAddress), "dTokenId")
192195 if ((fromBase58String(dTokenId) == i.payments[0].assetId))
193196 then if ((size(i.payments) > 0))
194197 then {
195198 let user = toBase58String(i.caller.bytes)
196199 let tokenAmount = invoke(addressFromStringValue(poolAddress), "withdraw", [user], i.payments)
197200 if ((tokenAmount == tokenAmount))
198201 then {
199202 let tokenId = getStringValue(addressFromStringValue(poolAddress), "assetId")
200203 match tokenAmount {
201204 case t: Int =>
202205 if ((tokenId == "WAVES"))
203206 then [ScriptTransfer(i.caller, t, unit)]
204207 else [ScriptTransfer(i.caller, t, fromBase58String(tokenId))]
205208 case t: String =>
206209 nil
207210 case _ =>
208211 throw("Incorrect invoke result!")
209212 }
210213 }
211214 else throw("Strict value is not equal to itself.")
212215 }
213216 else throw("No payment attached!")
214217 else throw("AssetIds does not match")
215218 }
216219 else throw("Pool address not found!")
217220
218221
219222
220223 @Callable(i)
221224 func repayTo (poolAddress) = if (checkPool(poolAddress))
222225 then {
223226 let poolAsset = getStringValue(addressFromStringValue(poolAddress), "assetId")
224227 if ((fromBase58String(poolAsset) == i.payments[0].assetId))
225228 then if ((size(i.payments) > 0))
226229 then {
227230 let user = toBase58String(i.caller.bytes)
228231 let amount = invoke(addressFromStringValue(poolAddress), "repay", [user], i.payments)
229232 if ((amount == amount))
230233 then {
231234 let assetId = getStringValue(addressFromStringValue(poolAddress), "assetId")
232235 match amount {
233236 case t: Int =>
234237 if ((assetId == "WAVES"))
235238 then [ScriptTransfer(i.caller, t, unit)]
236239 else [ScriptTransfer(i.caller, t, fromBase58String(assetId))]
237240 case t: String =>
238241 nil
239242 case _ =>
240243 throw("Incorrect invoke result!")
241244 }
242245 }
243246 else throw("Strict value is not equal to itself.")
244247 }
245248 else throw("No payment attached!")
246249 else throw("AssetIds does not match")
247250 }
248251 else throw("Pool address not found!")
249252
250253
251254
252255 @Callable(i)
256+func liquidateAt (userToLiquidate,liquidationPool,collateralPool,collateralAsset) = {
257+ let closeFactor = getIntegerValue(addressFromStringValue(config), "closeFactor")
258+ let penalty = getIntegerValue(addressFromStringValue(config), (collateralAsset + "_Penalty"))
259+ let liquidationAmount = i.payments[0].amount
260+ if ((checkUserHealth(userToLiquidate, 0, "", 0, "") == false))
261+ then {
262+ let borrowAsset = match i.payments[0].assetId {
263+ case t: ByteVector =>
264+ toBase58String(t)
265+ case _ =>
266+ throw("AssetId is not a String")
267+ }
268+ if (if (checkUserBorrow(userToLiquidate, liquidationPool, borrowAsset))
269+ then checkUserCollateral(userToLiquidate, collateralPool)
270+ else false)
271+ then {
272+ let result = invoke(addressFromStringValue(liquidationPool), "getBorrowUSD", [userToLiquidate], nil)
273+ if ((result == result))
274+ then {
275+ let userBorrow = match result {
276+ case t: (Int, Int, Int) =>
277+ t
278+ case _ =>
279+ throw("unexpected return value type")
280+ }
281+ let collateralResult = invoke(addressFromStringValue(collateralPool), "getCollateralUSD", [userToLiquidate], nil)
282+ if ((collateralResult == collateralResult))
283+ then {
284+ let userCollateral = match collateralResult {
285+ case a: (Int, Int, Int) =>
286+ a
287+ case _ =>
288+ throw("unexpected return value type")
289+ }
290+ if ((fraction(userBorrow._1, closeFactor, 1000) >= liquidationAmount))
291+ then {
292+ let collateralAmount = calcEqualCollateral(liquidationAmount, userBorrow._2, userBorrow._3, userCollateral._2, userCollateral._3, penalty)
293+ let repay = invoke(addressFromStringValue(liquidationPool), "repay", [userToLiquidate], i.payments)
294+ if ((repay == repay))
295+ then {
296+ let amount = invoke(addressFromStringValue(collateralPool), "payoutPenalty", [userToLiquidate, collateralAmount], nil)
297+ if ((amount == amount))
298+ then {
299+ let assetId = getStringValue(addressFromStringValue(collateralPool), "assetId")
300+ match amount {
301+ case t: Int =>
302+ if ((assetId == "WAVES"))
303+ then [ScriptTransfer(i.caller, t, unit)]
304+ else [ScriptTransfer(i.caller, t, fromBase58String(assetId))]
305+ case t: String =>
306+ nil
307+ case _ =>
308+ throw("Incorrect invoke result!")
309+ }
310+ }
311+ else throw("Strict value is not equal to itself.")
312+ }
313+ else throw("Strict value is not equal to itself.")
314+ }
315+ else throw("Liquidation amount exceeds closefactor!")
316+ }
317+ else throw("Strict value is not equal to itself.")
318+ }
319+ else throw("Strict value is not equal to itself.")
320+ }
321+ else throw("User does not have the required assets!")
322+ }
323+ else throw("Only unhealthy accounts can be liquidated!")
324+ }
325+
326+
327+
328+@Callable(i)
253329 func borrowFrom (poolAddress,assetId,amount) = if (checkPool(poolAddress))
254330 then {
255331 let poolAsset = getStringValue(addressFromStringValue(poolAddress), "assetId")
256332 if ((poolAsset == assetId))
257333 then if (checkPoolLiquidity(poolAddress, amount))
258334 then {
259335 let user = toBase58String(i.caller.bytes)
260336 if ((checkUserHealth(user, amount, assetId, 0, "") == true))
261337 then {
262338 let tokenAmount = invoke(addressFromStringValue(poolAddress), "borrow", [user, amount], nil)
263339 if ((tokenAmount == tokenAmount))
264340 then match tokenAmount {
265341 case t: Int =>
266342 if ((poolAsset == "WAVES"))
267343 then [ScriptTransfer(i.caller, t, unit)]
268344 else [ScriptTransfer(i.caller, t, fromBase58String(poolAsset))]
269345 case t: String =>
270346 nil
271347 case _ =>
272348 throw("Incorrect invoke result!")
273349 }
274350 else throw("Strict value is not equal to itself.")
275351 }
276352 else throw("Borrow exceeds user health!")
277353 }
278354 else throw("Pool liquidity is not sufficient!")
279355 else throw("AssetIds does not match")
280356 }
281357 else throw("Pool address not found!")
282358
283359
284360
285361 @Callable(i)
286362 func lockAsCollateralAt (poolAddress) = if (checkPool(poolAddress))
287363 then {
288364 let dTokenId = getStringValue(addressFromStringValue(poolAddress), "dTokenId")
289365 if ((fromBase58String(dTokenId) == i.payments[0].assetId))
290366 then if ((size(i.payments) > 0))
291367 then {
292368 let user = toBase58String(i.caller.bytes)
293369 let msg = invoke(addressFromStringValue(poolAddress), "lockAsCollateral", [user], i.payments)
294370 if ((msg == msg))
295371 then match msg {
296372 case t: String =>
297373 nil
298374 case _ =>
299375 throw("Incorrect invoke result!")
300376 }
301377 else throw("Strict value is not equal to itself.")
302378 }
303379 else throw("No payment attached!")
304380 else throw("AssetIds does not match")
305381 }
306382 else throw("Pool address not found!")
307383
308384
309385
310386 @Callable(i)
311387 func redeemCollateralFrom (poolAddress,dtokeId,amount) = if (checkPool(poolAddress))
312388 then {
313389 let poolDTokenId = getStringValue(addressFromStringValue(poolAddress), "dTokenId")
314390 if ((poolDTokenId == dtokeId))
315391 then {
316392 let user = toBase58String(i.caller.bytes)
317393 if ((checkUserHealth(user, 0, "", amount, dtokeId) == true))
318394 then {
319395 let tokenAmount = invoke(addressFromStringValue(poolAddress), "redeemCollateral", [user, amount], nil)
320396 if ((tokenAmount == tokenAmount))
321397 then {
322398 let tokenId = getStringValue(addressFromStringValue(poolAddress), "dTokenId")
323399 match tokenAmount {
324400 case t: Int =>
325401 [ScriptTransfer(i.caller, t, fromBase58String(tokenId))]
326402 case t: String =>
327403 nil
328404 case _ =>
329405 throw("Incorrect invoke result!")
330406 }
331407 }
332408 else throw("Strict value is not equal to itself.")
333409 }
334410 else throw("Borrow exceeds user health!")
335411 }
336412 else throw("AssetIds does not match")
337413 }
338414 else throw("Pool address not found!")
339415
340416
341417
342418 @Callable(i)
343419 func deleteData (name) = [DeleteEntry(name)]
344420
345421

github/deemru/w8io/169f3d6 
49.01 ms