tx · 6TPcFqN6ay2f4VK454xT1rFybx3knUMM4fLH3MMANeE8 3MxN27tyS9DuFsab1QSfM5Q2BfauiyVCr4M: -0.03700000 Waves 2023.04.17 20:05 [2538841] smart account 3MxN27tyS9DuFsab1QSfM5Q2BfauiyVCr4M > SELF 0.00000000 Waves
{ "type": 13, "id": "6TPcFqN6ay2f4VK454xT1rFybx3knUMM4fLH3MMANeE8", "fee": 3700000, "feeAssetId": null, "timestamp": 1681751195328, "version": 2, "chainId": 84, "sender": "3MxN27tyS9DuFsab1QSfM5Q2BfauiyVCr4M", "senderPublicKey": "6PjNBLx8VTTNLWTS5y6zecyVfYCUC9ZCrAULFnLQU4XM", "proofs": [ "MqjTTAoitV1Mzfjk9HkLU2c2o3ikkNoDtVnnFKnJrmbTzXKT6rR3ogiRd7LwyGTZsCxpEaxTFw1s1JMA6pkcEeB" ], "script": "base64:BgIXCAISABIECgIICBIDCgEIEgASBAoCCAErABBrX3JlZl9saW5rX293bmVyAhBrX3JlZl9saW5rX293bmVyABZrX3JlZl9saW5rX293bmVyX2NvdW50AhZrX3JlZl9saW5rX293bmVyX2NvdW50ABBrX3JlZl9vd25lcl9saW5rAhBrX3JlZl9vd25lcl9saW5rAAprX3JlZmVycmVyAgprX3JlZmVycmVyAAhrX2FjdGl2ZQIIa19hY3RpdmUADGtfZGVmYXVsdEZlZQIMa19kZWZhdWx0RmVlABRrX3JlZmVycmVyX3JlZl9jb3VudAIUa19yZWZlcnJlcl9yZWZfY291bnQAEWtfcmVmZXJyZXJfZWFybmVkAhFrX3JlZmVycmVyX2Vhcm5lZAASa19yZWZlcnJlcl9jbGFpbWVkAhJrX3JlZmVycmVyX2NsYWltZWQADWtfaW5pdGlhbGl6ZWQCDWtfaW5pdGlhbGl6ZWQAFGtfY29vcmRpbmF0b3JBZGRyZXNzAhRrX2Nvb3JkaW5hdG9yQWRkcmVzcwAHa19jaGlsZAIHa19jaGlsZAASa19nb3Zlcm5hbmNlX2Fzc2V0AgtrX2dvdl9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UBleHRyTmF0aXZlKDEwNjIpAQkBBXZhbHVlAQUFYWRtaW4JAKwCAgkArAICCQCsAgICB3N0YXR1c18JAKUIAQUEdGhpcwIBXwkA2AQBCAUCdHgCaWQHCQACAQIudW5hYmxlIHRvIHZlcmlmeTogYWRtaW4gbm90IHNldCBpbiBjb29yZGluYXRvcgkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAgFAnR4D3NlbmRlclB1YmxpY0tleR6+FKw=", "height": 2538841, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: A8RoaNxuSWcg7X6G1ECVao2vPNb8X7HoNqjsizy2tZpq Next: none Diff:
Old | New | Differences | |
---|---|---|---|
13 | 13 | ||
14 | 14 | let k_defaultFee = "k_defaultFee" | |
15 | 15 | ||
16 | - | let k_swapAddress = "k_swapAddress" | |
17 | - | ||
18 | 16 | let k_referrer_ref_count = "k_referrer_ref_count" | |
19 | 17 | ||
20 | 18 | let k_referrer_earned = "k_referrer_earned" | |
25 | 23 | ||
26 | 24 | let k_coordinatorAddress = "k_coordinatorAddress" | |
27 | 25 | ||
26 | + | let k_child = "k_child" | |
27 | + | ||
28 | 28 | let k_governance_asset = "k_gov_asset" | |
29 | - | ||
30 | - | let k_quote_asset = "k_quote_asset" | |
31 | - | ||
32 | - | let k_admin_public_key = "k_admin_public_key" | |
33 | 29 | ||
34 | 30 | let k_admin_address = "k_admin_address" | |
35 | 31 | ||
36 | 32 | let k_amm = "k_amm" | |
33 | + | ||
34 | + | let k_swap_address = "k_swap_address" | |
37 | 35 | ||
38 | 36 | func toCompositeKey (_key,_address) = ((_key + "_") + _address) | |
39 | 37 | ||
62 | 60 | func getActiveKey (_trader) = ((k_active + "_") + _trader) | |
63 | 61 | ||
64 | 62 | ||
65 | - | func coordinator () = valueOrErrorMessage(addressFromString( | |
63 | + | func coordinator () = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(this, k_coordinatorAddress), "Coordinator not set")), "Coordinator address invalid") | |
66 | 64 | ||
67 | 65 | ||
68 | - | func | |
66 | + | func adminAddress () = addressFromString(valueOrErrorMessage(getString(coordinator(), k_admin_address), "Admin address not set")) | |
69 | 67 | ||
70 | 68 | ||
71 | - | func | |
69 | + | func governanceAsset () = fromBase58String(valueOrErrorMessage(getString(coordinator(), k_governance_asset), "Governance asset not set")) | |
72 | 70 | ||
73 | 71 | ||
74 | - | func | |
72 | + | func swapAddress () = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(coordinator(), k_swap_address), "Swap address not set")), "Swap address invalid") | |
75 | 73 | ||
76 | 74 | ||
77 | - | func quoteAsset () = fromBase58String(getStringValue(coordinator(), k_quote_asset)) | |
78 | - | ||
79 | - | ||
80 | - | func isWhitelist (_address) = valueOrElse(getBoolean(coordinator(), toCompositeKey(k_amm, _address)), false) | |
75 | + | func isWhitelist (_address) = { | |
76 | + | let rootCoordinator = coordinator() | |
77 | + | let ammCoordinator = addressFromStringValue(valueOrErrorMessage(getString(addressFromStringValue(_address), k_coordinatorAddress), ("No coordinator set for possible AMM " + _address))) | |
78 | + | let ammCoordinatorHaveAmm = valueOrElse(getBoolean(ammCoordinator, toCompositeKey(k_amm, _address)), false) | |
79 | + | let isValidCoordinator = if ((rootCoordinator == ammCoordinator)) | |
80 | + | then true | |
81 | + | else valueOrElse(getBoolean(rootCoordinator, toCompositeKey(k_child, toString(ammCoordinator))), false) | |
82 | + | if (ammCoordinatorHaveAmm) | |
83 | + | then isValidCoordinator | |
84 | + | else false | |
85 | + | } | |
81 | 86 | ||
82 | 87 | ||
83 | 88 | let DECIMAL_UNIT = (1 * (((((10 * 10) * 10) * 10) * 10) * 10)) | |
84 | 89 | ||
85 | - | func swapAddress () = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(this, k_swapAddress), "Now swap address")), "Invalid swap address") | |
86 | - | ||
87 | - | ||
88 | - | func usdnFromDecimals (_amount) = (_amount / 100) | |
89 | - | ||
90 | - | ||
91 | - | func usdnToDecimals (_amount) = (_amount * 100) | |
92 | - | ||
93 | - | ||
94 | - | func divd (_x,_y) = fraction(_x, DECIMAL_UNIT, _y, HALFEVEN) | |
95 | - | ||
96 | - | ||
97 | 90 | func muld (_x,_y) = fraction(_x, _y, DECIMAL_UNIT, HALFEVEN) | |
98 | 91 | ||
99 | 92 | ||
100 | - | func abs (_x) = if ((_x > 0)) | |
101 | - | then _x | |
102 | - | else -(_x) | |
103 | - | ||
104 | - | ||
105 | - | func minv (_x,_y) = if ((_x > _y)) | |
106 | - | then _y | |
107 | - | else _x | |
108 | - | ||
109 | - | ||
110 | 93 | func int (k) = valueOrErrorMessage(getInteger(this, k), ("no value for " + k)) | |
111 | - | ||
112 | - | ||
113 | - | func int0 (k) = valueOrElse(getInteger(this, k), 0) | |
114 | 94 | ||
115 | 95 | ||
116 | 96 | func initialized () = valueOrElse(getBoolean(this, k_initialized), false) | |
162 | 142 | func acceptPaymentWithLink (_trader,_refLink) = { | |
163 | 143 | let _rawAmount = i.payments[0].amount | |
164 | 144 | let amm = toString(i.caller) | |
165 | - | if (if (!(isWhitelist(amm))) | |
145 | + | if (if (if (!(isWhitelist(amm))) | |
146 | + | then true | |
147 | + | else (size(i.payments) != 1)) | |
166 | 148 | then true | |
167 | 149 | else !(initialized())) | |
168 | 150 | then throw("Invalid acceptPaymentWithLink params") | |
180 | 162 | let beforeSwap = assetBalance(this, governanceAsset()) | |
181 | 163 | if ((beforeSwap == beforeSwap)) | |
182 | 164 | then { | |
183 | - | let doSwap = invoke(swapAddress(), "swap", [toBase58String(governanceAsset()), 0], [AttachedPayment( | |
165 | + | let doSwap = invoke(swapAddress(), "swap", [toBase58String(governanceAsset()), 0], [AttachedPayment(i.payments[0].assetId, amountToReferrer)]) | |
184 | 166 | if ((doSwap == doSwap)) | |
185 | 167 | then { | |
186 | 168 | let afterSwap = assetBalance(this, governanceAsset()) | |
209 | 191 | let beforeSwap = assetBalance(this, governanceAsset()) | |
210 | 192 | if ((beforeSwap == beforeSwap)) | |
211 | 193 | then { | |
212 | - | let doSwap = invoke(swapAddress(), "swap", [toBase58String(governanceAsset()), 0], [AttachedPayment( | |
194 | + | let doSwap = invoke(swapAddress(), "swap", [toBase58String(governanceAsset()), 0], [AttachedPayment(i.payments[0].assetId, amountToReferrer)]) | |
213 | 195 | if ((doSwap == doSwap)) | |
214 | 196 | then { | |
215 | 197 | let afterSwap = assetBalance(this, governanceAsset()) | |
237 | 219 | func acceptPayment (_trader) = { | |
238 | 220 | let _rawAmount = i.payments[0].amount | |
239 | 221 | let amm = toString(i.caller) | |
240 | - | if (if (!(isWhitelist(amm))) | |
222 | + | if (if (if (!(isWhitelist(amm))) | |
223 | + | then true | |
224 | + | else (size(i.payments) != 1)) | |
241 | 225 | then true | |
242 | 226 | else !(initialized())) | |
243 | 227 | then throw("Invalid acceptPayment params") | |
251 | 235 | let beforeSwap = assetBalance(this, governanceAsset()) | |
252 | 236 | if ((beforeSwap == beforeSwap)) | |
253 | 237 | then { | |
254 | - | let doSwap = invoke(swapAddress(), "swap", [toBase58String(governanceAsset()), 0], [AttachedPayment( | |
238 | + | let doSwap = invoke(swapAddress(), "swap", [toBase58String(governanceAsset()), 0], [AttachedPayment(i.payments[0].assetId, amountToReferrer)]) | |
255 | 239 | if ((doSwap == doSwap)) | |
256 | 240 | then { | |
257 | 241 | let afterSwap = assetBalance(this, governanceAsset()) | |
288 | 272 | ||
289 | 273 | ||
290 | 274 | @Callable(i) | |
291 | - | func initialize (_coordinator,_defaultFee,_swapAddress) = if (initialized()) | |
292 | - | then throw("Already initialized") | |
293 | - | else [StringEntry(k_coordinatorAddress, _coordinator), StringEntry(k_swapAddress, _swapAddress), IntegerEntry(k_defaultFee, _defaultFee), BooleanEntry(k_initialized, true)] | |
294 | - | ||
295 | - | ||
296 | - | ||
297 | - | @Callable(i) | |
298 | - | func setSwapAddress (_swapAddress) = if ((i.caller != adminAddress())) | |
299 | - | then throw("Invalid setSwapAddress params") | |
300 | - | else [StringEntry(k_swapAddress, _swapAddress)] | |
275 | + | func initialize (_coordinator,_defaultFee) = if (if (initialized()) | |
276 | + | then true | |
277 | + | else (i.caller != this)) | |
278 | + | then throw("Unable to initialize") | |
279 | + | else [StringEntry(k_coordinatorAddress, toString(addressFromStringValue(_coordinator))), IntegerEntry(k_defaultFee, _defaultFee), BooleanEntry(k_initialized, true)] | |
301 | 280 | ||
302 | 281 | ||
303 | 282 | @Verifier(tx) | |
304 | - | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], adminPublicKey()) | |
283 | + | func verify () = { | |
284 | + | let coordinatorStr = getString(this, k_coordinatorAddress) | |
285 | + | if (isDefined(coordinatorStr)) | |
286 | + | then { | |
287 | + | let admin = getString(addressFromStringValue(value(coordinatorStr)), k_admin_address) | |
288 | + | if (isDefined(admin)) | |
289 | + | then valueOrElse(getBoolean(addressFromStringValue(value(admin)), ((("status_" + toString(this)) + "_") + toBase58String(tx.id))), false) | |
290 | + | else throw("unable to verify: admin not set in coordinator") | |
291 | + | } | |
292 | + | else sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
293 | + | } | |
305 | 294 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let k_ref_link_owner = "k_ref_link_owner" | |
5 | 5 | ||
6 | 6 | let k_ref_link_owner_count = "k_ref_link_owner_count" | |
7 | 7 | ||
8 | 8 | let k_ref_owner_link = "k_ref_owner_link" | |
9 | 9 | ||
10 | 10 | let k_referrer = "k_referrer" | |
11 | 11 | ||
12 | 12 | let k_active = "k_active" | |
13 | 13 | ||
14 | 14 | let k_defaultFee = "k_defaultFee" | |
15 | 15 | ||
16 | - | let k_swapAddress = "k_swapAddress" | |
17 | - | ||
18 | 16 | let k_referrer_ref_count = "k_referrer_ref_count" | |
19 | 17 | ||
20 | 18 | let k_referrer_earned = "k_referrer_earned" | |
21 | 19 | ||
22 | 20 | let k_referrer_claimed = "k_referrer_claimed" | |
23 | 21 | ||
24 | 22 | let k_initialized = "k_initialized" | |
25 | 23 | ||
26 | 24 | let k_coordinatorAddress = "k_coordinatorAddress" | |
27 | 25 | ||
26 | + | let k_child = "k_child" | |
27 | + | ||
28 | 28 | let k_governance_asset = "k_gov_asset" | |
29 | - | ||
30 | - | let k_quote_asset = "k_quote_asset" | |
31 | - | ||
32 | - | let k_admin_public_key = "k_admin_public_key" | |
33 | 29 | ||
34 | 30 | let k_admin_address = "k_admin_address" | |
35 | 31 | ||
36 | 32 | let k_amm = "k_amm" | |
33 | + | ||
34 | + | let k_swap_address = "k_swap_address" | |
37 | 35 | ||
38 | 36 | func toCompositeKey (_key,_address) = ((_key + "_") + _address) | |
39 | 37 | ||
40 | 38 | ||
41 | 39 | func getReferrerLinkKey (_link) = ((k_ref_link_owner + "_") + _link) | |
42 | 40 | ||
43 | 41 | ||
44 | 42 | func getReferrerKey (_trader) = ((k_referrer + "_") + _trader) | |
45 | 43 | ||
46 | 44 | ||
47 | 45 | func getReferrerRefCountKey (_referrer) = ((k_referrer_ref_count + "_") + _referrer) | |
48 | 46 | ||
49 | 47 | ||
50 | 48 | func getReferrerLinkCountKey (_referrer) = ((k_ref_link_owner_count + "_") + _referrer) | |
51 | 49 | ||
52 | 50 | ||
53 | 51 | func getReferrerLinkKeyAt (_referrer,_linkId) = ((((k_ref_owner_link + "_") + _referrer) + "_") + toString(_linkId)) | |
54 | 52 | ||
55 | 53 | ||
56 | 54 | func getReferrerEarnedKey (_referrer) = ((k_referrer_earned + "_") + _referrer) | |
57 | 55 | ||
58 | 56 | ||
59 | 57 | func getReferrerClaimedKey (_referrer) = ((k_referrer_claimed + "_") + _referrer) | |
60 | 58 | ||
61 | 59 | ||
62 | 60 | func getActiveKey (_trader) = ((k_active + "_") + _trader) | |
63 | 61 | ||
64 | 62 | ||
65 | - | func coordinator () = valueOrErrorMessage(addressFromString( | |
63 | + | func coordinator () = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(this, k_coordinatorAddress), "Coordinator not set")), "Coordinator address invalid") | |
66 | 64 | ||
67 | 65 | ||
68 | - | func | |
66 | + | func adminAddress () = addressFromString(valueOrErrorMessage(getString(coordinator(), k_admin_address), "Admin address not set")) | |
69 | 67 | ||
70 | 68 | ||
71 | - | func | |
69 | + | func governanceAsset () = fromBase58String(valueOrErrorMessage(getString(coordinator(), k_governance_asset), "Governance asset not set")) | |
72 | 70 | ||
73 | 71 | ||
74 | - | func | |
72 | + | func swapAddress () = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(coordinator(), k_swap_address), "Swap address not set")), "Swap address invalid") | |
75 | 73 | ||
76 | 74 | ||
77 | - | func quoteAsset () = fromBase58String(getStringValue(coordinator(), k_quote_asset)) | |
78 | - | ||
79 | - | ||
80 | - | func isWhitelist (_address) = valueOrElse(getBoolean(coordinator(), toCompositeKey(k_amm, _address)), false) | |
75 | + | func isWhitelist (_address) = { | |
76 | + | let rootCoordinator = coordinator() | |
77 | + | let ammCoordinator = addressFromStringValue(valueOrErrorMessage(getString(addressFromStringValue(_address), k_coordinatorAddress), ("No coordinator set for possible AMM " + _address))) | |
78 | + | let ammCoordinatorHaveAmm = valueOrElse(getBoolean(ammCoordinator, toCompositeKey(k_amm, _address)), false) | |
79 | + | let isValidCoordinator = if ((rootCoordinator == ammCoordinator)) | |
80 | + | then true | |
81 | + | else valueOrElse(getBoolean(rootCoordinator, toCompositeKey(k_child, toString(ammCoordinator))), false) | |
82 | + | if (ammCoordinatorHaveAmm) | |
83 | + | then isValidCoordinator | |
84 | + | else false | |
85 | + | } | |
81 | 86 | ||
82 | 87 | ||
83 | 88 | let DECIMAL_UNIT = (1 * (((((10 * 10) * 10) * 10) * 10) * 10)) | |
84 | 89 | ||
85 | - | func swapAddress () = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(this, k_swapAddress), "Now swap address")), "Invalid swap address") | |
86 | - | ||
87 | - | ||
88 | - | func usdnFromDecimals (_amount) = (_amount / 100) | |
89 | - | ||
90 | - | ||
91 | - | func usdnToDecimals (_amount) = (_amount * 100) | |
92 | - | ||
93 | - | ||
94 | - | func divd (_x,_y) = fraction(_x, DECIMAL_UNIT, _y, HALFEVEN) | |
95 | - | ||
96 | - | ||
97 | 90 | func muld (_x,_y) = fraction(_x, _y, DECIMAL_UNIT, HALFEVEN) | |
98 | 91 | ||
99 | 92 | ||
100 | - | func abs (_x) = if ((_x > 0)) | |
101 | - | then _x | |
102 | - | else -(_x) | |
103 | - | ||
104 | - | ||
105 | - | func minv (_x,_y) = if ((_x > _y)) | |
106 | - | then _y | |
107 | - | else _x | |
108 | - | ||
109 | - | ||
110 | 93 | func int (k) = valueOrErrorMessage(getInteger(this, k), ("no value for " + k)) | |
111 | - | ||
112 | - | ||
113 | - | func int0 (k) = valueOrElse(getInteger(this, k), 0) | |
114 | 94 | ||
115 | 95 | ||
116 | 96 | func initialized () = valueOrElse(getBoolean(this, k_initialized), false) | |
117 | 97 | ||
118 | 98 | ||
119 | 99 | func getLinkReferrer (_link) = valueOrElse(getString(this, getReferrerLinkKey(_link)), "") | |
120 | 100 | ||
121 | 101 | ||
122 | 102 | func getReferrer (_trader) = valueOrElse(getString(this, getReferrerKey(_trader)), "") | |
123 | 103 | ||
124 | 104 | ||
125 | 105 | func isReferral (_trader) = (getReferrer(_trader) != "") | |
126 | 106 | ||
127 | 107 | ||
128 | 108 | func isFirstTime (_trader) = (valueOrElse(getBoolean(this, getActiveKey(_trader)), false) == false) | |
129 | 109 | ||
130 | 110 | ||
131 | 111 | func getDefaultFee () = int(k_defaultFee) | |
132 | 112 | ||
133 | 113 | ||
134 | 114 | func getReferrerRefCount (_referrer) = valueOrElse(getInteger(this, getReferrerRefCountKey(_referrer)), 0) | |
135 | 115 | ||
136 | 116 | ||
137 | 117 | func getReferrerLinkCount (_referrer) = valueOrElse(getInteger(this, getReferrerLinkCountKey(_referrer)), 0) | |
138 | 118 | ||
139 | 119 | ||
140 | 120 | func getReferrerEarned (_referrer) = valueOrElse(getInteger(this, getReferrerEarnedKey(_referrer)), 0) | |
141 | 121 | ||
142 | 122 | ||
143 | 123 | func getReferrerClaimed (_referrer) = valueOrElse(getInteger(this, getReferrerClaimedKey(_referrer)), 0) | |
144 | 124 | ||
145 | 125 | ||
146 | 126 | @Callable(i) | |
147 | 127 | func createReferralLink () = { | |
148 | 128 | let raw = (toBase58String(i.transactionId) + toBase58String(i.callerPublicKey)) | |
149 | 129 | let bytes = toBytes(raw) | |
150 | 130 | let long = toBase58String(sha256(bytes)) | |
151 | 131 | let short = take(long, 10) | |
152 | 132 | let key = getReferrerLinkKey(short) | |
153 | 133 | let linkId = (getReferrerLinkCount(toString(i.caller)) + 1) | |
154 | 134 | if (isDefined(getString(this, key))) | |
155 | 135 | then throw("Short link exists, try generating it again") | |
156 | 136 | else [StringEntry(getReferrerLinkKeyAt(toString(i.caller), linkId), short), StringEntry(key, toString(i.caller))] | |
157 | 137 | } | |
158 | 138 | ||
159 | 139 | ||
160 | 140 | ||
161 | 141 | @Callable(i) | |
162 | 142 | func acceptPaymentWithLink (_trader,_refLink) = { | |
163 | 143 | let _rawAmount = i.payments[0].amount | |
164 | 144 | let amm = toString(i.caller) | |
165 | - | if (if (!(isWhitelist(amm))) | |
145 | + | if (if (if (!(isWhitelist(amm))) | |
146 | + | then true | |
147 | + | else (size(i.payments) != 1)) | |
166 | 148 | then true | |
167 | 149 | else !(initialized())) | |
168 | 150 | then throw("Invalid acceptPaymentWithLink params") | |
169 | 151 | else { | |
170 | 152 | let _isReferral = isReferral(_trader) | |
171 | 153 | let _isFirstTime = isFirstTime(_trader) | |
172 | 154 | if (if (_isReferral) | |
173 | 155 | then true | |
174 | 156 | else _isFirstTime) | |
175 | 157 | then if (_isReferral) | |
176 | 158 | then { | |
177 | 159 | let referrer = getReferrer(_trader) | |
178 | 160 | let fee = getDefaultFee() | |
179 | 161 | let amountToReferrer = muld(_rawAmount, fee) | |
180 | 162 | let beforeSwap = assetBalance(this, governanceAsset()) | |
181 | 163 | if ((beforeSwap == beforeSwap)) | |
182 | 164 | then { | |
183 | - | let doSwap = invoke(swapAddress(), "swap", [toBase58String(governanceAsset()), 0], [AttachedPayment( | |
165 | + | let doSwap = invoke(swapAddress(), "swap", [toBase58String(governanceAsset()), 0], [AttachedPayment(i.payments[0].assetId, amountToReferrer)]) | |
184 | 166 | if ((doSwap == doSwap)) | |
185 | 167 | then { | |
186 | 168 | let afterSwap = assetBalance(this, governanceAsset()) | |
187 | 169 | if ((afterSwap == afterSwap)) | |
188 | 170 | then { | |
189 | 171 | let amountGovToReferrer = (afterSwap - beforeSwap) | |
190 | 172 | if ((amountGovToReferrer == amountGovToReferrer)) | |
191 | 173 | then $Tuple2([IntegerEntry(getReferrerEarnedKey(referrer), (getReferrerEarned(referrer) + amountGovToReferrer)), ScriptTransfer(i.caller, (i.payments[0].amount - amountToReferrer), i.payments[0].assetId)], amountToReferrer) | |
192 | 174 | else throw("Strict value is not equal to itself.") | |
193 | 175 | } | |
194 | 176 | else throw("Strict value is not equal to itself.") | |
195 | 177 | } | |
196 | 178 | else throw("Strict value is not equal to itself.") | |
197 | 179 | } | |
198 | 180 | else throw("Strict value is not equal to itself.") | |
199 | 181 | } | |
200 | 182 | else { | |
201 | 183 | let referrer = getLinkReferrer(_refLink) | |
202 | 184 | if (if ((referrer == "")) | |
203 | 185 | then true | |
204 | 186 | else (referrer == _trader)) | |
205 | 187 | then $Tuple2([ScriptTransfer(i.caller, i.payments[0].amount, i.payments[0].assetId), BooleanEntry(getActiveKey(_trader), true)], 0) | |
206 | 188 | else { | |
207 | 189 | let fee = getDefaultFee() | |
208 | 190 | let amountToReferrer = muld(_rawAmount, fee) | |
209 | 191 | let beforeSwap = assetBalance(this, governanceAsset()) | |
210 | 192 | if ((beforeSwap == beforeSwap)) | |
211 | 193 | then { | |
212 | - | let doSwap = invoke(swapAddress(), "swap", [toBase58String(governanceAsset()), 0], [AttachedPayment( | |
194 | + | let doSwap = invoke(swapAddress(), "swap", [toBase58String(governanceAsset()), 0], [AttachedPayment(i.payments[0].assetId, amountToReferrer)]) | |
213 | 195 | if ((doSwap == doSwap)) | |
214 | 196 | then { | |
215 | 197 | let afterSwap = assetBalance(this, governanceAsset()) | |
216 | 198 | if ((afterSwap == afterSwap)) | |
217 | 199 | then { | |
218 | 200 | let amountGovToReferrer = (afterSwap - beforeSwap) | |
219 | 201 | if ((amountGovToReferrer == amountGovToReferrer)) | |
220 | 202 | then $Tuple2([IntegerEntry(getReferrerRefCountKey(referrer), (getReferrerRefCount(referrer) + 1)), IntegerEntry(getReferrerEarnedKey(referrer), (getReferrerEarned(referrer) + amountGovToReferrer)), StringEntry(getReferrerKey(_trader), referrer), BooleanEntry(getActiveKey(_trader), true), ScriptTransfer(i.caller, (i.payments[0].amount - amountToReferrer), i.payments[0].assetId)], amountToReferrer) | |
221 | 203 | else throw("Strict value is not equal to itself.") | |
222 | 204 | } | |
223 | 205 | else throw("Strict value is not equal to itself.") | |
224 | 206 | } | |
225 | 207 | else throw("Strict value is not equal to itself.") | |
226 | 208 | } | |
227 | 209 | else throw("Strict value is not equal to itself.") | |
228 | 210 | } | |
229 | 211 | } | |
230 | 212 | else $Tuple2([ScriptTransfer(i.caller, i.payments[0].amount, i.payments[0].assetId)], 0) | |
231 | 213 | } | |
232 | 214 | } | |
233 | 215 | ||
234 | 216 | ||
235 | 217 | ||
236 | 218 | @Callable(i) | |
237 | 219 | func acceptPayment (_trader) = { | |
238 | 220 | let _rawAmount = i.payments[0].amount | |
239 | 221 | let amm = toString(i.caller) | |
240 | - | if (if (!(isWhitelist(amm))) | |
222 | + | if (if (if (!(isWhitelist(amm))) | |
223 | + | then true | |
224 | + | else (size(i.payments) != 1)) | |
241 | 225 | then true | |
242 | 226 | else !(initialized())) | |
243 | 227 | then throw("Invalid acceptPayment params") | |
244 | 228 | else { | |
245 | 229 | let _isReferral = isReferral(_trader) | |
246 | 230 | if (_isReferral) | |
247 | 231 | then { | |
248 | 232 | let referrer = getReferrer(_trader) | |
249 | 233 | let fee = getDefaultFee() | |
250 | 234 | let amountToReferrer = muld(_rawAmount, fee) | |
251 | 235 | let beforeSwap = assetBalance(this, governanceAsset()) | |
252 | 236 | if ((beforeSwap == beforeSwap)) | |
253 | 237 | then { | |
254 | - | let doSwap = invoke(swapAddress(), "swap", [toBase58String(governanceAsset()), 0], [AttachedPayment( | |
238 | + | let doSwap = invoke(swapAddress(), "swap", [toBase58String(governanceAsset()), 0], [AttachedPayment(i.payments[0].assetId, amountToReferrer)]) | |
255 | 239 | if ((doSwap == doSwap)) | |
256 | 240 | then { | |
257 | 241 | let afterSwap = assetBalance(this, governanceAsset()) | |
258 | 242 | if ((afterSwap == afterSwap)) | |
259 | 243 | then { | |
260 | 244 | let amountGovToReferrer = (afterSwap - beforeSwap) | |
261 | 245 | if ((amountGovToReferrer == amountGovToReferrer)) | |
262 | 246 | then $Tuple2([IntegerEntry(getReferrerEarnedKey(referrer), (getReferrerEarned(referrer) + amountGovToReferrer)), ScriptTransfer(i.caller, (i.payments[0].amount - amountToReferrer), i.payments[0].assetId)], amountToReferrer) | |
263 | 247 | else throw("Strict value is not equal to itself.") | |
264 | 248 | } | |
265 | 249 | else throw("Strict value is not equal to itself.") | |
266 | 250 | } | |
267 | 251 | else throw("Strict value is not equal to itself.") | |
268 | 252 | } | |
269 | 253 | else throw("Strict value is not equal to itself.") | |
270 | 254 | } | |
271 | 255 | else $Tuple2([ScriptTransfer(i.caller, i.payments[0].amount, i.payments[0].assetId)], 0) | |
272 | 256 | } | |
273 | 257 | } | |
274 | 258 | ||
275 | 259 | ||
276 | 260 | ||
277 | 261 | @Callable(i) | |
278 | 262 | func claimRewards () = { | |
279 | 263 | let referrer = toString(i.caller) | |
280 | 264 | let totalRewards = getReferrerEarned(referrer) | |
281 | 265 | let totalClaimed = getReferrerClaimed(referrer) | |
282 | 266 | let toClaim = (totalRewards - totalClaimed) | |
283 | 267 | if ((toClaim > 0)) | |
284 | 268 | then [IntegerEntry(getReferrerClaimedKey(referrer), (getReferrerClaimed(referrer) + toClaim)), ScriptTransfer(i.caller, toClaim, governanceAsset())] | |
285 | 269 | else throw("Nothing to claim") | |
286 | 270 | } | |
287 | 271 | ||
288 | 272 | ||
289 | 273 | ||
290 | 274 | @Callable(i) | |
291 | - | func initialize (_coordinator,_defaultFee,_swapAddress) = if (initialized()) | |
292 | - | then throw("Already initialized") | |
293 | - | else [StringEntry(k_coordinatorAddress, _coordinator), StringEntry(k_swapAddress, _swapAddress), IntegerEntry(k_defaultFee, _defaultFee), BooleanEntry(k_initialized, true)] | |
294 | - | ||
295 | - | ||
296 | - | ||
297 | - | @Callable(i) | |
298 | - | func setSwapAddress (_swapAddress) = if ((i.caller != adminAddress())) | |
299 | - | then throw("Invalid setSwapAddress params") | |
300 | - | else [StringEntry(k_swapAddress, _swapAddress)] | |
275 | + | func initialize (_coordinator,_defaultFee) = if (if (initialized()) | |
276 | + | then true | |
277 | + | else (i.caller != this)) | |
278 | + | then throw("Unable to initialize") | |
279 | + | else [StringEntry(k_coordinatorAddress, toString(addressFromStringValue(_coordinator))), IntegerEntry(k_defaultFee, _defaultFee), BooleanEntry(k_initialized, true)] | |
301 | 280 | ||
302 | 281 | ||
303 | 282 | @Verifier(tx) | |
304 | - | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], adminPublicKey()) | |
283 | + | func verify () = { | |
284 | + | let coordinatorStr = getString(this, k_coordinatorAddress) | |
285 | + | if (isDefined(coordinatorStr)) | |
286 | + | then { | |
287 | + | let admin = getString(addressFromStringValue(value(coordinatorStr)), k_admin_address) | |
288 | + | if (isDefined(admin)) | |
289 | + | then valueOrElse(getBoolean(addressFromStringValue(value(admin)), ((("status_" + toString(this)) + "_") + toBase58String(tx.id))), false) | |
290 | + | else throw("unable to verify: admin not set in coordinator") | |
291 | + | } | |
292 | + | else sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
293 | + | } | |
305 | 294 |
github/deemru/w8io/169f3d6 58.22 ms ◑