12 | | - | let e = base58'4TLuEDo8QjPsxUGjfRPyqqvAk4JtnYMXK1ypGo8uKrb2' |
---|
13 | | - | |
---|
14 | | - | let f = base58'3N2PGCSexF2nUN9SmgsaLedFix3M67A9reg' |
---|
15 | | - | |
---|
16 | | - | let g = base58'3N2iME1bcpy9zdFi2S1rmQDjPvvN5X8t3qW' |
---|
17 | | - | |
---|
18 | | - | let h = "total_pool_lp_staked" |
---|
19 | | - | |
---|
20 | | - | let i = "total_pool_earned" |
---|
21 | | - | |
---|
22 | | - | let j = "pool_current_claim_id" |
---|
23 | | - | |
---|
24 | | - | func k (l) = { |
---|
25 | | - | let m = l |
---|
26 | | - | if ($isInstanceOf(m, "AttachedPayment")) |
---|
27 | | - | then { |
---|
28 | | - | let n = m |
---|
29 | | - | n |
---|
30 | | - | } |
---|
31 | | - | else throw("fail to cast into AttachedPayment") |
---|
32 | | - | } |
---|
33 | | - | |
---|
34 | | - | |
---|
35 | | - | func o (p) = { |
---|
36 | | - | let m = p |
---|
37 | | - | if ($isInstanceOf(m, "Int")) |
---|
38 | | - | then { |
---|
39 | | - | let q = m |
---|
40 | | - | q |
---|
41 | | - | } |
---|
42 | | - | else throw("fail to cast into Int") |
---|
43 | | - | } |
---|
44 | | - | |
---|
45 | | - | |
---|
46 | | - | func r (p) = { |
---|
47 | | - | let m = p |
---|
48 | | - | if ($isInstanceOf(m, "String")) |
---|
49 | | - | then { |
---|
50 | | - | let s = m |
---|
51 | | - | s |
---|
52 | | - | } |
---|
53 | | - | else throw("fail to cast into String") |
---|
54 | | - | } |
---|
55 | | - | |
---|
56 | | - | |
---|
57 | | - | func t (u) = if (!(isDefined(getString(u)))) |
---|
58 | | - | then false |
---|
| 12 | + | @Callable(e) |
---|
| 13 | + | func constructor () = if (isDefined(getBoolean(a))) |
---|
| 14 | + | then throw("Constructor can be called one time") |
---|
60 | | - | let v = getIntegerValue(j) |
---|
61 | | - | let w = split(getStringValue(u), c) |
---|
62 | | - | let x = o(parseInt(w[2])) |
---|
63 | | - | (v > x) |
---|
64 | | - | } |
---|
65 | | - | |
---|
66 | | - | |
---|
67 | | - | @Callable(y) |
---|
68 | | - | func stakeLP () = if ((size(y.payments) != 1)) |
---|
69 | | - | then throw("One Payment expected") |
---|
70 | | - | else { |
---|
71 | | - | let z = toBase58String(y.caller.bytes) |
---|
72 | | - | let A = k(y.payments[0]) |
---|
73 | | - | if (if ((A.assetId != e)) |
---|
74 | | - | then true |
---|
75 | | - | else (0 >= A.amount)) |
---|
76 | | - | then throw("Wrong asset id or negative amount") |
---|
77 | | - | else if (t(z)) |
---|
78 | | - | then throw("You have unclaimed rewards on contract, claim them first") |
---|
79 | | - | else { |
---|
80 | | - | let B = valueOrElse(getInteger(j), 0) |
---|
81 | | - | let C = valueOrElse(getInteger(h), 0) |
---|
82 | | - | let D = valueOrElse(getInteger(i), 0) |
---|
83 | | - | let E = invoke(Address(f), "stakePoolLps", [d], [A]) |
---|
84 | | - | if ((E == E)) |
---|
85 | | - | then { |
---|
86 | | - | let F = getString(z) |
---|
87 | | - | let w = if (isDefined(F)) |
---|
88 | | - | then { |
---|
89 | | - | let w = split(r(F), c) |
---|
90 | | - | let G = o(parseInt(w[0])) |
---|
91 | | - | let H = [toString((G + A.amount)), removeByIndex(w, 0)] |
---|
92 | | - | makeString(H, c) |
---|
93 | | - | } |
---|
94 | | - | else makeString([toString(A.amount), "0", toString(B), toString(D)], c) |
---|
95 | | - | [StringEntry(z, w), IntegerEntry(j, B), IntegerEntry(i, D), IntegerEntry(h, (C + A.amount))] |
---|
96 | | - | } |
---|
97 | | - | else throw("Strict value is not equal to itself.") |
---|
98 | | - | } |
---|
| 16 | + | let f = Issue("WXTest", "", 1000000000000000, 8, false, unit, 0) |
---|
| 17 | + | let g = calculateAssetId(f) |
---|
| 18 | + | [f, StringEntry(b, toBase58String(g)), BooleanEntry(a, true), IntegerEntry(d, 0)] |
---|
103 | | - | @Callable(y) |
---|
104 | | - | func withdrawLP () = { |
---|
105 | | - | let z = toBase58String(y.caller.bytes) |
---|
106 | | - | if (t(z)) |
---|
107 | | - | then throw("You have unclaimed rewards on contract, claim them first") |
---|
108 | | - | else nil |
---|
| 23 | + | @Callable(e) |
---|
| 24 | + | func issueLPAsset (h) = { |
---|
| 25 | + | let f = Issue("LPPool", "", 1000000000000000, 8, false, unit, 0) |
---|
| 26 | + | let g = calculateAssetId(f) |
---|
| 27 | + | [f, StringEntry(c, toBase58String(g)), ScriptTransfer(Address(fromBase58String(h)), 1000000000000, g)] |
---|
113 | | - | @Callable(y) |
---|
114 | | - | func claimRewards () = { |
---|
115 | | - | let z = toBase58String(y.caller.bytes) |
---|
116 | | - | if (!(t(z))) |
---|
117 | | - | then throw("Nothing to claim, wait for a while, pool will collect the rewards from WX soon") |
---|
118 | | - | else { |
---|
119 | | - | let I = getIntegerValue(j) |
---|
120 | | - | let J = getIntegerValue(i) |
---|
121 | | - | let w = split(getStringValue(z), c) |
---|
122 | | - | let K = o(parseInt(w[0])) |
---|
123 | | - | let L = o(parseInt(w[1])) |
---|
124 | | - | let M = o(parseInt(w[2])) |
---|
125 | | - | let N = o(parseInt(w[3])) |
---|
126 | | - | let O = (J - N) |
---|
127 | | - | let P = (O - (L * b)) |
---|
128 | | - | let Q = fraction(P, K, b) |
---|
129 | | - | let H = makeString([w[0], toString((L + Q)), toString(I), w[3]], c) |
---|
130 | | - | [StringEntry(z, H), ScriptTransfer(y.caller, Q, a)] |
---|
131 | | - | } |
---|
| 32 | + | @Callable(e) |
---|
| 33 | + | func stakePoolLps (i) = [IntegerEntry("stakePoolLpsFuncCalled", height)] |
---|
| 34 | + | |
---|
| 35 | + | |
---|
| 36 | + | |
---|
| 37 | + | @Callable(e) |
---|
| 38 | + | func withdrawPoolLps (i) = [IntegerEntry("withdrawPoolLpsFuncCalled", height)] |
---|
| 39 | + | |
---|
| 40 | + | |
---|
| 41 | + | |
---|
| 42 | + | @Callable(e) |
---|
| 43 | + | func claimPoolRewards (i) = { |
---|
| 44 | + | let j = getIntegerValue(d) |
---|
| 45 | + | let g = getStringValue(b) |
---|
| 46 | + | let k = if ((j == 0)) |
---|
| 47 | + | then 10000000000 |
---|
| 48 | + | else if ((j == 1)) |
---|
| 49 | + | then 20000000000 |
---|
| 50 | + | else if ((j == 2)) |
---|
| 51 | + | then 5000000000 |
---|
| 52 | + | else if ((j == 3)) |
---|
| 53 | + | then 35000000000 |
---|
| 54 | + | else 22000000000 |
---|
| 55 | + | let l = if ((j == 4)) |
---|
| 56 | + | then 0 |
---|
| 57 | + | else (j + 1) |
---|
| 58 | + | [IntegerEntry(d, l), ScriptTransfer(e.caller, k, fromBase58String(g))] |
---|
135 | | - | |
---|
136 | | - | @Callable(y) |
---|
137 | | - | func claimPoolRewards () = if ((y.caller.bytes != g)) |
---|
138 | | - | then throw("Admin only") |
---|
139 | | - | else { |
---|
140 | | - | let R = getIntegerValue(h) |
---|
141 | | - | let J = getIntegerValue(i) |
---|
142 | | - | let I = getIntegerValue(j) |
---|
143 | | - | let S = assetBalance(this, a) |
---|
144 | | - | if ((S == S)) |
---|
145 | | - | then { |
---|
146 | | - | let E = invoke(Address(f), "claimPoolRewards", [d], nil) |
---|
147 | | - | if ((E == E)) |
---|
148 | | - | then { |
---|
149 | | - | let T = assetBalance(this, a) |
---|
150 | | - | let U = (T - S) |
---|
151 | | - | let V = fraction(U, b, R) |
---|
152 | | - | [IntegerEntry("CURRENT_WX_ON_CONTRACT", S), IntegerEntry("NEW_WX_ON_CONTRACT", T), IntegerEntry(j, (I + 1)), IntegerEntry(i, (J + V))] |
---|
153 | | - | } |
---|
154 | | - | else throw("Strict value is not equal to itself.") |
---|
155 | | - | } |
---|
156 | | - | else throw("Strict value is not equal to itself.") |
---|
157 | | - | } |
---|
158 | | - | |
---|
159 | | - | |
---|
160 | | - | @Verifier(W) |
---|
161 | | - | func X () = sigVerify(W.bodyBytes, W.proofs[0], W.senderPublicKey) |
---|
| 62 | + | @Verifier(m) |
---|
| 63 | + | func n () = sigVerify(m.bodyBytes, m.proofs[0], m.senderPublicKey) |
---|