tx · Bp2ucuWSx5Ze19CY2ywZaTwHNPqkVophepFgRi9X2gTU 3MxN27tyS9DuFsab1QSfM5Q2BfauiyVCr4M: -0.03400000 Waves 2022.09.13 17:16 [2227437] smart account 3MxN27tyS9DuFsab1QSfM5Q2BfauiyVCr4M > SELF 0.00000000 Waves
{ "type": 13, "id": "Bp2ucuWSx5Ze19CY2ywZaTwHNPqkVophepFgRi9X2gTU", "fee": 3400000, "feeAssetId": null, "timestamp": 1663078586214, "version": 2, "chainId": 84, "sender": "3MxN27tyS9DuFsab1QSfM5Q2BfauiyVCr4M", "senderPublicKey": "6PjNBLx8VTTNLWTS5y6zecyVfYCUC9ZCrAULFnLQU4XM", "proofs": [ "4XniBB3xXd9Us1aNhfXm5XtXm5Y3MmwjcL6Us1JLAMTLRMmQfCb9JrRSsMej3foWekChPMEgwcz2B1A27HKvyJpq" ], "script": "base64:BgIXCAISABIECgIICBIDCgEIEgASBAoCCAEuABBrX3JlZl9saW5rX293bmVyAhBrX3JlZl9saW5rX293bmVyAAprX3JlZmVycmVyAgprX3JlZmVycmVyAAhrX2FjdGl2ZQIIa19hY3RpdmUADGtfZGVmYXVsdEZlZQIMa19kZWZhdWx0RmVlABRrX3JlZmVycmVyX3JlZl9jb3VudAIUa19yZWZlcnJlcl9yZWZfY291bnQAEWtfcmVmZXJyZXJfZWFybmVkAhFrX3JlZmVycmVyX2Vhcm5lZAASa19yZWZlcnJlcl9jbGFpbWVkAhJrX3JlZmVycmVyX2NsYWltZWQADWtfaW5pdGlhbGl6ZWQCDWtfaW5pdGlhbGl6ZWQAFGtfY29vcmRpbmF0b3JBZGRyZXNzAhRrX2Nvb3JkaW5hdG9yQWRkcmVzcwASa19nb3Zlcm5hbmNlX2Fzc2V0AgtrX2dvdl9hc3NldAANa19xdW90ZV9hc3NldAINa19xdW90ZV9hc3NldAASa19hZG1pbl9wdWJsaWNfa2V5AhJrX2FkbWluX3B1YmxpY19rZXkABWtfYW1tAgVrX2FtbQEOdG9Db21wb3N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xdW90ZUFzc2V0AAUDbmlsCQACAQIQTm90aGluZyB0byBjbGFpbQFpAQppbml0aWFsaXplAgxfY29vcmRpbmF0b3ILX2RlZmF1bHRGZWUDCQELaW5pdGlhbGl6ZWQACQACAQITQWxyZWFkeSBpbml0aWFsaXplZAkAzAgCCQELU3RyaW5nRW50cnkCBRRrX2Nvb3JkaW5hdG9yQWRkcmVzcwUMX2Nvb3JkaW5hdG9yCQDMCAIJAQxJbnRlZ2VyRW50cnkCBQxrX2RlZmF1bHRGZWUFC19kZWZhdWx0RmVlCQDMCAIJAQxCb29sZWFuRW50cnkCBQ1rX2luaXRpYWxpemVkBgUDbmlsAQJ0eAEGdmVyaWZ5AAkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAkBDmFkbWluUHVibGljS2V5AFe87c0=", "height": 2227437, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: 7zoigKNpgR81ZhNZoqPtu4AUtrP4y4VoGP85qgPjn8Wi Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 6 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let k_ref_link_owner = "k_ref_link_owner" | |
5 | + | ||
6 | + | let k_referrer = "k_referrer" | |
7 | + | ||
8 | + | let k_active = "k_active" | |
9 | + | ||
10 | + | let k_defaultFee = "k_defaultFee" | |
11 | + | ||
12 | + | let k_referrer_ref_count = "k_referrer_ref_count" | |
13 | + | ||
14 | + | let k_referrer_earned = "k_referrer_earned" | |
15 | + | ||
16 | + | let k_referrer_claimed = "k_referrer_claimed" | |
17 | + | ||
18 | + | let k_initialized = "k_initialized" | |
19 | + | ||
20 | + | let k_coordinatorAddress = "k_coordinatorAddress" | |
21 | + | ||
22 | + | let k_governance_asset = "k_gov_asset" | |
23 | + | ||
24 | + | let k_quote_asset = "k_quote_asset" | |
25 | + | ||
26 | + | let k_admin_public_key = "k_admin_public_key" | |
27 | + | ||
28 | + | let k_amm = "k_amm" | |
29 | + | ||
30 | + | func toCompositeKey (_key,_address) = ((_key + "_") + _address) | |
31 | + | ||
32 | + | ||
33 | + | func getReferrerLinkKey (_link) = ((k_ref_link_owner + "_") + _link) | |
34 | + | ||
35 | + | ||
36 | + | func getReferrerKey (_trader) = ((k_referrer + "_") + _trader) | |
37 | + | ||
38 | + | ||
39 | + | func getReferrerRefCountKey (_referrer) = ((k_referrer_ref_count + "_") + _referrer) | |
40 | + | ||
41 | + | ||
42 | + | func getReferrerEarnedKey (_referrer) = ((k_referrer_earned + "_") + _referrer) | |
43 | + | ||
44 | + | ||
45 | + | func getReferrerClaimedKey (_referrer) = ((k_referrer_claimed + "_") + _referrer) | |
46 | + | ||
47 | + | ||
48 | + | func getActiveKey (_trader) = ((k_active + "_") + _trader) | |
49 | + | ||
50 | + | ||
51 | + | func coordinator () = valueOrErrorMessage(addressFromString(getStringValue(this, k_coordinatorAddress)), "Coordinator not set") | |
52 | + | ||
53 | + | ||
54 | + | func adminPublicKey () = fromBase58String(getStringValue(coordinator(), k_admin_public_key)) | |
55 | + | ||
56 | + | ||
57 | + | func governanceAsset () = fromBase58String(getStringValue(coordinator(), k_governance_asset)) | |
58 | + | ||
59 | + | ||
60 | + | func quoteAsset () = fromBase58String(getStringValue(coordinator(), k_quote_asset)) | |
61 | + | ||
62 | + | ||
63 | + | func isWhitelist (_address) = valueOrElse(getBoolean(coordinator(), toCompositeKey(k_amm, _address)), false) | |
64 | + | ||
65 | + | ||
66 | + | let DECIMAL_UNIT = (1 * (((((10 * 10) * 10) * 10) * 10) * 10)) | |
67 | + | ||
68 | + | let DURATION = ((60 * 60) * 24) | |
69 | + | ||
70 | + | let NO_ADDRESS = "" | |
71 | + | ||
72 | + | let NO_STAKER = 0 | |
73 | + | ||
74 | + | func usdnFromDecimals (_amount) = (_amount / 100) | |
75 | + | ||
76 | + | ||
77 | + | func usdnToDecimals (_amount) = (_amount * 100) | |
78 | + | ||
79 | + | ||
80 | + | func divd (_x,_y) = fraction(_x, DECIMAL_UNIT, _y, HALFEVEN) | |
81 | + | ||
82 | + | ||
83 | + | func muld (_x,_y) = fraction(_x, _y, DECIMAL_UNIT, HALFEVEN) | |
84 | + | ||
85 | + | ||
86 | + | func abs (_x) = if ((_x > 0)) | |
87 | + | then _x | |
88 | + | else -(_x) | |
89 | + | ||
90 | + | ||
91 | + | func minv (_x,_y) = if ((_x > _y)) | |
92 | + | then _y | |
93 | + | else _x | |
94 | + | ||
95 | + | ||
96 | + | func int (k) = valueOrErrorMessage(getInteger(this, k), ("no value for " + k)) | |
97 | + | ||
98 | + | ||
99 | + | func int0 (k) = valueOrElse(getInteger(this, k), 0) | |
100 | + | ||
101 | + | ||
102 | + | func initialized () = valueOrElse(getBoolean(this, k_initialized), false) | |
103 | + | ||
104 | + | ||
105 | + | func getLinkReferrer (_link) = valueOrElse(getString(this, getReferrerLinkKey(_link)), "") | |
106 | + | ||
107 | + | ||
108 | + | func getReferrer (_trader) = valueOrElse(getString(this, getReferrerKey(_trader)), "") | |
109 | + | ||
110 | + | ||
111 | + | func isReferral (_trader) = (getReferrer(_trader) != "") | |
112 | + | ||
113 | + | ||
114 | + | func isFirstTime (_trader) = (valueOrElse(getBoolean(this, getActiveKey(_trader)), false) == false) | |
115 | + | ||
116 | + | ||
117 | + | func getDefaultFee () = int(k_defaultFee) | |
118 | + | ||
119 | + | ||
120 | + | func getReferrerRefCount (_referrer) = valueOrElse(getInteger(this, getReferrerRefCountKey(_referrer)), 0) | |
121 | + | ||
122 | + | ||
123 | + | func getReferrerEarned (_referrer) = valueOrElse(getInteger(this, getReferrerEarnedKey(_referrer)), 0) | |
124 | + | ||
125 | + | ||
126 | + | func getReferrerClaimed (_referrer) = valueOrElse(getInteger(this, getReferrerClaimedKey(_referrer)), 0) | |
127 | + | ||
128 | + | ||
129 | + | @Callable(i) | |
130 | + | func createReferralLink () = { | |
131 | + | let raw = (toBase58String(i.transactionId) + toBase58String(i.callerPublicKey)) | |
132 | + | let bytes = toBytes(raw) | |
133 | + | let long = toBase58String(sha256(bytes)) | |
134 | + | let short = take(long, 10) | |
135 | + | let key = getReferrerLinkKey(short) | |
136 | + | if (isDefined(getString(this, key))) | |
137 | + | then throw("Short link exists, try generating it again") | |
138 | + | else [StringEntry(key, toString(i.caller))] | |
139 | + | } | |
140 | + | ||
141 | + | ||
142 | + | ||
143 | + | @Callable(i) | |
144 | + | func acceptPaymentWithLink (_trader,_refLink) = { | |
145 | + | let _amount = i.payments[0].amount | |
146 | + | let amm = toString(i.caller) | |
147 | + | if (if (!(isWhitelist(amm))) | |
148 | + | then true | |
149 | + | else !(initialized())) | |
150 | + | then throw("Invalid acceptPaymentWithLink params") | |
151 | + | else { | |
152 | + | let _isReferral = isReferral(_trader) | |
153 | + | let _isFirstTime = isFirstTime(_trader) | |
154 | + | if (if (isReferral(_trader)) | |
155 | + | then true | |
156 | + | else isFirstTime(_trader)) | |
157 | + | then if (_isReferral) | |
158 | + | then { | |
159 | + | let referrer = getReferrer(_trader) | |
160 | + | let fee = getDefaultFee() | |
161 | + | let amountToReferrer = muld(_amount, fee) | |
162 | + | $Tuple2([IntegerEntry(getReferrerEarnedKey(referrer), (getReferrerEarned(referrer) + amountToReferrer)), ScriptTransfer(i.caller, (i.payments[0].amount - amountToReferrer), i.payments[0].assetId)], amountToReferrer) | |
163 | + | } | |
164 | + | else { | |
165 | + | let referrer = getLinkReferrer(_refLink) | |
166 | + | if ((referrer == "")) | |
167 | + | then $Tuple2([ScriptTransfer(i.caller, i.payments[0].amount, i.payments[0].assetId), BooleanEntry(getActiveKey(_trader), true)], 0) | |
168 | + | else { | |
169 | + | let fee = getDefaultFee() | |
170 | + | let amountToReferrer = muld(_amount, fee) | |
171 | + | $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) | |
172 | + | } | |
173 | + | } | |
174 | + | else $Tuple2([ScriptTransfer(i.caller, i.payments[0].amount, i.payments[0].assetId)], 0) | |
175 | + | } | |
176 | + | } | |
177 | + | ||
178 | + | ||
179 | + | ||
180 | + | @Callable(i) | |
181 | + | func acceptPayment (_trader) = { | |
182 | + | let _amount = i.payments[0].amount | |
183 | + | let amm = toString(i.caller) | |
184 | + | if (if (!(isWhitelist(amm))) | |
185 | + | then true | |
186 | + | else !(initialized())) | |
187 | + | then throw("Invalid acceptPayment params") | |
188 | + | else { | |
189 | + | let _isReferral = isReferral(_trader) | |
190 | + | if (_isReferral) | |
191 | + | then { | |
192 | + | let referrer = getReferrer(_trader) | |
193 | + | let fee = getDefaultFee() | |
194 | + | let amountToReferrer = muld(_amount, fee) | |
195 | + | $Tuple2([IntegerEntry(getReferrerEarnedKey(referrer), (getReferrerEarned(referrer) + amountToReferrer)), ScriptTransfer(i.caller, (i.payments[0].amount - amountToReferrer), i.payments[0].assetId)], amountToReferrer) | |
196 | + | } | |
197 | + | else $Tuple2([ScriptTransfer(i.caller, i.payments[0].amount, i.payments[0].assetId)], 0) | |
198 | + | } | |
199 | + | } | |
200 | + | ||
201 | + | ||
202 | + | ||
203 | + | @Callable(i) | |
204 | + | func claimRewards () = { | |
205 | + | let referrer = toString(i.caller) | |
206 | + | let totalRewards = getReferrerEarned(referrer) | |
207 | + | let totalClaimed = getReferrerClaimed(referrer) | |
208 | + | let toClaim = (totalRewards - totalClaimed) | |
209 | + | if ((toClaim > 0)) | |
210 | + | then [IntegerEntry(getReferrerClaimedKey(referrer), (getReferrerClaimed(referrer) + toClaim)), ScriptTransfer(i.caller, toClaim, quoteAsset())] | |
211 | + | else throw("Nothing to claim") | |
212 | + | } | |
213 | + | ||
214 | + | ||
215 | + | ||
216 | + | @Callable(i) | |
217 | + | func initialize (_coordinator,_defaultFee) = if (initialized()) | |
218 | + | then throw("Already initialized") | |
219 | + | else [StringEntry(k_coordinatorAddress, _coordinator), IntegerEntry(k_defaultFee, _defaultFee), BooleanEntry(k_initialized, true)] | |
220 | + | ||
221 | + | ||
222 | + | @Verifier(tx) | |
223 | + | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], adminPublicKey()) | |
224 | + |
github/deemru/w8io/169f3d6 26.40 ms ◑