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