tx · HJNSTA4LU1KkwcJ1w4NDXyHRXeF3apNJWUKFMUAyw25e 3MrASWFH3k8Tkfq2eoMDH6vZWy2dywFQNen: -0.03400000 Waves 2022.11.10 12:43 [2310887] smart account 3MrASWFH3k8Tkfq2eoMDH6vZWy2dywFQNen > SELF 0.00000000 Waves
{ "type": 13, "id": "HJNSTA4LU1KkwcJ1w4NDXyHRXeF3apNJWUKFMUAyw25e", "fee": 3400000, "feeAssetId": null, "timestamp": 1668073464775, "version": 2, "chainId": 84, "sender": "3MrASWFH3k8Tkfq2eoMDH6vZWy2dywFQNen", "senderPublicKey": "9JqU7LHuYERXD76iWBYPkx8qsJ5kNWc8UjTncwigr2BS", "proofs": [ "2xChMAmpyJxjRXvJ4Fbfgixr31pisH7X4inDhdMCiba9fZkkt3xsuDvrEuRyn1Qhqwv5sotV8GXUNib4jJQnvsbD" ], "script": "base64:BgIgCAISBAoCCAgSAwoBCBIECgIICBIECgIICBIFCgMICAEfABJrX2Fzc2V0X2NvbGxhdGVyYWwCEmtfYXNzZXRfY29sbGF0ZXJhbAAga190cmFkZXJfbWFya2V0X2Fzc2V0X2NvbGxhdGVyYWwCIGtfdHJhZGVyX21hcmtldF9hc3NldF9jb2xsYXRlcmFsABFrX3doaXRlbGlzdF9hc3NldAIRa193aGl0ZWxpc3RfYXNzZXQADWtfaW5pdGlhbGl6ZWQCDWtfaW5pdGlhbGl6ZWQAFGtfY29vcmRpbmF0b3JBZGRyZXNzAhRrX2Nvb3JkaW5hdG9yQWRkcmVzcwASa19nb3Zlcm5hbmNlX2Fzc2V0AgtrX2dvdl9hc3NldAANa19xdW90ZV9hc3NldAINa19xdW90ZV9hc3NldAASa19hZG1pbl9wdWJsaWNfa2V5AhJrX2FkbWluX3B1YmxpY19rZXkAEWtfbWFuYWdlcl9hZGRyZXNzAhFrX21hbmFnZXJfYWRkcmVzcwAFa19hbW0CBWtfYW1tABNrX2luc3VyYW5jZV9hZGRyZXNzAhNrX2luc3VyYW5jZV9hZGRyZ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kACQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwAACQEOYWRtaW5QdWJsaWNLZXkAaxX5PQ==", "height": 2310887, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: HjFAsPEx8miJGpwHGm8oeru6Szzvk5yT5u4TifqfCTqK Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 6 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let k_asset_collateral = "k_asset_collateral" | |
5 | + | ||
6 | + | let k_trader_market_asset_collateral = "k_trader_market_asset_collateral" | |
7 | + | ||
8 | + | let k_whitelist_asset = "k_whitelist_asset" | |
9 | + | ||
10 | + | let k_initialized = "k_initialized" | |
11 | + | ||
12 | + | let k_coordinatorAddress = "k_coordinatorAddress" | |
13 | + | ||
14 | + | let k_governance_asset = "k_gov_asset" | |
15 | + | ||
16 | + | let k_quote_asset = "k_quote_asset" | |
17 | + | ||
18 | + | let k_admin_public_key = "k_admin_public_key" | |
19 | + | ||
20 | + | let k_manager_address = "k_manager_address" | |
21 | + | ||
22 | + | let k_amm = "k_amm" | |
23 | + | ||
24 | + | let k_insurance_address = "k_insurance_address" | |
25 | + | ||
26 | + | let k_exchange_address = "k_exchange_address" | |
27 | + | ||
28 | + | func toCompositeKey (_key,_address) = ((_key + "_") + _address) | |
29 | + | ||
30 | + | ||
31 | + | func coordinator () = valueOrErrorMessage(addressFromString(getStringValue(this, k_coordinatorAddress)), "Coordinator not set") | |
32 | + | ||
33 | + | ||
34 | + | func adminPublicKey () = fromBase58String(getStringValue(coordinator(), k_admin_public_key)) | |
35 | + | ||
36 | + | ||
37 | + | func governanceAsset () = fromBase58String(getStringValue(coordinator(), k_governance_asset)) | |
38 | + | ||
39 | + | ||
40 | + | func quoteAsset () = fromBase58String(getStringValue(coordinator(), k_quote_asset)) | |
41 | + | ||
42 | + | ||
43 | + | func managerAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_manager_address)), "Manager not set") | |
44 | + | ||
45 | + | ||
46 | + | func isWhitelist (_address) = valueOrElse(getBoolean(coordinator(), toCompositeKey(k_amm, _address)), false) | |
47 | + | ||
48 | + | ||
49 | + | func isWhitelistAsset (_assetId) = valueOrElse(getBoolean(this, toCompositeKey(k_whitelist_asset, _assetId)), false) | |
50 | + | ||
51 | + | ||
52 | + | func insuranceAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_insurance_address)), "Insurance not set") | |
53 | + | ||
54 | + | ||
55 | + | func swapAddress () = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(coordinator(), k_exchange_address), "No swap address")), "Invalid swap address") | |
56 | + | ||
57 | + | ||
58 | + | let DECIMAL_UNIT = (1 * (((((((10 * 10) * 10) * 10) * 10) * 10) * 10) * 10)) | |
59 | + | ||
60 | + | let DURATION = ((60 * 60) * 24) | |
61 | + | ||
62 | + | let NO_ADDRESS = "" | |
63 | + | ||
64 | + | let NO_STAKER = 0 | |
65 | + | ||
66 | + | func usdnFromDecimals (_amount) = (_amount / 100) | |
67 | + | ||
68 | + | ||
69 | + | func usdnToDecimals (_amount) = (_amount * 100) | |
70 | + | ||
71 | + | ||
72 | + | func initialized () = valueOrElse(getBoolean(this, k_initialized), false) | |
73 | + | ||
74 | + | ||
75 | + | func getBorrowedByTraderInMarketKey (_amm,_assetId,_trader) = ((((((k_trader_market_asset_collateral + "_") + _amm) + "_") + _assetId) + "_") + _trader) | |
76 | + | ||
77 | + | ||
78 | + | func getBorrowedByTraderInMarket (_amm,_assetId,_trader) = { | |
79 | + | let key = getBorrowedByTraderInMarketKey(_amm, _assetId, _trader) | |
80 | + | valueOrElse(getInteger(this, key), 0) | |
81 | + | } | |
82 | + | ||
83 | + | ||
84 | + | @Callable(i) | |
85 | + | func initialize (_coordinator,_whitelist) = if (initialized()) | |
86 | + | then throw("Already initialized") | |
87 | + | else { | |
88 | + | let initialAssetIds = split(_whitelist, ",") | |
89 | + | func doWhitelist (_acc,_assetId) = (_acc :+ BooleanEntry(toCompositeKey(k_whitelist_asset, _assetId), true)) | |
90 | + | ||
91 | + | ({ | |
92 | + | let $l = initialAssetIds | |
93 | + | let $s = size($l) | |
94 | + | let $acc0 = nil | |
95 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
96 | + | then $a | |
97 | + | else doWhitelist($a, $l[$i]) | |
98 | + | ||
99 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
100 | + | then $a | |
101 | + | else throw("List size exceeds 20") | |
102 | + | ||
103 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20) | |
104 | + | } ++ [StringEntry(k_coordinatorAddress, _coordinator), BooleanEntry(k_initialized, true)]) | |
105 | + | } | |
106 | + | ||
107 | + | ||
108 | + | ||
109 | + | @Callable(i) | |
110 | + | func borrow (_trader) = { | |
111 | + | let amount = i.payments[0].amount | |
112 | + | let assetId = toBase58String(valueOrErrorMessage(i.payments[0].assetId, "Invalid asset id")) | |
113 | + | let amm = toString(i.caller) | |
114 | + | if (if (!(isWhitelist(amm))) | |
115 | + | then true | |
116 | + | else !(isWhitelistAsset(assetId))) | |
117 | + | then throw("Invalid borrow parameters") | |
118 | + | else { | |
119 | + | let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [amount], nil) | |
120 | + | if ((withdrawInsurance == withdrawInsurance)) | |
121 | + | then [ScriptTransfer(i.caller, amount, quoteAsset()), IntegerEntry(getBorrowedByTraderInMarketKey(amm, assetId, _trader), (getBorrowedByTraderInMarket(amm, assetId, _trader) + amount))] | |
122 | + | else throw("Strict value is not equal to itself.") | |
123 | + | } | |
124 | + | } | |
125 | + | ||
126 | + | ||
127 | + | ||
128 | + | @Callable(i) | |
129 | + | func repay (_trader,_assetId) = { | |
130 | + | let amount = i.payments[0].amount | |
131 | + | let amm = toString(i.caller) | |
132 | + | if (if (!(isWhitelist(amm))) | |
133 | + | then true | |
134 | + | else !(isWhitelistAsset(_assetId))) | |
135 | + | then throw("Invalid repay parameters") | |
136 | + | else { | |
137 | + | let withdrawInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), amount)]) | |
138 | + | if ((withdrawInsurance == withdrawInsurance)) | |
139 | + | then { | |
140 | + | let newDebt = (getBorrowedByTraderInMarket(amm, _assetId, _trader) - amount) | |
141 | + | ([ScriptTransfer(i.caller, amount, fromBase58String(_assetId))] ++ (if ((newDebt > 0)) | |
142 | + | then [IntegerEntry(getBorrowedByTraderInMarketKey(amm, _assetId, _trader), newDebt)] | |
143 | + | else [DeleteEntry(getBorrowedByTraderInMarketKey(amm, _assetId, _trader))])) | |
144 | + | } | |
145 | + | else throw("Strict value is not equal to itself.") | |
146 | + | } | |
147 | + | } | |
148 | + | ||
149 | + | ||
150 | + | ||
151 | + | @Callable(i) | |
152 | + | func realizePartiallyAndClose (_trader,_assetId) = { | |
153 | + | let amount = if ((size(i.payments) > 0)) | |
154 | + | then i.payments[0].amount | |
155 | + | else 0 | |
156 | + | let amm = toString(i.caller) | |
157 | + | let debt = getBorrowedByTraderInMarket(amm, _assetId, _trader) | |
158 | + | let toSell = (debt - amount) | |
159 | + | let sanityCheck = if ((0 >= toSell)) | |
160 | + | then throw("Use repay instead") | |
161 | + | else nil | |
162 | + | if ((sanityCheck == sanityCheck)) | |
163 | + | then if (if (!(isWhitelist(amm))) | |
164 | + | then true | |
165 | + | else !(isWhitelistAsset(_assetId))) | |
166 | + | then throw("Invalid realizePartiallyAndClose parameters") | |
167 | + | else { | |
168 | + | let amountBefore = assetBalance(this, quoteAsset()) | |
169 | + | if ((amountBefore == amountBefore)) | |
170 | + | then { | |
171 | + | let doSwap = invoke(swapAddress(), "swap", [toBase58String(quoteAsset()), 0], [AttachedPayment(fromBase58String(_assetId), toSell)]) | |
172 | + | if ((doSwap == doSwap)) | |
173 | + | then { | |
174 | + | let amountAfter = assetBalance(this, quoteAsset()) | |
175 | + | if ((amountAfter == amountAfter)) | |
176 | + | then { | |
177 | + | let soldForAmount = (amountAfter - amountBefore) | |
178 | + | if ((soldForAmount == soldForAmount)) | |
179 | + | then { | |
180 | + | let withdrawInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), (amount + soldForAmount))]) | |
181 | + | if ((withdrawInsurance == withdrawInsurance)) | |
182 | + | then { | |
183 | + | let toGetBack = (debt - toSell) | |
184 | + | if ((toGetBack > 0)) | |
185 | + | then [ScriptTransfer(i.caller, (debt - toSell), fromBase58String(_assetId))] | |
186 | + | else (nil ++ [DeleteEntry(getBorrowedByTraderInMarketKey(amm, _assetId, _trader))]) | |
187 | + | } | |
188 | + | else throw("Strict value is not equal to itself.") | |
189 | + | } | |
190 | + | else throw("Strict value is not equal to itself.") | |
191 | + | } | |
192 | + | else throw("Strict value is not equal to itself.") | |
193 | + | } | |
194 | + | else throw("Strict value is not equal to itself.") | |
195 | + | } | |
196 | + | else throw("Strict value is not equal to itself.") | |
197 | + | } | |
198 | + | else throw("Strict value is not equal to itself.") | |
199 | + | } | |
200 | + | ||
201 | + | ||
202 | + | ||
203 | + | @Callable(i) | |
204 | + | func realizePartially (_trader,_assetId,_toSell) = { | |
205 | + | let amm = toString(i.caller) | |
206 | + | let debt = getBorrowedByTraderInMarket(amm, _assetId, _trader) | |
207 | + | let sanityCheck = if (if ((0 >= _toSell)) | |
208 | + | then true | |
209 | + | else (_toSell > debt)) | |
210 | + | then throw("Invalid realizePartiallyAndClose parameters") | |
211 | + | else nil | |
212 | + | if ((sanityCheck == sanityCheck)) | |
213 | + | then if (if (!(isWhitelist(amm))) | |
214 | + | then true | |
215 | + | else !(isWhitelistAsset(_assetId))) | |
216 | + | then throw("Invalid realizePartiallyAndClose parameters") | |
217 | + | else { | |
218 | + | let amountBefore = assetBalance(this, quoteAsset()) | |
219 | + | if ((amountBefore == amountBefore)) | |
220 | + | then { | |
221 | + | let doSwap = invoke(swapAddress(), "swap", [toBase58String(quoteAsset()), 0], [AttachedPayment(fromBase58String(_assetId), _toSell)]) | |
222 | + | if ((doSwap == doSwap)) | |
223 | + | then { | |
224 | + | let amountAfter = assetBalance(this, quoteAsset()) | |
225 | + | if ((amountAfter == amountAfter)) | |
226 | + | then { | |
227 | + | let soldForAmount = (amountAfter - amountBefore) | |
228 | + | if ((soldForAmount == soldForAmount)) | |
229 | + | then { | |
230 | + | let withdrawInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), soldForAmount)]) | |
231 | + | if ((withdrawInsurance == withdrawInsurance)) | |
232 | + | then [IntegerEntry(getBorrowedByTraderInMarketKey(amm, _assetId, _trader), (getBorrowedByTraderInMarket(amm, _assetId, _trader) - _toSell))] | |
233 | + | else throw("Strict value is not equal to itself.") | |
234 | + | } | |
235 | + | else throw("Strict value is not equal to itself.") | |
236 | + | } | |
237 | + | else throw("Strict value is not equal to itself.") | |
238 | + | } | |
239 | + | else throw("Strict value is not equal to itself.") | |
240 | + | } | |
241 | + | else throw("Strict value is not equal to itself.") | |
242 | + | } | |
243 | + | else throw("Strict value is not equal to itself.") | |
244 | + | } | |
245 | + | ||
246 | + | ||
247 | + | @Verifier(tx) | |
248 | + | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], adminPublicKey()) | |
249 | + |
github/deemru/w8io/169f3d6 25.72 ms ◑