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:AAIFAAAAAAAAAEQIAhIAEgQKAggYEgMKAQgSAwoBCBIECgIIBBIDCgEIEgMKAQgSBgoECAgICBIFCgMICAESAwoBCBIFCgMICAESAwoBCAAAAA8AAAAABmNvbmZpZwkBAAAAC3ZhbHVlT3JFbHNlAAAAAgkBAAAAEUBleHRyTmF0aXZlKDEwNTMpAAAAAgUAAAAEdGhpcwIAAAAGY29uZmlnAgAAAAAAAAAABWFkbWluCQEAAAALdmFsdWVPckVsc2UAAAACCQEAAAARQGV4dHJOYXRpdmUoMTA1MykAAAACCQEAAAARQGV4dHJOYXRpdmUoMTA2MikAAAABBQAAAAZjb25maWcCAAAABWFkbWluAgAAAAAAAAAABXBvb2xzCQEAAAALdmFsdWVPckVsc2UAAAACCQEAAAARQGV4dHJOYXRpdmUoMTA1MykAAAACBQAAAAR0aGlzAgAAAAVwb29scwIAAAAAAQAAAAdpc0FkbWluAAAAAQAAAA1jYWxsZXJBZGRyZXNzAwkAAAAAAAACBQAAAA1jYWxsZXJBZGRyZXNzCQEAAAARQGV4dHJOYXRpdmUoMTA2MikAAAABBQAAAAVhZG1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AAZTdHJpbmcEAAAAAXQFAAAAByRtYXRjaDAFAAAAA25pbAkAAAIAAAABAgAAABhJbmNvcnJlY3QgaW52b2tlIHJlc3VsdCEJAAACAAAAAQIAAAAkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuCQAAAgAAAAECAAAAG0JvcnJvdyBleGNlZWRzIHVzZXIgaGVhbHRoIQkAAAIAAAABAgAAABdBc3NldElkcyBkb2VzIG5vdCBtYXRjaAkAAAIAAAABAgAAABdQb29sIGFkZHJlc3Mgbm90IGZvdW5kIQAAAAFpAQAAAApkZWxldGVEYXRhAAAAAQAAAARuYW1lCQAETAAAAAIJAQAAAAtEZWxldGVFbnRyeQAAAAEFAAAABG5hbWUFAAAAA25pbAAAAADhlnHM", "height": 1691754, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 9Qg4aBQJM14m52ctZ1MorguHHCEiygA3CeFTXcXQcrmj Next: 58S5VFz1Fvx81Ufu1dckojkxjLNBcHvcMx2Gx9ZTVwvk Diff:
Old | New | Differences | |
---|---|---|---|
62 | 62 | } | |
63 | 63 | } | |
64 | 64 | ||
65 | - | let $ | |
66 | - | let $ | |
67 | - | let $ | |
68 | - | if (($ | |
69 | - | then $ | |
65 | + | let $list23512385 = poolList | |
66 | + | let $size23512385 = size($list23512385) | |
67 | + | let $acc023512385 = $Tuple2(0, 0) | |
68 | + | if (($size23512385 == 0)) | |
69 | + | then $acc023512385 | |
70 | 70 | else { | |
71 | - | let $ | |
72 | - | if (($ | |
73 | - | then $ | |
71 | + | let $acc123512385 = foldPools($acc023512385, $list23512385[0]) | |
72 | + | if (($size23512385 == 1)) | |
73 | + | then $acc123512385 | |
74 | 74 | else { | |
75 | - | let $ | |
76 | - | if (($ | |
77 | - | then $ | |
75 | + | let $acc223512385 = foldPools($acc123512385, $list23512385[1]) | |
76 | + | if (($size23512385 == 2)) | |
77 | + | then $acc223512385 | |
78 | 78 | else { | |
79 | - | let $ | |
79 | + | let $acc323512385 = foldPools($acc223512385, $list23512385[2]) | |
80 | 80 | throw("List size exceed 2") | |
81 | 81 | } | |
82 | 82 | } | |
93 | 93 | } | |
94 | 94 | ||
95 | 95 | ||
96 | - | func | |
96 | + | func checkUserBorrow (user,poolAddress,borrowAsset) = { | |
97 | 97 | let poolAsset = getString(addressFromStringValue(poolAddress), "assetId") | |
98 | 98 | if ((poolAsset == borrowAsset)) | |
99 | 99 | then { | |
106 | 106 | } | |
107 | 107 | ||
108 | 108 | ||
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) | |
119 | 122 | } | |
120 | 123 | ||
121 | 124 | ||
250 | 253 | ||
251 | 254 | ||
252 | 255 | @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) | |
253 | 329 | func borrowFrom (poolAddress,assetId,amount) = if (checkPool(poolAddress)) | |
254 | 330 | then { | |
255 | 331 | let poolAsset = getStringValue(addressFromStringValue(poolAddress), "assetId") |
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 | - | let $ | |
66 | - | let $ | |
67 | - | let $ | |
68 | - | if (($ | |
69 | - | then $ | |
65 | + | let $list23512385 = poolList | |
66 | + | let $size23512385 = size($list23512385) | |
67 | + | let $acc023512385 = $Tuple2(0, 0) | |
68 | + | if (($size23512385 == 0)) | |
69 | + | then $acc023512385 | |
70 | 70 | else { | |
71 | - | let $ | |
72 | - | if (($ | |
73 | - | then $ | |
71 | + | let $acc123512385 = foldPools($acc023512385, $list23512385[0]) | |
72 | + | if (($size23512385 == 1)) | |
73 | + | then $acc123512385 | |
74 | 74 | else { | |
75 | - | let $ | |
76 | - | if (($ | |
77 | - | then $ | |
75 | + | let $acc223512385 = foldPools($acc123512385, $list23512385[1]) | |
76 | + | if (($size23512385 == 2)) | |
77 | + | then $acc223512385 | |
78 | 78 | else { | |
79 | - | let $ | |
79 | + | let $acc323512385 = foldPools($acc223512385, $list23512385[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 | - | func | |
96 | + | func checkUserBorrow (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 | - | 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) | |
119 | 122 | } | |
120 | 123 | ||
121 | 124 | ||
122 | 125 | @Callable(i) | |
123 | 126 | func checkUserHealthTest () = { | |
124 | 127 | let user = toBase58String(i.caller.bytes) | |
125 | 128 | let bcBcu = calcBorrowCBorrowCU(user, 0, "", 0, "") | |
126 | 129 | let userHealth = calcHealthFactor(bcBcu._1, bcBcu._2) | |
127 | 130 | [writeInteger((user + "_health"), userHealth)] | |
128 | 131 | } | |
129 | 132 | ||
130 | 133 | ||
131 | 134 | ||
132 | 135 | @Callable(i) | |
133 | 136 | func setup (configAddress,pools) = if (if (!(isDefined(getString(this, "config")))) | |
134 | 137 | then !(isDefined(getString(this, "pools"))) | |
135 | 138 | else false) | |
136 | 139 | then [writeString("config", configAddress), writeString("pools", makeString(pools, ";"))] | |
137 | 140 | else throw("Admin and config address already definied!") | |
138 | 141 | ||
139 | 142 | ||
140 | 143 | ||
141 | 144 | @Callable(i) | |
142 | 145 | func addPool (poolAddress) = if (isAdmin(i.caller)) | |
143 | 146 | then { | |
144 | 147 | let poolList = split(pools, ";") | |
145 | 148 | if ((containsElement(poolList, poolAddress) == false)) | |
146 | 149 | then { | |
147 | 150 | let newPools = (poolList :+ poolAddress) | |
148 | 151 | [writeString("pools", makeString(newPools, ";"))] | |
149 | 152 | } | |
150 | 153 | else throw("Pool already exists!") | |
151 | 154 | } | |
152 | 155 | else throw("Address does not match with admin address!") | |
153 | 156 | ||
154 | 157 | ||
155 | 158 | ||
156 | 159 | @Callable(i) | |
157 | 160 | func updateConfig (configAddress) = if (isAdmin(i.caller)) | |
158 | 161 | then [writeString("config", configAddress)] | |
159 | 162 | else throw("Address does not match with admin address!") | |
160 | 163 | ||
161 | 164 | ||
162 | 165 | ||
163 | 166 | @Callable(i) | |
164 | 167 | func depositAt (poolAddress,isCollateral) = if (checkPool(poolAddress)) | |
165 | 168 | then if ((size(i.payments) > 0)) | |
166 | 169 | then { | |
167 | 170 | let user = toBase58String(i.caller.bytes) | |
168 | 171 | let tokenAmount = invoke(addressFromStringValue(poolAddress), "deposit", [user, isCollateral], i.payments) | |
169 | 172 | if ((tokenAmount == tokenAmount)) | |
170 | 173 | then { | |
171 | 174 | let tokenId = getStringValue(addressFromStringValue(poolAddress), "dTokenId") | |
172 | 175 | match tokenAmount { | |
173 | 176 | case t: Int => | |
174 | 177 | [ScriptTransfer(i.caller, t, fromBase58String(tokenId))] | |
175 | 178 | case t: String => | |
176 | 179 | nil | |
177 | 180 | case _ => | |
178 | 181 | throw("Incorrect invoke result!") | |
179 | 182 | } | |
180 | 183 | } | |
181 | 184 | else throw("Strict value is not equal to itself.") | |
182 | 185 | } | |
183 | 186 | else throw("No payment attached!") | |
184 | 187 | else throw("Pool address not found!") | |
185 | 188 | ||
186 | 189 | ||
187 | 190 | ||
188 | 191 | @Callable(i) | |
189 | 192 | func withdrawFrom (poolAddress) = if (checkPool(poolAddress)) | |
190 | 193 | then { | |
191 | 194 | let dTokenId = getStringValue(addressFromStringValue(poolAddress), "dTokenId") | |
192 | 195 | if ((fromBase58String(dTokenId) == i.payments[0].assetId)) | |
193 | 196 | then if ((size(i.payments) > 0)) | |
194 | 197 | then { | |
195 | 198 | let user = toBase58String(i.caller.bytes) | |
196 | 199 | let tokenAmount = invoke(addressFromStringValue(poolAddress), "withdraw", [user], i.payments) | |
197 | 200 | if ((tokenAmount == tokenAmount)) | |
198 | 201 | then { | |
199 | 202 | let tokenId = getStringValue(addressFromStringValue(poolAddress), "assetId") | |
200 | 203 | match tokenAmount { | |
201 | 204 | case t: Int => | |
202 | 205 | if ((tokenId == "WAVES")) | |
203 | 206 | then [ScriptTransfer(i.caller, t, unit)] | |
204 | 207 | else [ScriptTransfer(i.caller, t, fromBase58String(tokenId))] | |
205 | 208 | case t: String => | |
206 | 209 | nil | |
207 | 210 | case _ => | |
208 | 211 | throw("Incorrect invoke result!") | |
209 | 212 | } | |
210 | 213 | } | |
211 | 214 | else throw("Strict value is not equal to itself.") | |
212 | 215 | } | |
213 | 216 | else throw("No payment attached!") | |
214 | 217 | else throw("AssetIds does not match") | |
215 | 218 | } | |
216 | 219 | else throw("Pool address not found!") | |
217 | 220 | ||
218 | 221 | ||
219 | 222 | ||
220 | 223 | @Callable(i) | |
221 | 224 | func repayTo (poolAddress) = if (checkPool(poolAddress)) | |
222 | 225 | then { | |
223 | 226 | let poolAsset = getStringValue(addressFromStringValue(poolAddress), "assetId") | |
224 | 227 | if ((fromBase58String(poolAsset) == i.payments[0].assetId)) | |
225 | 228 | then if ((size(i.payments) > 0)) | |
226 | 229 | then { | |
227 | 230 | let user = toBase58String(i.caller.bytes) | |
228 | 231 | let amount = invoke(addressFromStringValue(poolAddress), "repay", [user], i.payments) | |
229 | 232 | if ((amount == amount)) | |
230 | 233 | then { | |
231 | 234 | let assetId = getStringValue(addressFromStringValue(poolAddress), "assetId") | |
232 | 235 | match amount { | |
233 | 236 | case t: Int => | |
234 | 237 | if ((assetId == "WAVES")) | |
235 | 238 | then [ScriptTransfer(i.caller, t, unit)] | |
236 | 239 | else [ScriptTransfer(i.caller, t, fromBase58String(assetId))] | |
237 | 240 | case t: String => | |
238 | 241 | nil | |
239 | 242 | case _ => | |
240 | 243 | throw("Incorrect invoke result!") | |
241 | 244 | } | |
242 | 245 | } | |
243 | 246 | else throw("Strict value is not equal to itself.") | |
244 | 247 | } | |
245 | 248 | else throw("No payment attached!") | |
246 | 249 | else throw("AssetIds does not match") | |
247 | 250 | } | |
248 | 251 | else throw("Pool address not found!") | |
249 | 252 | ||
250 | 253 | ||
251 | 254 | ||
252 | 255 | @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) | |
253 | 329 | func borrowFrom (poolAddress,assetId,amount) = if (checkPool(poolAddress)) | |
254 | 330 | then { | |
255 | 331 | let poolAsset = getStringValue(addressFromStringValue(poolAddress), "assetId") | |
256 | 332 | if ((poolAsset == assetId)) | |
257 | 333 | then if (checkPoolLiquidity(poolAddress, amount)) | |
258 | 334 | then { | |
259 | 335 | let user = toBase58String(i.caller.bytes) | |
260 | 336 | if ((checkUserHealth(user, amount, assetId, 0, "") == true)) | |
261 | 337 | then { | |
262 | 338 | let tokenAmount = invoke(addressFromStringValue(poolAddress), "borrow", [user, amount], nil) | |
263 | 339 | if ((tokenAmount == tokenAmount)) | |
264 | 340 | then match tokenAmount { | |
265 | 341 | case t: Int => | |
266 | 342 | if ((poolAsset == "WAVES")) | |
267 | 343 | then [ScriptTransfer(i.caller, t, unit)] | |
268 | 344 | else [ScriptTransfer(i.caller, t, fromBase58String(poolAsset))] | |
269 | 345 | case t: String => | |
270 | 346 | nil | |
271 | 347 | case _ => | |
272 | 348 | throw("Incorrect invoke result!") | |
273 | 349 | } | |
274 | 350 | else throw("Strict value is not equal to itself.") | |
275 | 351 | } | |
276 | 352 | else throw("Borrow exceeds user health!") | |
277 | 353 | } | |
278 | 354 | else throw("Pool liquidity is not sufficient!") | |
279 | 355 | else throw("AssetIds does not match") | |
280 | 356 | } | |
281 | 357 | else throw("Pool address not found!") | |
282 | 358 | ||
283 | 359 | ||
284 | 360 | ||
285 | 361 | @Callable(i) | |
286 | 362 | func lockAsCollateralAt (poolAddress) = if (checkPool(poolAddress)) | |
287 | 363 | then { | |
288 | 364 | let dTokenId = getStringValue(addressFromStringValue(poolAddress), "dTokenId") | |
289 | 365 | if ((fromBase58String(dTokenId) == i.payments[0].assetId)) | |
290 | 366 | then if ((size(i.payments) > 0)) | |
291 | 367 | then { | |
292 | 368 | let user = toBase58String(i.caller.bytes) | |
293 | 369 | let msg = invoke(addressFromStringValue(poolAddress), "lockAsCollateral", [user], i.payments) | |
294 | 370 | if ((msg == msg)) | |
295 | 371 | then match msg { | |
296 | 372 | case t: String => | |
297 | 373 | nil | |
298 | 374 | case _ => | |
299 | 375 | throw("Incorrect invoke result!") | |
300 | 376 | } | |
301 | 377 | else throw("Strict value is not equal to itself.") | |
302 | 378 | } | |
303 | 379 | else throw("No payment attached!") | |
304 | 380 | else throw("AssetIds does not match") | |
305 | 381 | } | |
306 | 382 | else throw("Pool address not found!") | |
307 | 383 | ||
308 | 384 | ||
309 | 385 | ||
310 | 386 | @Callable(i) | |
311 | 387 | func redeemCollateralFrom (poolAddress,dtokeId,amount) = if (checkPool(poolAddress)) | |
312 | 388 | then { | |
313 | 389 | let poolDTokenId = getStringValue(addressFromStringValue(poolAddress), "dTokenId") | |
314 | 390 | if ((poolDTokenId == dtokeId)) | |
315 | 391 | then { | |
316 | 392 | let user = toBase58String(i.caller.bytes) | |
317 | 393 | if ((checkUserHealth(user, 0, "", amount, dtokeId) == true)) | |
318 | 394 | then { | |
319 | 395 | let tokenAmount = invoke(addressFromStringValue(poolAddress), "redeemCollateral", [user, amount], nil) | |
320 | 396 | if ((tokenAmount == tokenAmount)) | |
321 | 397 | then { | |
322 | 398 | let tokenId = getStringValue(addressFromStringValue(poolAddress), "dTokenId") | |
323 | 399 | match tokenAmount { | |
324 | 400 | case t: Int => | |
325 | 401 | [ScriptTransfer(i.caller, t, fromBase58String(tokenId))] | |
326 | 402 | case t: String => | |
327 | 403 | nil | |
328 | 404 | case _ => | |
329 | 405 | throw("Incorrect invoke result!") | |
330 | 406 | } | |
331 | 407 | } | |
332 | 408 | else throw("Strict value is not equal to itself.") | |
333 | 409 | } | |
334 | 410 | else throw("Borrow exceeds user health!") | |
335 | 411 | } | |
336 | 412 | else throw("AssetIds does not match") | |
337 | 413 | } | |
338 | 414 | else throw("Pool address not found!") | |
339 | 415 | ||
340 | 416 | ||
341 | 417 | ||
342 | 418 | @Callable(i) | |
343 | 419 | func deleteData (name) = [DeleteEntry(name)] | |
344 | 420 | ||
345 | 421 |
github/deemru/w8io/169f3d6 49.01 ms ◑