15 | | - | func f (b,c) = { |
---|
16 | | - | let d = getString(b, c) |
---|
17 | | - | if ($isInstanceOf(d, "String")) |
---|
18 | | - | then { |
---|
19 | | - | let e = d |
---|
20 | | - | e |
---|
21 | | - | } |
---|
22 | | - | else "" |
---|
23 | | - | } |
---|
24 | | - | |
---|
25 | | - | |
---|
26 | | - | let g = 100000000 |
---|
27 | | - | |
---|
28 | | - | let h = (30 * 1440) |
---|
29 | | - | |
---|
30 | | - | let i = base58'2kpmuzw1ZbrtgAN3BrR7vbEW1XrJoJKCstL7mf7XNf2P' |
---|
31 | | - | |
---|
32 | | - | let j = (90 * 1440) |
---|
33 | | - | |
---|
34 | | - | let k = base58'4z8CKSYQBKkzx7PBb5uBP1YPa6YAHRNTApW1sQVHT5eU' |
---|
35 | | - | |
---|
36 | | - | let l = "Activated blockheight" |
---|
37 | | - | |
---|
38 | | - | let m = "surplus received in wavelets" |
---|
39 | | - | |
---|
40 | | - | let n = "total WAVES received in wavelets" |
---|
41 | | - | |
---|
42 | | - | let o = "total wavelets received for base treasury" |
---|
43 | | - | |
---|
44 | | - | let p = "total WAVES paid out in wavelets" |
---|
45 | | - | |
---|
46 | | - | let q = "ROI basis points" |
---|
47 | | - | |
---|
48 | | - | let r = "WHIRLPOOL issue price in wavelets" |
---|
49 | | - | |
---|
50 | | - | let s = base58'3PQHndCUVrv3wBuQjbvVP9SnGmfbfitGxfx' |
---|
51 | | - | |
---|
52 | | - | let t = base58'3PEtLVxDT8mxAh1SDAn8m7JTGNkdpkaFxBk' |
---|
53 | | - | |
---|
54 | | - | let u = base58'3P2myTbd5zpEHcYmNpdWTp5gXS5B8tL1RCY' |
---|
55 | | - | |
---|
56 | | - | let v = base58'73tY3E6Gd5AWYmsuq8m8Kek7KnJNAYyS3GoveTbc6jCi' |
---|
57 | | - | |
---|
58 | | - | let w = toBase58String(base58'73tY3E6Gd5AWYmsuq8m8Kek7KnJNAYyS3GoveTbc6jCi') |
---|
59 | | - | |
---|
60 | | - | let x = base58'WAVES' |
---|
61 | | - | |
---|
62 | | - | let y = base58'3VuV5WTmDz47Dmdn3QpcYjzbSdipjQE4JMdNe1xZpX13' |
---|
63 | | - | |
---|
64 | | - | let z = base58'YiNbofFzC17jEHHCMwrRcpy9MrrjabMMLZxg8g5xmf7' |
---|
65 | | - | |
---|
66 | | - | let A = base58'3P8eeDzUnoDNbQjW617pAe76cEUDQsP1m1V' |
---|
67 | | - | |
---|
68 | | - | let B = Address(base58'3PDPzZVLhN1EuzGy4xAxjjTVkawKDLEaHiV') |
---|
69 | | - | |
---|
70 | | - | let C = Address(base58'3P2yiVnK48evTLr8MAZWavpE4WA4fw1weQg') |
---|
71 | | - | |
---|
72 | | - | let D = a(Address(s), (("global_" + toBase58String(x)) + "_balance")) |
---|
73 | | - | |
---|
74 | | - | let E = a(Address(s), (toString(this) + "_indexStaked")) |
---|
75 | | - | |
---|
76 | | - | let F = a(Address(s), "global_poolToken_amount") |
---|
77 | | - | |
---|
78 | | - | func G (H,I) = { |
---|
79 | | - | let d = getInteger(B, H) |
---|
80 | | - | if ($isInstanceOf(d, "Int")) |
---|
81 | | - | then { |
---|
82 | | - | let J = d |
---|
83 | | - | J |
---|
84 | | - | } |
---|
85 | | - | else I |
---|
86 | | - | } |
---|
87 | | - | |
---|
88 | | - | |
---|
89 | | - | func K (H,I) = { |
---|
90 | | - | let d = getBinary(B, H) |
---|
91 | | - | if ($isInstanceOf(d, "ByteVector")) |
---|
92 | | - | then { |
---|
93 | | - | let J = d |
---|
94 | | - | toBigInt(J) |
---|
95 | | - | } |
---|
96 | | - | else I |
---|
97 | | - | } |
---|
98 | | - | |
---|
99 | | - | |
---|
100 | | - | let L = K("LAST_RATE", toBigInt(1000000000000)) |
---|
101 | | - | |
---|
102 | | - | let M = K("CURRENT_RATE", toBigInt(0)) |
---|
103 | | - | |
---|
104 | | - | let N = G("LAST_HEIGHT", 0) |
---|
105 | | - | |
---|
106 | | - | let O = min([G("TARGET_HEIGHT", 0), height]) |
---|
107 | | - | |
---|
108 | | - | let P = (L + (M * toBigInt((O - N)))) |
---|
109 | | - | |
---|
110 | | - | let Q = toInt(fraction(toBigInt(assetBalance(C, z)), P, toBigInt(1000000000000), FLOOR)) |
---|
111 | | - | |
---|
112 | | - | let R = (wavesBalance(C).regular + Q) |
---|
113 | | - | |
---|
114 | | - | let S = assetBalance(C, y) |
---|
115 | | - | |
---|
116 | | - | let T = fraction(g, R, S) |
---|
117 | | - | |
---|
118 | | - | let U = a(Address(u), (("global_" + toBase58String(x)) + "_balance")) |
---|
119 | | - | |
---|
120 | | - | let V = a(Address(u), (("global_" + w) + "_balance")) |
---|
121 | | - | |
---|
122 | | - | let W = a(Address(u), (toString(this) + "_indexStaked")) |
---|
123 | | - | |
---|
124 | | - | let X = a(Address(u), "global_poolToken_amount") |
---|
125 | | - | |
---|
126 | | - | let Y = f(Address(base58'3PMtGnf3LXiEG6isDQLq1xMDKUqjQGqNHLb'), (("%s%s%s__vault__" + toString(this)) + "__WAVES")) |
---|
127 | | - | |
---|
128 | | - | let Z = parseIntValue(split(Y, "__")[2]) |
---|
129 | | - | |
---|
130 | | - | let aa = Address(base58'3PHxubMUtynEY2AeHq3K1kUizRPN9HUC2rt') |
---|
131 | | - | |
---|
132 | | - | let ab = a(aa, (toString(this) + "_aTokenBalance")) |
---|
133 | | - | |
---|
134 | | - | let ac = a(aa, "aTokenCirculation") |
---|
135 | | - | |
---|
136 | | - | let ad = parseIntValue(split(f(aa, "reserveGlobalData"), "|")[1]) |
---|
137 | | - | |
---|
138 | | - | let ae = fraction(ab, ad, ac) |
---|
139 | | - | |
---|
140 | | - | let af = fraction(ae, T, g) |
---|
141 | | - | |
---|
142 | | - | let ag = ((fraction((D * 10), E, F) + fraction((U * 10), W, X)) + af) |
---|
143 | | - | |
---|
144 | | - | let ah = Z |
---|
145 | | - | |
---|
146 | | - | let ai = (ah + ag) |
---|
147 | | - | |
---|
148 | | - | let aj = { |
---|
149 | | - | let d = assetInfo(v) |
---|
150 | | - | if ($isInstanceOf(d, "Asset")) |
---|
151 | | - | then { |
---|
152 | | - | let ak = d |
---|
153 | | - | ak.quantity |
---|
154 | | - | } |
---|
155 | | - | else throw("Can't find asset") |
---|
156 | | - | } |
---|
157 | | - | |
---|
158 | | - | let al = if (((fraction((ag + a(this, m)), g, aj) + g) >= a(this, r))) |
---|
159 | | - | then (fraction((ag + a(this, m)), g, aj) + g) |
---|
160 | | - | else a(this, r) |
---|
161 | | - | |
---|
162 | | - | @Callable(am) |
---|
163 | | - | func buyWHIRLPOOLwithWAVES () = { |
---|
164 | | - | let an = assetBalance(this, v) |
---|
165 | | - | if ((an == an)) |
---|
166 | | - | then { |
---|
167 | | - | let ao = value(am.payments[0]) |
---|
168 | | - | let ap = fraction((al - g), ao.amount, g) |
---|
169 | | - | let aq = if ((ao.amount >= fraction(ao.amount, g, al))) |
---|
170 | | - | then fraction(ao.amount, g, al) |
---|
171 | | - | else throw("please contact project owner: issue amount error") |
---|
172 | | - | let ar = (ao.amount - fraction(ao.amount, 200, 10000)) |
---|
173 | | - | let as = fraction(V, ((g * g) - toInt(pow(fraction(toBigInt(U), toBigInt((g * g)), toBigInt((U + ar)), HALFUP), 16, toBigInt(fraction(100000, 10000, 900000)), 4, 16, CEILING))), (g * g), DOWN) |
---|
174 | | - | if (((g / 20) > ao.amount)) |
---|
175 | | - | then throw("minimum payment 0.05 WAVES") |
---|
176 | | - | else if ((ao.assetId != unit)) |
---|
177 | | - | then throw("attach WAVES token only") |
---|
178 | | - | else { |
---|
179 | | - | let at = if ((as > aq)) |
---|
180 | | - | then invoke(Address(u), "swap", [w, (aq + 1)], [AttachedPayment(unit, ao.amount)]) |
---|
181 | | - | else unit |
---|
182 | | - | if ((at == at)) |
---|
183 | | - | then { |
---|
184 | | - | let au = assetBalance(this, v) |
---|
185 | | - | let av = (au - an) |
---|
186 | | - | [Reissue(v, if ((aq >= as)) |
---|
187 | | - | then aq |
---|
188 | | - | else 0, true), if ((as > aq)) |
---|
189 | | - | then ScriptTransfer(am.caller, av, v) |
---|
190 | | - | else ScriptTransfer(am.caller, aq, v), IntegerEntry(r, al), IntegerEntry(if ((as > aq)) |
---|
191 | | - | then "price WHIRLPOOL/WAVES" |
---|
192 | | - | else "WHIRLPOOL/WAVES mid market price", if ((as > aq)) |
---|
193 | | - | then fraction(g, ao.amount, av) |
---|
194 | | - | else fraction(g, (U * 9), V)), IntegerEntry(n, if ((aq >= as)) |
---|
195 | | - | then (ao.amount + a(this, n)) |
---|
196 | | - | else a(this, n)), IntegerEntry(o, if ((aq >= as)) |
---|
197 | | - | then ((ao.amount - ap) + a(this, o)) |
---|
198 | | - | else a(this, o)), IntegerEntry(m, if ((as > aq)) |
---|
199 | | - | then getIntegerValue(this, m) |
---|
200 | | - | else (ap + getIntegerValue(this, m)))] |
---|
201 | | - | } |
---|
202 | | - | else throw("Strict value is not equal to itself.") |
---|
203 | | - | } |
---|
204 | | - | } |
---|
205 | | - | else throw("Strict value is not equal to itself.") |
---|
206 | | - | } |
---|
207 | | - | |
---|
208 | | - | |
---|
209 | | - | |
---|
210 | | - | @Callable(am) |
---|
211 | | - | func priceAndTreasuryStats () = [IntegerEntry("BT WAVES in EAST vault", Z), IntegerEntry("ST BURN-XTN x PepeTeam in wavelets", fraction((D * 10), E, F)), IntegerEntry("ST WHIRLPOOL AMM in wavelets", fraction((U * 10), W, X)), IntegerEntry("ST vETH", ae), IntegerEntry("ST vETH in wavelets", af), IntegerEntry("Total ST in wavelets", ag), IntegerEntry(r, al), IntegerEntry("WHIRLPOOL/WAVES mid market price", fraction(g, (U * 9), V)), IntegerEntry("WHIRLPOOL total supply", aj), IntegerEntry("Total treasury", ai), IntegerEntry("NAV WHIRLPOOL", fraction(g, ai, aj)), IntegerEntry(n, a(this, n)), IntegerEntry(m, a(this, m)), IntegerEntry(o, a(this, o)), IntegerEntry(p, a(this, p)), IntegerEntry("total WAVES received", (a(this, n) / g)), IntegerEntry("Total treasury in WAVES", (ai / g)), IntegerEntry("surplus received in WAVES", (a(this, m) / g)), IntegerEntry("total WAVES received for base treasury", (a(this, o) / g)), IntegerEntry("total WAVES paid out in WAVES", (a(this, p) / g)), IntegerEntry(q, fraction(a(this, p), 10000, a(this, n)))] |
---|
212 | | - | |
---|
213 | | - | |
---|
214 | | - | |
---|
215 | | - | @Callable(am) |
---|
216 | | - | func boostPoolAPY (aw) = if ((am.caller != this)) |
---|
217 | | - | then throw("access only by project owner") |
---|
218 | | - | else { |
---|
219 | | - | let ax = fraction(aw, 80, 100) |
---|
220 | | - | if ((ax == ax)) |
---|
221 | | - | then { |
---|
222 | | - | let ay = fraction(aw, 20, 100) |
---|
223 | | - | if ((ay == ay)) |
---|
224 | | - | then { |
---|
225 | | - | let az = invoke(Address(A), "addBoosting", [toBase58String(u), 7], [AttachedPayment(unit, ax)]) |
---|
226 | | - | if ((az == az)) |
---|
227 | | - | then [ScriptTransfer(Address(t), ay, unit), IntegerEntry(p, (ax + a(this, p))), IntegerEntry(q, fraction(a(this, p), 10000, a(this, n))), IntegerEntry(l, height)] |
---|
228 | | - | else throw("Strict value is not equal to itself.") |
---|
229 | | - | } |
---|
230 | | - | else throw("Strict value is not equal to itself.") |
---|
231 | | - | } |
---|
232 | | - | else throw("Strict value is not equal to itself.") |
---|
233 | | - | } |
---|
234 | | - | |
---|
235 | | - | |
---|
236 | | - | |
---|
237 | | - | @Callable(am) |
---|
238 | | - | func transferPoolAPY (aw) = if ((am.caller != this)) |
---|
239 | | - | then throw("access only by project owner") |
---|
240 | | - | else { |
---|
241 | | - | let ax = fraction(aw, 80, 100) |
---|
242 | | - | if ((ax == ax)) |
---|
243 | | - | then { |
---|
244 | | - | let ay = fraction(aw, 20, 100) |
---|
245 | | - | if ((ay == ay)) |
---|
246 | | - | then [ScriptTransfer(Address(u), ax, unit), ScriptTransfer(Address(t), ay, unit), IntegerEntry(p, (ax + a(this, p))), IntegerEntry(q, fraction(a(this, p), 10000, a(this, n))), IntegerEntry(l, height)] |
---|
247 | | - | else throw("Strict value is not equal to itself.") |
---|
248 | | - | } |
---|
249 | | - | else throw("Strict value is not equal to itself.") |
---|
250 | | - | } |
---|
251 | | - | |
---|
252 | | - | |
---|
253 | | - | |
---|
254 | | - | @Callable(am) |
---|
255 | | - | func poolOneTokenSurplus () = if ((am.caller != this)) |
---|
256 | | - | then throw("access only by project owner") |
---|
257 | | - | else { |
---|
258 | | - | let aA = a(this, m) |
---|
259 | | - | let aB = invoke(Address(base58'3PR1Qvi9mHT35SwWEkLSqqE2L8thiPLdVWU'), "generateIndexWithOneTokenAndStake", [toBase58String(s)], [AttachedPayment(unit, aA)]) |
---|
260 | | - | if ((aB == aB)) |
---|
261 | | - | then [IntegerEntry(m, (a(this, m) - aA))] |
---|
262 | | - | else throw("Strict value is not equal to itself.") |
---|
263 | | - | } |
---|
264 | | - | |
---|
265 | | - | |
---|
266 | | - | |
---|
267 | | - | @Callable(am) |
---|
268 | | - | func surplusInvested (aC) = if ((am.caller != this)) |
---|
269 | | - | then throw("access only by project owner") |
---|
270 | | - | else { |
---|
271 | | - | let aD = (aC * g) |
---|
272 | | - | [IntegerEntry(m, (a(this, m) - aD))] |
---|
273 | | - | } |
---|
274 | | - | |
---|
275 | | - | |
---|
276 | | - | |
---|
277 | | - | @Callable(am) |
---|
278 | | - | func changeIntegerEntry (aE,aF) = if ((am.caller != this)) |
---|
279 | | - | then throw("access only by project owner") |
---|
280 | | - | else [IntegerEntry(aE, aF)] |
---|
281 | | - | |
---|
282 | | - | |
---|
283 | | - | |
---|
284 | | - | @Callable(am) |
---|
285 | | - | func activated () = if ((am.caller != this)) |
---|
286 | | - | then throw("you are not allowed") |
---|
287 | | - | else [IntegerEntry(l, height)] |
---|
288 | | - | |
---|
289 | | - | |
---|
290 | | - | @Verifier(aG) |
---|
291 | | - | func aH () = if (sigVerify_8Kb(aG.bodyBytes, aG.proofs[0], aG.senderPublicKey)) |
---|
292 | | - | then true |
---|
293 | | - | else if (((getIntegerValue(this, l) + h) > height)) |
---|
294 | | - | then false |
---|
295 | | - | else if (sigVerify_8Kb(aG.bodyBytes, aG.proofs[0], i)) |
---|
296 | | - | then true |
---|
297 | | - | else if (((getIntegerValue(this, l) + j) > height)) |
---|
298 | | - | then false |
---|
299 | | - | else sigVerify_8Kb(aG.bodyBytes, aG.proofs[0], k) |
---|