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:AAIFAAAAAAAAADwIAhIAEgQKAggYEgMKAQgSAwoBCBIECgIIBBIDCgEIEgMKAQgSBQoDCAgBEgMKAQgSBQoDCAgBEgMKAQgAAAAPAAAAAAZjb25maWcJAQAAAAt2YWx1ZU9yRWxzZQAAAAIJAQAAABFAZXh0ck5hdGl2ZSgxMDUzKQAAAAIFAAAABHRoaXMCAAAABmNvbmZpZwIAAAAAAAAAAAVhZG1pbgkBAAAAC3ZhbHVlT3JFbHNlAAAAAgkBAAAAEUBleHRyTmF0aXZlKDEwNTMpAAAAAgkBAAAAEUBleHRyTmF0aXZlKDEwNjIpAAAAAQUAAAAGY29uZmlnAgAAAAVhZG1pbgIAAAAAAAAAAAVwb29scwkBAAAAC3ZhbHVlT3JFbHNlAAAAAgkBAAAAEUBleHRyTmF0aXZlKDEwNTMpAAAAAgUAAAAEdGhpcwIAAAAFcG9vbHMCAAAAAAEAAAAHaXNBZG1pbgAAAAEAAAANY2FsbGVyQWRkcmVzcwMJAAAAAAAAAgUAAAANY2FsbGVyQWRkcmVzcwkBAAAAEUBleHRyTmF0aXZlKDEwNjIpAAAAA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AAAB3Rva2VuSWQJAQAAABFAZXh0ck5hdGl2ZSgxMDUzKQAAAAIJAQAAABFAZXh0ck5hdGl2ZSgxMDYyKQAAAAEFAAAAC3Bvb2xBZGRyZXNzAgAAAAhkVG9rZW5JZAQAAAAHJG1hdGNoMAUAAAALdG9rZW5BbW91bnQDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABdAUAAAAHJG1hdGNoMAkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAABaQAAAAZjYWxsZXIFAAAAAXQJAAJZAAAAAQUAAAAHdG9rZW5JZAUAAAADbmlsAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAAXQFAAAAByRtYXRjaDAFAAAAA25pbAkAAAIAAAABAgAAABhJbmNvcnJlY3QgaW52b2tlIHJlc3VsdCEJAAACAAAAAQIAAAAkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuCQAAAgAAAAECAAAAG0JvcnJvdyBleGNlZWRzIHVzZXIgaGVhbHRoIQkAAAIAAAABAgAAABdBc3NldElkcyBkb2VzIG5vdCBtYXRjaAkAAAIAAAABAgAAABdQb29sIGFkZHJlc3Mgbm90IGZvdW5kIQAAAAFpAQAAAApkZWxldGVEYXRhAAAAAQAAAARuYW1lCQAETAAAAAIJAQAAAAtEZWxldGVFbnRyeQAAAAEFAAAABG5hbWUFAAAAA25pbAAAAAAsQmiW", "height": 1691312, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: BXe4xkbsyqYZcukriWez3gfhvtJdyY4iHxkDNMthG8fe Next: 4d964j65MaLLYWwP2anVKH5eK5DRzy1X2NsdVXUmX6Yx Diff:
OldNewDifferences
8989 then true
9090 else false
9191 }
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+
92134
93135
94136 @Callable(i)
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) = fraction((borrowCapacity - borrowCapacityUsed), 1000, borrowCapacity)
4848
4949
5050 func calcBorrowCBorrowCU (user,newDebtAmount,newDebtId,collateralAmount,collateralId) = {
5151 let poolList = split(pools, ";")
5252 let listSize = size(poolList)
5353 func foldPools (accum,next) = {
5454 let healthParams = getHealthParameter(user, next, newDebtAmount, newDebtId, collateralAmount, collateralId)
5555 match healthParams {
5656 case t: (Int, Int) =>
5757 $Tuple2((accum._1 + healthParams._1), (accum._2 + healthParams._1))
5858 case e =>
5959 throw("Test")
6060 }
6161 }
6262
6363 let $list23122346 = poolList
6464 let $size23122346 = size($list23122346)
6565 let $acc023122346 = $Tuple2(0, 0)
6666 if (($size23122346 == 0))
6767 then $acc023122346
6868 else {
6969 let $acc123122346 = foldPools($acc023122346, $list23122346[0])
7070 if (($size23122346 == 1))
7171 then $acc123122346
7272 else {
7373 let $acc223122346 = foldPools($acc123122346, $list23122346[1])
7474 if (($size23122346 == 2))
7575 then $acc223122346
7676 else {
7777 let $acc323122346 = foldPools($acc223122346, $list23122346[2])
7878 throw("List size exceed 2")
7979 }
8080 }
8181 }
8282 }
8383
8484
8585 func checkUserHealth (user,newDebtAmount,newDebtId,collateralAmount,collateralId) = {
8686 let bcBcu = calcBorrowCBorrowCU(user, newDebtAmount, newDebtId, collateralAmount, collateralId)
8787 let userHealth = calcHealthFactor(bcBcu._1, bcBcu._2)
8888 if ((userHealth >= 0))
8989 then true
9090 else false
9191 }
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+
92134
93135
94136 @Callable(i)
95137 func setup (configAddress,pools) = if (if (!(isDefined(getString(this, "config"))))
96138 then !(isDefined(getString(this, "pools")))
97139 else false)
98140 then [writeString("config", configAddress), writeString("pools", makeString(pools, ";"))]
99141 else throw("Admin and config address already definied!")
100142
101143
102144
103145 @Callable(i)
104146 func addPool (poolAddress) = if (isAdmin(i.caller))
105147 then {
106148 let poolList = split(pools, ";")
107149 if ((containsElement(poolList, poolAddress) == false))
108150 then {
109151 let newPools = (poolList :+ poolAddress)
110152 [writeString("pools", makeString(newPools, ";"))]
111153 }
112154 else throw("Pool already exists!")
113155 }
114156 else throw("Address does not match with admin address!")
115157
116158
117159
118160 @Callable(i)
119161 func updateConfig (configAddress) = if (isAdmin(i.caller))
120162 then [writeString("config", configAddress)]
121163 else throw("Address does not match with admin address!")
122164
123165
124166
125167 @Callable(i)
126168 func depositAt (poolAddress,isCollateral) = if (checkPool(poolAddress))
127169 then if ((size(i.payments) > 0))
128170 then {
129171 let user = toBase58String(i.caller.bytes)
130172 let tokenAmount = invoke(addressFromStringValue(poolAddress), "deposit", [user, isCollateral], i.payments)
131173 if ((tokenAmount == tokenAmount))
132174 then {
133175 let tokenId = getStringValue(addressFromStringValue(poolAddress), "dTokenId")
134176 match tokenAmount {
135177 case t: Int =>
136178 [ScriptTransfer(i.caller, t, fromBase58String(tokenId))]
137179 case t: String =>
138180 nil
139181 case _ =>
140182 throw("Incorrect invoke result!")
141183 }
142184 }
143185 else throw("Strict value is not equal to itself.")
144186 }
145187 else throw("No payment attached!")
146188 else throw("Pool address not found!")
147189
148190
149191
150192 @Callable(i)
151193 func withdrawFrom (poolAddress) = if (checkPool(poolAddress))
152194 then {
153195 let dTokenId = getStringValue(addressFromStringValue(poolAddress), "dTokenId")
154196 if ((fromBase58String(dTokenId) == i.payments[0].assetId))
155197 then if ((size(i.payments) > 0))
156198 then {
157199 let user = toBase58String(i.caller.bytes)
158200 let tokenAmount = invoke(addressFromStringValue(poolAddress), "withdraw", [user], i.payments)
159201 if ((tokenAmount == tokenAmount))
160202 then {
161203 let tokenId = getStringValue(addressFromStringValue(poolAddress), "assetId")
162204 match tokenAmount {
163205 case t: Int =>
164206 if ((tokenId == "WAVES"))
165207 then [ScriptTransfer(i.caller, t, unit)]
166208 else [ScriptTransfer(i.caller, t, fromBase58String(tokenId))]
167209 case t: String =>
168210 nil
169211 case _ =>
170212 throw("Incorrect invoke result!")
171213 }
172214 }
173215 else throw("Strict value is not equal to itself.")
174216 }
175217 else throw("No payment attached!")
176218 else throw("AssetIds does not match")
177219 }
178220 else throw("Pool address not found!")
179221
180222
181223
182224 @Callable(i)
183225 func repayTo (poolAddress) = if (checkPool(poolAddress))
184226 then {
185227 let poolAsset = getStringValue(addressFromStringValue(poolAddress), "assetId")
186228 if ((fromBase58String(poolAsset) == i.payments[0].assetId))
187229 then if ((size(i.payments) > 0))
188230 then {
189231 let user = toBase58String(i.caller.bytes)
190232 let amount = invoke(addressFromStringValue(poolAddress), "repay", [user], i.payments)
191233 if ((amount == amount))
192234 then {
193235 let assetId = getStringValue(addressFromStringValue(poolAddress), "assetId")
194236 match amount {
195237 case t: Int =>
196238 if ((assetId == "WAVES"))
197239 then [ScriptTransfer(i.caller, t, unit)]
198240 else [ScriptTransfer(i.caller, t, fromBase58String(assetId))]
199241 case t: String =>
200242 nil
201243 case _ =>
202244 throw("Incorrect invoke result!")
203245 }
204246 }
205247 else throw("Strict value is not equal to itself.")
206248 }
207249 else throw("No payment attached!")
208250 else throw("AssetIds does not match")
209251 }
210252 else throw("Pool address not found!")
211253
212254
213255
214256 @Callable(i)
215257 func borrowFrom (poolAddress,assetId,amount) = if (checkPool(poolAddress))
216258 then {
217259 let poolAsset = getStringValue(addressFromStringValue(poolAddress), "assetId")
218260 if ((poolAsset == assetId))
219261 then if (checkPoolLiquidity(poolAddress, amount))
220262 then {
221263 let user = toBase58String(i.caller.bytes)
222264 if (checkUserHealth(user, amount, assetId, 0, ""))
223265 then {
224266 let tokenAmount = invoke(addressFromStringValue(poolAddress), "borrow", [user, amount], nil)
225267 if ((tokenAmount == tokenAmount))
226268 then match tokenAmount {
227269 case t: Int =>
228270 if ((poolAsset == "WAVES"))
229271 then [ScriptTransfer(i.caller, t, unit)]
230272 else [ScriptTransfer(i.caller, t, fromBase58String(poolAsset))]
231273 case t: String =>
232274 nil
233275 case _ =>
234276 throw("Incorrect invoke result!")
235277 }
236278 else throw("Strict value is not equal to itself.")
237279 }
238280 else throw("Borrow exceeds user health!")
239281 }
240282 else throw("Pool liquidity is not sufficient!")
241283 else throw("AssetIds does not match")
242284 }
243285 else throw("Pool address not found!")
244286
245287
246288
247289 @Callable(i)
248290 func lockAsCollateralAt (poolAddress) = if (checkPool(poolAddress))
249291 then {
250292 let dTokenId = getStringValue(addressFromStringValue(poolAddress), "dTokenId")
251293 if ((fromBase58String(dTokenId) == i.payments[0].assetId))
252294 then if ((size(i.payments) > 0))
253295 then {
254296 let user = toBase58String(i.caller.bytes)
255297 let msg = invoke(addressFromStringValue(poolAddress), "lockAsCollateral", [user], i.payments)
256298 if ((msg == msg))
257299 then match msg {
258300 case t: String =>
259301 nil
260302 case _ =>
261303 throw("Incorrect invoke result!")
262304 }
263305 else throw("Strict value is not equal to itself.")
264306 }
265307 else throw("No payment attached!")
266308 else throw("AssetIds does not match")
267309 }
268310 else throw("Pool address not found!")
269311
270312
271313
272314 @Callable(i)
273315 func redeemCollateralFrom (poolAddress,dtokeId,amount) = if (checkPool(poolAddress))
274316 then {
275317 let poolDTokenId = getStringValue(addressFromStringValue(poolAddress), "dTokenId")
276318 if ((poolDTokenId == dtokeId))
277319 then {
278320 let user = toBase58String(i.caller.bytes)
279321 if (checkUserHealth(user, 0, "", amount, dtokeId))
280322 then {
281323 let tokenAmount = invoke(addressFromStringValue(poolAddress), "redeemCollateral", [user, amount], nil)
282324 if ((tokenAmount == tokenAmount))
283325 then {
284326 let tokenId = getStringValue(addressFromStringValue(poolAddress), "dTokenId")
285327 match tokenAmount {
286328 case t: Int =>
287329 [ScriptTransfer(i.caller, t, fromBase58String(tokenId))]
288330 case t: String =>
289331 nil
290332 case _ =>
291333 throw("Incorrect invoke result!")
292334 }
293335 }
294336 else throw("Strict value is not equal to itself.")
295337 }
296338 else throw("Borrow exceeds user health!")
297339 }
298340 else throw("AssetIds does not match")
299341 }
300342 else throw("Pool address not found!")
301343
302344
303345
304346 @Callable(i)
305347 func deleteData (name) = [DeleteEntry(name)]
306348
307349

github/deemru/w8io/026f985 
74.86 ms