tx · HTJ3HgBmFsnQYV2RYceizJivKZewYYtousKdAFE9DABR 3MvGMtmdY1eSW4iY922zj5bx8hBfyP1qgHo: -0.04000000 Waves 2021.09.05 01:23 [1688895] smart account 3MvGMtmdY1eSW4iY922zj5bx8hBfyP1qgHo > SELF 0.00000000 Waves
{ "type": 13, "id": "HTJ3HgBmFsnQYV2RYceizJivKZewYYtousKdAFE9DABR", "fee": 4000000, "feeAssetId": null, "timestamp": 1630794272264, "version": 2, "chainId": 84, "sender": "3MvGMtmdY1eSW4iY922zj5bx8hBfyP1qgHo", "senderPublicKey": "CD4N2SBeZVBUwmtsqwfmQ3ZKnBP3AxpZCvJ5QkHytUed", "proofs": [ "44JXbZXqEAumzGSSCAuZ6NY6HHrfMCQjnFukq5kjrkFz8fng4AeoJWohLMksShwQqPsqZDtr7VougXDQ8CXgXRqf" ], "script": "base64:AAIFAAAAAAAAACkIAhIECgIIGBIDCgEIEgMKAQgSBAoCCAQSAwoBCBIDCgEIEgUKAwgIAQAAAAwAAAAABmNvbmZpZwkBAAAAC3ZhbHVlT3JFbHNlAAAAAgkBAAAAEUBleHRyTmF0aXZlKDEwNTMpAAAAAgUAAAAEdGhpcwIAAAAGY29uZmlnAgAAAAAAAAAABWFkbWluCQEAAAALdmFsdWVPckVsc2UAAAACCQEAAAARQGV4dHJOYXRpdmUoMTA1MykAAAACCQEAAAARQGV4dHJOYXRpdmUoMTA2MikAAAABBQAAAAZjb25maWcCAAAABWFkbWluAgAAAAAAAAAABXBvb2xzCQEAAAALdmFsdWVPckVsc2UAAAACCQEAAAARQGV4dHJOYXRpdmUoMTA1MykAAAACBQAAAAR0aGlzAgAAAAVwb29scwIAAAAAAQAAAAdpc0FkbWluAAAAAQAAAA1jYWxsZXJBZGRyZXNzAwkAAAAAAAACBQAAAA1jYWxsZXJBZGRyZXNzCQEAAAARQGV4dHJOYXRpdmUoMTA2MikAAAABBQAAAAVhZG1pbgYHAQAAAAljaGVja1Bvb2wAAAABAAAAB3Bvb2xB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CQACWAAAAAEICAUAAAABaQAAAAZjYWxsZXIAAAAFYnl0ZXMDCQEAAAAPY2hlY2tVc2VySGVhbHRoAAAABQUAAAAEdXNlcgUAAAAGYW1vdW50BQAAAAdhc3NldElkAAAAAAAAAAAAAgAAAAAFAAAAA25pbAkAAAIAAAABAgAAABtCb3Jyb3cgZXhjZWVkcyB1c2VyIGhlYWx0aCEJAAACAAAAAQIAAAAhUG9vbCBsaXF1aWRpdHkgaXMgbm90IHN1ZmZpY2llbnQhCQAAAgAAAAECAAAAF0Fzc2V0SWRzIGRvZXMgbm90IG1hdGNoCQAAAgAAAAECAAAAF1Bvb2wgYWRkcmVzcyBub3QgZm91bmQhAAAAAIYo+t0=", "height": 1688895, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: J65DvWsrD6ZHhSEaU2wehVvbVMZTGLFfGctRKSHUz8DN Next: DCKGNAwRjGUSt2oyuhKPQrkAcemx85YkmidsrKxPvwPs Diff:
Old | New | Differences | |
---|---|---|---|
34 | 34 | ||
35 | 35 | ||
36 | 36 | func getHealthParameter (user,poolAddress,newDebtAmount,newDebtId,collateralAmount,collateralId) = { | |
37 | - | let result = | |
37 | + | let result = $Tuple2(1, 1) | |
38 | 38 | match result { | |
39 | 39 | case t: (Int, Int) => | |
40 | 40 | t | |
60 | 60 | } | |
61 | 61 | } | |
62 | 62 | ||
63 | - | let $ | |
64 | - | let $ | |
65 | - | let $ | |
66 | - | if (($ | |
67 | - | then $ | |
63 | + | let $list23102344 = poolList | |
64 | + | let $size23102344 = size($list23102344) | |
65 | + | let $acc023102344 = $Tuple2(0, 0) | |
66 | + | if (($size23102344 == 0)) | |
67 | + | then $acc023102344 | |
68 | 68 | else { | |
69 | - | let $ | |
70 | - | if (($ | |
71 | - | then $ | |
69 | + | let $acc123102344 = foldPools($acc023102344, $list23102344[0]) | |
70 | + | if (($size23102344 == 1)) | |
71 | + | then $acc123102344 | |
72 | 72 | else { | |
73 | - | let $ | |
74 | - | if (($ | |
75 | - | then $ | |
73 | + | let $acc223102344 = foldPools($acc123102344, $list23102344[1]) | |
74 | + | if (($size23102344 == 2)) | |
75 | + | then $acc223102344 | |
76 | 76 | else { | |
77 | - | let $ | |
77 | + | let $acc323102344 = foldPools($acc223102344, $list23102344[2]) | |
78 | 78 | throw("List size exceed 2") | |
79 | 79 | } | |
80 | 80 | } | |
212 | 212 | then if (checkPoolLiquidity(poolAddress, amount)) | |
213 | 213 | then { | |
214 | 214 | let user = toBase58String(i.caller.bytes) | |
215 | - | nil | |
215 | + | if (checkUserHealth(user, amount, assetId, 0, "")) | |
216 | + | then nil | |
217 | + | else throw("Borrow exceeds user health!") | |
216 | 218 | } | |
217 | 219 | else throw("Pool liquidity is not sufficient!") | |
218 | 220 | else throw("AssetIds does not match") |
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 | - | let result = | |
37 | + | let result = $Tuple2(1, 1) | |
38 | 38 | match result { | |
39 | 39 | case t: (Int, Int) => | |
40 | 40 | t | |
41 | 41 | case _ => | |
42 | 42 | throw("Wrong Datatyp!") | |
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 | - | let $ | |
64 | - | let $ | |
65 | - | let $ | |
66 | - | if (($ | |
67 | - | then $ | |
63 | + | let $list23102344 = poolList | |
64 | + | let $size23102344 = size($list23102344) | |
65 | + | let $acc023102344 = $Tuple2(0, 0) | |
66 | + | if (($size23102344 == 0)) | |
67 | + | then $acc023102344 | |
68 | 68 | else { | |
69 | - | let $ | |
70 | - | if (($ | |
71 | - | then $ | |
69 | + | let $acc123102344 = foldPools($acc023102344, $list23102344[0]) | |
70 | + | if (($size23102344 == 1)) | |
71 | + | then $acc123102344 | |
72 | 72 | else { | |
73 | - | let $ | |
74 | - | if (($ | |
75 | - | then $ | |
73 | + | let $acc223102344 = foldPools($acc123102344, $list23102344[1]) | |
74 | + | if (($size23102344 == 2)) | |
75 | + | then $acc223102344 | |
76 | 76 | else { | |
77 | - | let $ | |
77 | + | let $acc323102344 = foldPools($acc223102344, $list23102344[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 | 92 | ||
93 | 93 | ||
94 | 94 | @Callable(i) | |
95 | 95 | func setup (configAddress,pools) = if (if (!(isDefined(getString(this, "config")))) | |
96 | 96 | then !(isDefined(getString(this, "pools"))) | |
97 | 97 | else false) | |
98 | 98 | then [writeString("config", configAddress), writeString("pools", makeString(pools, ";"))] | |
99 | 99 | else throw("Admin and config address already definied!") | |
100 | 100 | ||
101 | 101 | ||
102 | 102 | ||
103 | 103 | @Callable(i) | |
104 | 104 | func addPool (poolAddress) = if (isAdmin(i.caller)) | |
105 | 105 | then { | |
106 | 106 | let poolList = split(pools, ";") | |
107 | 107 | if ((containsElement(poolList, poolAddress) == false)) | |
108 | 108 | then { | |
109 | 109 | let newPools = (poolList :+ poolAddress) | |
110 | 110 | [writeString("pools", makeString(newPools, ";"))] | |
111 | 111 | } | |
112 | 112 | else throw("Pool already exists!") | |
113 | 113 | } | |
114 | 114 | else throw("Address does not match with admin address!") | |
115 | 115 | ||
116 | 116 | ||
117 | 117 | ||
118 | 118 | @Callable(i) | |
119 | 119 | func updateConfig (configAddress) = if (isAdmin(i.caller)) | |
120 | 120 | then [writeString("config", configAddress)] | |
121 | 121 | else throw("Address does not match with admin address!") | |
122 | 122 | ||
123 | 123 | ||
124 | 124 | ||
125 | 125 | @Callable(i) | |
126 | 126 | func depositAt (poolAddress,isCollateral) = if (checkPool(poolAddress)) | |
127 | 127 | then if ((size(i.payments) > 0)) | |
128 | 128 | then { | |
129 | 129 | let user = toBase58String(i.caller.bytes) | |
130 | 130 | let tokenAmount = invoke(addressFromStringValue(poolAddress), "deposit", [user, isCollateral], i.payments) | |
131 | 131 | if ((tokenAmount == tokenAmount)) | |
132 | 132 | then { | |
133 | 133 | let tokenId = getStringValue(addressFromStringValue(poolAddress), "dTokenId") | |
134 | 134 | match tokenAmount { | |
135 | 135 | case t: Int => | |
136 | 136 | [ScriptTransfer(i.caller, t, fromBase58String(tokenId))] | |
137 | 137 | case t: String => | |
138 | 138 | nil | |
139 | 139 | case _ => | |
140 | 140 | throw("Incorrect invoke result!") | |
141 | 141 | } | |
142 | 142 | } | |
143 | 143 | else throw("Strict value is not equal to itself.") | |
144 | 144 | } | |
145 | 145 | else throw("No payment attached!") | |
146 | 146 | else throw("Pool address not found!") | |
147 | 147 | ||
148 | 148 | ||
149 | 149 | ||
150 | 150 | @Callable(i) | |
151 | 151 | func withdrawFrom (poolAddress) = if (checkPool(poolAddress)) | |
152 | 152 | then { | |
153 | 153 | let dTokenId = getStringValue(addressFromStringValue(poolAddress), "dTokenId") | |
154 | 154 | if ((fromBase58String(dTokenId) == i.payments[0].assetId)) | |
155 | 155 | then if ((size(i.payments) > 0)) | |
156 | 156 | then { | |
157 | 157 | let user = toBase58String(i.caller.bytes) | |
158 | 158 | let tokenAmount = invoke(addressFromStringValue(poolAddress), "withdraw", [user], i.payments) | |
159 | 159 | if ((tokenAmount == tokenAmount)) | |
160 | 160 | then { | |
161 | 161 | let tokenId = getStringValue(addressFromStringValue(poolAddress), "assetId") | |
162 | 162 | match tokenAmount { | |
163 | 163 | case t: Int => | |
164 | 164 | if ((tokenId == "WAVES")) | |
165 | 165 | then [ScriptTransfer(i.caller, t, unit)] | |
166 | 166 | else [ScriptTransfer(i.caller, t, fromBase58String(tokenId))] | |
167 | 167 | case t: String => | |
168 | 168 | nil | |
169 | 169 | case _ => | |
170 | 170 | throw("Incorrect invoke result!") | |
171 | 171 | } | |
172 | 172 | } | |
173 | 173 | else throw("Strict value is not equal to itself.") | |
174 | 174 | } | |
175 | 175 | else throw("No payment attached!") | |
176 | 176 | else throw("AssetIds does not match") | |
177 | 177 | } | |
178 | 178 | else throw("Pool address not found!") | |
179 | 179 | ||
180 | 180 | ||
181 | 181 | ||
182 | 182 | @Callable(i) | |
183 | 183 | func lockAsCollateralAt (poolAddress) = if (checkPool(poolAddress)) | |
184 | 184 | then { | |
185 | 185 | let dTokenId = getStringValue(addressFromStringValue(poolAddress), "dTokenId") | |
186 | 186 | if ((fromBase58String(dTokenId) == i.payments[0].assetId)) | |
187 | 187 | then if ((size(i.payments) > 0)) | |
188 | 188 | then { | |
189 | 189 | let user = toBase58String(i.caller.bytes) | |
190 | 190 | let msg = invoke(addressFromStringValue(poolAddress), "lockAsCollateral", [user], i.payments) | |
191 | 191 | if ((msg == msg)) | |
192 | 192 | then match msg { | |
193 | 193 | case t: String => | |
194 | 194 | nil | |
195 | 195 | case _ => | |
196 | 196 | throw("Incorrect invoke result!") | |
197 | 197 | } | |
198 | 198 | else throw("Strict value is not equal to itself.") | |
199 | 199 | } | |
200 | 200 | else throw("No payment attached!") | |
201 | 201 | else throw("AssetIds does not match") | |
202 | 202 | } | |
203 | 203 | else throw("Pool address not found!") | |
204 | 204 | ||
205 | 205 | ||
206 | 206 | ||
207 | 207 | @Callable(i) | |
208 | 208 | func borrowFrom (poolAddress,assetId,amount) = if (checkPool(poolAddress)) | |
209 | 209 | then { | |
210 | 210 | let poolAsset = getStringValue(addressFromStringValue(poolAddress), "assetId") | |
211 | 211 | if ((poolAsset == assetId)) | |
212 | 212 | then if (checkPoolLiquidity(poolAddress, amount)) | |
213 | 213 | then { | |
214 | 214 | let user = toBase58String(i.caller.bytes) | |
215 | - | nil | |
215 | + | if (checkUserHealth(user, amount, assetId, 0, "")) | |
216 | + | then nil | |
217 | + | else throw("Borrow exceeds user health!") | |
216 | 218 | } | |
217 | 219 | else throw("Pool liquidity is not sufficient!") | |
218 | 220 | else throw("AssetIds does not match") | |
219 | 221 | } | |
220 | 222 | else throw("Pool address not found!") | |
221 | 223 | ||
222 | 224 |
github/deemru/w8io/026f985 52.88 ms ◑