tx · AQAh3Mj5gYC5vcLENxLAbSMYkcsqM5kj3UMGJMm3kJUG

3N3tDUvYTUkPj99XK6ahYY1seKQssSPSUxa:  -0.00100000 Waves

2022.09.07 13:53 [2218589] smart account 3N3tDUvYTUkPj99XK6ahYY1seKQssSPSUxa > SELF 0.00000000 Waves

{ "type": 13, "id": "AQAh3Mj5gYC5vcLENxLAbSMYkcsqM5kj3UMGJMm3kJUG", "fee": 100000, "feeAssetId": null, "timestamp": 1662547982488, "version": 2, "chainId": 84, "sender": "3N3tDUvYTUkPj99XK6ahYY1seKQssSPSUxa", "senderPublicKey": "uabndDFnsGq9PjWSXCTHbtJ6qRyJrTnAiV1p3iLLEBf", "proofs": [ "5gXjC3fge85XMtCBpyMH6RoskaY4kCZdwZEx8nVjAQ3pbkrSfFpwDksiHXBuDZ298cZ2qh2ae4JMgDczDyNfHXNG" ], "script": "base64:AAIFAAAAAAAAAAcIAhIDCgEIAAAAAgAAAAAEVVNETgEAAAAgtiYpwwT1zlORpA5LdSQvZIxRsfrfr1QpvUjSHSqyqtEAAAAAC3plZnRBZGRyZXNzCQEAAAAHQWRkcmVzcwAAAAEBAAAAGgFUmTdczELFE8GJ6RS3xffhbl9ZidNnbG3LAAAAAQAAAAFpAQAAAAZjYWxsXzEAAAABAAAACW15YWRkcmVzcwQAAAAFYWRtaW4CAAAAIzNOM3REVXZZVFVrUGo5OVhLNmFoWVkxc2VLUXNzU1BTVXhhAwkBAAAAAiE9AAAAAgkABCUAAAABCAUAAAABaQAAAAZjYWxsZXIFAAAABWFkbWluCQAAAgAAAAECAAAAEW9ubHkgYWRtaW4gY2FuIGRvBAAAAAZyZXN1bHQJAAP9AAAABAkBAAAAEUBleHRyTmF0aXZlKDEwNjIpAAAAAQUAAAAJbXlhZGRyZXNzAgAAAAh1c2RuXzEwMAUAAAADbmlsBQAAAANuaWwDCQAAAAAAAAIFAAAABnJlc3VsdAUAAAAGcmVzdWx0CQAAAgAAAAECAAAAB3N1Y2Nlc3MJAAACAAAAAQIAAAAkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAAAAAEp/rxs=", "height": 2218589, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: BGdn1CTMD15hT3Y29evbW5xkEPDxVzjM3eA62Sct1rmy Next: ofzQx5nEf5DcmcnsqtR5FyjfLvrYeh2VhtnLqwRddrY Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let factorsBase = 1000
4+let USDN = base58'DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p'
55
6-func asUserBalanceData (value) = match value {
7- case x: (Int, Int, Int, Int, Int, Boolean) =>
8- x
9- case t =>
10- throw("expected int5&boolean")
11-}
12-
13-
14-let adminStore = "admin"
15-
16-let configStore = "config"
17-
18-let reservesStore = "reserves"
19-
20-let aTokenIdStore = "aTokenId"
21-
22-let assetIdStore = "assetId"
23-
24-let admin = addressFromStringValue(getStringValue(this, adminStore))
25-
26-let config = addressFromStringValue(getStringValue(this, configStore))
27-
28-let reservesStr = valueOrErrorMessage(getString(this, reservesStore), "no reserves registered")
29-
30-let reserves = split(reservesStr, "|")
31-
32-func assetIdOfReserve (reserve) = valueOrErrorMessage(getString(reserve, assetIdStore), "no assetId in reserve")
33-
34-
35-func collateralFactor (reserve) = valueOrErrorMessage(getInteger(config, (assetIdOfReserve(reserve) + "_CollateralFactor")), "no CollateralFactor in config")
36-
37-
38-func liquidationThreshold (reserve) = valueOrErrorMessage(getInteger(config, (assetIdOfReserve(reserve) + "_LiquidationThreshold")), "no LiquidationThreshold in config")
39-
40-
41-func liquidationPenalty (assetId) = valueOrErrorMessage(getInteger(config, (assetId + "_LiquidationPenalty")), "no LiquidationPenalty in config")
42-
43-
44-let accountHealthThreshold = valueOrErrorMessage(getInteger(config, "account_health_threshold"), "no account_health_threshold")
45-
46-let accountHealthOverlap = valueOrErrorMessage(getInteger(config, "account_health_overlap"), "no account_health_overlap")
47-
48-let collapsePenalty = valueOrErrorMessage(getInteger(config, "collapse_penalty"), "no collapse_penalty")
49-
50-let liquidators = valueOrElse(getString(config, "liquidators"), "")
51-
52-func validateReserve (r) = if (contains(reservesStr, r))
53- then true
54- else throw(("unknown reserve:" + r))
55-
56-
57-func userBalance (reserve,user) = asUserBalanceData(invoke(reserve, "userBalance", [user], nil))
58-
59-
60-func findReserveBy (store,value) = {
61- func fold (a,r) = match a {
62- case found: Address =>
63- found
64- case _ =>
65- let reserve = valueOrErrorMessage(addressFromString(r), "reserve bad address")
66- if ((valueOrErrorMessage(getString(reserve, store), ("reserve has no " + store)) == value))
67- then reserve
68- else unit
69- }
70-
71- match let $l = reserves
72- let $s = size($l)
73- let $acc0 = unit
74- func $f0_1 ($a,$i) = if (($i >= $s))
75- then $a
76- else fold($a, $l[$i])
77-
78- func $f0_2 ($a,$i) = if (($i >= $s))
79- then $a
80- else throw("List size exceeds 6")
81-
82- $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6) {
83- case found: Address =>
84- found
85- case _ =>
86- throw(("unknown " + store))
87- }
88- }
89-
90-
91-func fractionCeil (value,numerator,denominator) = {
92- let cand = fraction(value, numerator, denominator)
93- let D = 3037000499
94- let exact = ((((cand % D) * (denominator % D)) % D) == (((value % D) * (numerator % D)) % D))
95- if (exact)
96- then cand
97- else (cand + 1)
98- }
99-
100-
101-func userPower (user) = {
102- func fold (totals,r) = {
103- let $t028302859 = totals
104- let totalD = $t028302859._1
105- let totalB = $t028302859._2
106- let reserve = valueOrErrorMessage(addressFromString(r), "reserve bad address")
107- let cf = collateralFactor(reserve)
108- let lt = liquidationThreshold(reserve)
109- let $t030303118 = userBalance(reserve, user)
110- let token = $t030303118._1
111- let asset = $t030303118._2
112- let depositUsd = $t030303118._3
113- let debt = $t030303118._4
114- let debtUsd = $t030303118._5
115- let asCollateral = $t030303118._6
116- let effectiveDepositUsd = if (asCollateral)
117- then depositUsd
118- else 0
119- let overlapUsd = min([debtUsd, effectiveDepositUsd])
120- let overlapCharge = fractionCeil(overlapUsd, accountHealthOverlap, factorsBase)
121- if ((debtUsd > effectiveDepositUsd))
122- then $Tuple2(totalD, ((totalB + fraction((debtUsd - effectiveDepositUsd), factorsBase, lt)) + overlapCharge))
123- else $Tuple2((totalD + fraction((effectiveDepositUsd - debtUsd), cf, factorsBase)), (totalB + overlapCharge))
124- }
125-
126- let $l = reserves
127- let $s = size($l)
128- let $acc0 = $Tuple2(0, 0)
129- func $f0_1 ($a,$i) = if (($i >= $s))
130- then $a
131- else fold($a, $l[$i])
132-
133- func $f0_2 ($a,$i) = if (($i >= $s))
134- then $a
135- else throw("List size exceeds 6")
136-
137- $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6)
138- }
139-
140-
141-func validateAfter (user,op) = {
142- let $t036723703 = userPower(user)
143- let bp = $t036723703._1
144- let bpu = $t036723703._2
145- let accHealth = (((bp - bpu) * factorsBase) / bp)
146- if (if ((bp == 0))
147- then (bpu == 0)
148- else false)
149- then nil
150- else if (if ((bp == 0))
151- then (bpu > 0)
152- else false)
153- then throw(((op + " too much: breaching liquidation threshold(bp=0, bpu=") + toString(bpu)))
154- else if ((accountHealthThreshold > accHealth))
155- then throw((((((((op + " too much: breaching liquidation threshold(bp=") + toString(bp)) + ", bpu=") + toString(bpu)) + ", health=") + toString(accHealth)) + ")"))
156- else nil
157- }
158-
6+let zeftAddress = Address(base58'3N3tDUvYTUkPj99XK6ahYY1seKQssSPSUxa')
1597
1608 @Callable(i)
161-func withdraw (assetId,amount) = {
162- let user = toString(i.caller)
163- let targetContract = findReserveBy(assetIdStore, assetId)
164- let doWithdraw = invoke(targetContract, "withdrawFor", [user, amount], nil)
165- if ((doWithdraw == doWithdraw))
166- then validateAfter(user, "withdrawing")
167- else throw("Strict value is not equal to itself.")
168- }
169-
170-
171-
172-@Callable(i)
173-func withdraw2 (reserve,amount) = {
174- let v = validateReserve(reserve)
175- if ((v == v))
176- then {
177- let user = toString(i.caller)
178- let targetContract = addressFromStringValue(reserve)
179- let doWithdraw = invoke(targetContract, "withdrawFor", [user, amount], nil)
180- if ((doWithdraw == doWithdraw))
181- then validateAfter(user, "withdrawing2")
9+func call_1 (myaddress) = {
10+ let admin = "3N3tDUvYTUkPj99XK6ahYY1seKQssSPSUxa"
11+ if ((toString(i.caller) != admin))
12+ then throw("only admin can do")
13+ else {
14+ let result = reentrantInvoke(addressFromStringValue(myaddress), "usdn_100", nil, nil)
15+ if ((result == result))
16+ then throw("success")
18217 else throw("Strict value is not equal to itself.")
18318 }
184- else throw("Strict value is not equal to itself.")
18519 }
18620
18721

github/deemru/w8io/026f985 
46.26 ms