tx · BXe4xkbsyqYZcukriWez3gfhvtJdyY4iHxkDNMthG8fe 3MvGMtmdY1eSW4iY922zj5bx8hBfyP1qgHo: -0.04000000 Waves 2021.09.05 21:55 [1690134] smart account 3MvGMtmdY1eSW4iY922zj5bx8hBfyP1qgHo > SELF 0.00000000 Waves
{ "type": 13, "id": "BXe4xkbsyqYZcukriWez3gfhvtJdyY4iHxkDNMthG8fe", "fee": 4000000, "feeAssetId": null, "timestamp": 1630868204251, "version": 2, "chainId": 84, "sender": "3MvGMtmdY1eSW4iY922zj5bx8hBfyP1qgHo", "senderPublicKey": "CD4N2SBeZVBUwmtsqwfmQ3ZKnBP3AxpZCvJ5QkHytUed", "proofs": [ "51jsp3K9im5EdMcgAoJrQyEh1ezQuimp8ybrBFg1KuTE9d9U7g8sV3EPzYmrKuLqKASQwBWSwqgyWmedVE1Uv4bq" ], "script": "base64:AAIFAAAAAAAAADoIAhIECgIIGBIDCgEIEgMKAQgSBAoCCAQSAwoBCBIDCgEIEgUKAwgIARIDCgEIEgUKAwgIARIDCgEIAAAADAAAAAAGY29uZmlnCQEAAAALdmFsdWVPckVsc2UAAAACCQEAAAARQGV4dHJOYXRpdmUoMTA1MykAAAACBQAAAAR0aGlzAgAAAAZjb25maWcCAAAAAAAAAAAFYWRtaW4JAQAAAAt2YWx1ZU9yRWxzZQAAAAIJAQAAABFAZXh0ck5hdGl2ZSgxMDUzKQAAAAIJAQAAABFAZXh0ck5hdGl2ZSgxMDYyKQAAAAEFAAAABmNvbmZpZwIAAAAFYWRtaW4CAAAAAAAAAAAFcG9vbHMJAQAAAAt2YWx1ZU9yRWxzZQAAAAIJAQAAABFAZXh0ck5hdGl2ZSgxMDUzKQAAAAIFAAAABHRoaXMCAAAABXBvb2xzAgAAAAABAAAAB2lzQWRtaW4AAAABAAAADWNhbGxlckFkZHJlc3MDCQAAAAAAAAIFAAAADWNhbGxlckFkZHJlc3MJAQAAABFAZXh0ck5hdGl2ZSgxMDYyKQAAAAEFAAAABWFkb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ZQkABEwAAAACCQEAAAALRGVsZXRlRW50cnkAAAABBQAAAARuYW1lBQAAAANuaWwAAAAAdhp2MA==", "height": 1690134, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 3j4sC8PjvcAqGKV9Znf6DEYrnNUiqTKC1sHnkfizoPcN Next: 8SePcoWGcguP1VHso6rjpGWaHtxSzKRdU1PN3vxGjMiX Diff:
Old | New | Differences | |
---|---|---|---|
92 | 92 | ||
93 | 93 | ||
94 | 94 | @Callable(i) | |
95 | - | func repayTo (poolAddress) = if (checkPool(poolAddress)) | |
96 | - | then { | |
97 | - | let poolAsset = getStringValue(addressFromStringValue(poolAddress), "assetId") | |
98 | - | if ((fromBase58String(poolAsset) == i.payments[0].assetId)) | |
99 | - | then if ((size(i.payments) > 0)) | |
100 | - | then { | |
101 | - | let user = toBase58String(i.caller.bytes) | |
102 | - | let amount = invoke(addressFromStringValue(poolAddress), "repay", [user], i.payments) | |
103 | - | if ((amount == amount)) | |
104 | - | then { | |
105 | - | let assetId = getStringValue(addressFromStringValue(poolAddress), "assetId") | |
106 | - | match amount { | |
107 | - | case t: Int => | |
108 | - | if ((assetId == "WAVES")) | |
109 | - | then [ScriptTransfer(i.caller, t, unit)] | |
110 | - | else [ScriptTransfer(i.caller, t, fromBase58String(assetId))] | |
111 | - | case t: String => | |
112 | - | nil | |
113 | - | case _ => | |
114 | - | throw("Incorrect invoke result!") | |
115 | - | } | |
116 | - | } | |
117 | - | else throw("Strict value is not equal to itself.") | |
118 | - | } | |
119 | - | else throw("No payment attached!") | |
120 | - | else throw("AssetIds does not match") | |
121 | - | } | |
122 | - | else throw("Pool address not found!") | |
123 | - | ||
124 | - | ||
125 | - | ||
126 | - | @Callable(i) | |
127 | - | func borrowFrom (poolAddress,assetId,amount) = if (checkPool(poolAddress)) | |
128 | - | then { | |
129 | - | let poolAsset = getStringValue(addressFromStringValue(poolAddress), "assetId") | |
130 | - | if ((poolAsset == assetId)) | |
131 | - | then if (checkPoolLiquidity(poolAddress, amount)) | |
132 | - | then { | |
133 | - | let user = toBase58String(i.caller.bytes) | |
134 | - | if (checkUserHealth(user, amount, assetId, 0, "")) | |
135 | - | then { | |
136 | - | let tokenAmount = invoke(addressFromStringValue(poolAddress), "borrow", [user, amount], nil) | |
137 | - | if ((tokenAmount == tokenAmount)) | |
138 | - | then match tokenAmount { | |
139 | - | case t: Int => | |
140 | - | if ((poolAsset == "WAVES")) | |
141 | - | then [ScriptTransfer(i.caller, t, unit)] | |
142 | - | else [ScriptTransfer(i.caller, t, fromBase58String(poolAsset))] | |
143 | - | case t: String => | |
144 | - | nil | |
145 | - | case _ => | |
146 | - | throw("Incorrect invoke result!") | |
147 | - | } | |
148 | - | else throw("Strict value is not equal to itself.") | |
149 | - | } | |
150 | - | else throw("Borrow exceeds user health!") | |
151 | - | } | |
152 | - | else throw("Pool liquidity is not sufficient!") | |
153 | - | else throw("AssetIds does not match") | |
154 | - | } | |
155 | - | else throw("Pool address not found!") | |
156 | - | ||
157 | - | ||
158 | - | ||
159 | - | @Callable(i) | |
160 | 95 | func setup (configAddress,pools) = if (if (!(isDefined(getString(this, "config")))) | |
161 | 96 | then !(isDefined(getString(this, "pools"))) | |
162 | 97 | else false) | |
245 | 180 | ||
246 | 181 | ||
247 | 182 | @Callable(i) | |
183 | + | func repayTo (poolAddress) = if (checkPool(poolAddress)) | |
184 | + | then { | |
185 | + | let poolAsset = getStringValue(addressFromStringValue(poolAddress), "assetId") | |
186 | + | if ((fromBase58String(poolAsset) == i.payments[0].assetId)) | |
187 | + | then if ((size(i.payments) > 0)) | |
188 | + | then { | |
189 | + | let user = toBase58String(i.caller.bytes) | |
190 | + | let amount = invoke(addressFromStringValue(poolAddress), "repay", [user], i.payments) | |
191 | + | if ((amount == amount)) | |
192 | + | then { | |
193 | + | let assetId = getStringValue(addressFromStringValue(poolAddress), "assetId") | |
194 | + | match amount { | |
195 | + | case t: Int => | |
196 | + | if ((assetId == "WAVES")) | |
197 | + | then [ScriptTransfer(i.caller, t, unit)] | |
198 | + | else [ScriptTransfer(i.caller, t, fromBase58String(assetId))] | |
199 | + | case t: String => | |
200 | + | nil | |
201 | + | case _ => | |
202 | + | throw("Incorrect invoke result!") | |
203 | + | } | |
204 | + | } | |
205 | + | else throw("Strict value is not equal to itself.") | |
206 | + | } | |
207 | + | else throw("No payment attached!") | |
208 | + | else throw("AssetIds does not match") | |
209 | + | } | |
210 | + | else throw("Pool address not found!") | |
211 | + | ||
212 | + | ||
213 | + | ||
214 | + | @Callable(i) | |
215 | + | func borrowFrom (poolAddress,assetId,amount) = if (checkPool(poolAddress)) | |
216 | + | then { | |
217 | + | let poolAsset = getStringValue(addressFromStringValue(poolAddress), "assetId") | |
218 | + | if ((poolAsset == assetId)) | |
219 | + | then if (checkPoolLiquidity(poolAddress, amount)) | |
220 | + | then { | |
221 | + | let user = toBase58String(i.caller.bytes) | |
222 | + | if (checkUserHealth(user, amount, assetId, 0, "")) | |
223 | + | then { | |
224 | + | let tokenAmount = invoke(addressFromStringValue(poolAddress), "borrow", [user, amount], nil) | |
225 | + | if ((tokenAmount == tokenAmount)) | |
226 | + | then match tokenAmount { | |
227 | + | case t: Int => | |
228 | + | if ((poolAsset == "WAVES")) | |
229 | + | then [ScriptTransfer(i.caller, t, unit)] | |
230 | + | else [ScriptTransfer(i.caller, t, fromBase58String(poolAsset))] | |
231 | + | case t: String => | |
232 | + | nil | |
233 | + | case _ => | |
234 | + | throw("Incorrect invoke result!") | |
235 | + | } | |
236 | + | else throw("Strict value is not equal to itself.") | |
237 | + | } | |
238 | + | else throw("Borrow exceeds user health!") | |
239 | + | } | |
240 | + | else throw("Pool liquidity is not sufficient!") | |
241 | + | else throw("AssetIds does not match") | |
242 | + | } | |
243 | + | else throw("Pool address not found!") | |
244 | + | ||
245 | + | ||
246 | + | ||
247 | + | @Callable(i) | |
248 | 248 | func lockAsCollateralAt (poolAddress) = if (checkPool(poolAddress)) | |
249 | 249 | then { | |
250 | 250 | let dTokenId = getStringValue(addressFromStringValue(poolAddress), "dTokenId") | |
270 | 270 | ||
271 | 271 | ||
272 | 272 | @Callable(i) | |
273 | + | func redeemCollateralFrom (poolAddress,dtokeId,amount) = if (checkPool(poolAddress)) | |
274 | + | then { | |
275 | + | let poolDTokenId = getStringValue(addressFromStringValue(poolAddress), "dTokenId") | |
276 | + | if ((poolDTokenId == dtokeId)) | |
277 | + | then { | |
278 | + | let user = toBase58String(i.caller.bytes) | |
279 | + | if (checkUserHealth(user, 0, "", amount, dtokeId)) | |
280 | + | then { | |
281 | + | let tokenAmount = invoke(addressFromStringValue(poolAddress), "redeemCollateral", [user, amount], nil) | |
282 | + | if ((tokenAmount == tokenAmount)) | |
283 | + | then { | |
284 | + | let tokenId = getStringValue(addressFromStringValue(poolAddress), "dTokenId") | |
285 | + | match tokenAmount { | |
286 | + | case t: Int => | |
287 | + | [ScriptTransfer(i.caller, t, fromBase58String(tokenId))] | |
288 | + | case t: String => | |
289 | + | nil | |
290 | + | case _ => | |
291 | + | throw("Incorrect invoke result!") | |
292 | + | } | |
293 | + | } | |
294 | + | else throw("Strict value is not equal to itself.") | |
295 | + | } | |
296 | + | else throw("Borrow exceeds user health!") | |
297 | + | } | |
298 | + | else throw("AssetIds does not match") | |
299 | + | } | |
300 | + | else throw("Pool address not found!") | |
301 | + | ||
302 | + | ||
303 | + | ||
304 | + | @Callable(i) | |
273 | 305 | func deleteData (name) = [DeleteEntry(name)] | |
274 | 306 | ||
275 | 307 |
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 | 92 | ||
93 | 93 | ||
94 | 94 | @Callable(i) | |
95 | - | func repayTo (poolAddress) = if (checkPool(poolAddress)) | |
96 | - | then { | |
97 | - | let poolAsset = getStringValue(addressFromStringValue(poolAddress), "assetId") | |
98 | - | if ((fromBase58String(poolAsset) == i.payments[0].assetId)) | |
99 | - | then if ((size(i.payments) > 0)) | |
100 | - | then { | |
101 | - | let user = toBase58String(i.caller.bytes) | |
102 | - | let amount = invoke(addressFromStringValue(poolAddress), "repay", [user], i.payments) | |
103 | - | if ((amount == amount)) | |
104 | - | then { | |
105 | - | let assetId = getStringValue(addressFromStringValue(poolAddress), "assetId") | |
106 | - | match amount { | |
107 | - | case t: Int => | |
108 | - | if ((assetId == "WAVES")) | |
109 | - | then [ScriptTransfer(i.caller, t, unit)] | |
110 | - | else [ScriptTransfer(i.caller, t, fromBase58String(assetId))] | |
111 | - | case t: String => | |
112 | - | nil | |
113 | - | case _ => | |
114 | - | throw("Incorrect invoke result!") | |
115 | - | } | |
116 | - | } | |
117 | - | else throw("Strict value is not equal to itself.") | |
118 | - | } | |
119 | - | else throw("No payment attached!") | |
120 | - | else throw("AssetIds does not match") | |
121 | - | } | |
122 | - | else throw("Pool address not found!") | |
123 | - | ||
124 | - | ||
125 | - | ||
126 | - | @Callable(i) | |
127 | - | func borrowFrom (poolAddress,assetId,amount) = if (checkPool(poolAddress)) | |
128 | - | then { | |
129 | - | let poolAsset = getStringValue(addressFromStringValue(poolAddress), "assetId") | |
130 | - | if ((poolAsset == assetId)) | |
131 | - | then if (checkPoolLiquidity(poolAddress, amount)) | |
132 | - | then { | |
133 | - | let user = toBase58String(i.caller.bytes) | |
134 | - | if (checkUserHealth(user, amount, assetId, 0, "")) | |
135 | - | then { | |
136 | - | let tokenAmount = invoke(addressFromStringValue(poolAddress), "borrow", [user, amount], nil) | |
137 | - | if ((tokenAmount == tokenAmount)) | |
138 | - | then match tokenAmount { | |
139 | - | case t: Int => | |
140 | - | if ((poolAsset == "WAVES")) | |
141 | - | then [ScriptTransfer(i.caller, t, unit)] | |
142 | - | else [ScriptTransfer(i.caller, t, fromBase58String(poolAsset))] | |
143 | - | case t: String => | |
144 | - | nil | |
145 | - | case _ => | |
146 | - | throw("Incorrect invoke result!") | |
147 | - | } | |
148 | - | else throw("Strict value is not equal to itself.") | |
149 | - | } | |
150 | - | else throw("Borrow exceeds user health!") | |
151 | - | } | |
152 | - | else throw("Pool liquidity is not sufficient!") | |
153 | - | else throw("AssetIds does not match") | |
154 | - | } | |
155 | - | else throw("Pool address not found!") | |
156 | - | ||
157 | - | ||
158 | - | ||
159 | - | @Callable(i) | |
160 | 95 | func setup (configAddress,pools) = if (if (!(isDefined(getString(this, "config")))) | |
161 | 96 | then !(isDefined(getString(this, "pools"))) | |
162 | 97 | else false) | |
163 | 98 | then [writeString("config", configAddress), writeString("pools", makeString(pools, ";"))] | |
164 | 99 | else throw("Admin and config address already definied!") | |
165 | 100 | ||
166 | 101 | ||
167 | 102 | ||
168 | 103 | @Callable(i) | |
169 | 104 | func addPool (poolAddress) = if (isAdmin(i.caller)) | |
170 | 105 | then { | |
171 | 106 | let poolList = split(pools, ";") | |
172 | 107 | if ((containsElement(poolList, poolAddress) == false)) | |
173 | 108 | then { | |
174 | 109 | let newPools = (poolList :+ poolAddress) | |
175 | 110 | [writeString("pools", makeString(newPools, ";"))] | |
176 | 111 | } | |
177 | 112 | else throw("Pool already exists!") | |
178 | 113 | } | |
179 | 114 | else throw("Address does not match with admin address!") | |
180 | 115 | ||
181 | 116 | ||
182 | 117 | ||
183 | 118 | @Callable(i) | |
184 | 119 | func updateConfig (configAddress) = if (isAdmin(i.caller)) | |
185 | 120 | then [writeString("config", configAddress)] | |
186 | 121 | else throw("Address does not match with admin address!") | |
187 | 122 | ||
188 | 123 | ||
189 | 124 | ||
190 | 125 | @Callable(i) | |
191 | 126 | func depositAt (poolAddress,isCollateral) = if (checkPool(poolAddress)) | |
192 | 127 | then if ((size(i.payments) > 0)) | |
193 | 128 | then { | |
194 | 129 | let user = toBase58String(i.caller.bytes) | |
195 | 130 | let tokenAmount = invoke(addressFromStringValue(poolAddress), "deposit", [user, isCollateral], i.payments) | |
196 | 131 | if ((tokenAmount == tokenAmount)) | |
197 | 132 | then { | |
198 | 133 | let tokenId = getStringValue(addressFromStringValue(poolAddress), "dTokenId") | |
199 | 134 | match tokenAmount { | |
200 | 135 | case t: Int => | |
201 | 136 | [ScriptTransfer(i.caller, t, fromBase58String(tokenId))] | |
202 | 137 | case t: String => | |
203 | 138 | nil | |
204 | 139 | case _ => | |
205 | 140 | throw("Incorrect invoke result!") | |
206 | 141 | } | |
207 | 142 | } | |
208 | 143 | else throw("Strict value is not equal to itself.") | |
209 | 144 | } | |
210 | 145 | else throw("No payment attached!") | |
211 | 146 | else throw("Pool address not found!") | |
212 | 147 | ||
213 | 148 | ||
214 | 149 | ||
215 | 150 | @Callable(i) | |
216 | 151 | func withdrawFrom (poolAddress) = if (checkPool(poolAddress)) | |
217 | 152 | then { | |
218 | 153 | let dTokenId = getStringValue(addressFromStringValue(poolAddress), "dTokenId") | |
219 | 154 | if ((fromBase58String(dTokenId) == i.payments[0].assetId)) | |
220 | 155 | then if ((size(i.payments) > 0)) | |
221 | 156 | then { | |
222 | 157 | let user = toBase58String(i.caller.bytes) | |
223 | 158 | let tokenAmount = invoke(addressFromStringValue(poolAddress), "withdraw", [user], i.payments) | |
224 | 159 | if ((tokenAmount == tokenAmount)) | |
225 | 160 | then { | |
226 | 161 | let tokenId = getStringValue(addressFromStringValue(poolAddress), "assetId") | |
227 | 162 | match tokenAmount { | |
228 | 163 | case t: Int => | |
229 | 164 | if ((tokenId == "WAVES")) | |
230 | 165 | then [ScriptTransfer(i.caller, t, unit)] | |
231 | 166 | else [ScriptTransfer(i.caller, t, fromBase58String(tokenId))] | |
232 | 167 | case t: String => | |
233 | 168 | nil | |
234 | 169 | case _ => | |
235 | 170 | throw("Incorrect invoke result!") | |
236 | 171 | } | |
237 | 172 | } | |
238 | 173 | else throw("Strict value is not equal to itself.") | |
239 | 174 | } | |
240 | 175 | else throw("No payment attached!") | |
241 | 176 | else throw("AssetIds does not match") | |
242 | 177 | } | |
243 | 178 | else throw("Pool address not found!") | |
244 | 179 | ||
245 | 180 | ||
246 | 181 | ||
247 | 182 | @Callable(i) | |
183 | + | func repayTo (poolAddress) = if (checkPool(poolAddress)) | |
184 | + | then { | |
185 | + | let poolAsset = getStringValue(addressFromStringValue(poolAddress), "assetId") | |
186 | + | if ((fromBase58String(poolAsset) == i.payments[0].assetId)) | |
187 | + | then if ((size(i.payments) > 0)) | |
188 | + | then { | |
189 | + | let user = toBase58String(i.caller.bytes) | |
190 | + | let amount = invoke(addressFromStringValue(poolAddress), "repay", [user], i.payments) | |
191 | + | if ((amount == amount)) | |
192 | + | then { | |
193 | + | let assetId = getStringValue(addressFromStringValue(poolAddress), "assetId") | |
194 | + | match amount { | |
195 | + | case t: Int => | |
196 | + | if ((assetId == "WAVES")) | |
197 | + | then [ScriptTransfer(i.caller, t, unit)] | |
198 | + | else [ScriptTransfer(i.caller, t, fromBase58String(assetId))] | |
199 | + | case t: String => | |
200 | + | nil | |
201 | + | case _ => | |
202 | + | throw("Incorrect invoke result!") | |
203 | + | } | |
204 | + | } | |
205 | + | else throw("Strict value is not equal to itself.") | |
206 | + | } | |
207 | + | else throw("No payment attached!") | |
208 | + | else throw("AssetIds does not match") | |
209 | + | } | |
210 | + | else throw("Pool address not found!") | |
211 | + | ||
212 | + | ||
213 | + | ||
214 | + | @Callable(i) | |
215 | + | func borrowFrom (poolAddress,assetId,amount) = if (checkPool(poolAddress)) | |
216 | + | then { | |
217 | + | let poolAsset = getStringValue(addressFromStringValue(poolAddress), "assetId") | |
218 | + | if ((poolAsset == assetId)) | |
219 | + | then if (checkPoolLiquidity(poolAddress, amount)) | |
220 | + | then { | |
221 | + | let user = toBase58String(i.caller.bytes) | |
222 | + | if (checkUserHealth(user, amount, assetId, 0, "")) | |
223 | + | then { | |
224 | + | let tokenAmount = invoke(addressFromStringValue(poolAddress), "borrow", [user, amount], nil) | |
225 | + | if ((tokenAmount == tokenAmount)) | |
226 | + | then match tokenAmount { | |
227 | + | case t: Int => | |
228 | + | if ((poolAsset == "WAVES")) | |
229 | + | then [ScriptTransfer(i.caller, t, unit)] | |
230 | + | else [ScriptTransfer(i.caller, t, fromBase58String(poolAsset))] | |
231 | + | case t: String => | |
232 | + | nil | |
233 | + | case _ => | |
234 | + | throw("Incorrect invoke result!") | |
235 | + | } | |
236 | + | else throw("Strict value is not equal to itself.") | |
237 | + | } | |
238 | + | else throw("Borrow exceeds user health!") | |
239 | + | } | |
240 | + | else throw("Pool liquidity is not sufficient!") | |
241 | + | else throw("AssetIds does not match") | |
242 | + | } | |
243 | + | else throw("Pool address not found!") | |
244 | + | ||
245 | + | ||
246 | + | ||
247 | + | @Callable(i) | |
248 | 248 | func lockAsCollateralAt (poolAddress) = if (checkPool(poolAddress)) | |
249 | 249 | then { | |
250 | 250 | let dTokenId = getStringValue(addressFromStringValue(poolAddress), "dTokenId") | |
251 | 251 | if ((fromBase58String(dTokenId) == i.payments[0].assetId)) | |
252 | 252 | then if ((size(i.payments) > 0)) | |
253 | 253 | then { | |
254 | 254 | let user = toBase58String(i.caller.bytes) | |
255 | 255 | let msg = invoke(addressFromStringValue(poolAddress), "lockAsCollateral", [user], i.payments) | |
256 | 256 | if ((msg == msg)) | |
257 | 257 | then match msg { | |
258 | 258 | case t: String => | |
259 | 259 | nil | |
260 | 260 | case _ => | |
261 | 261 | throw("Incorrect invoke result!") | |
262 | 262 | } | |
263 | 263 | else throw("Strict value is not equal to itself.") | |
264 | 264 | } | |
265 | 265 | else throw("No payment attached!") | |
266 | 266 | else throw("AssetIds does not match") | |
267 | 267 | } | |
268 | 268 | else throw("Pool address not found!") | |
269 | 269 | ||
270 | 270 | ||
271 | 271 | ||
272 | 272 | @Callable(i) | |
273 | + | func redeemCollateralFrom (poolAddress,dtokeId,amount) = if (checkPool(poolAddress)) | |
274 | + | then { | |
275 | + | let poolDTokenId = getStringValue(addressFromStringValue(poolAddress), "dTokenId") | |
276 | + | if ((poolDTokenId == dtokeId)) | |
277 | + | then { | |
278 | + | let user = toBase58String(i.caller.bytes) | |
279 | + | if (checkUserHealth(user, 0, "", amount, dtokeId)) | |
280 | + | then { | |
281 | + | let tokenAmount = invoke(addressFromStringValue(poolAddress), "redeemCollateral", [user, amount], nil) | |
282 | + | if ((tokenAmount == tokenAmount)) | |
283 | + | then { | |
284 | + | let tokenId = getStringValue(addressFromStringValue(poolAddress), "dTokenId") | |
285 | + | match tokenAmount { | |
286 | + | case t: Int => | |
287 | + | [ScriptTransfer(i.caller, t, fromBase58String(tokenId))] | |
288 | + | case t: String => | |
289 | + | nil | |
290 | + | case _ => | |
291 | + | throw("Incorrect invoke result!") | |
292 | + | } | |
293 | + | } | |
294 | + | else throw("Strict value is not equal to itself.") | |
295 | + | } | |
296 | + | else throw("Borrow exceeds user health!") | |
297 | + | } | |
298 | + | else throw("AssetIds does not match") | |
299 | + | } | |
300 | + | else throw("Pool address not found!") | |
301 | + | ||
302 | + | ||
303 | + | ||
304 | + | @Callable(i) | |
273 | 305 | func deleteData (name) = [DeleteEntry(name)] | |
274 | 306 | ||
275 | 307 |
github/deemru/w8io/026f985 43.56 ms ◑