tx · zW2PW8MLZuACT52u9w7FsurykWxCiXKPVPGd8EJSTnC 3MvXnAcEtL9x3i499UcvTQZPufrT5ZZUEd5: -0.01300000 Waves 2022.09.15 15:51 [2230247] smart account 3MvXnAcEtL9x3i499UcvTQZPufrT5ZZUEd5 > SELF 0.00000000 Waves
{ "type": 13, "id": "zW2PW8MLZuACT52u9w7FsurykWxCiXKPVPGd8EJSTnC", "fee": 1300000, "feeAssetId": null, "timestamp": 1663246325633, "version": 1, "sender": "3MvXnAcEtL9x3i499UcvTQZPufrT5ZZUEd5", "senderPublicKey": "GSAhb4fdky75LiCZ4p4DDK4rmWpmsgGBg1ZVdtPfmRES", "proofs": [ "57S1X1HHLwJUc13nw9d25pW2U9nuQ8RtbxHi9ogd2BueTUfKS6cmB5mEkv3HEcaiCdVoCLPfTMDpf5giU19Zho4c" ], "script": "base64:BgIsCAISCgoICAgBAQEBAQESAwoBCBIDCgEIEgUKAwgIARIECgIICBIDCgEIEgATAANTRVACAl9fARNrZXlNYW5hZ2VyUHVibGljS2V5AAIUJXNfX21hbmFnZXJQdWJsaWNLZXkBGmtleVBlbmRpbmdNYW5hZ2VyUHVibGljS2V5AAIbJXNfX3BlbmRpbmdNYW5hZ2VyUHVibGljS2V5ARBrZXlXaXRoZHJhd0RlbGF5AgZhc3NldEEGYXNzZXRCCQC5CQIJAMwIAgIGJXMlcyVzCQDMCAICDXdpdGhkcmF3RGVsYXkJAMwIAgUGYXNzZXRBCQDMCAIFBmFzc2V0QgUDbmlsBQNTRVABFWtleURlcG9zaXRGZWVQZXJtaWxsZQIGYXNzZXRBBmFzc2V0QgkAuQkCCQDMCAICBiVzJXMlcwkAzAgCAhJkZXBvc2l0RmVlUGVybWlsbGUJAMwIAgUGYXNzZXRBCQDMCAIFBmFzc2V0QgUDbmlsBQNTRVABFmtleVdpdGhkcmF3RmVlUGVybWlsbGUCBmFzc2V0QQZhc3NldEIJALkJAgkAzAgCAgYlcyVzJXMJAMwIAgITd2l0aGRyYXdGZWV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lclB1YmxpY0tleQAJANgEAQkBBXZhbHVlAQUCcG0JAMwIAgkBC0RlbGV0ZUVudHJ5AQkBGmtleVBlbmRpbmdNYW5hZ2VyUHVibGljS2V5AAUDbmlsCQACAQIkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuCQACAQIkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAQJ0eAEGdmVyaWZ5AAQPdGFyZ2V0UHVibGljS2V5BAckbWF0Y2gwCQEWbWFuYWdlclB1YmxpY0tleU9yVW5pdAADCQABAgUHJG1hdGNoMAIKQnl0ZVZlY3RvcgQCcGsFByRtYXRjaDAFAnBrAwkAAQIFByRtYXRjaDACBFVuaXQIBQJ0eA9zZW5kZXJQdWJsaWNLZXkJAAIBAgtNYXRjaCBlcnJvcgkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAUPdGFyZ2V0UHVibGljS2V5MSfnAw==", "chainId": 84, "height": 2230247, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: AyvHf53oAhd9xGmjEpdmTPbpRPDdc5VkPoxrs5NMKyvo Next: 88Q9PZWhruvsXjkn5kzxLGt7NHAMuhFccib1Tfr58XbS Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let SEP = "__" | |
5 | + | ||
4 | 6 | func keyManagerPublicKey () = "%s__managerPublicKey" | |
5 | 7 | ||
6 | 8 | ||
7 | - | func | |
9 | + | func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey" | |
8 | 10 | ||
9 | 11 | ||
10 | - | func | |
12 | + | func keyWithdrawDelay (assetA,assetB) = makeString(["%s%s%s", "withdrawDelay", assetA, assetB], SEP) | |
11 | 13 | ||
12 | 14 | ||
13 | - | func | |
15 | + | func keyDepositFeePermille (assetA,assetB) = makeString(["%s%s%s", "depositFeePermille", assetA, assetB], SEP) | |
14 | 16 | ||
15 | 17 | ||
16 | - | func | |
18 | + | func keyWithdrawFeePermille (assetA,assetB) = makeString(["%s%s%s", "withdrawFeePermille", assetA, assetB], SEP) | |
17 | 19 | ||
18 | 20 | ||
19 | - | func | |
21 | + | func keyMinAmountDeposit (assetA,assetB) = makeString(["%s%s%s", "minAmountDeposit", assetA, assetB], SEP) | |
20 | 22 | ||
21 | 23 | ||
22 | - | func | |
24 | + | func keyAssetsPairStatus (assetA,assetB) = makeString(["%s%s%s", "assetsPairStatus", assetA, assetB], SEP) | |
23 | 25 | ||
24 | 26 | ||
25 | - | func | |
27 | + | func keyMinAmountWithdraw (assetA,assetB) = makeString(["%s%s%s", "minAmountWithdraw", assetA, assetB], SEP) | |
26 | 28 | ||
27 | 29 | ||
28 | - | func | |
30 | + | func keyBalance (assetA,assetB,userAddress) = makeString(["%s%s%s%s", "balance", assetA, assetB, userAddress], SEP) | |
29 | 31 | ||
30 | 32 | ||
31 | - | func | |
33 | + | func keyTotalFeeCollectedDeposit (assetA,assetB) = makeString(["%s%s%s%s", "totalFeeCollected", "deposit", assetA, assetB], SEP) | |
32 | 34 | ||
33 | 35 | ||
34 | - | func | |
36 | + | func keyTotalFeeCollectedWithdraw (assetA,assetB) = makeString(["%s%s%s%s", "totalFeeCollected", "withdraw", assetA, assetB], SEP) | |
35 | 37 | ||
36 | 38 | ||
37 | - | func | |
39 | + | func keyAssetLockTime (assetA,assetB,userAddress) = makeString(["%s%s%s%s", "assetLockTime", assetA, assetB, userAddress], SEP) | |
38 | 40 | ||
39 | 41 | ||
40 | - | func collectProcessDoneKey (userAddress,assetA,assetB,heightInKey) = makeString(["%s%s%s%s__withdrawProcess__done", userAddress, assetA, assetB, toString(heightInKey)], "__") | |
42 | + | func keyProcessInProgress (userAddress,assetA,assetB,heightInKey) = makeString(["%s%s%s%s%s%s", "withdrawProcess", "inProgress", userAddress, assetA, assetB, toString(heightInKey)], SEP) | |
43 | + | ||
44 | + | ||
45 | + | func keyProcessDone (userAddress,assetA,assetB,heightInKey) = makeString(["%s%s%s%s%s%s", "withdrawProcess", "done", userAddress, assetA, assetB, toString(heightInKey)], SEP) | |
41 | 46 | ||
42 | 47 | ||
43 | 48 | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
49 | + | case s: String => | |
50 | + | fromBase58String(s) | |
51 | + | case _: Unit => | |
52 | + | unit | |
53 | + | case _ => | |
54 | + | throw("Match error") | |
55 | + | } | |
56 | + | ||
57 | + | ||
58 | + | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { | |
44 | 59 | case s: String => | |
45 | 60 | fromBase58String(s) | |
46 | 61 | case _: Unit => | |
67 | 82 | } | |
68 | 83 | ||
69 | 84 | ||
85 | + | func throwErr (msg) = throw(makeString(["otc_multiasset.ride:", msg], " ")) | |
86 | + | ||
87 | + | ||
70 | 88 | @Callable(i) | |
71 | 89 | func registerAsset (assetA,assetB,withdrawDelay,depositFee,withdrawFee,minAmountDeposit,minAmountWithdraw,pairStatus) = { | |
72 | 90 | let checkCaller = mustManager(i) | |
73 | 91 | if ((checkCaller == checkCaller)) | |
74 | 92 | then { | |
75 | - | let withdrawDelayKey = | |
76 | - | let depositFeePermilleKey = | |
77 | - | let withdrawFeePermilleKey = | |
78 | - | let minAmountDepositKey = | |
79 | - | let minAmountWithdrawKey = | |
80 | - | let pairStatusKey = | |
93 | + | let withdrawDelayKey = keyWithdrawDelay(assetA, assetB) | |
94 | + | let depositFeePermilleKey = keyDepositFeePermille(assetA, assetB) | |
95 | + | let withdrawFeePermilleKey = keyWithdrawFeePermille(assetA, assetB) | |
96 | + | let minAmountDepositKey = keyMinAmountDeposit(assetA, assetB) | |
97 | + | let minAmountWithdrawKey = keyMinAmountWithdraw(assetA, assetB) | |
98 | + | let pairStatusKey = keyAssetsPairStatus(assetA, assetB) | |
81 | 99 | [IntegerEntry(withdrawDelayKey, withdrawDelay), IntegerEntry(depositFeePermilleKey, depositFee), IntegerEntry(withdrawFeePermilleKey, withdrawFee), IntegerEntry(minAmountDepositKey, minAmountDeposit), IntegerEntry(minAmountWithdrawKey, minAmountWithdraw), IntegerEntry(pairStatusKey, pairStatus)] | |
82 | 100 | } | |
83 | 101 | else throw("Strict value is not equal to itself.") | |
89 | 107 | func swapAssetsAToB (assetB) = { | |
90 | 108 | let payment = value(i.payments[0]) | |
91 | 109 | let assetA = toBase58String(value(payment.assetId)) | |
110 | + | let asset = fromBase58String(value(assetB)) | |
92 | 111 | let userAddress = toString(i.caller) | |
93 | - | let minAmountDeposit = valueOrErrorMessage(getInteger( | |
112 | + | let minAmountDeposit = valueOrErrorMessage(getInteger(keyMinAmountDeposit(assetA, assetB)), "This asset pair does not exist.") | |
94 | 113 | let toDeposit = payment.amount | |
95 | - | let depositFeePermilleKey = collectDepositFeePermilleKey(assetA, assetB) | |
96 | - | let depositFee = valueOrElse(getInteger(this, depositFeePermilleKey), 0) | |
114 | + | let depositFee = valueOrElse(getInteger(keyDepositFeePermille(assetA, assetB)), 0) | |
97 | 115 | let fee = ((toDeposit / 1000) * depositFee) | |
98 | - | let currentUserBalance = valueOrElse(getInteger(collectBalanceKey(assetA, assetB, userAddress)), 0) | |
99 | - | let totalCommissions = valueOrElse(getInteger(collectTotalCommissionsCollectedDepositKey(assetA, assetB)), 0) | |
100 | - | let asset = fromBase58String(value(assetB)) | |
101 | - | if ((value(getInteger(collectAssetsPairStatusKey(assetA, assetB))) != 0)) | |
102 | - | then throw("The couple's deposit is blocked.") | |
103 | - | else if ((minAmountDeposit > payment.amount)) | |
104 | - | then throw("Swap amount fail, amount is to small.") | |
105 | - | else [IntegerEntry(collectBalanceKey(assetA, assetB, userAddress), ((currentUserBalance + payment.amount) - fee)), IntegerEntry(collectTotalCommissionsCollectedDepositKey(assetA, assetB), (totalCommissions + fee)), ScriptTransfer(i.caller, toDeposit, asset)] | |
116 | + | let currentUserBalance = valueOrElse(getInteger(keyBalance(assetA, assetB, userAddress)), 0) | |
117 | + | let totalCommissions = valueOrElse(getInteger(keyTotalFeeCollectedDeposit(assetA, assetB)), 0) | |
118 | + | let pairStaus = value(getInteger(keyAssetsPairStatus(assetA, assetB))) | |
119 | + | let checkPairStatus = if ((pairStaus == 0)) | |
120 | + | then true | |
121 | + | else throwErr("The couple's deposit is blocked.") | |
122 | + | if ((checkPairStatus == checkPairStatus)) | |
123 | + | then { | |
124 | + | let checkPayment = if ((toDeposit > minAmountDeposit)) | |
125 | + | then true | |
126 | + | else throwErr("Swap amount fail, amount is to small.") | |
127 | + | if ((checkPayment == checkPayment)) | |
128 | + | then { | |
129 | + | let newBalance = ((currentUserBalance + toDeposit) - fee) | |
130 | + | let checkBalance = if ((newBalance > 0)) | |
131 | + | then true | |
132 | + | else throwErr("Swap amount fail, amount is to small.") | |
133 | + | if ((checkBalance == checkBalance)) | |
134 | + | then [IntegerEntry(keyBalance(assetA, assetB, userAddress), newBalance), IntegerEntry(keyTotalFeeCollectedDeposit(assetA, assetB), (totalCommissions + fee)), ScriptTransfer(i.caller, toDeposit, asset)] | |
135 | + | else throw("Strict value is not equal to itself.") | |
136 | + | } | |
137 | + | else throw("Strict value is not equal to itself.") | |
138 | + | } | |
139 | + | else throw("Strict value is not equal to itself.") | |
106 | 140 | } | |
107 | 141 | ||
108 | 142 | ||
109 | 143 | ||
110 | 144 | @Callable(i) | |
111 | - | func initializationSwapAssetsBToA (assetA | |
145 | + | func initializationSwapAssetsBToA (assetA) = { | |
112 | 146 | let payment = value(i.payments[0]) | |
113 | 147 | let amount = payment.amount | |
148 | + | let assetB = toBase58String(value(payment.assetId)) | |
114 | 149 | let userAddress = toString(i.caller) | |
115 | - | let minAmountDeposit = valueOrErrorMessage(getInteger( | |
116 | - | let assetLockHeight = (height + valueOrElse(getInteger( | |
117 | - | let currentUserBalance = valueOrErrorMessage(getInteger( | |
118 | - | let totalCommissions = valueOrElse(getInteger( | |
119 | - | let withdrawFeePermilleKey = | |
150 | + | let minAmountDeposit = valueOrErrorMessage(getInteger(keyMinAmountWithdraw(assetA, assetB)), "This asset pair does not exist.") | |
151 | + | let assetLockHeight = (height + valueOrElse(getInteger(keyWithdrawDelay(assetA, assetB)), 0)) | |
152 | + | let currentUserBalance = valueOrErrorMessage(getInteger(keyBalance(assetA, assetB, userAddress)), "This user balance does not exist.") | |
153 | + | let totalCommissions = valueOrElse(getInteger(keyTotalFeeCollectedDeposit(assetA, assetB)), 0) | |
154 | + | let withdrawFeePermilleKey = keyWithdrawFeePermille(assetA, assetB) | |
120 | 155 | let withdrawFee = valueOrElse(getInteger(withdrawFeePermilleKey), 0) | |
121 | 156 | let fee = ((amount / 1000) * withdrawFee) | |
122 | - | [IntegerEntry(collectAssetLockTimeKey(assetA, assetB, userAddress), assetLockHeight), IntegerEntry(collectBalanceKey(assetA, assetB, userAddress), ((currentUserBalance - amount) - fee)), IntegerEntry(collectProcessInProgressKey(userAddress, assetA, assetB, assetLockHeight), (amount - fee)), IntegerEntry(collectTotalCommissionsCollectedWithdrawKey(assetA, assetB), (totalCommissions + fee))] | |
157 | + | let newBalance = ((currentUserBalance - amount) - fee) | |
158 | + | let checkBalance = if ((newBalance > 0)) | |
159 | + | then true | |
160 | + | else throwErr("Swap amount fail, amount is to small.") | |
161 | + | if ((checkBalance == checkBalance)) | |
162 | + | then { | |
163 | + | let checkProcess = if ((valueOrElse(getInteger(keyProcessInProgress(userAddress, assetA, assetB, assetLockHeight)), 0) == 0)) | |
164 | + | then true | |
165 | + | else throwErr("At this height, there is already an exchange of this pair.") | |
166 | + | if ((checkProcess == checkProcess)) | |
167 | + | then [IntegerEntry(keyAssetLockTime(assetA, assetB, userAddress), assetLockHeight), IntegerEntry(keyBalance(assetA, assetB, userAddress), newBalance), IntegerEntry(keyProcessInProgress(userAddress, assetA, assetB, assetLockHeight), (amount - fee)), IntegerEntry(keyTotalFeeCollectedWithdraw(assetA, assetB), (totalCommissions + fee))] | |
168 | + | else throw("Strict value is not equal to itself.") | |
169 | + | } | |
170 | + | else throw("Strict value is not equal to itself.") | |
123 | 171 | } | |
124 | 172 | ||
125 | 173 | ||
127 | 175 | @Callable(i) | |
128 | 176 | func withdrawAsset (assetA,assetB,heightInKey) = { | |
129 | 177 | let userAddress = toString(i.caller) | |
130 | - | let | |
131 | - | let toWithdraw = | |
178 | + | let assetLockHeight = value(getInteger(keyAssetLockTime(assetA, assetB, userAddress))) | |
179 | + | let toWithdraw = value(getInteger(keyProcessInProgress(userAddress, assetA, assetB, heightInKey))) | |
132 | 180 | let asset = fromBase58String(value(assetA)) | |
133 | - | if ((height > assetLockTime)) | |
134 | - | then throw((("Withdrawal is possible after " + toString(heightInKey)) + " height or you have already withdrawn.")) | |
135 | - | else [DeleteEntry(collectProcessInProgressKey(userAddress, assetA, assetB, heightInKey)), IntegerEntry(collectProcessDoneKey(userAddress, assetA, assetB, heightInKey), toWithdraw), IntegerEntry(collectBalanceKey(assetA, assetB, userAddress), toWithdraw), ScriptTransfer(i.caller, toWithdraw, asset)] | |
181 | + | let checkHeight = if ((height >= assetLockHeight)) | |
182 | + | then true | |
183 | + | else throwErr((("Withdrawal is possible after " + toString(heightInKey)) + " height or you have already withdrawn.")) | |
184 | + | if ((checkHeight == checkHeight)) | |
185 | + | then [DeleteEntry(keyProcessInProgress(userAddress, assetA, assetB, heightInKey)), IntegerEntry(keyProcessDone(userAddress, assetA, assetB, heightInKey), toWithdraw), IntegerEntry(keyBalance(assetA, assetB, userAddress), toWithdraw), ScriptTransfer(i.caller, toWithdraw, asset)] | |
186 | + | else throw("Strict value is not equal to itself.") | |
136 | 187 | } | |
137 | 188 | ||
138 | 189 | ||
142 | 193 | let checkCaller = mustManager(i) | |
143 | 194 | if ((checkCaller == checkCaller)) | |
144 | 195 | then { | |
145 | - | let toWithdrawA = valueOrElse(getInteger( | |
196 | + | let toWithdrawA = valueOrElse(getInteger(keyTotalFeeCollectedDeposit(assetA, assetB)), 0) | |
146 | 197 | let withdrawAssetA = fromBase58String(value(assetA)) | |
147 | - | let toWithdrawB = valueOrElse(getInteger( | |
198 | + | let toWithdrawB = valueOrElse(getInteger(keyTotalFeeCollectedWithdraw(assetA, assetB)), 0) | |
148 | 199 | let withdrawAssetB = fromBase58String(value(assetB)) | |
149 | - | [IntegerEntry(collectTotalCommissionsCollectedDepositKey(assetA, assetB), 0), ScriptTransfer(i.caller, toWithdrawA, withdrawAssetA), IntegerEntry(collectTotalCommissionsCollectedWithdrawKey(assetA, assetB), 0), ScriptTransfer(i.caller, toWithdrawB, withdrawAssetB)] | |
200 | + | [IntegerEntry(keyTotalFeeCollectedDeposit(assetA, assetB), 0), ScriptTransfer(i.caller, toWithdrawA, withdrawAssetA), IntegerEntry(keyTotalFeeCollectedWithdraw(assetA, assetB), 0), ScriptTransfer(i.caller, toWithdrawB, withdrawAssetB)] | |
201 | + | } | |
202 | + | else throw("Strict value is not equal to itself.") | |
203 | + | } | |
204 | + | ||
205 | + | ||
206 | + | ||
207 | + | @Callable(i) | |
208 | + | func setManager (pendingManagerPublicKey) = { | |
209 | + | let checkCaller = mustManager(i) | |
210 | + | if ((checkCaller == checkCaller)) | |
211 | + | then { | |
212 | + | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
213 | + | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
214 | + | then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)] | |
215 | + | else throw("Strict value is not equal to itself.") | |
216 | + | } | |
217 | + | else throw("Strict value is not equal to itself.") | |
218 | + | } | |
219 | + | ||
220 | + | ||
221 | + | ||
222 | + | @Callable(i) | |
223 | + | func confirmManager () = { | |
224 | + | let pm = pendingManagerPublicKeyOrUnit() | |
225 | + | let hasPM = if (isDefined(pm)) | |
226 | + | then true | |
227 | + | else throwErr("no pending manager") | |
228 | + | if ((hasPM == hasPM)) | |
229 | + | then { | |
230 | + | let checkPM = if ((i.callerPublicKey == value(pm))) | |
231 | + | then true | |
232 | + | else throwErr("you are not pending manager") | |
233 | + | if ((checkPM == checkPM)) | |
234 | + | then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())] | |
235 | + | else throw("Strict value is not equal to itself.") | |
150 | 236 | } | |
151 | 237 | else throw("Strict value is not equal to itself.") | |
152 | 238 | } |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let SEP = "__" | |
5 | + | ||
4 | 6 | func keyManagerPublicKey () = "%s__managerPublicKey" | |
5 | 7 | ||
6 | 8 | ||
7 | - | func | |
9 | + | func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey" | |
8 | 10 | ||
9 | 11 | ||
10 | - | func | |
12 | + | func keyWithdrawDelay (assetA,assetB) = makeString(["%s%s%s", "withdrawDelay", assetA, assetB], SEP) | |
11 | 13 | ||
12 | 14 | ||
13 | - | func | |
15 | + | func keyDepositFeePermille (assetA,assetB) = makeString(["%s%s%s", "depositFeePermille", assetA, assetB], SEP) | |
14 | 16 | ||
15 | 17 | ||
16 | - | func | |
18 | + | func keyWithdrawFeePermille (assetA,assetB) = makeString(["%s%s%s", "withdrawFeePermille", assetA, assetB], SEP) | |
17 | 19 | ||
18 | 20 | ||
19 | - | func | |
21 | + | func keyMinAmountDeposit (assetA,assetB) = makeString(["%s%s%s", "minAmountDeposit", assetA, assetB], SEP) | |
20 | 22 | ||
21 | 23 | ||
22 | - | func | |
24 | + | func keyAssetsPairStatus (assetA,assetB) = makeString(["%s%s%s", "assetsPairStatus", assetA, assetB], SEP) | |
23 | 25 | ||
24 | 26 | ||
25 | - | func | |
27 | + | func keyMinAmountWithdraw (assetA,assetB) = makeString(["%s%s%s", "minAmountWithdraw", assetA, assetB], SEP) | |
26 | 28 | ||
27 | 29 | ||
28 | - | func | |
30 | + | func keyBalance (assetA,assetB,userAddress) = makeString(["%s%s%s%s", "balance", assetA, assetB, userAddress], SEP) | |
29 | 31 | ||
30 | 32 | ||
31 | - | func | |
33 | + | func keyTotalFeeCollectedDeposit (assetA,assetB) = makeString(["%s%s%s%s", "totalFeeCollected", "deposit", assetA, assetB], SEP) | |
32 | 34 | ||
33 | 35 | ||
34 | - | func | |
36 | + | func keyTotalFeeCollectedWithdraw (assetA,assetB) = makeString(["%s%s%s%s", "totalFeeCollected", "withdraw", assetA, assetB], SEP) | |
35 | 37 | ||
36 | 38 | ||
37 | - | func | |
39 | + | func keyAssetLockTime (assetA,assetB,userAddress) = makeString(["%s%s%s%s", "assetLockTime", assetA, assetB, userAddress], SEP) | |
38 | 40 | ||
39 | 41 | ||
40 | - | func collectProcessDoneKey (userAddress,assetA,assetB,heightInKey) = makeString(["%s%s%s%s__withdrawProcess__done", userAddress, assetA, assetB, toString(heightInKey)], "__") | |
42 | + | func keyProcessInProgress (userAddress,assetA,assetB,heightInKey) = makeString(["%s%s%s%s%s%s", "withdrawProcess", "inProgress", userAddress, assetA, assetB, toString(heightInKey)], SEP) | |
43 | + | ||
44 | + | ||
45 | + | func keyProcessDone (userAddress,assetA,assetB,heightInKey) = makeString(["%s%s%s%s%s%s", "withdrawProcess", "done", userAddress, assetA, assetB, toString(heightInKey)], SEP) | |
41 | 46 | ||
42 | 47 | ||
43 | 48 | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
49 | + | case s: String => | |
50 | + | fromBase58String(s) | |
51 | + | case _: Unit => | |
52 | + | unit | |
53 | + | case _ => | |
54 | + | throw("Match error") | |
55 | + | } | |
56 | + | ||
57 | + | ||
58 | + | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { | |
44 | 59 | case s: String => | |
45 | 60 | fromBase58String(s) | |
46 | 61 | case _: Unit => | |
47 | 62 | unit | |
48 | 63 | case _ => | |
49 | 64 | throw("Match error") | |
50 | 65 | } | |
51 | 66 | ||
52 | 67 | ||
53 | 68 | func mustManager (i) = { | |
54 | 69 | let pd = throw("Permission denied") | |
55 | 70 | match managerPublicKeyOrUnit() { | |
56 | 71 | case pk: ByteVector => | |
57 | 72 | if ((i.callerPublicKey == pk)) | |
58 | 73 | then true | |
59 | 74 | else pd | |
60 | 75 | case _: Unit => | |
61 | 76 | if ((i.caller == this)) | |
62 | 77 | then true | |
63 | 78 | else pd | |
64 | 79 | case _ => | |
65 | 80 | throw("Match error") | |
66 | 81 | } | |
67 | 82 | } | |
68 | 83 | ||
69 | 84 | ||
85 | + | func throwErr (msg) = throw(makeString(["otc_multiasset.ride:", msg], " ")) | |
86 | + | ||
87 | + | ||
70 | 88 | @Callable(i) | |
71 | 89 | func registerAsset (assetA,assetB,withdrawDelay,depositFee,withdrawFee,minAmountDeposit,minAmountWithdraw,pairStatus) = { | |
72 | 90 | let checkCaller = mustManager(i) | |
73 | 91 | if ((checkCaller == checkCaller)) | |
74 | 92 | then { | |
75 | - | let withdrawDelayKey = | |
76 | - | let depositFeePermilleKey = | |
77 | - | let withdrawFeePermilleKey = | |
78 | - | let minAmountDepositKey = | |
79 | - | let minAmountWithdrawKey = | |
80 | - | let pairStatusKey = | |
93 | + | let withdrawDelayKey = keyWithdrawDelay(assetA, assetB) | |
94 | + | let depositFeePermilleKey = keyDepositFeePermille(assetA, assetB) | |
95 | + | let withdrawFeePermilleKey = keyWithdrawFeePermille(assetA, assetB) | |
96 | + | let minAmountDepositKey = keyMinAmountDeposit(assetA, assetB) | |
97 | + | let minAmountWithdrawKey = keyMinAmountWithdraw(assetA, assetB) | |
98 | + | let pairStatusKey = keyAssetsPairStatus(assetA, assetB) | |
81 | 99 | [IntegerEntry(withdrawDelayKey, withdrawDelay), IntegerEntry(depositFeePermilleKey, depositFee), IntegerEntry(withdrawFeePermilleKey, withdrawFee), IntegerEntry(minAmountDepositKey, minAmountDeposit), IntegerEntry(minAmountWithdrawKey, minAmountWithdraw), IntegerEntry(pairStatusKey, pairStatus)] | |
82 | 100 | } | |
83 | 101 | else throw("Strict value is not equal to itself.") | |
84 | 102 | } | |
85 | 103 | ||
86 | 104 | ||
87 | 105 | ||
88 | 106 | @Callable(i) | |
89 | 107 | func swapAssetsAToB (assetB) = { | |
90 | 108 | let payment = value(i.payments[0]) | |
91 | 109 | let assetA = toBase58String(value(payment.assetId)) | |
110 | + | let asset = fromBase58String(value(assetB)) | |
92 | 111 | let userAddress = toString(i.caller) | |
93 | - | let minAmountDeposit = valueOrErrorMessage(getInteger( | |
112 | + | let minAmountDeposit = valueOrErrorMessage(getInteger(keyMinAmountDeposit(assetA, assetB)), "This asset pair does not exist.") | |
94 | 113 | let toDeposit = payment.amount | |
95 | - | let depositFeePermilleKey = collectDepositFeePermilleKey(assetA, assetB) | |
96 | - | let depositFee = valueOrElse(getInteger(this, depositFeePermilleKey), 0) | |
114 | + | let depositFee = valueOrElse(getInteger(keyDepositFeePermille(assetA, assetB)), 0) | |
97 | 115 | let fee = ((toDeposit / 1000) * depositFee) | |
98 | - | let currentUserBalance = valueOrElse(getInteger(collectBalanceKey(assetA, assetB, userAddress)), 0) | |
99 | - | let totalCommissions = valueOrElse(getInteger(collectTotalCommissionsCollectedDepositKey(assetA, assetB)), 0) | |
100 | - | let asset = fromBase58String(value(assetB)) | |
101 | - | if ((value(getInteger(collectAssetsPairStatusKey(assetA, assetB))) != 0)) | |
102 | - | then throw("The couple's deposit is blocked.") | |
103 | - | else if ((minAmountDeposit > payment.amount)) | |
104 | - | then throw("Swap amount fail, amount is to small.") | |
105 | - | else [IntegerEntry(collectBalanceKey(assetA, assetB, userAddress), ((currentUserBalance + payment.amount) - fee)), IntegerEntry(collectTotalCommissionsCollectedDepositKey(assetA, assetB), (totalCommissions + fee)), ScriptTransfer(i.caller, toDeposit, asset)] | |
116 | + | let currentUserBalance = valueOrElse(getInteger(keyBalance(assetA, assetB, userAddress)), 0) | |
117 | + | let totalCommissions = valueOrElse(getInteger(keyTotalFeeCollectedDeposit(assetA, assetB)), 0) | |
118 | + | let pairStaus = value(getInteger(keyAssetsPairStatus(assetA, assetB))) | |
119 | + | let checkPairStatus = if ((pairStaus == 0)) | |
120 | + | then true | |
121 | + | else throwErr("The couple's deposit is blocked.") | |
122 | + | if ((checkPairStatus == checkPairStatus)) | |
123 | + | then { | |
124 | + | let checkPayment = if ((toDeposit > minAmountDeposit)) | |
125 | + | then true | |
126 | + | else throwErr("Swap amount fail, amount is to small.") | |
127 | + | if ((checkPayment == checkPayment)) | |
128 | + | then { | |
129 | + | let newBalance = ((currentUserBalance + toDeposit) - fee) | |
130 | + | let checkBalance = if ((newBalance > 0)) | |
131 | + | then true | |
132 | + | else throwErr("Swap amount fail, amount is to small.") | |
133 | + | if ((checkBalance == checkBalance)) | |
134 | + | then [IntegerEntry(keyBalance(assetA, assetB, userAddress), newBalance), IntegerEntry(keyTotalFeeCollectedDeposit(assetA, assetB), (totalCommissions + fee)), ScriptTransfer(i.caller, toDeposit, asset)] | |
135 | + | else throw("Strict value is not equal to itself.") | |
136 | + | } | |
137 | + | else throw("Strict value is not equal to itself.") | |
138 | + | } | |
139 | + | else throw("Strict value is not equal to itself.") | |
106 | 140 | } | |
107 | 141 | ||
108 | 142 | ||
109 | 143 | ||
110 | 144 | @Callable(i) | |
111 | - | func initializationSwapAssetsBToA (assetA | |
145 | + | func initializationSwapAssetsBToA (assetA) = { | |
112 | 146 | let payment = value(i.payments[0]) | |
113 | 147 | let amount = payment.amount | |
148 | + | let assetB = toBase58String(value(payment.assetId)) | |
114 | 149 | let userAddress = toString(i.caller) | |
115 | - | let minAmountDeposit = valueOrErrorMessage(getInteger( | |
116 | - | let assetLockHeight = (height + valueOrElse(getInteger( | |
117 | - | let currentUserBalance = valueOrErrorMessage(getInteger( | |
118 | - | let totalCommissions = valueOrElse(getInteger( | |
119 | - | let withdrawFeePermilleKey = | |
150 | + | let minAmountDeposit = valueOrErrorMessage(getInteger(keyMinAmountWithdraw(assetA, assetB)), "This asset pair does not exist.") | |
151 | + | let assetLockHeight = (height + valueOrElse(getInteger(keyWithdrawDelay(assetA, assetB)), 0)) | |
152 | + | let currentUserBalance = valueOrErrorMessage(getInteger(keyBalance(assetA, assetB, userAddress)), "This user balance does not exist.") | |
153 | + | let totalCommissions = valueOrElse(getInteger(keyTotalFeeCollectedDeposit(assetA, assetB)), 0) | |
154 | + | let withdrawFeePermilleKey = keyWithdrawFeePermille(assetA, assetB) | |
120 | 155 | let withdrawFee = valueOrElse(getInteger(withdrawFeePermilleKey), 0) | |
121 | 156 | let fee = ((amount / 1000) * withdrawFee) | |
122 | - | [IntegerEntry(collectAssetLockTimeKey(assetA, assetB, userAddress), assetLockHeight), IntegerEntry(collectBalanceKey(assetA, assetB, userAddress), ((currentUserBalance - amount) - fee)), IntegerEntry(collectProcessInProgressKey(userAddress, assetA, assetB, assetLockHeight), (amount - fee)), IntegerEntry(collectTotalCommissionsCollectedWithdrawKey(assetA, assetB), (totalCommissions + fee))] | |
157 | + | let newBalance = ((currentUserBalance - amount) - fee) | |
158 | + | let checkBalance = if ((newBalance > 0)) | |
159 | + | then true | |
160 | + | else throwErr("Swap amount fail, amount is to small.") | |
161 | + | if ((checkBalance == checkBalance)) | |
162 | + | then { | |
163 | + | let checkProcess = if ((valueOrElse(getInteger(keyProcessInProgress(userAddress, assetA, assetB, assetLockHeight)), 0) == 0)) | |
164 | + | then true | |
165 | + | else throwErr("At this height, there is already an exchange of this pair.") | |
166 | + | if ((checkProcess == checkProcess)) | |
167 | + | then [IntegerEntry(keyAssetLockTime(assetA, assetB, userAddress), assetLockHeight), IntegerEntry(keyBalance(assetA, assetB, userAddress), newBalance), IntegerEntry(keyProcessInProgress(userAddress, assetA, assetB, assetLockHeight), (amount - fee)), IntegerEntry(keyTotalFeeCollectedWithdraw(assetA, assetB), (totalCommissions + fee))] | |
168 | + | else throw("Strict value is not equal to itself.") | |
169 | + | } | |
170 | + | else throw("Strict value is not equal to itself.") | |
123 | 171 | } | |
124 | 172 | ||
125 | 173 | ||
126 | 174 | ||
127 | 175 | @Callable(i) | |
128 | 176 | func withdrawAsset (assetA,assetB,heightInKey) = { | |
129 | 177 | let userAddress = toString(i.caller) | |
130 | - | let | |
131 | - | let toWithdraw = | |
178 | + | let assetLockHeight = value(getInteger(keyAssetLockTime(assetA, assetB, userAddress))) | |
179 | + | let toWithdraw = value(getInteger(keyProcessInProgress(userAddress, assetA, assetB, heightInKey))) | |
132 | 180 | let asset = fromBase58String(value(assetA)) | |
133 | - | if ((height > assetLockTime)) | |
134 | - | then throw((("Withdrawal is possible after " + toString(heightInKey)) + " height or you have already withdrawn.")) | |
135 | - | else [DeleteEntry(collectProcessInProgressKey(userAddress, assetA, assetB, heightInKey)), IntegerEntry(collectProcessDoneKey(userAddress, assetA, assetB, heightInKey), toWithdraw), IntegerEntry(collectBalanceKey(assetA, assetB, userAddress), toWithdraw), ScriptTransfer(i.caller, toWithdraw, asset)] | |
181 | + | let checkHeight = if ((height >= assetLockHeight)) | |
182 | + | then true | |
183 | + | else throwErr((("Withdrawal is possible after " + toString(heightInKey)) + " height or you have already withdrawn.")) | |
184 | + | if ((checkHeight == checkHeight)) | |
185 | + | then [DeleteEntry(keyProcessInProgress(userAddress, assetA, assetB, heightInKey)), IntegerEntry(keyProcessDone(userAddress, assetA, assetB, heightInKey), toWithdraw), IntegerEntry(keyBalance(assetA, assetB, userAddress), toWithdraw), ScriptTransfer(i.caller, toWithdraw, asset)] | |
186 | + | else throw("Strict value is not equal to itself.") | |
136 | 187 | } | |
137 | 188 | ||
138 | 189 | ||
139 | 190 | ||
140 | 191 | @Callable(i) | |
141 | 192 | func withdrawFee (assetA,assetB) = { | |
142 | 193 | let checkCaller = mustManager(i) | |
143 | 194 | if ((checkCaller == checkCaller)) | |
144 | 195 | then { | |
145 | - | let toWithdrawA = valueOrElse(getInteger( | |
196 | + | let toWithdrawA = valueOrElse(getInteger(keyTotalFeeCollectedDeposit(assetA, assetB)), 0) | |
146 | 197 | let withdrawAssetA = fromBase58String(value(assetA)) | |
147 | - | let toWithdrawB = valueOrElse(getInteger( | |
198 | + | let toWithdrawB = valueOrElse(getInteger(keyTotalFeeCollectedWithdraw(assetA, assetB)), 0) | |
148 | 199 | let withdrawAssetB = fromBase58String(value(assetB)) | |
149 | - | [IntegerEntry(collectTotalCommissionsCollectedDepositKey(assetA, assetB), 0), ScriptTransfer(i.caller, toWithdrawA, withdrawAssetA), IntegerEntry(collectTotalCommissionsCollectedWithdrawKey(assetA, assetB), 0), ScriptTransfer(i.caller, toWithdrawB, withdrawAssetB)] | |
200 | + | [IntegerEntry(keyTotalFeeCollectedDeposit(assetA, assetB), 0), ScriptTransfer(i.caller, toWithdrawA, withdrawAssetA), IntegerEntry(keyTotalFeeCollectedWithdraw(assetA, assetB), 0), ScriptTransfer(i.caller, toWithdrawB, withdrawAssetB)] | |
201 | + | } | |
202 | + | else throw("Strict value is not equal to itself.") | |
203 | + | } | |
204 | + | ||
205 | + | ||
206 | + | ||
207 | + | @Callable(i) | |
208 | + | func setManager (pendingManagerPublicKey) = { | |
209 | + | let checkCaller = mustManager(i) | |
210 | + | if ((checkCaller == checkCaller)) | |
211 | + | then { | |
212 | + | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
213 | + | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
214 | + | then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)] | |
215 | + | else throw("Strict value is not equal to itself.") | |
216 | + | } | |
217 | + | else throw("Strict value is not equal to itself.") | |
218 | + | } | |
219 | + | ||
220 | + | ||
221 | + | ||
222 | + | @Callable(i) | |
223 | + | func confirmManager () = { | |
224 | + | let pm = pendingManagerPublicKeyOrUnit() | |
225 | + | let hasPM = if (isDefined(pm)) | |
226 | + | then true | |
227 | + | else throwErr("no pending manager") | |
228 | + | if ((hasPM == hasPM)) | |
229 | + | then { | |
230 | + | let checkPM = if ((i.callerPublicKey == value(pm))) | |
231 | + | then true | |
232 | + | else throwErr("you are not pending manager") | |
233 | + | if ((checkPM == checkPM)) | |
234 | + | then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())] | |
235 | + | else throw("Strict value is not equal to itself.") | |
150 | 236 | } | |
151 | 237 | else throw("Strict value is not equal to itself.") | |
152 | 238 | } | |
153 | 239 | ||
154 | 240 | ||
155 | 241 | @Verifier(tx) | |
156 | 242 | func verify () = { | |
157 | 243 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
158 | 244 | case pk: ByteVector => | |
159 | 245 | pk | |
160 | 246 | case _: Unit => | |
161 | 247 | tx.senderPublicKey | |
162 | 248 | case _ => | |
163 | 249 | throw("Match error") | |
164 | 250 | } | |
165 | 251 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
166 | 252 | } | |
167 | 253 |
github/deemru/w8io/026f985 168.17 ms ◑