43 | | - | let r = invoke(Address(e), "usdN_stake", nil, [AttachedPayment(a, l)]) |
---|
44 | | - | if ((r == r)) |
---|
45 | | - | then [IntegerEntry((("usdn_" + toString(j.originCaller)) + "_credit"), m), IntegerEntry((("usdn_" + toString(j.originCaller)) + "_block"), p), IntegerEntry("usdn_all_credit", o), IntegerEntry("usdn_all_block", p)] |
---|
46 | | - | else throw("Strict value is not equal to itself.") |
---|
47 | | - | } |
---|
48 | | - | |
---|
49 | | - | |
---|
50 | | - | |
---|
51 | | - | @Callable(j) |
---|
52 | | - | func buy_usdc_ticket () = if ((j.payments[0].assetId != b)) |
---|
53 | | - | then throw("Please deposit USD-N token only") |
---|
54 | | - | else { |
---|
55 | | - | let k = f((("usdc_" + toString(j.originCaller)) + "_credit")) |
---|
56 | | - | let l = j.payments[0].amount |
---|
57 | | - | let m = (k + l) |
---|
58 | | - | let n = f("usdc_all_credit") |
---|
59 | | - | let o = (n + l) |
---|
60 | | - | let p = { |
---|
61 | | - | let h = lastBlock.height |
---|
62 | | - | if ($isInstanceOf(h, "Int")) |
---|
63 | | - | then { |
---|
64 | | - | let q = h |
---|
65 | | - | q |
---|
66 | | - | } |
---|
67 | | - | else throw("Error block number") |
---|
68 | | - | } |
---|
69 | | - | let r = invoke(Address(e), "usdC_stake", nil, [AttachedPayment(b, l)]) |
---|
70 | | - | if ((r == r)) |
---|
71 | | - | then [IntegerEntry((("usdc_" + toString(j.originCaller)) + "_credit"), m), IntegerEntry((("usdc_" + toString(j.originCaller)) + "_block"), p), IntegerEntry("usdc_all_credit", o), IntegerEntry("usdc_all_block", p)] |
---|
72 | | - | else throw("Strict value is not equal to itself.") |
---|
73 | | - | } |
---|
74 | | - | |
---|
75 | | - | |
---|
76 | | - | |
---|
77 | | - | @Callable(j) |
---|
78 | | - | func sell_usdn_ticket (s) = { |
---|
79 | | - | let k = f((("usdn_" + toString(j.originCaller)) + "_credit")) |
---|
80 | | - | if ((s > k)) |
---|
81 | | - | then throw(("sorry you can't withdraw this amount, because u=you have only " + toString(k))) |
---|
82 | | - | else { |
---|
83 | | - | let m = (k - s) |
---|
84 | | - | let n = f("usdn_all_credit") |
---|
85 | | - | let o = (n - s) |
---|
86 | | - | let p = { |
---|
87 | | - | let h = lastBlock.height |
---|
88 | | - | if ($isInstanceOf(h, "Int")) |
---|
89 | | - | then { |
---|
90 | | - | let q = h |
---|
91 | | - | q |
---|
92 | | - | } |
---|
93 | | - | else throw("Error block number") |
---|
94 | | - | } |
---|
95 | | - | let r = invoke(Address(e), "usdN_cancelStake", [s], nil) |
---|
96 | | - | if ((r == r)) |
---|
97 | | - | then [IntegerEntry((("usdn_" + toString(j.originCaller)) + "_credit"), m), IntegerEntry((("usdn_" + toString(j.originCaller)) + "_block"), p), IntegerEntry("usdn_all_credit", o), IntegerEntry("usdn_all_block", p)] |
---|
98 | | - | else throw("Strict value is not equal to itself.") |
---|
99 | | - | } |
---|
100 | | - | } |
---|
101 | | - | |
---|
102 | | - | |
---|
103 | | - | |
---|
104 | | - | @Callable(j) |
---|
105 | | - | func sell_usdc_ticket (s) = { |
---|
106 | | - | let k = f((("usdc_" + toString(j.originCaller)) + "_credit")) |
---|
107 | | - | if ((s > k)) |
---|
108 | | - | then throw(("sorry you can't withdraw this amount, because u=you have only " + toString(k))) |
---|
109 | | - | else { |
---|
110 | | - | let m = (k - s) |
---|
111 | | - | let n = f("usdc_all_credit") |
---|
112 | | - | let o = (n - s) |
---|
113 | | - | let p = { |
---|
114 | | - | let h = lastBlock.height |
---|
115 | | - | if ($isInstanceOf(h, "Int")) |
---|
116 | | - | then { |
---|
117 | | - | let q = h |
---|
118 | | - | q |
---|
119 | | - | } |
---|
120 | | - | else throw("Error block number") |
---|
121 | | - | } |
---|
122 | | - | let r = invoke(Address(e), "usdC_cancelStake", [s], nil) |
---|
123 | | - | if ((r == r)) |
---|
124 | | - | then [IntegerEntry((("usdc_" + toString(j.originCaller)) + "_credit"), m), IntegerEntry((("usdc_" + toString(j.originCaller)) + "_block"), p), IntegerEntry("usdc_all_credit", o), IntegerEntry("usdc_all_block", p)] |
---|
125 | | - | else throw("Strict value is not equal to itself.") |
---|
126 | | - | } |
---|
127 | | - | } |
---|
128 | | - | |
---|
129 | | - | |
---|
130 | | - | |
---|
131 | | - | @Callable(j) |
---|
132 | | - | func usdn_calc_profit_amount () = if ((toString(j.originCaller) != c)) |
---|
133 | | - | then throw("Sorry! you are not allowed to use this funaction") |
---|
134 | | - | else { |
---|
135 | | - | let t = f("usdn_profit_last_block") |
---|
136 | | - | let u = f("usdn_profit_last_amount") |
---|
137 | | - | let p = { |
---|
138 | | - | let h = lastBlock.height |
---|
139 | | - | if ($isInstanceOf(h, "Int")) |
---|
140 | | - | then { |
---|
141 | | - | let q = h |
---|
142 | | - | q |
---|
143 | | - | } |
---|
144 | | - | else throw("Error block number") |
---|
145 | | - | } |
---|
146 | | - | let v = (p - t) |
---|
147 | | - | if ((d > v)) |
---|
148 | | - | then throw((("Please try again after " + toString((d - v))) + " block")) |
---|
| 27 | + | if ((g > 2000000000)) |
---|
| 28 | + | then throw("the max amount to withdraw is 10 waves") |
---|
155 | | - | |
---|
156 | | - | |
---|
157 | | - | @Callable(j) |
---|
158 | | - | func usdn_send_profit_amount () = { |
---|
159 | | - | let u = f("usdn_profit_last_amount") |
---|
160 | | - | if ((0 >= u)) |
---|
161 | | - | then throw(("you dont have profit amount " + toString(u))) |
---|
162 | | - | else { |
---|
163 | | - | let x = ScriptTransfer(addressFromStringValue(c), u, a) |
---|
164 | | - | [x] |
---|
165 | | - | } |
---|
166 | | - | } |
---|
167 | | - | |
---|
168 | | - | |
---|
169 | | - | |
---|
170 | | - | @Callable(j) |
---|
171 | | - | func usdc_calc_profit_amount () = if ((toString(j.originCaller) != c)) |
---|
172 | | - | then throw("Sorry! you are not allowed to use this funaction") |
---|
173 | | - | else { |
---|
174 | | - | let y = f("usdc_profit_last_block") |
---|
175 | | - | let z = f("usdc_profit_last_amount") |
---|
176 | | - | let p = { |
---|
177 | | - | let h = lastBlock.height |
---|
178 | | - | if ($isInstanceOf(h, "Int")) |
---|
179 | | - | then { |
---|
180 | | - | let q = h |
---|
181 | | - | q |
---|
182 | | - | } |
---|
183 | | - | else throw("Error block number") |
---|
184 | | - | } |
---|
185 | | - | let v = (p - y) |
---|
186 | | - | if ((d > v)) |
---|
187 | | - | then throw((("Please try again after " + toString((d - v))) + " block")) |
---|
188 | | - | else { |
---|
189 | | - | let A = assetBalance(this, b) |
---|
190 | | - | [IntegerEntry("usdc_profit_last_block", p), IntegerEntry("usdc_profit_last_amount", A)] |
---|
191 | | - | } |
---|
192 | | - | } |
---|
193 | | - | |
---|
194 | | - | |
---|
195 | | - | |
---|
196 | | - | @Callable(j) |
---|
197 | | - | func usdc_send_profit_amount () = { |
---|
198 | | - | let z = f("usdc_profit_last_amount") |
---|
199 | | - | if ((0 >= z)) |
---|
200 | | - | then throw(("you dont have profit amount " + toString(z))) |
---|
201 | | - | else { |
---|
202 | | - | let x = ScriptTransfer(addressFromStringValue(c), z, b) |
---|
203 | | - | [x] |
---|
204 | | - | } |
---|
205 | | - | } |
---|
206 | | - | |
---|
207 | | - | |
---|
208 | | - | @Verifier(B) |
---|
209 | | - | func C () = sigVerify(B.bodyBytes, B.proofs[0], B.senderPublicKey) |
---|