tx · 4Sh1sWEgaRyo5KrvZiZhbGp6ri4p2j1sWLU9kjoYF89D 3Mzj8MyE3E3G55SLVE6Dgd6ew2uERLxiE4U: -0.01300000 Waves 2022.07.20 13:15 [2147947] smart account 3Mzj8MyE3E3G55SLVE6Dgd6ew2uERLxiE4U > SELF 0.00000000 Waves
{ "type": 13, "id": "4Sh1sWEgaRyo5KrvZiZhbGp6ri4p2j1sWLU9kjoYF89D", "fee": 1300000, "feeAssetId": null, "timestamp": 1658312111926, "version": 1, "sender": "3Mzj8MyE3E3G55SLVE6Dgd6ew2uERLxiE4U", "senderPublicKey": "8E1ZoUTJyyA7ybXtP2NxUZKdAwvR1ruiQUxZD2bYJJMF", "proofs": [ "5fBZMLx3z2TntY1xNbKt9Mx9sarU4WGCCsRmsqsZnU9CPzhW3bD8FTgJa9FUncNN7p33sFfpVgBCEWtnYCZFmWqF" ], "script": "base64:BgIjCAISAwoBARIDCgEBEgQKAggIEgASABIECgIBARIDCgEIEgAaAA13aXRoZHJhd0RlbGF5ALQLAA9kZWNpbWFsUGFydFVTRE4AwIQ9AA9kZWNpbWFsUGFydFVTRFQAwIQ9ABdtaW5pbWFsQW1vdW50VG9Td2FwVVNEVAkAaAIAkE4FD2RlY2ltYWxQYXJ0VVNETgAXbWluaW1hbEFtb3VudFRvU3dhcFVTRE4JAGgCAJBOBQ9kZWNpbWFsUGFydFVTRFQBE2tleU1hbmFnZXJQdWJsaWNLZXkAAhQlc19fbWFuYWdlclB1YmxpY0tleQEaa2V5UGVuZGluZ01hbmFnZXJQdWJsaWNLZXkAAhslc19fcGVuZGluZ01hbmFnZXJQdWJsaWNLZXkBDmtleVVzZHRBc3NldElkAAIPJXNfX3VzZHRBc3NldElkAQ5rZXlVc2RuQXNzZXRJZAACDyVzX191c2RuQXNzZXRJZAENa2V5RGVwb3NpdEZlZQACDSVzX19kZXBvc2lGZWUBDmtleVdpdGhkcmF3RmVlAAIPJXNfX3dpdGhkcmF3RmVlAQR1c2R0AAkA2QQBC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atus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: GNg83bYGYeVzNGCTkkY5pfv9w4gmXSSSj9hstpHakDgi Next: v8PNEpxBnSPUFF8j2JDntX9weaDytHw4hfTaDYsJAja Diff:
Old | New | Differences | |
---|---|---|---|
17 | 17 | func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey" | |
18 | 18 | ||
19 | 19 | ||
20 | - | func keyUsdtAssetId () = "%s__ | |
20 | + | func keyUsdtAssetId () = "%s__usdtAssetId" | |
21 | 21 | ||
22 | 22 | ||
23 | - | func keyUsdnAssetId () = "%s__USDN" | |
23 | + | func keyUsdnAssetId () = "%s__usdnAssetId" | |
24 | + | ||
25 | + | ||
26 | + | func keyDepositFee () = "%s__deposiFee" | |
27 | + | ||
28 | + | ||
29 | + | func keyWithdrawFee () = "%s__withdrawFee" | |
30 | + | ||
31 | + | ||
32 | + | func usdt () = fromBase58String(value(getString(keyUsdtAssetId()))) | |
33 | + | ||
34 | + | ||
35 | + | func usdn () = fromBase58String(value(getString(keyUsdnAssetId()))) | |
24 | 36 | ||
25 | 37 | ||
26 | 38 | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
87 | 99 | else { | |
88 | 100 | let toWithdrawWithoutFee = getWithoutFeeWithdraw(amount, currentClientBalance) | |
89 | 101 | let toWithdrawWithFee = (amount - toWithdrawWithoutFee) | |
90 | - | let fee = ((toWithdrawWithFee / 100) * | |
102 | + | let fee = ((toWithdrawWithFee / 100) * value(getInteger(keyWithdrawFee()))) | |
91 | 103 | [toWithdrawWithoutFee, toWithdrawWithFee, fee] | |
92 | 104 | } | |
93 | 105 | } | |
111 | 123 | ||
112 | 124 | ||
113 | 125 | @Callable(i) | |
126 | + | func setWithdrawFee (newFee) = { | |
127 | + | let checkCaller = mustManager(i) | |
128 | + | if ((checkCaller == checkCaller)) | |
129 | + | then [IntegerEntry(keyWithdrawFee(), newFee)] | |
130 | + | else throw("Strict value is not equal to itself.") | |
131 | + | } | |
132 | + | ||
133 | + | ||
134 | + | ||
135 | + | @Callable(i) | |
136 | + | func setDepositFee (newFee) = { | |
137 | + | let checkCaller = mustManager(i) | |
138 | + | if ((checkCaller == checkCaller)) | |
139 | + | then [IntegerEntry(keyDepositFee(), newFee)] | |
140 | + | else throw("Strict value is not equal to itself.") | |
141 | + | } | |
142 | + | ||
143 | + | ||
144 | + | ||
145 | + | @Callable(i) | |
114 | 146 | func constructor (usdtAssetId,usdnAssetId) = { | |
115 | 147 | let checkCaller = mustManager(i) | |
116 | 148 | if ((checkCaller == checkCaller)) | |
124 | 156 | func swapUSDTtoUSDN () = { | |
125 | 157 | let balanceKey = collectBalanceKeyWithFee(toString(invoke.caller)) | |
126 | 158 | let payment = value(invoke.payments[0]) | |
127 | - | if ((payment.assetId != | |
159 | + | if ((payment.assetId != usdt())) | |
128 | 160 | then usdtToUsdnAssetError() | |
129 | 161 | else { | |
130 | 162 | let amount = payment.amount | |
131 | - | let fee = ((amount / 100) * | |
163 | + | let fee = ((amount / 100) * value(getInteger(keyDepositFee()))) | |
132 | 164 | let currentClientBalanceUSDT = valueOrElse(getInteger(this, balanceKey), 0) | |
133 | 165 | if ((minimalAmountToSwapUSDT > amount)) | |
134 | 166 | then usdtToUsdnLowLimitError() | |
135 | - | else [IntegerEntry(balanceKey, (currentClientBalanceUSDT + amount)), ScriptTransfer(invoke.caller, (amount - fee), | |
167 | + | else [IntegerEntry(balanceKey, (currentClientBalanceUSDT + amount)), ScriptTransfer(invoke.caller, (amount - fee), usdn())] | |
136 | 168 | } | |
137 | 169 | } | |
138 | 170 | ||
142 | 174 | func initializationUSDNtoUSDTswap () = { | |
143 | 175 | let payment = value(invoke.payments[0]) | |
144 | 176 | let address = toString(invoke.caller) | |
145 | - | if ((payment.assetId != | |
177 | + | if ((payment.assetId != usdn())) | |
146 | 178 | then usdnToUsdtAssetError() | |
147 | 179 | else { | |
148 | 180 | let amount = payment.amount | |
173 | 205 | if (if ((height >= heightInKey)) | |
174 | 206 | then contains(withdrawnInfo, "not_withdrawn") | |
175 | 207 | else false) | |
176 | - | then [DeleteEntry(key), ScriptTransfer(invoke.caller, valueOrErrorMessage(parseInt(toWithdraw), "Wrong withdraw data!"), | |
208 | + | then [DeleteEntry(key), ScriptTransfer(invoke.caller, valueOrErrorMessage(parseInt(toWithdraw), "Wrong withdraw data!"), usdt())] | |
177 | 209 | else throw((("Withdrawal is possible after " + toString(heightInKey)) + " height or you have already withdrawn USDT.")) | |
178 | 210 | } | |
179 | 211 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let withdrawDelay = 1460 | |
5 | 5 | ||
6 | 6 | let decimalPartUSDN = 1000000 | |
7 | 7 | ||
8 | 8 | let decimalPartUSDT = 1000000 | |
9 | 9 | ||
10 | 10 | let minimalAmountToSwapUSDT = (10000 * decimalPartUSDN) | |
11 | 11 | ||
12 | 12 | let minimalAmountToSwapUSDN = (10000 * decimalPartUSDT) | |
13 | 13 | ||
14 | 14 | func keyManagerPublicKey () = "%s__managerPublicKey" | |
15 | 15 | ||
16 | 16 | ||
17 | 17 | func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey" | |
18 | 18 | ||
19 | 19 | ||
20 | - | func keyUsdtAssetId () = "%s__ | |
20 | + | func keyUsdtAssetId () = "%s__usdtAssetId" | |
21 | 21 | ||
22 | 22 | ||
23 | - | func keyUsdnAssetId () = "%s__USDN" | |
23 | + | func keyUsdnAssetId () = "%s__usdnAssetId" | |
24 | + | ||
25 | + | ||
26 | + | func keyDepositFee () = "%s__deposiFee" | |
27 | + | ||
28 | + | ||
29 | + | func keyWithdrawFee () = "%s__withdrawFee" | |
30 | + | ||
31 | + | ||
32 | + | func usdt () = fromBase58String(value(getString(keyUsdtAssetId()))) | |
33 | + | ||
34 | + | ||
35 | + | func usdn () = fromBase58String(value(getString(keyUsdnAssetId()))) | |
24 | 36 | ||
25 | 37 | ||
26 | 38 | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
27 | 39 | case s: String => | |
28 | 40 | fromBase58String(s) | |
29 | 41 | case _: Unit => | |
30 | 42 | unit | |
31 | 43 | case _ => | |
32 | 44 | throw("Match error") | |
33 | 45 | } | |
34 | 46 | ||
35 | 47 | ||
36 | 48 | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { | |
37 | 49 | case s: String => | |
38 | 50 | fromBase58String(s) | |
39 | 51 | case _: Unit => | |
40 | 52 | unit | |
41 | 53 | case _ => | |
42 | 54 | throw("Match error") | |
43 | 55 | } | |
44 | 56 | ||
45 | 57 | ||
46 | 58 | func collectKey (address,amountToSwapInKey,allowToWithdrawHeight) = makeString([address, "WITHDRAW", toString(amountToSwapInKey), "HEIGHT", toString(allowToWithdrawHeight)], "_") | |
47 | 59 | ||
48 | 60 | ||
49 | 61 | func collectBalanceKey (address) = makeString([address, "balance"], "_") | |
50 | 62 | ||
51 | 63 | ||
52 | 64 | func collectBalanceKeyWithFee (address) = makeString([address, "balance_with_fee"], "_") | |
53 | 65 | ||
54 | 66 | ||
55 | 67 | func usdtToUsdnAssetError () = throw("To swap USDT to USDN you need attach payment in USDT") | |
56 | 68 | ||
57 | 69 | ||
58 | 70 | func usdnToUsdtAssetError () = throw("To swap USDN to USDT you need attach payment in USDN") | |
59 | 71 | ||
60 | 72 | ||
61 | 73 | func usdtToUsdnLowLimitError () = throw((("you can swap at least " + toString((minimalAmountToSwapUSDT / decimalPartUSDT))) + " tokens")) | |
62 | 74 | ||
63 | 75 | ||
64 | 76 | func abs (n) = if ((0 > n)) | |
65 | 77 | then (n * -1) | |
66 | 78 | else n | |
67 | 79 | ||
68 | 80 | ||
69 | 81 | func getWithoutFeeWithdraw (amount,balanceWithoutFee) = min([amount, balanceWithoutFee]) | |
70 | 82 | ||
71 | 83 | ||
72 | 84 | func getListElementOrDefault (list,index,default) = if ((size(list) > index)) | |
73 | 85 | then list[index] | |
74 | 86 | else default | |
75 | 87 | ||
76 | 88 | ||
77 | 89 | func currentWithdrawals (address,amount) = { | |
78 | 90 | let balanceKey = collectBalanceKey(address) | |
79 | 91 | let balanceWithFeeKey = collectBalanceKeyWithFee(address) | |
80 | 92 | let currentClientBalance = valueOrElse(getInteger(this, balanceKey), 0) | |
81 | 93 | let currentClientBalanceWithFee = valueOrElse(getInteger(this, balanceWithFeeKey), 0) | |
82 | 94 | let userBalance = (currentClientBalance + currentClientBalanceWithFee) | |
83 | 95 | if (if ((amount > userBalance)) | |
84 | 96 | then true | |
85 | 97 | else (minimalAmountToSwapUSDN > amount)) | |
86 | 98 | then throw("Swap amount fail, amount is to small or to big.") | |
87 | 99 | else { | |
88 | 100 | let toWithdrawWithoutFee = getWithoutFeeWithdraw(amount, currentClientBalance) | |
89 | 101 | let toWithdrawWithFee = (amount - toWithdrawWithoutFee) | |
90 | - | let fee = ((toWithdrawWithFee / 100) * | |
102 | + | let fee = ((toWithdrawWithFee / 100) * value(getInteger(keyWithdrawFee()))) | |
91 | 103 | [toWithdrawWithoutFee, toWithdrawWithFee, fee] | |
92 | 104 | } | |
93 | 105 | } | |
94 | 106 | ||
95 | 107 | ||
96 | 108 | func mustManager (i) = { | |
97 | 109 | let pd = throw("Permission denied") | |
98 | 110 | match managerPublicKeyOrUnit() { | |
99 | 111 | case pk: ByteVector => | |
100 | 112 | if ((i.callerPublicKey == pk)) | |
101 | 113 | then true | |
102 | 114 | else pd | |
103 | 115 | case _: Unit => | |
104 | 116 | if ((i.caller == this)) | |
105 | 117 | then true | |
106 | 118 | else pd | |
107 | 119 | case _ => | |
108 | 120 | throw("Match error") | |
109 | 121 | } | |
110 | 122 | } | |
111 | 123 | ||
112 | 124 | ||
113 | 125 | @Callable(i) | |
126 | + | func setWithdrawFee (newFee) = { | |
127 | + | let checkCaller = mustManager(i) | |
128 | + | if ((checkCaller == checkCaller)) | |
129 | + | then [IntegerEntry(keyWithdrawFee(), newFee)] | |
130 | + | else throw("Strict value is not equal to itself.") | |
131 | + | } | |
132 | + | ||
133 | + | ||
134 | + | ||
135 | + | @Callable(i) | |
136 | + | func setDepositFee (newFee) = { | |
137 | + | let checkCaller = mustManager(i) | |
138 | + | if ((checkCaller == checkCaller)) | |
139 | + | then [IntegerEntry(keyDepositFee(), newFee)] | |
140 | + | else throw("Strict value is not equal to itself.") | |
141 | + | } | |
142 | + | ||
143 | + | ||
144 | + | ||
145 | + | @Callable(i) | |
114 | 146 | func constructor (usdtAssetId,usdnAssetId) = { | |
115 | 147 | let checkCaller = mustManager(i) | |
116 | 148 | if ((checkCaller == checkCaller)) | |
117 | 149 | then [StringEntry(keyUsdtAssetId(), usdtAssetId), StringEntry(keyUsdnAssetId(), usdnAssetId)] | |
118 | 150 | else throw("Strict value is not equal to itself.") | |
119 | 151 | } | |
120 | 152 | ||
121 | 153 | ||
122 | 154 | ||
123 | 155 | @Callable(invoke) | |
124 | 156 | func swapUSDTtoUSDN () = { | |
125 | 157 | let balanceKey = collectBalanceKeyWithFee(toString(invoke.caller)) | |
126 | 158 | let payment = value(invoke.payments[0]) | |
127 | - | if ((payment.assetId != | |
159 | + | if ((payment.assetId != usdt())) | |
128 | 160 | then usdtToUsdnAssetError() | |
129 | 161 | else { | |
130 | 162 | let amount = payment.amount | |
131 | - | let fee = ((amount / 100) * | |
163 | + | let fee = ((amount / 100) * value(getInteger(keyDepositFee()))) | |
132 | 164 | let currentClientBalanceUSDT = valueOrElse(getInteger(this, balanceKey), 0) | |
133 | 165 | if ((minimalAmountToSwapUSDT > amount)) | |
134 | 166 | then usdtToUsdnLowLimitError() | |
135 | - | else [IntegerEntry(balanceKey, (currentClientBalanceUSDT + amount)), ScriptTransfer(invoke.caller, (amount - fee), | |
167 | + | else [IntegerEntry(balanceKey, (currentClientBalanceUSDT + amount)), ScriptTransfer(invoke.caller, (amount - fee), usdn())] | |
136 | 168 | } | |
137 | 169 | } | |
138 | 170 | ||
139 | 171 | ||
140 | 172 | ||
141 | 173 | @Callable(invoke) | |
142 | 174 | func initializationUSDNtoUSDTswap () = { | |
143 | 175 | let payment = value(invoke.payments[0]) | |
144 | 176 | let address = toString(invoke.caller) | |
145 | - | if ((payment.assetId != | |
177 | + | if ((payment.assetId != usdn())) | |
146 | 178 | then usdnToUsdtAssetError() | |
147 | 179 | else { | |
148 | 180 | let amount = payment.amount | |
149 | 181 | let balanceKey = collectBalanceKey(address) | |
150 | 182 | let balanceWithFeeKey = collectBalanceKeyWithFee(address) | |
151 | 183 | let currentClientBalance = valueOrElse(getInteger(this, balanceKey), 0) | |
152 | 184 | let currentClientBalanceWithFee = valueOrElse(getInteger(this, balanceWithFeeKey), 0) | |
153 | 185 | let userBalance = (currentClientBalance + currentClientBalanceWithFee) | |
154 | 186 | let data = currentWithdrawals(toString(invoke.caller), amount) | |
155 | 187 | let toWithdrawWithoutFee = valueOrErrorMessage(data[0], "Wrong 'currentWithdrawals' method!") | |
156 | 188 | let toWithdrawWithFee = valueOrErrorMessage(data[1], "Wrong 'currentWithdrawals' method!") | |
157 | 189 | let fee = valueOrErrorMessage(data[2], "Wrong 'currentWithdrawals' method!") | |
158 | 190 | let total = ((toWithdrawWithFee + toWithdrawWithoutFee) - fee) | |
159 | 191 | let allowToWithDrawHeight = (height + withdrawDelay) | |
160 | 192 | if (isDefined(getString(this, collectKey(toString(invoke.caller), amount, allowToWithDrawHeight)))) | |
161 | 193 | then throw("You have already started withdrawal process, wait next block.") | |
162 | 194 | else [IntegerEntry(balanceKey, (currentClientBalance - toWithdrawWithoutFee)), IntegerEntry(balanceWithFeeKey, (currentClientBalanceWithFee - toWithdrawWithFee)), StringEntry(collectKey(toString(invoke.caller), amount, allowToWithDrawHeight), makeString(["not_withdrawn", toString((amount - fee))], "_"))] | |
163 | 195 | } | |
164 | 196 | } | |
165 | 197 | ||
166 | 198 | ||
167 | 199 | ||
168 | 200 | @Callable(invoke) | |
169 | 201 | func swapUSDNtoUSDT (amount,heightInKey) = { | |
170 | 202 | let key = collectKey(toString(invoke.caller), amount, heightInKey) | |
171 | 203 | let withdrawnInfo = valueOrErrorMessage(getString(this, key), ((("This key doesn't exists " + key) + " at address ") + toString(this))) | |
172 | 204 | let toWithdraw = getListElementOrDefault(split(withdrawnInfo, "_"), 2, toString(amount)) | |
173 | 205 | if (if ((height >= heightInKey)) | |
174 | 206 | then contains(withdrawnInfo, "not_withdrawn") | |
175 | 207 | else false) | |
176 | - | then [DeleteEntry(key), ScriptTransfer(invoke.caller, valueOrErrorMessage(parseInt(toWithdraw), "Wrong withdraw data!"), | |
208 | + | then [DeleteEntry(key), ScriptTransfer(invoke.caller, valueOrErrorMessage(parseInt(toWithdraw), "Wrong withdraw data!"), usdt())] | |
177 | 209 | else throw((("Withdrawal is possible after " + toString(heightInKey)) + " height or you have already withdrawn USDT.")) | |
178 | 210 | } | |
179 | 211 | ||
180 | 212 | ||
181 | 213 | ||
182 | 214 | @Callable(i) | |
183 | 215 | func setManager (pendingManagerPublicKey) = { | |
184 | 216 | let checkCaller = mustManager(i) | |
185 | 217 | if ((checkCaller == checkCaller)) | |
186 | 218 | then { | |
187 | 219 | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
188 | 220 | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
189 | 221 | then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)] | |
190 | 222 | else throw("Strict value is not equal to itself.") | |
191 | 223 | } | |
192 | 224 | else throw("Strict value is not equal to itself.") | |
193 | 225 | } | |
194 | 226 | ||
195 | 227 | ||
196 | 228 | ||
197 | 229 | @Callable(i) | |
198 | 230 | func confirmManager () = { | |
199 | 231 | let pm = pendingManagerPublicKeyOrUnit() | |
200 | 232 | let hasPM = if (isDefined(pm)) | |
201 | 233 | then true | |
202 | 234 | else throw("No pending manager") | |
203 | 235 | if ((hasPM == hasPM)) | |
204 | 236 | then { | |
205 | 237 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
206 | 238 | then true | |
207 | 239 | else throw("You are not pending manager") | |
208 | 240 | if ((checkPM == checkPM)) | |
209 | 241 | then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())] | |
210 | 242 | else throw("Strict value is not equal to itself.") | |
211 | 243 | } | |
212 | 244 | else throw("Strict value is not equal to itself.") | |
213 | 245 | } | |
214 | 246 | ||
215 | 247 | ||
216 | 248 | @Verifier(tx) | |
217 | 249 | func verify () = { | |
218 | 250 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
219 | 251 | case pk: ByteVector => | |
220 | 252 | pk | |
221 | 253 | case _: Unit => | |
222 | 254 | tx.senderPublicKey | |
223 | 255 | case _ => | |
224 | 256 | throw("Match error") | |
225 | 257 | } | |
226 | 258 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
227 | 259 | } | |
228 | 260 |
github/deemru/w8io/026f985 47.15 ms ◑