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:BgIsCAISCgoICAgBAQEBAQESAwoBCBIDCgEIEgUKAwgIARIECgIICBIDCgEIEgATAANTRVACAl9fARNrZXlNYW5hZ2VyUHVibGljS2V5AAIUJXNfX21hbmFnZXJQdWJsaWNLZXkBGmtleVBlbmRpbmdNYW5hZ2VyUHVibGljS2V5AAIbJXNfX3BlbmRpbmdNYW5hZ2VyUHVibGljS2V5ARBrZXlXaXRoZHJhd0RlbGF5AgZhc3NldEEGYXNzZXRCCQC5CQIJAMwIAgIGJXMlcyVzCQDMCAICDXdpdGhkcmF3RGVsYXkJAMwIAgUGYXNzZXRBCQDMCAIFBmFzc2V0QgUDbmlsBQNTRVABFWtleURlcG9zaXRGZWVQZXJtaWxsZQIGYXNzZXRBBmFzc2V0QgkAuQkCCQDMCAICBiVzJXMlcwkAzAgCAhJkZXBvc2l0RmVlUGVybWlsbGUJAMwIAgUGYXNzZXRBCQDMCAIFBmFzc2V0QgUDbmlsBQNTRVABFmtleVdpdGhkcmF3RmVlUGVybWlsbGUCBmFzc2V0QQZhc3NldEIJALkJAgkAzAgCAgYlcyVzJXMJAMwIAgITd2l0aGRyYXdGZW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dlclB1YmxpY0tleQAJANgEAQkBBXZhbHVlAQUCcG0JAMwIAgkBC0RlbGV0ZUVudHJ5AQkBGmtleVBlbmRpbmdNYW5hZ2VyUHVibGljS2V5AAUDbmlsCQACAQIkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuCQACAQIkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAQJ0eAEGdmVyaWZ5AAQPdGFyZ2V0UHVibGljS2V5BAckbWF0Y2gwCQEWbWFuYWdlclB1YmxpY0tleU9yVW5pdAADCQABAgUHJG1hdGNoMAIKQnl0ZVZlY3RvcgQCcGsFByRtYXRjaDAFAnBrAwkAAQIFByRtYXRjaDACBFVuaXQIBQJ0eA9zZW5kZXJQdWJsaWNLZXkJAAIBAgtNYXRjaCBlcnJvcgkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAUPdGFyZ2V0UHVibGljS2V5MSfnAw==", "chainId": 84, "height": 2230247, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: AyvHf53oAhd9xGmjEpdmTPbpRPDdc5VkPoxrs5NMKyvo Next: 88Q9PZWhruvsXjkn5kzxLGt7NHAMuhFccib1Tfr58XbS Diff:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4+let SEP = "__"
5+
46 func keyManagerPublicKey () = "%s__managerPublicKey"
57
68
7-func collectWithdrawDelayKey (assetA,assetB) = makeString(["%s%s%s__withdrawDelay", assetA, assetB], "__")
9+func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey"
810
911
10-func collectDepositFeePermilleKey (assetA,assetB) = makeString(["%s%s%s__depositFeePermille", assetA, assetB], "__")
12+func keyWithdrawDelay (assetA,assetB) = makeString(["%s%s%s", "withdrawDelay", assetA, assetB], SEP)
1113
1214
13-func collectWithdrawFeePermilleKey (assetA,assetB) = makeString(["%s%s%s__withdrawFeePermille", assetA, assetB], "__")
15+func keyDepositFeePermille (assetA,assetB) = makeString(["%s%s%s", "depositFeePermille", assetA, assetB], SEP)
1416
1517
16-func collectMinAmountDepositKey (assetA,assetB) = makeString(["%s%s%s__minAmountDeposit", assetA, assetB], "__")
18+func keyWithdrawFeePermille (assetA,assetB) = makeString(["%s%s%s", "withdrawFeePermille", assetA, assetB], SEP)
1719
1820
19-func collectAssetsPairStatusKey (assetA,assetB) = makeString(["%s%s%s__assetsPairStatus", assetA, assetB], "__")
21+func keyMinAmountDeposit (assetA,assetB) = makeString(["%s%s%s", "minAmountDeposit", assetA, assetB], SEP)
2022
2123
22-func collectMinAmountWithdrawKey (assetA,assetB) = makeString(["%s%s%s__minAmountWithdraw", assetA, assetB], "__")
24+func keyAssetsPairStatus (assetA,assetB) = makeString(["%s%s%s", "assetsPairStatus", assetA, assetB], SEP)
2325
2426
25-func collectBalanceKey (assetA,assetB,userAddress) = makeString(["%s%s%s%s__balance", assetA, assetB, userAddress], "__")
27+func keyMinAmountWithdraw (assetA,assetB) = makeString(["%s%s%s", "minAmountWithdraw", assetA, assetB], SEP)
2628
2729
28-func collectTotalCommissionsCollectedDepositKey (assetA,assetB) = makeString(["%s%s%s%s__totalCommissionsCollected__deposit", assetA, assetB], "__")
30+func keyBalance (assetA,assetB,userAddress) = makeString(["%s%s%s%s", "balance", assetA, assetB, userAddress], SEP)
2931
3032
31-func collectTotalCommissionsCollectedWithdrawKey (assetA,assetB) = makeString(["%s%s%s%s__totalCommissionsCollected__withdraw", assetA, assetB], "__")
33+func keyTotalFeeCollectedDeposit (assetA,assetB) = makeString(["%s%s%s%s", "totalFeeCollected", "deposit", assetA, assetB], SEP)
3234
3335
34-func collectAssetLockTimeKey (assetA,assetB,userAddress) = makeString(["%s%s%s%s__assetLockTime", assetA, assetB, userAddress], "__")
36+func keyTotalFeeCollectedWithdraw (assetA,assetB) = makeString(["%s%s%s%s", "totalFeeCollected", "withdraw", assetA, assetB], SEP)
3537
3638
37-func collectProcessInProgressKey (userAddress,assetA,assetB,heightInKey) = makeString(["%s%s%s%s__withdrawProcess__inProgress", userAddress, assetA, assetB, toString(heightInKey)], "__")
39+func keyAssetLockTime (assetA,assetB,userAddress) = makeString(["%s%s%s%s", "assetLockTime", assetA, assetB, userAddress], SEP)
3840
3941
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)
4146
4247
4348 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()) {
4459 case s: String =>
4560 fromBase58String(s)
4661 case _: Unit =>
6782 }
6883
6984
85+func throwErr (msg) = throw(makeString(["otc_multiasset.ride:", msg], " "))
86+
87+
7088 @Callable(i)
7189 func registerAsset (assetA,assetB,withdrawDelay,depositFee,withdrawFee,minAmountDeposit,minAmountWithdraw,pairStatus) = {
7290 let checkCaller = mustManager(i)
7391 if ((checkCaller == checkCaller))
7492 then {
75- let withdrawDelayKey = collectWithdrawDelayKey(assetA, assetB)
76- let depositFeePermilleKey = collectDepositFeePermilleKey(assetA, assetB)
77- let withdrawFeePermilleKey = collectWithdrawFeePermilleKey(assetA, assetB)
78- let minAmountDepositKey = collectMinAmountDepositKey(assetA, assetB)
79- let minAmountWithdrawKey = collectMinAmountWithdrawKey(assetA, assetB)
80- let pairStatusKey = collectAssetsPairStatusKey(assetA, assetB)
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)
8199 [IntegerEntry(withdrawDelayKey, withdrawDelay), IntegerEntry(depositFeePermilleKey, depositFee), IntegerEntry(withdrawFeePermilleKey, withdrawFee), IntegerEntry(minAmountDepositKey, minAmountDeposit), IntegerEntry(minAmountWithdrawKey, minAmountWithdraw), IntegerEntry(pairStatusKey, pairStatus)]
82100 }
83101 else throw("Strict value is not equal to itself.")
89107 func swapAssetsAToB (assetB) = {
90108 let payment = value(i.payments[0])
91109 let assetA = toBase58String(value(payment.assetId))
110+ let asset = fromBase58String(value(assetB))
92111 let userAddress = toString(i.caller)
93- let minAmountDeposit = valueOrErrorMessage(getInteger(collectMinAmountDepositKey(assetA, assetB)), "This asset pair does not exist.")
112+ let minAmountDeposit = valueOrErrorMessage(getInteger(keyMinAmountDeposit(assetA, assetB)), "This asset pair does not exist.")
94113 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)
97115 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.")
106140 }
107141
108142
109143
110144 @Callable(i)
111-func initializationSwapAssetsBToA (assetA,assetB) = {
145+func initializationSwapAssetsBToA (assetA) = {
112146 let payment = value(i.payments[0])
113147 let amount = payment.amount
148+ let assetB = toBase58String(value(payment.assetId))
114149 let userAddress = toString(i.caller)
115- let minAmountDeposit = valueOrErrorMessage(getInteger(collectMinAmountWithdrawKey(assetA, assetB)), "This asset pair does not exist.")
116- let assetLockHeight = (height + valueOrElse(getInteger(collectWithdrawDelayKey(assetA, assetB)), 0))
117- let currentUserBalance = valueOrErrorMessage(getInteger(collectBalanceKey(assetA, assetB, userAddress)), "This user balance does not exist.")
118- let totalCommissions = valueOrElse(getInteger(collectTotalCommissionsCollectedDepositKey(assetA, assetB)), 0)
119- let withdrawFeePermilleKey = collectWithdrawFeePermilleKey(assetA, assetB)
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)
120155 let withdrawFee = valueOrElse(getInteger(withdrawFeePermilleKey), 0)
121156 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.")
123171 }
124172
125173
127175 @Callable(i)
128176 func withdrawAsset (assetA,assetB,heightInKey) = {
129177 let userAddress = toString(i.caller)
130- let assetLockTime = valueOrElse(getInteger(collectAssetLockTimeKey(assetA, assetB, userAddress)), 0)
131- let toWithdraw = valueOrElse(getInteger(collectProcessInProgressKey(userAddress, assetA, assetB, heightInKey)), 0)
178+ let assetLockHeight = value(getInteger(keyAssetLockTime(assetA, assetB, userAddress)))
179+ let toWithdraw = value(getInteger(keyProcessInProgress(userAddress, assetA, assetB, heightInKey)))
132180 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.")
136187 }
137188
138189
142193 let checkCaller = mustManager(i)
143194 if ((checkCaller == checkCaller))
144195 then {
145- let toWithdrawA = valueOrElse(getInteger(collectTotalCommissionsCollectedDepositKey(assetA, assetB)), 0)
196+ let toWithdrawA = valueOrElse(getInteger(keyTotalFeeCollectedDeposit(assetA, assetB)), 0)
146197 let withdrawAssetA = fromBase58String(value(assetA))
147- let toWithdrawB = valueOrElse(getInteger(collectTotalCommissionsCollectedWithdrawKey(assetA, assetB)), 0)
198+ let toWithdrawB = valueOrElse(getInteger(keyTotalFeeCollectedWithdraw(assetA, assetB)), 0)
148199 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.")
150236 }
151237 else throw("Strict value is not equal to itself.")
152238 }
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4+let SEP = "__"
5+
46 func keyManagerPublicKey () = "%s__managerPublicKey"
57
68
7-func collectWithdrawDelayKey (assetA,assetB) = makeString(["%s%s%s__withdrawDelay", assetA, assetB], "__")
9+func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey"
810
911
10-func collectDepositFeePermilleKey (assetA,assetB) = makeString(["%s%s%s__depositFeePermille", assetA, assetB], "__")
12+func keyWithdrawDelay (assetA,assetB) = makeString(["%s%s%s", "withdrawDelay", assetA, assetB], SEP)
1113
1214
13-func collectWithdrawFeePermilleKey (assetA,assetB) = makeString(["%s%s%s__withdrawFeePermille", assetA, assetB], "__")
15+func keyDepositFeePermille (assetA,assetB) = makeString(["%s%s%s", "depositFeePermille", assetA, assetB], SEP)
1416
1517
16-func collectMinAmountDepositKey (assetA,assetB) = makeString(["%s%s%s__minAmountDeposit", assetA, assetB], "__")
18+func keyWithdrawFeePermille (assetA,assetB) = makeString(["%s%s%s", "withdrawFeePermille", assetA, assetB], SEP)
1719
1820
19-func collectAssetsPairStatusKey (assetA,assetB) = makeString(["%s%s%s__assetsPairStatus", assetA, assetB], "__")
21+func keyMinAmountDeposit (assetA,assetB) = makeString(["%s%s%s", "minAmountDeposit", assetA, assetB], SEP)
2022
2123
22-func collectMinAmountWithdrawKey (assetA,assetB) = makeString(["%s%s%s__minAmountWithdraw", assetA, assetB], "__")
24+func keyAssetsPairStatus (assetA,assetB) = makeString(["%s%s%s", "assetsPairStatus", assetA, assetB], SEP)
2325
2426
25-func collectBalanceKey (assetA,assetB,userAddress) = makeString(["%s%s%s%s__balance", assetA, assetB, userAddress], "__")
27+func keyMinAmountWithdraw (assetA,assetB) = makeString(["%s%s%s", "minAmountWithdraw", assetA, assetB], SEP)
2628
2729
28-func collectTotalCommissionsCollectedDepositKey (assetA,assetB) = makeString(["%s%s%s%s__totalCommissionsCollected__deposit", assetA, assetB], "__")
30+func keyBalance (assetA,assetB,userAddress) = makeString(["%s%s%s%s", "balance", assetA, assetB, userAddress], SEP)
2931
3032
31-func collectTotalCommissionsCollectedWithdrawKey (assetA,assetB) = makeString(["%s%s%s%s__totalCommissionsCollected__withdraw", assetA, assetB], "__")
33+func keyTotalFeeCollectedDeposit (assetA,assetB) = makeString(["%s%s%s%s", "totalFeeCollected", "deposit", assetA, assetB], SEP)
3234
3335
34-func collectAssetLockTimeKey (assetA,assetB,userAddress) = makeString(["%s%s%s%s__assetLockTime", assetA, assetB, userAddress], "__")
36+func keyTotalFeeCollectedWithdraw (assetA,assetB) = makeString(["%s%s%s%s", "totalFeeCollected", "withdraw", assetA, assetB], SEP)
3537
3638
37-func collectProcessInProgressKey (userAddress,assetA,assetB,heightInKey) = makeString(["%s%s%s%s__withdrawProcess__inProgress", userAddress, assetA, assetB, toString(heightInKey)], "__")
39+func keyAssetLockTime (assetA,assetB,userAddress) = makeString(["%s%s%s%s", "assetLockTime", assetA, assetB, userAddress], SEP)
3840
3941
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)
4146
4247
4348 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()) {
4459 case s: String =>
4560 fromBase58String(s)
4661 case _: Unit =>
4762 unit
4863 case _ =>
4964 throw("Match error")
5065 }
5166
5267
5368 func mustManager (i) = {
5469 let pd = throw("Permission denied")
5570 match managerPublicKeyOrUnit() {
5671 case pk: ByteVector =>
5772 if ((i.callerPublicKey == pk))
5873 then true
5974 else pd
6075 case _: Unit =>
6176 if ((i.caller == this))
6277 then true
6378 else pd
6479 case _ =>
6580 throw("Match error")
6681 }
6782 }
6883
6984
85+func throwErr (msg) = throw(makeString(["otc_multiasset.ride:", msg], " "))
86+
87+
7088 @Callable(i)
7189 func registerAsset (assetA,assetB,withdrawDelay,depositFee,withdrawFee,minAmountDeposit,minAmountWithdraw,pairStatus) = {
7290 let checkCaller = mustManager(i)
7391 if ((checkCaller == checkCaller))
7492 then {
75- let withdrawDelayKey = collectWithdrawDelayKey(assetA, assetB)
76- let depositFeePermilleKey = collectDepositFeePermilleKey(assetA, assetB)
77- let withdrawFeePermilleKey = collectWithdrawFeePermilleKey(assetA, assetB)
78- let minAmountDepositKey = collectMinAmountDepositKey(assetA, assetB)
79- let minAmountWithdrawKey = collectMinAmountWithdrawKey(assetA, assetB)
80- let pairStatusKey = collectAssetsPairStatusKey(assetA, assetB)
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)
8199 [IntegerEntry(withdrawDelayKey, withdrawDelay), IntegerEntry(depositFeePermilleKey, depositFee), IntegerEntry(withdrawFeePermilleKey, withdrawFee), IntegerEntry(minAmountDepositKey, minAmountDeposit), IntegerEntry(minAmountWithdrawKey, minAmountWithdraw), IntegerEntry(pairStatusKey, pairStatus)]
82100 }
83101 else throw("Strict value is not equal to itself.")
84102 }
85103
86104
87105
88106 @Callable(i)
89107 func swapAssetsAToB (assetB) = {
90108 let payment = value(i.payments[0])
91109 let assetA = toBase58String(value(payment.assetId))
110+ let asset = fromBase58String(value(assetB))
92111 let userAddress = toString(i.caller)
93- let minAmountDeposit = valueOrErrorMessage(getInteger(collectMinAmountDepositKey(assetA, assetB)), "This asset pair does not exist.")
112+ let minAmountDeposit = valueOrErrorMessage(getInteger(keyMinAmountDeposit(assetA, assetB)), "This asset pair does not exist.")
94113 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)
97115 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.")
106140 }
107141
108142
109143
110144 @Callable(i)
111-func initializationSwapAssetsBToA (assetA,assetB) = {
145+func initializationSwapAssetsBToA (assetA) = {
112146 let payment = value(i.payments[0])
113147 let amount = payment.amount
148+ let assetB = toBase58String(value(payment.assetId))
114149 let userAddress = toString(i.caller)
115- let minAmountDeposit = valueOrErrorMessage(getInteger(collectMinAmountWithdrawKey(assetA, assetB)), "This asset pair does not exist.")
116- let assetLockHeight = (height + valueOrElse(getInteger(collectWithdrawDelayKey(assetA, assetB)), 0))
117- let currentUserBalance = valueOrErrorMessage(getInteger(collectBalanceKey(assetA, assetB, userAddress)), "This user balance does not exist.")
118- let totalCommissions = valueOrElse(getInteger(collectTotalCommissionsCollectedDepositKey(assetA, assetB)), 0)
119- let withdrawFeePermilleKey = collectWithdrawFeePermilleKey(assetA, assetB)
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)
120155 let withdrawFee = valueOrElse(getInteger(withdrawFeePermilleKey), 0)
121156 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.")
123171 }
124172
125173
126174
127175 @Callable(i)
128176 func withdrawAsset (assetA,assetB,heightInKey) = {
129177 let userAddress = toString(i.caller)
130- let assetLockTime = valueOrElse(getInteger(collectAssetLockTimeKey(assetA, assetB, userAddress)), 0)
131- let toWithdraw = valueOrElse(getInteger(collectProcessInProgressKey(userAddress, assetA, assetB, heightInKey)), 0)
178+ let assetLockHeight = value(getInteger(keyAssetLockTime(assetA, assetB, userAddress)))
179+ let toWithdraw = value(getInteger(keyProcessInProgress(userAddress, assetA, assetB, heightInKey)))
132180 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.")
136187 }
137188
138189
139190
140191 @Callable(i)
141192 func withdrawFee (assetA,assetB) = {
142193 let checkCaller = mustManager(i)
143194 if ((checkCaller == checkCaller))
144195 then {
145- let toWithdrawA = valueOrElse(getInteger(collectTotalCommissionsCollectedDepositKey(assetA, assetB)), 0)
196+ let toWithdrawA = valueOrElse(getInteger(keyTotalFeeCollectedDeposit(assetA, assetB)), 0)
146197 let withdrawAssetA = fromBase58String(value(assetA))
147- let toWithdrawB = valueOrElse(getInteger(collectTotalCommissionsCollectedWithdrawKey(assetA, assetB)), 0)
198+ let toWithdrawB = valueOrElse(getInteger(keyTotalFeeCollectedWithdraw(assetA, assetB)), 0)
148199 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.")
150236 }
151237 else throw("Strict value is not equal to itself.")
152238 }
153239
154240
155241 @Verifier(tx)
156242 func verify () = {
157243 let targetPublicKey = match managerPublicKeyOrUnit() {
158244 case pk: ByteVector =>
159245 pk
160246 case _: Unit =>
161247 tx.senderPublicKey
162248 case _ =>
163249 throw("Match error")
164250 }
165251 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
166252 }
167253

github/deemru/w8io/026f985 
54.74 ms