12 | | - | let keyInvokeNext = "invoke next" |
---|
13 | | - | |
---|
14 | | - | let keyActivated = "Activated blockheight" |
---|
15 | | - | |
---|
16 | | - | let keyActivated2 = "Activated 2 blockheight" |
---|
17 | | - | |
---|
18 | | - | let keyBotAddress = "bot address string" |
---|
19 | | - | |
---|
20 | | - | let keyBurnAmount = "burn amount" |
---|
21 | | - | |
---|
22 | | - | let keyBurnxtnAmount = "burn BURN-XTN amount" |
---|
23 | | - | |
---|
24 | | - | let d6 = 1000000 |
---|
25 | | - | |
---|
26 | | - | let vvxtnlp = base58'8KEtor9aSsSj38MknyAE7k1uRThHY9prAXgiE4D7WpyL' |
---|
27 | | - | |
---|
28 | | - | let xtnId = base58'DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p' |
---|
29 | | - | |
---|
30 | | - | let burnxtnId = base58'3SjxA2YLdfF9fTRbzLm9xFn27C6MW34W1YsdJ6Axefns' |
---|
31 | | - | |
---|
32 | | - | let surfId = base58'At8D6NFFpheCbvKVnjVoeLL84Eo8NZn6ovManxfLaFWL' |
---|
33 | | - | |
---|
34 | | - | let burn = Address(base58'3PCBL2vbjAVFbiCwmGsPmT6QdATutQnM8ov') |
---|
35 | | - | |
---|
36 | | - | let bbb = Address(base58'3PEgVPqJ3NYWbRn1CLELUpuY9KCmragc7sY') |
---|
37 | | - | |
---|
38 | | - | let bot = addressFromStringValue(getStringValue(this, keyBotAddress)) |
---|
| 8 | + | let d8 = 100000000 |
---|
41 | | - | func invoker () = { |
---|
42 | | - | let inv1 = invoke(Address(base58'3PAucbbumdUXmhzcR421zGiayphEdo2tRoz'), "withdraw", nil, nil) |
---|
43 | | - | if ((inv1 == inv1)) |
---|
44 | | - | then { |
---|
45 | | - | let inv2 = if ((50 > assetBalance(Address(base58'3PAucbbumdUXmhzcR421zGiayphEdo2tRoz'), vvxtnlp))) |
---|
46 | | - | then invoke(Address(base58'3PAkmJniMgnnAej5pYf2jFYkCbZow5pt9tr'), "withdraw", nil, nil) |
---|
47 | | - | else invoke(Address(base58'3PAucbbumdUXmhzcR421zGiayphEdo2tRoz'), "importVVXTNLP", nil, nil) |
---|
48 | | - | if ((inv2 == inv2)) |
---|
49 | | - | then { |
---|
50 | | - | let inv3 = invoke(Address(base58'3PPCzX2doZ7agBNuGSKqjrbdXgGEtE7CpQ3'), "withdraw", nil, nil) |
---|
51 | | - | if ((inv3 == inv3)) |
---|
52 | | - | then { |
---|
53 | | - | let inv4 = invoke(Address(base58'3PHLhWPrs1mrpM1ZDUv1VmUnZRwchADJELc'), "withdraw", nil, nil) |
---|
54 | | - | if ((inv4 == inv4)) |
---|
55 | | - | then nil |
---|
56 | | - | else throw("Strict value is not equal to itself.") |
---|
57 | | - | } |
---|
58 | | - | else throw("Strict value is not equal to itself.") |
---|
59 | | - | } |
---|
60 | | - | else throw("Strict value is not equal to itself.") |
---|
61 | | - | } |
---|
62 | | - | else throw("Strict value is not equal to itself.") |
---|
63 | | - | } |
---|
64 | | - | |
---|
65 | | - | |
---|
66 | | - | |
---|
67 | | - | @Callable(i) |
---|
68 | | - | func invokerBBB () = if ((i.caller != bot)) |
---|
69 | | - | then throw("no") |
---|
| 11 | + | func stakeUnstake (stake,amount) = if ((i.caller != this)) |
---|
| 12 | + | then throw("fu") |
---|
71 | | - | let inv = if ((tryGetInteger(bbb, keyInvokeNext) == 2)) |
---|
72 | | - | then invoke(this, "BBB2", nil, nil) |
---|
73 | | - | else invoke(this, "BBB1", nil, nil) |
---|
74 | | - | if ((inv == inv)) |
---|
75 | | - | then nil |
---|
76 | | - | else throw("Strict value is not equal to itself.") |
---|
| 14 | + | let pool = Address(base58'3PCrRrwHEjGXFjYtXDsNv78f3Ch3CH3p6V1') |
---|
| 15 | + | let leasingId = getBinary(this, kLeasingId) |
---|
| 16 | + | let leasingAmount = valueOrElse(getInteger(this, kLeasingAmount), 0) |
---|
| 17 | + | let newLeaseAmount = if (stake) |
---|
| 18 | + | then ((leasingAmount + wavesBalance(this).available) - d8) |
---|
| 19 | + | else (leasingAmount - amount) |
---|
| 20 | + | let newLease = Lease(pool, newLeaseAmount) |
---|
| 21 | + | let newLeaseId = calculateLeaseId(newLease) |
---|
| 22 | + | let baseEntry = [newLease, BinaryEntry(kLeasingId, newLeaseId), IntegerEntry(kLeasingAmount, newLeaseAmount)] |
---|
| 23 | + | match leasingId { |
---|
| 24 | + | case lId: ByteVector => |
---|
| 25 | + | ([LeaseCancel(lId)] ++ baseEntry) |
---|
| 26 | + | case _ => |
---|
| 27 | + | baseEntry |
---|
78 | | - | |
---|
79 | | - | |
---|
80 | | - | |
---|
81 | | - | @Callable(i) |
---|
82 | | - | func BBB1 () = if ((i.caller != this)) |
---|
83 | | - | then throw("no") |
---|
84 | | - | else if (((getIntegerValue(bbb, keyActivated) + (7 * 1440)) > height)) |
---|
85 | | - | then throw(("Wait till blockheight" + toString((getIntegerValue(bbb, keyActivated) + (7 * 1440))))) |
---|
86 | | - | else { |
---|
87 | | - | let inv = invoke(bbb, "claimInvestPuzzle", nil, nil) |
---|
88 | | - | if ((inv == inv)) |
---|
89 | | - | then [ScriptTransfer(bot, d6, unit)] |
---|
90 | | - | else throw("Strict value is not equal to itself.") |
---|
91 | | - | } |
---|
92 | | - | |
---|
93 | | - | |
---|
94 | | - | |
---|
95 | | - | @Callable(i) |
---|
96 | | - | func BBB2 () = if ((i.caller != this)) |
---|
97 | | - | then throw("no") |
---|
98 | | - | else if (((getIntegerValue(bbb, keyActivated2) + (7 * 1440)) > height)) |
---|
99 | | - | then throw(("Wait till blockheight" + toString((getIntegerValue(bbb, keyActivated2) + (7 * 1440))))) |
---|
100 | | - | else { |
---|
101 | | - | let inv = invoke(bbb, "distribute", nil, nil) |
---|
102 | | - | if ((inv == inv)) |
---|
103 | | - | then [ScriptTransfer(bot, d6, unit)] |
---|
104 | | - | else throw("Strict value is not equal to itself.") |
---|
105 | | - | } |
---|
106 | | - | |
---|
107 | | - | |
---|
108 | | - | |
---|
109 | | - | @Callable(i) |
---|
110 | | - | func BBB1any () = if ((((getIntegerValue(bbb, keyActivated) + (7 * 1440)) + 2) > height)) |
---|
111 | | - | then throw(("Wait till blockheight" + toString(((getIntegerValue(bbb, keyActivated) + (7 * 1440)) + 2)))) |
---|
112 | | - | else if ((tryGetInteger(bbb, keyInvokeNext) == 2)) |
---|
113 | | - | then throw("invoke BBB2any first") |
---|
114 | | - | else { |
---|
115 | | - | let inv = invoke(bbb, "claimInvestPuzzle", nil, nil) |
---|
116 | | - | if ((inv == inv)) |
---|
117 | | - | then [ScriptTransfer(bot, d6, unit)] |
---|
118 | | - | else throw("Strict value is not equal to itself.") |
---|
119 | | - | } |
---|
120 | | - | |
---|
121 | | - | |
---|
122 | | - | |
---|
123 | | - | @Callable(i) |
---|
124 | | - | func BBB2any () = if ((((getIntegerValue(bbb, keyActivated2) + (7 * 1440)) + 2) > height)) |
---|
125 | | - | then throw(("Wait till blockheight" + toString(((getIntegerValue(bbb, keyActivated2) + (7 * 1440)) + 2)))) |
---|
126 | | - | else if ((tryGetInteger(bbb, keyInvokeNext) == 1)) |
---|
127 | | - | then throw("invoke BBB1any first") |
---|
128 | | - | else { |
---|
129 | | - | let inv = invoke(bbb, "distribute", nil, nil) |
---|
130 | | - | if ((inv == inv)) |
---|
131 | | - | then [ScriptTransfer(bot, d6, unit)] |
---|
132 | | - | else throw("Strict value is not equal to itself.") |
---|
133 | | - | } |
---|
134 | | - | |
---|
135 | | - | |
---|
136 | | - | |
---|
137 | | - | @Callable(i) |
---|
138 | | - | func botAddress (address) = if ((i.caller != this)) |
---|
139 | | - | then throw("no") |
---|
140 | | - | else [StringEntry(keyBotAddress, address)] |
---|
141 | | - | |
---|
142 | | - | |
---|
143 | | - | |
---|
144 | | - | @Callable(i) |
---|
145 | | - | func changeIntegerEntry (keyString,integer) = if ((i.caller != this)) |
---|
146 | | - | then throw("access only by project owner") |
---|
147 | | - | else [IntegerEntry(keyString, integer)] |
---|
148 | | - | |
---|
149 | | - | |
---|
150 | | - | |
---|
151 | | - | @Callable(i) |
---|
152 | | - | func burnXTN () = if (if ((i.caller != this)) |
---|
153 | | - | then (i.caller != burn) |
---|
154 | | - | else false) |
---|
155 | | - | then throw("access only by project owner") |
---|
156 | | - | else { |
---|
157 | | - | let xtnBurnAmount = if ((assetBalance(this, xtnId) >= tryGetInteger(burn, keyBurnAmount))) |
---|
158 | | - | then tryGetInteger(burn, keyBurnAmount) |
---|
159 | | - | else 0 |
---|
160 | | - | let xtnBurn = Burn(xtnId, xtnBurnAmount) |
---|
161 | | - | let surfBurnAmount = if ((assetBalance(this, surfId) >= tryGetInteger(burn, keyBurnAmount))) |
---|
162 | | - | then tryGetInteger(burn, keyBurnAmount) |
---|
163 | | - | else 0 |
---|
164 | | - | let surfBurn = Burn(surfId, surfBurnAmount) |
---|
165 | | - | let burnxtnBurnAmount = if ((assetBalance(this, burnxtnId) >= tryGetInteger(burn, keyBurnxtnAmount))) |
---|
166 | | - | then tryGetInteger(burn, keyBurnxtnAmount) |
---|
167 | | - | else 0 |
---|
168 | | - | let burnxtnBurn = Burn(burnxtnId, burnxtnBurnAmount) |
---|
169 | | - | [xtnBurn, surfBurn, burnxtnBurn, IntegerEntry("XTN total burned", (getIntegerValue(this, "XTN total burned") + xtnBurnAmount)), IntegerEntry("SURF total burned", (tryGetInteger(this, "SURF total burned") + surfBurnAmount))] |
---|