tx · Fmm7rCSdDzrRFWPreEevEYf2k7ZnXjdnGvBteysP2i1J 3NBBWfzZtZtszaXbitTKnrB2xXwv26Bn7H9: -0.12400000 Waves 2022.09.14 18:15 [2228940] smart account 3NBBWfzZtZtszaXbitTKnrB2xXwv26Bn7H9 > SELF 0.00000000 Waves
{ "type": 13, "id": "Fmm7rCSdDzrRFWPreEevEYf2k7ZnXjdnGvBteysP2i1J", "fee": 12400000, "feeAssetId": null, "timestamp": 1663168499215, "version": 2, "chainId": 84, "sender": "3NBBWfzZtZtszaXbitTKnrB2xXwv26Bn7H9", "senderPublicKey": "D1X9WatF6ARMCmm3jC4Ex5Wd5VQ3LY8i1xbHNqeHqeAa", "proofs": [ "sTkdfFb38sazAuC7sdxUGFkTf5EfYWBqYLeCtS4ZdgrFFhUTkqapd37TuwVsHvfnj9pfo14W7uQgvWxVJwRtgaU", "4i4RTohwGwiW8qqbNbtphtUrytNapN82nGZvbRbq8J8Xj7NZhYdUx3yzqGsfgk4rmsrkb4DebJcA9xF5R8pvKJZa" ], "script": "base64:BgIlCAISAwoBCBIDCgEIEgMKAQgSAwoBCBIECgIIARIDCgEIEgASAGYAFGtleVNoYXJlVG9rZW5zTG9ja2VkAhpfdG90YWxfc2hhcmVfdG9rZW5zX2xvY2tlZAALa1NoYXJlTGltaXQCHHNoYXJlX2xpbWl0X29uX2ZpcnN0X2hhcnZlc3QACWtleUFjdGl2ZQIGYWN0aXZlAAhrZXlDYXVzZQIOc2h1dGRvd25fY2F1c2UAHGtleVJld2FyZFBvb2xGcmFjdGlvbkN1cnJlbnQCHV9jdXJyZW50X3Bvb2xfZnJhY3Rpb25fcmV3YXJkAB1rZXlSZXdhcmRQb29sRnJhY3Rpb25QcmV2aW91cwIeX3ByZXZpb3VzX3Bvb2xfZnJhY3Rpb25fcmV3YXJkABVrZXlIZWlnaHRQb29sRnJhY3Rpb24CGl9wb29sX3Jld2FyZF91cGRhdGVfaGVpZ2h0AB1rZXlUb3RhbFJld2FyZFBlckJ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ibGljS2V5CQACAQIhT25seSBhZG1pbiBjYW4gY2FsbCB0aGlzIGZ1bmN0aW9uCQDMCAIJAQxCb29sZWFuRW50cnkCBQlrZXlBY3RpdmUGCQDMCAIJAQtEZWxldGVFbnRyeQEFCGtleUNhdXNlBQNuaWwBAnR4AQZ2ZXJpZnkABAckbWF0Y2gwBQJ0eAQSYWRtaW5QdWJLZXkxU2lnbmVkAwkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAUMYWRtaW5QdWJLZXkxAAEAAAQSYWRtaW5QdWJLZXkyU2lnbmVkAwkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAQUMYWRtaW5QdWJLZXkyAAEAAAQSYWRtaW5QdWJLZXkzU2lnbmVkAwkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAgUMYWRtaW5QdWJLZXkzAAEAAAkAZwIJAGQCCQBkAgUSYWRtaW5QdWJLZXkxU2lnbmVkBRJhZG1pblB1YktleTJTaWduZWQFEmFkbWluUHViS2V5M1NpZ25lZAACWmDT3A==", "height": 2228940, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 2qFuQqzD9B5T9YcgyS87Yz4rdLamFfQSFhNef1pTb2oc Next: HDP2ao8emwk1b6q1Z5VLnW3mwb9QZU2227sy6bGotwJe Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let | |
4 | + | let keyShareTokensLocked = "_total_share_tokens_locked" | |
5 | 5 | ||
6 | - | let | |
6 | + | let kShareLimit = "share_limit_on_first_harvest" | |
7 | 7 | ||
8 | - | let | |
8 | + | let keyActive = "active" | |
9 | 9 | ||
10 | - | let | |
10 | + | let keyCause = "shutdown_cause" | |
11 | 11 | ||
12 | - | let | |
12 | + | let keyRewardPoolFractionCurrent = "_current_pool_fraction_reward" | |
13 | 13 | ||
14 | - | let | |
14 | + | let keyRewardPoolFractionPrevious = "_previous_pool_fraction_reward" | |
15 | 15 | ||
16 | - | let kRoutingFee = "routing_fee" | |
16 | + | let keyHeightPoolFraction = "_pool_reward_update_height" | |
17 | + | ||
18 | + | let keyTotalRewardPerBlockCurrent = "total_reward_per_block_current" | |
19 | + | ||
20 | + | let keyTotalRewardPerBlockPrevious = "total_reward_per_block_previous" | |
21 | + | ||
22 | + | let keyRewardUpdateHeight = "reward_update_height" | |
23 | + | ||
24 | + | let keyLastInterest = "_last_interest" | |
25 | + | ||
26 | + | let keyLastInterestHeight = "_last_interest_height" | |
27 | + | ||
28 | + | let keyUserShareTokensLocked = "_share_tokens_locked" | |
29 | + | ||
30 | + | let keyUserLastInterest = "_last_interest" | |
31 | + | ||
32 | + | let keySWOPid = "SWOP_id" | |
33 | + | ||
34 | + | let keyUserSWOPClaimedAmount = "_SWOP_claimed_amount" | |
35 | + | ||
36 | + | let keyUserSWOPLastClaimedAmount = "_SWOP_last_claimed_amount" | |
37 | + | ||
38 | + | let keyAvailableSWOP = "_available_SWOP" | |
39 | + | ||
40 | + | let keyFarmingStartHeight = "farming_start_height" | |
41 | + | ||
42 | + | let keyAPY = "apy" | |
43 | + | ||
44 | + | let kPreviousTotalVoteSWOP = "previous_total_vote_SWOP" | |
45 | + | ||
46 | + | let keySwopYearEmission = "swop_year_emission" | |
47 | + | ||
48 | + | let keyBalancecpmmA = "A_asset_balance" | |
49 | + | ||
50 | + | let keyBalancecpmmB = "B_asset_balance" | |
51 | + | ||
52 | + | let kHarvestPoolActiveVoteStrucVoting = "_harvest_pool_activeVote_struc" | |
53 | + | ||
54 | + | let kHarvestUserPoolActiveVoteStrucVoting = "_harvest_user_pool_activeVote_struc" | |
55 | + | ||
56 | + | let keyLimitShareFirstHarvest = "share_limit_on_first_harvest" | |
57 | + | ||
58 | + | let keyAssetIdA = "A_asset_id" | |
59 | + | ||
60 | + | let keyAssetIdB = "B_asset_id" | |
61 | + | ||
62 | + | let keyFirstHarvestHeight = "first_harvest_height" | |
63 | + | ||
64 | + | let keyfirstHarvestCpmm = "first_harvest" | |
65 | + | ||
66 | + | let keyTempPrevSum = "sum_reward_previous" | |
67 | + | ||
68 | + | let keyTempCurSum = "sum_reward_current" | |
69 | + | ||
70 | + | let oneWeekInBlock = 10106 | |
71 | + | ||
72 | + | let totalVoteShare = 10000000000 | |
73 | + | ||
74 | + | let scaleValue1 = 10 | |
75 | + | ||
76 | + | let scaleValue3 = 1000 | |
77 | + | ||
78 | + | let scaleValue5 = 100000 | |
79 | + | ||
80 | + | let scaleValue6 = 1000000 | |
81 | + | ||
82 | + | let scaleValue8 = 100000000 | |
83 | + | ||
84 | + | let scaleValue11 = 100000000000 | |
17 | 85 | ||
18 | 86 | let kAdminPubKey1 = "admin_pub_1" | |
19 | 87 | ||
21 | 89 | ||
22 | 90 | let kAdminPubKey3 = "admin_pub_3" | |
23 | 91 | ||
92 | + | let kAdminInvokePubKey = "admin_invoke_pub" | |
93 | + | ||
24 | 94 | let kMoneyBoxAddress = "money_box_address" | |
95 | + | ||
96 | + | let kVotingAddress = "voting_address" | |
25 | 97 | ||
26 | 98 | let kGovAddress = "governance_address" | |
27 | 99 | ||
28 | - | let kFee = "commission" | |
29 | - | ||
30 | - | let kMultyAssetBalance = "_balance" | |
31 | - | ||
32 | - | let digits8 = 8 | |
33 | - | ||
34 | - | let scale8 = 100000000 | |
35 | - | ||
36 | - | let scale16 = 10000000000000000 | |
37 | - | ||
38 | - | let alpha = 50 | |
39 | - | ||
40 | - | let alphaDigits = 2 | |
41 | - | ||
42 | - | let beta = 4600000000000000 | |
100 | + | let kLPFarmingAddress = "lp_farming" | |
43 | 101 | ||
44 | 102 | let oracle = Address(base58'3NBBWfzZtZtszaXbitTKnrB2xXwv26Bn7H9') | |
45 | 103 | ||
59 | 117 | ||
60 | 118 | let moneyBoxAddress = Address(getBase58FromOracle(kMoneyBoxAddress)) | |
61 | 119 | ||
120 | + | let votingAddress = Address(getBase58FromOracle(kVotingAddress)) | |
121 | + | ||
62 | 122 | let govAddress = Address(getBase58FromOracle(kGovAddress)) | |
63 | 123 | ||
64 | - | let | |
124 | + | let adminInvokePubKey = getBase58FromOracle(kAdminInvokePubKey) | |
65 | 125 | ||
66 | - | let | |
126 | + | let lpFarmingAddress = Address(getBase58FromOracle(kLPFarmingAddress)) | |
67 | 127 | ||
68 | - | let feeScale6 = 1000000 | |
69 | - | ||
70 | - | func isActive () = if (active) | |
71 | - | then unit | |
72 | - | else throw("DApp is inactive at this moment") | |
128 | + | func strAssetIdA (pool) = getStringValue(pool, keyAssetIdA) | |
73 | 129 | ||
74 | 130 | ||
75 | - | func isAdminCall (i) = if (containsElement([adminPubKey1, adminPubKey2, adminPubKey3], i.callerPublicKey)) | |
76 | - | then unit | |
77 | - | else throw("Only admin can call this function") | |
131 | + | func strAssetIdB (pool) = getStringValue(pool, keyAssetIdB) | |
78 | 132 | ||
79 | 133 | ||
80 | - | func throwIsActive () = throw("DApp is already active") | |
134 | + | func assetIdA (pool) = if ((strAssetIdA(pool) == "WAVES")) | |
135 | + | then unit | |
136 | + | else fromBase58String(strAssetIdA(pool)) | |
81 | 137 | ||
82 | 138 | ||
83 | - | func suspend (cause) = [BooleanEntry(kActive, false), StringEntry(kCause, cause)] | |
139 | + | func assetIdB (pool) = if ((strAssetIdB(pool) == "WAVES")) | |
140 | + | then unit | |
141 | + | else fromBase58String(strAssetIdB(pool)) | |
84 | 142 | ||
85 | 143 | ||
86 | - | func skewness (x,y) = ((fraction(scale16, x, y) + fraction(scale16, y, x)) / 2) | |
144 | + | let kBasePeriod = "base_period" | |
145 | + | ||
146 | + | let kPeriodLength = "period_length" | |
147 | + | ||
148 | + | let kStartHeight = "start_height" | |
149 | + | ||
150 | + | let kFirstHarvestHeight = "first_harvest_height" | |
151 | + | ||
152 | + | let kDurationFullVotePower = "duration_full_vote_power" | |
153 | + | ||
154 | + | let kMinVotePower = "min_vote_power" | |
155 | + | ||
156 | + | let basePeriod = valueOrErrorMessage(getInteger(votingAddress, kBasePeriod), "Empty kBasePeriod") | |
157 | + | ||
158 | + | let startHeight = valueOrErrorMessage(getInteger(votingAddress, kStartHeight), "Empty kStartHeight") | |
159 | + | ||
160 | + | let periodLength = valueOrErrorMessage(getInteger(votingAddress, kPeriodLength), "Empty kPeriodLength") | |
161 | + | ||
162 | + | let durationFullVotePower = valueOrErrorMessage(getInteger(votingAddress, kDurationFullVotePower), "Empty kDurationFullVotePower") | |
163 | + | ||
164 | + | let minVotePower = valueOrErrorMessage(getInteger(votingAddress, kMinVotePower), "Empty kMinVotePower") | |
165 | + | ||
166 | + | let isActive = getBooleanValue(this, keyActive) | |
167 | + | ||
168 | + | let currPeriod = (basePeriod + ((height - startHeight) / periodLength)) | |
169 | + | ||
170 | + | func getLimitToken (pool) = valueOrElse(getIntegerValue(pool, keyLimitShareFirstHarvest), 0) | |
87 | 171 | ||
88 | 172 | ||
89 | - | func invariantCalc (x,y) = { | |
90 | - | let sk = skewness(x, y) | |
91 | - | (fraction((x + y), scale16, pow(sk, digits8, alpha, alphaDigits, digits8, CEILING)) + (2 * fraction(toInt(pow(fraction(toBigInt(x), toBigInt(y), toBigInt(scale8)), 0, toBigInt(5), 1, (digits8 / 2), DOWN)), pow((sk - beta), digits8, alpha, alphaDigits, digits8, DOWN), scale8))) | |
173 | + | let APY = getIntegerValue(this, keyAPY) | |
174 | + | ||
175 | + | let SwopYearEmission = getIntegerValue(this, keySwopYearEmission) | |
176 | + | ||
177 | + | func assetNameA (pool) = match assetIdA(pool) { | |
178 | + | case id: ByteVector => | |
179 | + | value(assetInfo(id)).name | |
180 | + | case waves: Unit => | |
181 | + | "WAVES" | |
182 | + | case _ => | |
183 | + | throw("Match error") | |
184 | + | } | |
185 | + | ||
186 | + | ||
187 | + | func assetNameB (pool) = match assetIdB(pool) { | |
188 | + | case id: ByteVector => | |
189 | + | value(assetInfo(id)).name | |
190 | + | case waves: Unit => | |
191 | + | "WAVES" | |
192 | + | case _ => | |
193 | + | throw("Match error") | |
194 | + | } | |
195 | + | ||
196 | + | ||
197 | + | let SWOP = fromBase58String(getStringValue(this, keySWOPid)) | |
198 | + | ||
199 | + | func isFirstHarvest (pool) = valueOrElse(getBoolean(pool, keyfirstHarvestCpmm), false) | |
200 | + | ||
201 | + | ||
202 | + | func getHeightFirstHarvest (pool) = valueOrElse(getInteger(pool, keyFirstHarvestHeight), 0) | |
203 | + | ||
204 | + | ||
205 | + | func getBalanceA (pool) = valueOrErrorMessage(getInteger(pool, keyBalancecpmmA), ("No data on the key: " + keyBalancecpmmA)) | |
206 | + | ||
207 | + | ||
208 | + | func getBalanceB (pool) = valueOrErrorMessage(getInteger(pool, keyBalancecpmmB), ("No data on the key: " + keyBalancecpmmB)) | |
209 | + | ||
210 | + | ||
211 | + | func getShareLimitToken (pool) = valueOrErrorMessage(getInteger(pool, kShareLimit), ("No data on the key: " + kShareLimit)) | |
212 | + | ||
213 | + | ||
214 | + | func getTotalShareTokenLocked (pool) = valueOrErrorMessage(getInteger(this, (pool + keyShareTokensLocked)), (("No data on the key: " + pool) + keyShareTokensLocked)) | |
215 | + | ||
216 | + | ||
217 | + | func getShareAssetId (pool) = fromBase58String(getStringValue(value(addressFromString(pool)), "share_asset_id")) | |
218 | + | ||
219 | + | ||
220 | + | func accountBalance (assetId) = match assetId { | |
221 | + | case id: ByteVector => | |
222 | + | assetBalance(this, id) | |
223 | + | case waves: Unit => | |
224 | + | wavesBalance(this).available | |
225 | + | case _ => | |
226 | + | throw("Match error") | |
227 | + | } | |
228 | + | ||
229 | + | ||
230 | + | func getAssetInfo (assetId) = match assetId { | |
231 | + | case id: ByteVector => | |
232 | + | let stringId = toBase58String(id) | |
233 | + | let info = valueOrErrorMessage(assetInfo(id), (("Asset " + stringId) + " doesn't exist")) | |
234 | + | $Tuple3(stringId, info.name, info.decimals) | |
235 | + | case waves: Unit => | |
236 | + | $Tuple3("WAVES", "WAVES", 8) | |
237 | + | case _ => | |
238 | + | throw("Match error") | |
239 | + | } | |
240 | + | ||
241 | + | ||
242 | + | func calcScaleValue (assetId1,assetId2) = { | |
243 | + | let assetId1Decimals = value(assetInfo(assetId1)).decimals | |
244 | + | let assetId2Decimals = value(assetInfo(assetId2)).decimals | |
245 | + | let scaleDigits = ((assetId2Decimals - assetId1Decimals) + 8) | |
246 | + | pow(10, 0, scaleDigits, 0, 0, DOWN) | |
92 | 247 | } | |
93 | 248 | ||
94 | 249 | ||
95 | - | func calculateFeeDiscount (userAddr) = { | |
96 | - | let swopAmount = valueOrElse(getInteger(govAddress, (toString(userAddr) + kUserSwopInGov)), 0) | |
97 | - | let discountValues = split(getStringValue(oracle, kDiscountValues), ",") | |
98 | - | let discounts = split(getStringValue(oracle, kDiscounts), ",") | |
99 | - | if (if ((swopAmount >= parseIntValue(discountValues[0]))) | |
100 | - | then (parseIntValue(discountValues[1]) > swopAmount) | |
101 | - | else false) | |
102 | - | then (feeScale6 - parseIntValue(discounts[0])) | |
103 | - | else if (if ((swopAmount >= parseIntValue(discountValues[1]))) | |
104 | - | then (parseIntValue(discountValues[2]) > swopAmount) | |
105 | - | else false) | |
106 | - | then (feeScale6 - parseIntValue(discounts[1])) | |
107 | - | else if (if ((swopAmount >= parseIntValue(discountValues[2]))) | |
108 | - | then (parseIntValue(discountValues[3]) > swopAmount) | |
109 | - | else false) | |
110 | - | then (feeScale6 - parseIntValue(discounts[2])) | |
111 | - | else if (if ((swopAmount >= parseIntValue(discountValues[3]))) | |
112 | - | then (parseIntValue(discountValues[4]) > swopAmount) | |
113 | - | else false) | |
114 | - | then (feeScale6 - parseIntValue(discounts[3])) | |
115 | - | else if ((swopAmount >= parseIntValue(discountValues[4]))) | |
116 | - | then (feeScale6 - parseIntValue(discounts[4])) | |
117 | - | else feeScale6 | |
250 | + | func userAvailableSWOP (pool,user) = valueOrElse(getInteger(this, (((pool + "_") + toString(user)) + keyAvailableSWOP)), 0) | |
251 | + | ||
252 | + | ||
253 | + | func rewardInfo (pool) = { | |
254 | + | let totalRewardPerBlockCurrent = valueOrErrorMessage(getInteger(govAddress, keyTotalRewardPerBlockCurrent), ((("No data on the key: " + keyTotalRewardPerBlockCurrent) + " at address ") + toString(govAddress))) | |
255 | + | let totalRewardPerBlockPrevious = valueOrErrorMessage(getInteger(govAddress, keyTotalRewardPerBlockPrevious), ((("No data on the key: " + keyTotalRewardPerBlockPrevious) + " at address ") + toString(govAddress))) | |
256 | + | let rewardPoolFractionCurrent = valueOrErrorMessage(getInteger(govAddress, (pool + keyRewardPoolFractionCurrent)), (((("No data on the key: " + pool) + keyRewardPoolFractionCurrent) + " at address ") + toString(govAddress))) | |
257 | + | let rewardUpdateHeight = valueOrErrorMessage(getInteger(govAddress, keyRewardUpdateHeight), ((("No data on the key: " + keyRewardUpdateHeight) + " at address ") + toString(govAddress))) | |
258 | + | let poolRewardUpdateHeight = valueOrElse(getInteger(govAddress, (pool + keyHeightPoolFraction)), 0) | |
259 | + | let rewardPoolFractionPrevious = valueOrErrorMessage(getInteger(govAddress, (pool + keyRewardPoolFractionPrevious)), (((("No data on the key: " + pool) + keyRewardPoolFractionPrevious) + " at address ") + toString(govAddress))) | |
260 | + | let rewardPoolCurrent = fraction(totalRewardPerBlockCurrent, rewardPoolFractionCurrent, totalVoteShare) | |
261 | + | let rewardPoolPrevious = fraction(totalRewardPerBlockPrevious, rewardPoolFractionPrevious, totalVoteShare) | |
262 | + | if (if ((rewardPoolCurrent > totalRewardPerBlockCurrent)) | |
263 | + | then true | |
264 | + | else (rewardPoolPrevious > totalRewardPerBlockPrevious)) | |
265 | + | then throw("rewardPoolCurrent > totalRewardPerBlockCurrent or rewardPoolPrevious > totalRewardPerBlockPrevious") | |
266 | + | else $Tuple4(rewardPoolCurrent, rewardUpdateHeight, rewardPoolPrevious, poolRewardUpdateHeight) | |
118 | 267 | } | |
119 | 268 | ||
120 | 269 | ||
121 | - | func checkPossibility (caller,pmtAmount,minAmountToReceive,exchangers,exchangersType,routingAssetsKeys,args1,args2) = { | |
122 | - | let feeDiscount = calculateFeeDiscount(caller) | |
123 | - | let getFrom1TradeWithFee = if ((exchangersType[0] == "curveMultyFlat")) | |
124 | - | then { | |
125 | - | let inv = { | |
126 | - | let @ = invoke(addressFromStringValue(exchangers[0]), "getDy", [routingAssetsKeys[0], routingAssetsKeys[1], pmtAmount, toString(caller)], nil) | |
127 | - | if ($isInstanceOf(@, "(Int, Int)")) | |
128 | - | then @ | |
129 | - | else throw(($getType(invoke(addressFromStringValue(exchangers[0]), "getDy", [routingAssetsKeys[0], routingAssetsKeys[1], pmtAmount, toString(caller)], nil)) + " couldn't be cast to (Int, Int)")) | |
130 | - | } | |
131 | - | if ((inv == inv)) | |
132 | - | then inv._1 | |
133 | - | else throw("Strict value is not equal to itself.") | |
134 | - | } | |
135 | - | else { | |
136 | - | let dApp1TokenPay = getIntegerValue(addressFromStringValue(exchangers[0]), routingAssetsKeys[0]) | |
137 | - | let dApp1TokenGet = getIntegerValue(addressFromStringValue(exchangers[0]), routingAssetsKeys[1]) | |
138 | - | if ((exchangersType[0] == "cpmm")) | |
139 | - | then { | |
140 | - | let fee = getIntegerValue(addressFromStringValue(exchangers[0]), kFee) | |
141 | - | let getFrom1TradeWithoutFee = fraction(dApp1TokenGet, pmtAmount, (pmtAmount + dApp1TokenPay)) | |
142 | - | fraction(getFrom1TradeWithoutFee, (feeScale6 - fraction(fee, feeDiscount, feeScale6)), feeScale6) | |
143 | - | } | |
144 | - | else if ((exchangersType[0] == "flat")) | |
145 | - | then { | |
146 | - | let invariant = invariantCalc(dApp1TokenPay, dApp1TokenGet) | |
147 | - | let minAmountToReceive1 = args2[0] | |
148 | - | let invariantNew = invariantCalc((dApp1TokenPay + pmtAmount), (dApp1TokenGet - minAmountToReceive1)) | |
149 | - | if ((invariantNew >= invariant)) | |
150 | - | then minAmountToReceive1 | |
151 | - | else throw("Flat contract: invariantNew < invariant") | |
152 | - | } | |
153 | - | else throw("Incorrect exchange type") | |
154 | - | } | |
155 | - | let getFrom2TradeWithFee = if ((exchangersType[1] == "curveMultyFlat")) | |
156 | - | then { | |
157 | - | let inv = { | |
158 | - | let @ = invoke(addressFromStringValue(exchangers[1]), "getDy", [routingAssetsKeys[2], routingAssetsKeys[3], getFrom1TradeWithFee, toString(caller)], nil) | |
159 | - | if ($isInstanceOf(@, "(Int, Int)")) | |
160 | - | then @ | |
161 | - | else throw(($getType(invoke(addressFromStringValue(exchangers[1]), "getDy", [routingAssetsKeys[2], routingAssetsKeys[3], getFrom1TradeWithFee, toString(caller)], nil)) + " couldn't be cast to (Int, Int)")) | |
162 | - | } | |
163 | - | if ((inv == inv)) | |
164 | - | then inv._1 | |
165 | - | else throw("Strict value is not equal to itself.") | |
166 | - | } | |
167 | - | else { | |
168 | - | let dApp2TokenPay = getIntegerValue(addressFromStringValue(exchangers[1]), routingAssetsKeys[2]) | |
169 | - | let dApp2TokenGet = getIntegerValue(addressFromStringValue(exchangers[1]), routingAssetsKeys[3]) | |
170 | - | if ((exchangersType[1] == "cpmm")) | |
171 | - | then { | |
172 | - | let getFrom2TradeWithoutFee = fraction(dApp2TokenGet, getFrom1TradeWithFee, (getFrom1TradeWithFee + dApp2TokenPay)) | |
173 | - | let fee = getIntegerValue(addressFromStringValue(exchangers[1]), kFee) | |
174 | - | fraction(getFrom2TradeWithoutFee, (feeScale6 - fraction(fee, feeDiscount, feeScale6)), feeScale6) | |
175 | - | } | |
176 | - | else if ((exchangersType[1] == "flat")) | |
177 | - | then { | |
178 | - | let invariant = invariantCalc(dApp2TokenPay, dApp2TokenGet) | |
179 | - | let minAmountToReceive2 = args2[1] | |
180 | - | let invariantNew = invariantCalc((dApp2TokenPay + getFrom1TradeWithFee), (dApp2TokenGet - minAmountToReceive2)) | |
181 | - | if ((invariantNew >= invariant)) | |
182 | - | then minAmountToReceive2 | |
183 | - | else throw("Flat contract: invariantNew < invariant") | |
184 | - | } | |
185 | - | else throw("Incorrect exchange type") | |
186 | - | } | |
187 | - | (getFrom2TradeWithFee >= minAmountToReceive) | |
270 | + | func getLastInterestInfo (pool) = { | |
271 | + | let lastInterest = valueOrErrorMessage(getInteger(this, (pool + keyLastInterest)), (("No data on the key: " + pool) + keyLastInterest)) | |
272 | + | let lastInterestHeight = valueOrElse(getInteger(this, (pool + keyLastInterestHeight)), height) | |
273 | + | $Tuple2(lastInterestHeight, lastInterest) | |
188 | 274 | } | |
189 | 275 | ||
190 | 276 | ||
191 | - | ||
192 | - | ||
193 | - | let | |
194 | - | let | |
195 | - | let | |
196 | - | | |
197 | - | | |
198 | - | | |
199 | - | | |
200 | - | | |
201 | - | ||
202 | - | | |
203 | - | | |
204 | - | | |
205 | - | | |
206 | - | | |
207 | - | | |
208 | - | | |
209 | - | ||
210 | - | ||
211 | - | ||
212 | - | | |
213 | - | | |
214 | - | | |
215 | - | ||
216 | - | ||
217 | - | ||
218 | - | ||
219 | - | | |
220 | - | | |
221 | - | | |
222 | - | | |
223 | - | | |
224 | - | ||
225 | - | | |
226 | - | | |
227 | - | | |
228 | - | | |
229 | - | | |
230 | - | | |
231 | - | | |
232 | - | | |
233 | - | | |
234 | - | ||
235 | - | | |
236 | - | | |
237 | - | ||
238 | - | | |
239 | - | | |
240 | - | | |
241 | - | | |
242 | - | ||
243 | - | ||
244 | - | ||
245 | - | ||
246 | - | | |
247 | - | | |
248 | - | | |
249 | - | | |
250 | - | | |
251 | - | | |
252 | - | | |
253 | - | ||
254 | - | | |
255 | - | | |
256 | - | | |
257 | - | | |
277 | + | func getUserInterestInfo (pool,userAddress) = { | |
278 | + | let userLastInterest = getInteger(this, (((pool + "_") + toString(userAddress)) + keyUserLastInterest)) | |
279 | + | let userShare = getInteger(this, (((pool + "_") + toString(userAddress)) + keyUserShareTokensLocked)) | |
280 | + | let lastInterest = valueOrErrorMessage(getInteger(this, (pool + keyLastInterest)), (("No data on the key: " + pool) + keyLastInterest)) | |
281 | + | let userLastInterestValue = match userLastInterest { | |
282 | + | case userLastInterest: Int => | |
283 | + | userLastInterest | |
284 | + | case _ => | |
285 | + | lastInterest | |
286 | + | } | |
287 | + | let userShareTokensAmount = match userShare { | |
288 | + | case userShare: Int => | |
289 | + | userShare | |
290 | + | case _ => | |
291 | + | 0 | |
292 | + | } | |
293 | + | $Tuple2(userLastInterestValue, userShareTokensAmount) | |
294 | + | } | |
295 | + | ||
296 | + | ||
297 | + | func calcInterest (lastInterestHeight,rewardUpdateHeight,poolRewardUpdateHeight,lastInterest,currentRewardPerBlock,shareTokenLocked,previousRewardPerBlock,shareAssetId,scaleValue,pmtAmount) = if ((shareTokenLocked == 0)) | |
298 | + | then 0 | |
299 | + | else if ((poolRewardUpdateHeight != 0)) | |
300 | + | then if (if ((rewardUpdateHeight > height)) | |
301 | + | then (rewardUpdateHeight == poolRewardUpdateHeight) | |
302 | + | else false) | |
303 | + | then { | |
304 | + | let reward = (previousRewardPerBlock * (height - lastInterestHeight)) | |
305 | + | (lastInterest + fraction(reward, scaleValue, shareTokenLocked)) | |
306 | + | } | |
307 | + | else if (if ((height > rewardUpdateHeight)) | |
308 | + | then (rewardUpdateHeight != poolRewardUpdateHeight) | |
309 | + | else false) | |
310 | + | then { | |
311 | + | let reward = (previousRewardPerBlock * (height - lastInterestHeight)) | |
312 | + | (lastInterest + fraction(reward, scaleValue, shareTokenLocked)) | |
313 | + | } | |
314 | + | else if (if (if ((height > rewardUpdateHeight)) | |
315 | + | then (rewardUpdateHeight == poolRewardUpdateHeight) | |
316 | + | else false) | |
317 | + | then (lastInterestHeight > rewardUpdateHeight) | |
318 | + | else false) | |
319 | + | then { | |
320 | + | let reward = (currentRewardPerBlock * (height - lastInterestHeight)) | |
321 | + | (lastInterest + fraction(reward, scaleValue, shareTokenLocked)) | |
322 | + | } | |
323 | + | else { | |
324 | + | let rewardAfterLastInterestBeforeReawardUpdate = (previousRewardPerBlock * (rewardUpdateHeight - lastInterestHeight)) | |
325 | + | let interestAfterUpdate = (lastInterest + fraction(rewardAfterLastInterestBeforeReawardUpdate, scaleValue, shareTokenLocked)) | |
326 | + | let reward = (currentRewardPerBlock * (height - rewardUpdateHeight)) | |
327 | + | (interestAfterUpdate + fraction(reward, scaleValue, shareTokenLocked)) | |
328 | + | } | |
329 | + | else if ((rewardUpdateHeight > height)) | |
330 | + | then { | |
331 | + | let reward = (previousRewardPerBlock * (height - lastInterestHeight)) | |
332 | + | (lastInterest + fraction(reward, scaleValue, shareTokenLocked)) | |
333 | + | } | |
334 | + | else if ((lastInterestHeight > rewardUpdateHeight)) | |
335 | + | then { | |
336 | + | let reward = (currentRewardPerBlock * (height - lastInterestHeight)) | |
337 | + | (lastInterest + fraction(reward, scaleValue, shareTokenLocked)) | |
338 | + | } | |
339 | + | else { | |
340 | + | let rewardAfterLastInterestBeforeReawardUpdate = (previousRewardPerBlock * (rewardUpdateHeight - lastInterestHeight)) | |
341 | + | let interestAfterUpdate = (lastInterest + fraction(rewardAfterLastInterestBeforeReawardUpdate, scaleValue, shareTokenLocked)) | |
342 | + | let reward = (currentRewardPerBlock * (height - rewardUpdateHeight)) | |
343 | + | (interestAfterUpdate + fraction(reward, scaleValue, shareTokenLocked)) | |
258 | 344 | } | |
259 | 345 | ||
260 | - | let $t095349640 = { | |
261 | - | let $l = exchangers | |
262 | - | let $s = size($l) | |
263 | - | let $acc0 = $Tuple3(0, 0, base58'') | |
264 | - | func $f0_1 ($a,$i) = if (($i >= $s)) | |
265 | - | then $a | |
266 | - | else exchangeFold($a, $l[$i]) | |
267 | 346 | ||
268 | - | func $f0_2 ($a,$i) = if (($i >= $s)) | |
269 | - | then $a | |
270 | - | else throw("List size exceeds 3") | |
347 | + | func claimCalc (pool,caller,pmtAmount) = { | |
348 | + | let shareAssetId = getShareAssetId(pool) | |
349 | + | let scaleValue = calcScaleValue(SWOP, shareAssetId) | |
350 | + | let shareTokenLocked = getTotalShareTokenLocked(pool) | |
351 | + | let $t01352213587 = getLastInterestInfo(pool) | |
352 | + | let lastInterestHeight = $t01352213587._1 | |
353 | + | let lastInterest = $t01352213587._2 | |
354 | + | let $t01359213704 = rewardInfo(pool) | |
355 | + | let currentRewardPerBlock = $t01359213704._1 | |
356 | + | let rewardUpdateHeight = $t01359213704._2 | |
357 | + | let previousRewardPerBlock = $t01359213704._3 | |
358 | + | let poolRewardUpdateHeight = $t01359213704._4 | |
359 | + | let $t01370913788 = getUserInterestInfo(pool, caller) | |
360 | + | let userLastInterest = $t01370913788._1 | |
361 | + | let userShareTokensAmount = $t01370913788._2 | |
362 | + | let currentInterest = calcInterest(lastInterestHeight, rewardUpdateHeight, poolRewardUpdateHeight, lastInterest, currentRewardPerBlock, shareTokenLocked, previousRewardPerBlock, shareAssetId, scaleValue, pmtAmount) | |
363 | + | let claimAmount = fraction(userShareTokensAmount, (currentInterest - userLastInterest), scaleValue) | |
364 | + | let userNewInterest = currentInterest | |
365 | + | $Tuple4(userNewInterest, currentInterest, claimAmount, userShareTokensAmount) | |
366 | + | } | |
271 | 367 | ||
272 | - | $f0_2($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3) | |
368 | + | ||
369 | + | func calculateProtocolReward (pool) = { | |
370 | + | let $t01430614371 = getLastInterestInfo(pool) | |
371 | + | let lastInterestHeight = $t01430614371._1 | |
372 | + | let lastInterest = $t01430614371._2 | |
373 | + | let $t01437614487 = rewardInfo(pool) | |
374 | + | let currentRewardPerBlock = $t01437614487._1 | |
375 | + | let rewardUpdateHeight = $t01437614487._2 | |
376 | + | let previousRewardPerBlock = $t01437614487._3 | |
377 | + | let poolRewardUpdateHeight = $t01437614487._4 | |
378 | + | let shareTokenLocked = getTotalShareTokenLocked(pool) | |
379 | + | if (if ((shareTokenLocked == 0)) | |
380 | + | then (poolRewardUpdateHeight == 0) | |
381 | + | else false) | |
382 | + | then if ((rewardUpdateHeight > height)) | |
383 | + | then { | |
384 | + | let reward = (previousRewardPerBlock * (height - lastInterestHeight)) | |
385 | + | reward | |
386 | + | } | |
387 | + | else if ((lastInterestHeight > rewardUpdateHeight)) | |
388 | + | then { | |
389 | + | let reward = (currentRewardPerBlock * (height - lastInterestHeight)) | |
390 | + | reward | |
273 | 391 | } | |
274 | - | let exchangeCounter = $t095349640._1 | |
275 | - | let amountWithoutFee = $t095349640._2 | |
276 | - | let assetIdSend = $t095349640._3 | |
277 | - | let amountWithFee = fraction(amountWithoutFee, (feeScale6 - routingFee), feeScale6) | |
278 | - | if (if ((exchangeCounter == routingSize)) | |
279 | - | then (amountWithFee >= minAmountToReceive) | |
392 | + | else { | |
393 | + | let rewardAfterLastInterestBeforeReawardUpdate = (previousRewardPerBlock * (rewardUpdateHeight - lastInterestHeight)) | |
394 | + | let reward = (currentRewardPerBlock * (height - rewardUpdateHeight)) | |
395 | + | (reward + rewardAfterLastInterestBeforeReawardUpdate) | |
396 | + | } | |
397 | + | else if (if ((shareTokenLocked == 0)) | |
398 | + | then (poolRewardUpdateHeight != 0) | |
399 | + | else false) | |
400 | + | then if (if ((rewardUpdateHeight > height)) | |
401 | + | then (rewardUpdateHeight == poolRewardUpdateHeight) | |
402 | + | else false) | |
403 | + | then { | |
404 | + | let reward = (previousRewardPerBlock * (height - lastInterestHeight)) | |
405 | + | reward | |
406 | + | } | |
407 | + | else if (if ((height > rewardUpdateHeight)) | |
408 | + | then (rewardUpdateHeight != poolRewardUpdateHeight) | |
280 | 409 | else false) | |
281 | - | then [ScriptTransfer(i.caller, amountWithFee, assetIdSend), ScriptTransfer(moneyBoxAddress, (amountWithoutFee - amountWithFee), assetIdSend)] | |
282 | - | else throw("routing != routingSize or amountToRecieve < minAmountToReceive") | |
283 | - | } | |
284 | - | }) | |
410 | + | then { | |
411 | + | let reward = (previousRewardPerBlock * (height - lastInterestHeight)) | |
412 | + | reward | |
413 | + | } | |
414 | + | else if (if (if ((height > rewardUpdateHeight)) | |
415 | + | then (rewardUpdateHeight == poolRewardUpdateHeight) | |
416 | + | else false) | |
417 | + | then (lastInterestHeight > rewardUpdateHeight) | |
418 | + | else false) | |
419 | + | then { | |
420 | + | let reward = (currentRewardPerBlock * (height - lastInterestHeight)) | |
421 | + | reward | |
422 | + | } | |
423 | + | else { | |
424 | + | let rewardAfterLastInterestBeforeReawardUpdate = (previousRewardPerBlock * (rewardUpdateHeight - lastInterestHeight)) | |
425 | + | let reward = (currentRewardPerBlock * (height - rewardUpdateHeight)) | |
426 | + | (reward + rewardAfterLastInterestBeforeReawardUpdate) | |
427 | + | } | |
428 | + | else 0 | |
429 | + | } | |
430 | + | ||
431 | + | ||
432 | + | func checkPmtAssetIdCorrect (pool,pmtAssetId) = { | |
433 | + | let poolShareAssetId = fromBase58String(getStringValue(value(addressFromString(pool)), "share_asset_id")) | |
434 | + | if ((pmtAssetId == poolShareAssetId)) | |
435 | + | then true | |
436 | + | else false | |
437 | + | } | |
438 | + | ||
439 | + | ||
440 | + | func getUserSWOPClaimedAmount (pool,user) = valueOrElse(getInteger(this, (((pool + "_") + toString(user)) + keyUserSWOPClaimedAmount)), 0) | |
441 | + | ||
442 | + | ||
443 | + | func suspend (cause) = [BooleanEntry(keyActive, false), StringEntry(keyCause, cause)] | |
444 | + | ||
445 | + | ||
446 | + | @Callable(i) | |
447 | + | func init (earlyLP) = if (isDefined(getString(this, keySWOPid))) | |
448 | + | then throw("SWOP already initialized") | |
449 | + | else { | |
450 | + | let initAmount = 100000000000000 | |
451 | + | let SWOPissue = Issue("SWOP", "SWOP protocol token", initAmount, 8, true) | |
452 | + | let SWOPid = calculateAssetId(SWOPissue) | |
453 | + | [BooleanEntry(keyActive, true), Issue("SWOP", "SWOP protocol token", initAmount, 8, true), StringEntry(keySWOPid, toBase58String(SWOPid))] | |
454 | + | } | |
285 | 455 | ||
286 | 456 | ||
287 | 457 | ||
288 | 458 | @Callable(i) | |
289 | - | func shutdown () = valueOrElse(isAdminCall(i), if (!(active)) | |
290 | - | then throw(("DApp is already suspended. Cause: " + valueOrElse(getString(this, kCause), "the cause wasn't specified"))) | |
291 | - | else suspend("Paused by admin")) | |
459 | + | func initPoolShareFarming (pool) = if ((i.caller != this)) | |
460 | + | then throw("Only the DApp itself can call this function") | |
461 | + | else { | |
462 | + | let $t01746917572 = rewardInfo(pool) | |
463 | + | let currentReward = $t01746917572._1 | |
464 | + | let rewardUpdateHeight = $t01746917572._2 | |
465 | + | let previousRewardPerBlock = $t01746917572._3 | |
466 | + | let poolRewardUpdateHeight = $t01746917572._4 | |
467 | + | [IntegerEntry((pool + keyShareTokensLocked), 0), IntegerEntry((pool + keyLastInterest), 0), IntegerEntry((pool + keyLastInterestHeight), height)] | |
468 | + | } | |
292 | 469 | ||
293 | 470 | ||
294 | 471 | ||
295 | 472 | @Callable(i) | |
296 | - | func activate () = valueOrElse(isAdminCall(i), if (active) | |
297 | - | then throwIsActive() | |
298 | - | else [BooleanEntry(kActive, true), DeleteEntry(kCause)]) | |
473 | + | func updatePoolInterest (pool) = if ((i.caller != moneyBoxAddress)) | |
474 | + | then throw("Only the Admin itself can call this function") | |
475 | + | else if (!(isActive)) | |
476 | + | then throw("DApp is inactive at this moment") | |
477 | + | else { | |
478 | + | let $t01799018123 = claimCalc(pool, addressFromPublicKey(adminInvokePubKey), 0) | |
479 | + | let userNewInterest = $t01799018123._1 | |
480 | + | let currentInterest = $t01799018123._2 | |
481 | + | let claimAmount = $t01799018123._3 | |
482 | + | let userShareTokensAmount = $t01799018123._4 | |
483 | + | let $t01812818231 = rewardInfo(pool) | |
484 | + | let currentReward = $t01812818231._1 | |
485 | + | let rewardUpdateHeight = $t01812818231._2 | |
486 | + | let previousRewardPerBlock = $t01812818231._3 | |
487 | + | let poolRewardUpdateHeight = $t01812818231._4 | |
488 | + | [IntegerEntry((pool + keyLastInterest), userNewInterest), IntegerEntry((pool + keyLastInterestHeight), height)] | |
489 | + | } | |
490 | + | ||
491 | + | ||
492 | + | ||
493 | + | @Callable(i) | |
494 | + | func lockShareTokens (pool) = { | |
495 | + | let $t01842318498 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
496 | + | let pmtAmount = $t01842318498._1 | |
497 | + | let pmtAssetId = $t01842318498._2 | |
498 | + | let $t01850318576 = getAssetInfo(pmtAssetId) | |
499 | + | let pmtStrAssetId = $t01850318576._1 | |
500 | + | let pmtAssetName = $t01850318576._2 | |
501 | + | let pmtDecimals = $t01850318576._3 | |
502 | + | let $t01858118698 = claimCalc(pool, i.originCaller, pmtAmount) | |
503 | + | let userNewInterest = $t01858118698._1 | |
504 | + | let currentInterest = $t01858118698._2 | |
505 | + | let claimAmount = $t01858118698._3 | |
506 | + | let userShareTokensAmount = $t01858118698._4 | |
507 | + | let userShareAmountNew = (userShareTokensAmount + pmtAmount) | |
508 | + | let availableFundsNew = (userAvailableSWOP(pool, i.originCaller) + claimAmount) | |
509 | + | let totalShareAmount = getTotalShareTokenLocked(pool) | |
510 | + | let totalShareAmountNew = (totalShareAmount + pmtAmount) | |
511 | + | let userClaimedAmount = getUserSWOPClaimedAmount(pool, i.originCaller) | |
512 | + | let userClaimedAmountNew = (userClaimedAmount + claimAmount) | |
513 | + | let baseEntry = [IntegerEntry((((pool + "_") + toString(i.originCaller)) + keyUserLastInterest), userNewInterest), IntegerEntry((((pool + "_") + toString(i.originCaller)) + keyUserShareTokensLocked), userShareAmountNew), IntegerEntry((pool + keyShareTokensLocked), totalShareAmountNew), IntegerEntry((pool + keyLastInterest), currentInterest), IntegerEntry((pool + keyLastInterestHeight), height), IntegerEntry((((pool + "_") + toString(i.originCaller)) + keyUserSWOPClaimedAmount), userClaimedAmountNew), IntegerEntry((((pool + "_") + toString(i.originCaller)) + keyUserSWOPLastClaimedAmount), claimAmount), IntegerEntry((((pool + "_") + toString(i.originCaller)) + keyAvailableSWOP), availableFundsNew)] | |
514 | + | let uplp = if ((getString(Address(fromBase58String(pool)), "version") == "3.0.0")) | |
515 | + | then invoke(lpFarmingAddress, "updateUserInterest", [userShareAmountNew], nil) | |
516 | + | else 0 | |
517 | + | if ((uplp == uplp)) | |
518 | + | then if ((0 >= pmtAmount)) | |
519 | + | then throw("You can't lock token") | |
520 | + | else if (!(isActive)) | |
521 | + | then throw("DApp is inactive at this moment") | |
522 | + | else if (!(checkPmtAssetIdCorrect(pool, pmtAssetId))) | |
523 | + | then throw("Incorrect pmtAssetId") | |
524 | + | else if (if (isFirstHarvest(Address(fromBase58String(pool)))) | |
525 | + | then (getHeightFirstHarvest(Address(fromBase58String(pool))) > height) | |
526 | + | else false) | |
527 | + | then { | |
528 | + | let harvestPeriod = ((((getHeightFirstHarvest(Address(fromBase58String(pool))) - startHeight) + 1) / periodLength) - 1) | |
529 | + | let amountOfVoting = split(getStringValue(votingAddress, (((toString(i.originCaller) + "_") + pool) + "_user_pool_struc")), "_") | |
530 | + | let amountPoolStract = split(getStringValue(votingAddress, (pool + "_pool_struc")), "_") | |
531 | + | let amountActiveVoteUserPoolStract = split(valueOrElse(getString(votingAddress, (((toString(i.originCaller) + "_") + pool) + kHarvestUserPoolActiveVoteStrucVoting)), ""), "_") | |
532 | + | let amountPoolActiveVoteStract = split(valueOrElse(getString(votingAddress, (pool + kHarvestPoolActiveVoteStrucVoting)), ""), "_") | |
533 | + | let userShareTokenLocked = userShareTokensAmount | |
534 | + | let userPoolActiveVote = if ((toString(currPeriod) == amountOfVoting[2])) | |
535 | + | then valueOrElse(parseInt(amountActiveVoteUserPoolStract[0]), 0) | |
536 | + | else valueOrElse(parseInt(amountOfVoting[1]), 0) | |
537 | + | let poolActiveVote = if ((toString(currPeriod) == amountPoolStract[2])) | |
538 | + | then valueOrElse(parseInt(amountPoolActiveVoteStract[0]), 0) | |
539 | + | else valueOrElse(parseInt(amountPoolStract[1]), 0) | |
540 | + | let protocolReward = calculateProtocolReward(pool) | |
541 | + | if ((userPoolActiveVote != 0)) | |
542 | + | then { | |
543 | + | let limitShareToken = getShareLimitToken(addressFromStringValue(pool)) | |
544 | + | let shareToken = (fraction(limitShareToken, userPoolActiveVote, poolActiveVote) - userShareTokenLocked) | |
545 | + | if (if ((size(amountActiveVoteUserPoolStract) > 1)) | |
546 | + | then (valueOrElse(parseInt(amountActiveVoteUserPoolStract[1]), 0) >= harvestPeriod) | |
547 | + | else false) | |
548 | + | then throw("You can't share token") | |
549 | + | else if ((pmtAmount > limitShareToken)) | |
550 | + | then throw(("You can't share token more than " + toString(limitShareToken))) | |
551 | + | else if ((shareToken > 0)) | |
552 | + | then if ((fraction(99, (accountBalance(pmtAssetId) + pmtAmount), 100) > totalShareAmountNew)) | |
553 | + | then throw("Balance of share-token is greater than totalAmount") | |
554 | + | else if ((totalShareAmount == 0)) | |
555 | + | then (baseEntry ++ [Reissue(SWOP, protocolReward, true), ScriptTransfer(moneyBoxAddress, protocolReward, SWOP)]) | |
556 | + | else if ((shareToken >= pmtAmount)) | |
557 | + | then baseEntry | |
558 | + | else throw(("Your maximum share token is " + toString(shareToken))) | |
559 | + | else throw("You can't share token") | |
560 | + | } | |
561 | + | else throw("Your amount of token less than 0") | |
562 | + | } | |
563 | + | else baseEntry | |
564 | + | else throw("Strict value is not equal to itself.") | |
565 | + | } | |
566 | + | ||
567 | + | ||
568 | + | ||
569 | + | @Callable(i) | |
570 | + | func withdrawShareTokens (pool,shareTokensWithdrawAmount) = { | |
571 | + | let shareTokensId = fromBase58String(getStringValue(value(addressFromString(pool)), "share_asset_id")) | |
572 | + | let $t02331623427 = claimCalc(pool, i.originCaller, 1) | |
573 | + | let userNewInterest = $t02331623427._1 | |
574 | + | let currentInterest = $t02331623427._2 | |
575 | + | let claimAmount = $t02331623427._3 | |
576 | + | let userShareTokensAmount = $t02331623427._4 | |
577 | + | let userShareAmountNew = (userShareTokensAmount - shareTokensWithdrawAmount) | |
578 | + | let availableFundsNew = (userAvailableSWOP(pool, i.originCaller) + claimAmount) | |
579 | + | let totalShareAmount = getTotalShareTokenLocked(pool) | |
580 | + | let totalShareAmountNew = (totalShareAmount - shareTokensWithdrawAmount) | |
581 | + | let userClaimedAmount = getUserSWOPClaimedAmount(pool, i.originCaller) | |
582 | + | let userClaimedAmountNew = (userClaimedAmount + claimAmount) | |
583 | + | if ((shareTokensWithdrawAmount > userShareTokensAmount)) | |
584 | + | then throw("Withdraw amount more then user locked amount") | |
585 | + | else if (!(isActive)) | |
586 | + | then throw("DApp is inactive at this moment") | |
587 | + | else if ((shareTokensWithdrawAmount > userShareTokensAmount)) | |
588 | + | then throw("Withdraw amount more then user locked amount") | |
589 | + | else if ((fraction(99, (accountBalance(shareTokensId) - shareTokensWithdrawAmount), 100) > totalShareAmountNew)) | |
590 | + | then throw("Balance of share-token is greater than totalAmount") | |
591 | + | else { | |
592 | + | let uplp = if ((getString(Address(fromBase58String(pool)), "version") == "3.0.0")) | |
593 | + | then invoke(lpFarmingAddress, "updateUserInterest", [userShareAmountNew], nil) | |
594 | + | else 0 | |
595 | + | if ((uplp == uplp)) | |
596 | + | then [IntegerEntry((((pool + "_") + toString(i.originCaller)) + keyUserLastInterest), userNewInterest), IntegerEntry((((pool + "_") + toString(i.originCaller)) + keyUserShareTokensLocked), userShareAmountNew), IntegerEntry((pool + keyLastInterest), currentInterest), IntegerEntry((pool + keyLastInterestHeight), height), IntegerEntry((pool + keyShareTokensLocked), totalShareAmountNew), IntegerEntry((((pool + "_") + toString(i.originCaller)) + keyAvailableSWOP), availableFundsNew), IntegerEntry((((pool + "_") + toString(i.originCaller)) + keyUserSWOPClaimedAmount), userClaimedAmountNew), IntegerEntry((((pool + "_") + toString(i.originCaller)) + keyUserSWOPLastClaimedAmount), claimAmount), ScriptTransfer(i.caller, shareTokensWithdrawAmount, shareTokensId)] | |
597 | + | else throw("Strict value is not equal to itself.") | |
598 | + | } | |
599 | + | } | |
600 | + | ||
601 | + | ||
602 | + | ||
603 | + | @Callable(i) | |
604 | + | func claim (pool) = { | |
605 | + | let shareTokensId = fromBase58String(getStringValue(value(addressFromString(pool)), "share_asset_id")) | |
606 | + | let shareTokenLocked = getTotalShareTokenLocked(pool) | |
607 | + | let $t02568925755 = getLastInterestInfo(pool) | |
608 | + | let lastInterestHeight = $t02568925755._1 | |
609 | + | let lastInterest = $t02568925755._2 | |
610 | + | let $t02576025874 = rewardInfo(pool) | |
611 | + | let currentRewardPerBlock = $t02576025874._1 | |
612 | + | let rewardUpdateHeight = $t02576025874._2 | |
613 | + | let previousRewardPerBlock = $t02576025874._3 | |
614 | + | let poolRewardUpdateHeight = $t02576025874._4 | |
615 | + | let $t02587925984 = claimCalc(pool, i.caller, 1) | |
616 | + | let userNewInterest = $t02587925984._1 | |
617 | + | let currentInterest = $t02587925984._2 | |
618 | + | let claimAmount = $t02587925984._3 | |
619 | + | let userShareTokensAmount = $t02587925984._4 | |
620 | + | let availableFund = (userAvailableSWOP(pool, i.caller) + claimAmount) | |
621 | + | let userClaimedAmount = getUserSWOPClaimedAmount(pool, i.caller) | |
622 | + | let userClaimedAmountNew = (userClaimedAmount + claimAmount) | |
623 | + | if ((availableFund == 0)) | |
624 | + | then throw("You have 0 available SWOP") | |
625 | + | else if (!(isActive)) | |
626 | + | then throw("DApp is inactive at this moment") | |
627 | + | else if ((availableFund == 0)) | |
628 | + | then throw("You have 0 available SWOP") | |
629 | + | else if ((fraction(99, accountBalance(shareTokensId), 100) > shareTokenLocked)) | |
630 | + | then throw("Balance of share-token is greater than totalAmount") | |
631 | + | else [IntegerEntry((((pool + "_") + toString(i.caller)) + keyUserLastInterest), userNewInterest), IntegerEntry((pool + keyLastInterest), currentInterest), IntegerEntry((pool + keyLastInterestHeight), height), IntegerEntry((((pool + "_") + toString(i.caller)) + keyAvailableSWOP), 0), Reissue(SWOP, availableFund, true), IntegerEntry((((pool + "_") + toString(i.caller)) + keyUserSWOPClaimedAmount), userClaimedAmountNew), IntegerEntry((((pool + "_") + toString(i.caller)) + keyUserSWOPLastClaimedAmount), claimAmount), ScriptTransfer(i.caller, availableFund, SWOP)] | |
632 | + | } | |
633 | + | ||
634 | + | ||
635 | + | ||
636 | + | @Callable(i) | |
637 | + | func shutdown () = if (!(isActive)) | |
638 | + | then throw(("DApp is already suspended. Cause: " + valueOrElse(getString(this, keyCause), "the cause wasn't specified"))) | |
639 | + | else if (!(containsElement([adminPubKey1, adminPubKey2, adminPubKey3], i.callerPublicKey))) | |
640 | + | then throw("Only admin can call this function") | |
641 | + | else suspend("Paused by admin") | |
642 | + | ||
643 | + | ||
644 | + | ||
645 | + | @Callable(i) | |
646 | + | func activate () = if (isActive) | |
647 | + | then throw("DApp is already active") | |
648 | + | else if (!(containsElement([adminPubKey1, adminPubKey2, adminPubKey3], i.callerPublicKey))) | |
649 | + | then throw("Only admin can call this function") | |
650 | + | else [BooleanEntry(keyActive, true), DeleteEntry(keyCause)] | |
299 | 651 | ||
300 | 652 | ||
301 | 653 | @Verifier(tx) | |
302 | - | func verify () = { | |
303 | - | | |
654 | + | func verify () = match tx { | |
655 | + | case _ => | |
304 | 656 | let adminPubKey1Signed = if (sigVerify(tx.bodyBytes, tx.proofs[0], adminPubKey1)) | |
305 | 657 | then 1 | |
306 | 658 | else 0 | |
311 | 663 | then 1 | |
312 | 664 | else 0 | |
313 | 665 | (((adminPubKey1Signed + adminPubKey2Signed) + adminPubKey3Signed) >= 2) | |
314 | - | } | |
315 | - | match tx { | |
316 | - | case _ => | |
317 | - | multiSignedByAdmins | |
318 | - | } | |
319 | - | } | |
666 | + | } | |
320 | 667 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let | |
4 | + | let keyShareTokensLocked = "_total_share_tokens_locked" | |
5 | 5 | ||
6 | - | let | |
6 | + | let kShareLimit = "share_limit_on_first_harvest" | |
7 | 7 | ||
8 | - | let | |
8 | + | let keyActive = "active" | |
9 | 9 | ||
10 | - | let | |
10 | + | let keyCause = "shutdown_cause" | |
11 | 11 | ||
12 | - | let | |
12 | + | let keyRewardPoolFractionCurrent = "_current_pool_fraction_reward" | |
13 | 13 | ||
14 | - | let | |
14 | + | let keyRewardPoolFractionPrevious = "_previous_pool_fraction_reward" | |
15 | 15 | ||
16 | - | let kRoutingFee = "routing_fee" | |
16 | + | let keyHeightPoolFraction = "_pool_reward_update_height" | |
17 | + | ||
18 | + | let keyTotalRewardPerBlockCurrent = "total_reward_per_block_current" | |
19 | + | ||
20 | + | let keyTotalRewardPerBlockPrevious = "total_reward_per_block_previous" | |
21 | + | ||
22 | + | let keyRewardUpdateHeight = "reward_update_height" | |
23 | + | ||
24 | + | let keyLastInterest = "_last_interest" | |
25 | + | ||
26 | + | let keyLastInterestHeight = "_last_interest_height" | |
27 | + | ||
28 | + | let keyUserShareTokensLocked = "_share_tokens_locked" | |
29 | + | ||
30 | + | let keyUserLastInterest = "_last_interest" | |
31 | + | ||
32 | + | let keySWOPid = "SWOP_id" | |
33 | + | ||
34 | + | let keyUserSWOPClaimedAmount = "_SWOP_claimed_amount" | |
35 | + | ||
36 | + | let keyUserSWOPLastClaimedAmount = "_SWOP_last_claimed_amount" | |
37 | + | ||
38 | + | let keyAvailableSWOP = "_available_SWOP" | |
39 | + | ||
40 | + | let keyFarmingStartHeight = "farming_start_height" | |
41 | + | ||
42 | + | let keyAPY = "apy" | |
43 | + | ||
44 | + | let kPreviousTotalVoteSWOP = "previous_total_vote_SWOP" | |
45 | + | ||
46 | + | let keySwopYearEmission = "swop_year_emission" | |
47 | + | ||
48 | + | let keyBalancecpmmA = "A_asset_balance" | |
49 | + | ||
50 | + | let keyBalancecpmmB = "B_asset_balance" | |
51 | + | ||
52 | + | let kHarvestPoolActiveVoteStrucVoting = "_harvest_pool_activeVote_struc" | |
53 | + | ||
54 | + | let kHarvestUserPoolActiveVoteStrucVoting = "_harvest_user_pool_activeVote_struc" | |
55 | + | ||
56 | + | let keyLimitShareFirstHarvest = "share_limit_on_first_harvest" | |
57 | + | ||
58 | + | let keyAssetIdA = "A_asset_id" | |
59 | + | ||
60 | + | let keyAssetIdB = "B_asset_id" | |
61 | + | ||
62 | + | let keyFirstHarvestHeight = "first_harvest_height" | |
63 | + | ||
64 | + | let keyfirstHarvestCpmm = "first_harvest" | |
65 | + | ||
66 | + | let keyTempPrevSum = "sum_reward_previous" | |
67 | + | ||
68 | + | let keyTempCurSum = "sum_reward_current" | |
69 | + | ||
70 | + | let oneWeekInBlock = 10106 | |
71 | + | ||
72 | + | let totalVoteShare = 10000000000 | |
73 | + | ||
74 | + | let scaleValue1 = 10 | |
75 | + | ||
76 | + | let scaleValue3 = 1000 | |
77 | + | ||
78 | + | let scaleValue5 = 100000 | |
79 | + | ||
80 | + | let scaleValue6 = 1000000 | |
81 | + | ||
82 | + | let scaleValue8 = 100000000 | |
83 | + | ||
84 | + | let scaleValue11 = 100000000000 | |
17 | 85 | ||
18 | 86 | let kAdminPubKey1 = "admin_pub_1" | |
19 | 87 | ||
20 | 88 | let kAdminPubKey2 = "admin_pub_2" | |
21 | 89 | ||
22 | 90 | let kAdminPubKey3 = "admin_pub_3" | |
23 | 91 | ||
92 | + | let kAdminInvokePubKey = "admin_invoke_pub" | |
93 | + | ||
24 | 94 | let kMoneyBoxAddress = "money_box_address" | |
95 | + | ||
96 | + | let kVotingAddress = "voting_address" | |
25 | 97 | ||
26 | 98 | let kGovAddress = "governance_address" | |
27 | 99 | ||
28 | - | let kFee = "commission" | |
29 | - | ||
30 | - | let kMultyAssetBalance = "_balance" | |
31 | - | ||
32 | - | let digits8 = 8 | |
33 | - | ||
34 | - | let scale8 = 100000000 | |
35 | - | ||
36 | - | let scale16 = 10000000000000000 | |
37 | - | ||
38 | - | let alpha = 50 | |
39 | - | ||
40 | - | let alphaDigits = 2 | |
41 | - | ||
42 | - | let beta = 4600000000000000 | |
100 | + | let kLPFarmingAddress = "lp_farming" | |
43 | 101 | ||
44 | 102 | let oracle = Address(base58'3NBBWfzZtZtszaXbitTKnrB2xXwv26Bn7H9') | |
45 | 103 | ||
46 | 104 | func getBase58FromOracle (key) = match getString(oracle, key) { | |
47 | 105 | case string: String => | |
48 | 106 | fromBase58String(string) | |
49 | 107 | case nothing => | |
50 | 108 | throw((key + "is empty")) | |
51 | 109 | } | |
52 | 110 | ||
53 | 111 | ||
54 | 112 | let adminPubKey1 = getBase58FromOracle(kAdminPubKey1) | |
55 | 113 | ||
56 | 114 | let adminPubKey2 = getBase58FromOracle(kAdminPubKey2) | |
57 | 115 | ||
58 | 116 | let adminPubKey3 = getBase58FromOracle(kAdminPubKey3) | |
59 | 117 | ||
60 | 118 | let moneyBoxAddress = Address(getBase58FromOracle(kMoneyBoxAddress)) | |
61 | 119 | ||
120 | + | let votingAddress = Address(getBase58FromOracle(kVotingAddress)) | |
121 | + | ||
62 | 122 | let govAddress = Address(getBase58FromOracle(kGovAddress)) | |
63 | 123 | ||
64 | - | let | |
124 | + | let adminInvokePubKey = getBase58FromOracle(kAdminInvokePubKey) | |
65 | 125 | ||
66 | - | let | |
126 | + | let lpFarmingAddress = Address(getBase58FromOracle(kLPFarmingAddress)) | |
67 | 127 | ||
68 | - | let feeScale6 = 1000000 | |
69 | - | ||
70 | - | func isActive () = if (active) | |
71 | - | then unit | |
72 | - | else throw("DApp is inactive at this moment") | |
128 | + | func strAssetIdA (pool) = getStringValue(pool, keyAssetIdA) | |
73 | 129 | ||
74 | 130 | ||
75 | - | func isAdminCall (i) = if (containsElement([adminPubKey1, adminPubKey2, adminPubKey3], i.callerPublicKey)) | |
76 | - | then unit | |
77 | - | else throw("Only admin can call this function") | |
131 | + | func strAssetIdB (pool) = getStringValue(pool, keyAssetIdB) | |
78 | 132 | ||
79 | 133 | ||
80 | - | func throwIsActive () = throw("DApp is already active") | |
134 | + | func assetIdA (pool) = if ((strAssetIdA(pool) == "WAVES")) | |
135 | + | then unit | |
136 | + | else fromBase58String(strAssetIdA(pool)) | |
81 | 137 | ||
82 | 138 | ||
83 | - | func suspend (cause) = [BooleanEntry(kActive, false), StringEntry(kCause, cause)] | |
139 | + | func assetIdB (pool) = if ((strAssetIdB(pool) == "WAVES")) | |
140 | + | then unit | |
141 | + | else fromBase58String(strAssetIdB(pool)) | |
84 | 142 | ||
85 | 143 | ||
86 | - | func skewness (x,y) = ((fraction(scale16, x, y) + fraction(scale16, y, x)) / 2) | |
144 | + | let kBasePeriod = "base_period" | |
145 | + | ||
146 | + | let kPeriodLength = "period_length" | |
147 | + | ||
148 | + | let kStartHeight = "start_height" | |
149 | + | ||
150 | + | let kFirstHarvestHeight = "first_harvest_height" | |
151 | + | ||
152 | + | let kDurationFullVotePower = "duration_full_vote_power" | |
153 | + | ||
154 | + | let kMinVotePower = "min_vote_power" | |
155 | + | ||
156 | + | let basePeriod = valueOrErrorMessage(getInteger(votingAddress, kBasePeriod), "Empty kBasePeriod") | |
157 | + | ||
158 | + | let startHeight = valueOrErrorMessage(getInteger(votingAddress, kStartHeight), "Empty kStartHeight") | |
159 | + | ||
160 | + | let periodLength = valueOrErrorMessage(getInteger(votingAddress, kPeriodLength), "Empty kPeriodLength") | |
161 | + | ||
162 | + | let durationFullVotePower = valueOrErrorMessage(getInteger(votingAddress, kDurationFullVotePower), "Empty kDurationFullVotePower") | |
163 | + | ||
164 | + | let minVotePower = valueOrErrorMessage(getInteger(votingAddress, kMinVotePower), "Empty kMinVotePower") | |
165 | + | ||
166 | + | let isActive = getBooleanValue(this, keyActive) | |
167 | + | ||
168 | + | let currPeriod = (basePeriod + ((height - startHeight) / periodLength)) | |
169 | + | ||
170 | + | func getLimitToken (pool) = valueOrElse(getIntegerValue(pool, keyLimitShareFirstHarvest), 0) | |
87 | 171 | ||
88 | 172 | ||
89 | - | func invariantCalc (x,y) = { | |
90 | - | let sk = skewness(x, y) | |
91 | - | (fraction((x + y), scale16, pow(sk, digits8, alpha, alphaDigits, digits8, CEILING)) + (2 * fraction(toInt(pow(fraction(toBigInt(x), toBigInt(y), toBigInt(scale8)), 0, toBigInt(5), 1, (digits8 / 2), DOWN)), pow((sk - beta), digits8, alpha, alphaDigits, digits8, DOWN), scale8))) | |
173 | + | let APY = getIntegerValue(this, keyAPY) | |
174 | + | ||
175 | + | let SwopYearEmission = getIntegerValue(this, keySwopYearEmission) | |
176 | + | ||
177 | + | func assetNameA (pool) = match assetIdA(pool) { | |
178 | + | case id: ByteVector => | |
179 | + | value(assetInfo(id)).name | |
180 | + | case waves: Unit => | |
181 | + | "WAVES" | |
182 | + | case _ => | |
183 | + | throw("Match error") | |
184 | + | } | |
185 | + | ||
186 | + | ||
187 | + | func assetNameB (pool) = match assetIdB(pool) { | |
188 | + | case id: ByteVector => | |
189 | + | value(assetInfo(id)).name | |
190 | + | case waves: Unit => | |
191 | + | "WAVES" | |
192 | + | case _ => | |
193 | + | throw("Match error") | |
194 | + | } | |
195 | + | ||
196 | + | ||
197 | + | let SWOP = fromBase58String(getStringValue(this, keySWOPid)) | |
198 | + | ||
199 | + | func isFirstHarvest (pool) = valueOrElse(getBoolean(pool, keyfirstHarvestCpmm), false) | |
200 | + | ||
201 | + | ||
202 | + | func getHeightFirstHarvest (pool) = valueOrElse(getInteger(pool, keyFirstHarvestHeight), 0) | |
203 | + | ||
204 | + | ||
205 | + | func getBalanceA (pool) = valueOrErrorMessage(getInteger(pool, keyBalancecpmmA), ("No data on the key: " + keyBalancecpmmA)) | |
206 | + | ||
207 | + | ||
208 | + | func getBalanceB (pool) = valueOrErrorMessage(getInteger(pool, keyBalancecpmmB), ("No data on the key: " + keyBalancecpmmB)) | |
209 | + | ||
210 | + | ||
211 | + | func getShareLimitToken (pool) = valueOrErrorMessage(getInteger(pool, kShareLimit), ("No data on the key: " + kShareLimit)) | |
212 | + | ||
213 | + | ||
214 | + | func getTotalShareTokenLocked (pool) = valueOrErrorMessage(getInteger(this, (pool + keyShareTokensLocked)), (("No data on the key: " + pool) + keyShareTokensLocked)) | |
215 | + | ||
216 | + | ||
217 | + | func getShareAssetId (pool) = fromBase58String(getStringValue(value(addressFromString(pool)), "share_asset_id")) | |
218 | + | ||
219 | + | ||
220 | + | func accountBalance (assetId) = match assetId { | |
221 | + | case id: ByteVector => | |
222 | + | assetBalance(this, id) | |
223 | + | case waves: Unit => | |
224 | + | wavesBalance(this).available | |
225 | + | case _ => | |
226 | + | throw("Match error") | |
227 | + | } | |
228 | + | ||
229 | + | ||
230 | + | func getAssetInfo (assetId) = match assetId { | |
231 | + | case id: ByteVector => | |
232 | + | let stringId = toBase58String(id) | |
233 | + | let info = valueOrErrorMessage(assetInfo(id), (("Asset " + stringId) + " doesn't exist")) | |
234 | + | $Tuple3(stringId, info.name, info.decimals) | |
235 | + | case waves: Unit => | |
236 | + | $Tuple3("WAVES", "WAVES", 8) | |
237 | + | case _ => | |
238 | + | throw("Match error") | |
239 | + | } | |
240 | + | ||
241 | + | ||
242 | + | func calcScaleValue (assetId1,assetId2) = { | |
243 | + | let assetId1Decimals = value(assetInfo(assetId1)).decimals | |
244 | + | let assetId2Decimals = value(assetInfo(assetId2)).decimals | |
245 | + | let scaleDigits = ((assetId2Decimals - assetId1Decimals) + 8) | |
246 | + | pow(10, 0, scaleDigits, 0, 0, DOWN) | |
92 | 247 | } | |
93 | 248 | ||
94 | 249 | ||
95 | - | func calculateFeeDiscount (userAddr) = { | |
96 | - | let swopAmount = valueOrElse(getInteger(govAddress, (toString(userAddr) + kUserSwopInGov)), 0) | |
97 | - | let discountValues = split(getStringValue(oracle, kDiscountValues), ",") | |
98 | - | let discounts = split(getStringValue(oracle, kDiscounts), ",") | |
99 | - | if (if ((swopAmount >= parseIntValue(discountValues[0]))) | |
100 | - | then (parseIntValue(discountValues[1]) > swopAmount) | |
101 | - | else false) | |
102 | - | then (feeScale6 - parseIntValue(discounts[0])) | |
103 | - | else if (if ((swopAmount >= parseIntValue(discountValues[1]))) | |
104 | - | then (parseIntValue(discountValues[2]) > swopAmount) | |
105 | - | else false) | |
106 | - | then (feeScale6 - parseIntValue(discounts[1])) | |
107 | - | else if (if ((swopAmount >= parseIntValue(discountValues[2]))) | |
108 | - | then (parseIntValue(discountValues[3]) > swopAmount) | |
109 | - | else false) | |
110 | - | then (feeScale6 - parseIntValue(discounts[2])) | |
111 | - | else if (if ((swopAmount >= parseIntValue(discountValues[3]))) | |
112 | - | then (parseIntValue(discountValues[4]) > swopAmount) | |
113 | - | else false) | |
114 | - | then (feeScale6 - parseIntValue(discounts[3])) | |
115 | - | else if ((swopAmount >= parseIntValue(discountValues[4]))) | |
116 | - | then (feeScale6 - parseIntValue(discounts[4])) | |
117 | - | else feeScale6 | |
250 | + | func userAvailableSWOP (pool,user) = valueOrElse(getInteger(this, (((pool + "_") + toString(user)) + keyAvailableSWOP)), 0) | |
251 | + | ||
252 | + | ||
253 | + | func rewardInfo (pool) = { | |
254 | + | let totalRewardPerBlockCurrent = valueOrErrorMessage(getInteger(govAddress, keyTotalRewardPerBlockCurrent), ((("No data on the key: " + keyTotalRewardPerBlockCurrent) + " at address ") + toString(govAddress))) | |
255 | + | let totalRewardPerBlockPrevious = valueOrErrorMessage(getInteger(govAddress, keyTotalRewardPerBlockPrevious), ((("No data on the key: " + keyTotalRewardPerBlockPrevious) + " at address ") + toString(govAddress))) | |
256 | + | let rewardPoolFractionCurrent = valueOrErrorMessage(getInteger(govAddress, (pool + keyRewardPoolFractionCurrent)), (((("No data on the key: " + pool) + keyRewardPoolFractionCurrent) + " at address ") + toString(govAddress))) | |
257 | + | let rewardUpdateHeight = valueOrErrorMessage(getInteger(govAddress, keyRewardUpdateHeight), ((("No data on the key: " + keyRewardUpdateHeight) + " at address ") + toString(govAddress))) | |
258 | + | let poolRewardUpdateHeight = valueOrElse(getInteger(govAddress, (pool + keyHeightPoolFraction)), 0) | |
259 | + | let rewardPoolFractionPrevious = valueOrErrorMessage(getInteger(govAddress, (pool + keyRewardPoolFractionPrevious)), (((("No data on the key: " + pool) + keyRewardPoolFractionPrevious) + " at address ") + toString(govAddress))) | |
260 | + | let rewardPoolCurrent = fraction(totalRewardPerBlockCurrent, rewardPoolFractionCurrent, totalVoteShare) | |
261 | + | let rewardPoolPrevious = fraction(totalRewardPerBlockPrevious, rewardPoolFractionPrevious, totalVoteShare) | |
262 | + | if (if ((rewardPoolCurrent > totalRewardPerBlockCurrent)) | |
263 | + | then true | |
264 | + | else (rewardPoolPrevious > totalRewardPerBlockPrevious)) | |
265 | + | then throw("rewardPoolCurrent > totalRewardPerBlockCurrent or rewardPoolPrevious > totalRewardPerBlockPrevious") | |
266 | + | else $Tuple4(rewardPoolCurrent, rewardUpdateHeight, rewardPoolPrevious, poolRewardUpdateHeight) | |
118 | 267 | } | |
119 | 268 | ||
120 | 269 | ||
121 | - | func checkPossibility (caller,pmtAmount,minAmountToReceive,exchangers,exchangersType,routingAssetsKeys,args1,args2) = { | |
122 | - | let feeDiscount = calculateFeeDiscount(caller) | |
123 | - | let getFrom1TradeWithFee = if ((exchangersType[0] == "curveMultyFlat")) | |
124 | - | then { | |
125 | - | let inv = { | |
126 | - | let @ = invoke(addressFromStringValue(exchangers[0]), "getDy", [routingAssetsKeys[0], routingAssetsKeys[1], pmtAmount, toString(caller)], nil) | |
127 | - | if ($isInstanceOf(@, "(Int, Int)")) | |
128 | - | then @ | |
129 | - | else throw(($getType(invoke(addressFromStringValue(exchangers[0]), "getDy", [routingAssetsKeys[0], routingAssetsKeys[1], pmtAmount, toString(caller)], nil)) + " couldn't be cast to (Int, Int)")) | |
130 | - | } | |
131 | - | if ((inv == inv)) | |
132 | - | then inv._1 | |
133 | - | else throw("Strict value is not equal to itself.") | |
134 | - | } | |
135 | - | else { | |
136 | - | let dApp1TokenPay = getIntegerValue(addressFromStringValue(exchangers[0]), routingAssetsKeys[0]) | |
137 | - | let dApp1TokenGet = getIntegerValue(addressFromStringValue(exchangers[0]), routingAssetsKeys[1]) | |
138 | - | if ((exchangersType[0] == "cpmm")) | |
139 | - | then { | |
140 | - | let fee = getIntegerValue(addressFromStringValue(exchangers[0]), kFee) | |
141 | - | let getFrom1TradeWithoutFee = fraction(dApp1TokenGet, pmtAmount, (pmtAmount + dApp1TokenPay)) | |
142 | - | fraction(getFrom1TradeWithoutFee, (feeScale6 - fraction(fee, feeDiscount, feeScale6)), feeScale6) | |
143 | - | } | |
144 | - | else if ((exchangersType[0] == "flat")) | |
145 | - | then { | |
146 | - | let invariant = invariantCalc(dApp1TokenPay, dApp1TokenGet) | |
147 | - | let minAmountToReceive1 = args2[0] | |
148 | - | let invariantNew = invariantCalc((dApp1TokenPay + pmtAmount), (dApp1TokenGet - minAmountToReceive1)) | |
149 | - | if ((invariantNew >= invariant)) | |
150 | - | then minAmountToReceive1 | |
151 | - | else throw("Flat contract: invariantNew < invariant") | |
152 | - | } | |
153 | - | else throw("Incorrect exchange type") | |
154 | - | } | |
155 | - | let getFrom2TradeWithFee = if ((exchangersType[1] == "curveMultyFlat")) | |
156 | - | then { | |
157 | - | let inv = { | |
158 | - | let @ = invoke(addressFromStringValue(exchangers[1]), "getDy", [routingAssetsKeys[2], routingAssetsKeys[3], getFrom1TradeWithFee, toString(caller)], nil) | |
159 | - | if ($isInstanceOf(@, "(Int, Int)")) | |
160 | - | then @ | |
161 | - | else throw(($getType(invoke(addressFromStringValue(exchangers[1]), "getDy", [routingAssetsKeys[2], routingAssetsKeys[3], getFrom1TradeWithFee, toString(caller)], nil)) + " couldn't be cast to (Int, Int)")) | |
162 | - | } | |
163 | - | if ((inv == inv)) | |
164 | - | then inv._1 | |
165 | - | else throw("Strict value is not equal to itself.") | |
166 | - | } | |
167 | - | else { | |
168 | - | let dApp2TokenPay = getIntegerValue(addressFromStringValue(exchangers[1]), routingAssetsKeys[2]) | |
169 | - | let dApp2TokenGet = getIntegerValue(addressFromStringValue(exchangers[1]), routingAssetsKeys[3]) | |
170 | - | if ((exchangersType[1] == "cpmm")) | |
171 | - | then { | |
172 | - | let getFrom2TradeWithoutFee = fraction(dApp2TokenGet, getFrom1TradeWithFee, (getFrom1TradeWithFee + dApp2TokenPay)) | |
173 | - | let fee = getIntegerValue(addressFromStringValue(exchangers[1]), kFee) | |
174 | - | fraction(getFrom2TradeWithoutFee, (feeScale6 - fraction(fee, feeDiscount, feeScale6)), feeScale6) | |
175 | - | } | |
176 | - | else if ((exchangersType[1] == "flat")) | |
177 | - | then { | |
178 | - | let invariant = invariantCalc(dApp2TokenPay, dApp2TokenGet) | |
179 | - | let minAmountToReceive2 = args2[1] | |
180 | - | let invariantNew = invariantCalc((dApp2TokenPay + getFrom1TradeWithFee), (dApp2TokenGet - minAmountToReceive2)) | |
181 | - | if ((invariantNew >= invariant)) | |
182 | - | then minAmountToReceive2 | |
183 | - | else throw("Flat contract: invariantNew < invariant") | |
184 | - | } | |
185 | - | else throw("Incorrect exchange type") | |
186 | - | } | |
187 | - | (getFrom2TradeWithFee >= minAmountToReceive) | |
270 | + | func getLastInterestInfo (pool) = { | |
271 | + | let lastInterest = valueOrErrorMessage(getInteger(this, (pool + keyLastInterest)), (("No data on the key: " + pool) + keyLastInterest)) | |
272 | + | let lastInterestHeight = valueOrElse(getInteger(this, (pool + keyLastInterestHeight)), height) | |
273 | + | $Tuple2(lastInterestHeight, lastInterest) | |
188 | 274 | } | |
189 | 275 | ||
190 | 276 | ||
191 | - | ||
192 | - | ||
193 | - | let | |
194 | - | let | |
195 | - | let | |
196 | - | | |
197 | - | | |
198 | - | | |
199 | - | | |
200 | - | | |
201 | - | ||
202 | - | | |
203 | - | | |
204 | - | | |
205 | - | | |
206 | - | | |
207 | - | | |
208 | - | | |
209 | - | ||
210 | - | ||
211 | - | ||
212 | - | | |
213 | - | | |
214 | - | | |
215 | - | ||
216 | - | ||
217 | - | ||
218 | - | ||
219 | - | | |
220 | - | | |
221 | - | | |
222 | - | | |
223 | - | | |
224 | - | ||
225 | - | | |
226 | - | | |
227 | - | | |
228 | - | | |
229 | - | | |
230 | - | | |
231 | - | | |
232 | - | | |
233 | - | | |
234 | - | ||
235 | - | | |
236 | - | | |
237 | - | ||
238 | - | | |
239 | - | | |
240 | - | | |
241 | - | | |
242 | - | ||
243 | - | ||
244 | - | ||
245 | - | ||
246 | - | | |
247 | - | | |
248 | - | | |
249 | - | | |
250 | - | | |
251 | - | | |
252 | - | | |
253 | - | ||
254 | - | | |
255 | - | | |
256 | - | | |
257 | - | | |
277 | + | func getUserInterestInfo (pool,userAddress) = { | |
278 | + | let userLastInterest = getInteger(this, (((pool + "_") + toString(userAddress)) + keyUserLastInterest)) | |
279 | + | let userShare = getInteger(this, (((pool + "_") + toString(userAddress)) + keyUserShareTokensLocked)) | |
280 | + | let lastInterest = valueOrErrorMessage(getInteger(this, (pool + keyLastInterest)), (("No data on the key: " + pool) + keyLastInterest)) | |
281 | + | let userLastInterestValue = match userLastInterest { | |
282 | + | case userLastInterest: Int => | |
283 | + | userLastInterest | |
284 | + | case _ => | |
285 | + | lastInterest | |
286 | + | } | |
287 | + | let userShareTokensAmount = match userShare { | |
288 | + | case userShare: Int => | |
289 | + | userShare | |
290 | + | case _ => | |
291 | + | 0 | |
292 | + | } | |
293 | + | $Tuple2(userLastInterestValue, userShareTokensAmount) | |
294 | + | } | |
295 | + | ||
296 | + | ||
297 | + | func calcInterest (lastInterestHeight,rewardUpdateHeight,poolRewardUpdateHeight,lastInterest,currentRewardPerBlock,shareTokenLocked,previousRewardPerBlock,shareAssetId,scaleValue,pmtAmount) = if ((shareTokenLocked == 0)) | |
298 | + | then 0 | |
299 | + | else if ((poolRewardUpdateHeight != 0)) | |
300 | + | then if (if ((rewardUpdateHeight > height)) | |
301 | + | then (rewardUpdateHeight == poolRewardUpdateHeight) | |
302 | + | else false) | |
303 | + | then { | |
304 | + | let reward = (previousRewardPerBlock * (height - lastInterestHeight)) | |
305 | + | (lastInterest + fraction(reward, scaleValue, shareTokenLocked)) | |
306 | + | } | |
307 | + | else if (if ((height > rewardUpdateHeight)) | |
308 | + | then (rewardUpdateHeight != poolRewardUpdateHeight) | |
309 | + | else false) | |
310 | + | then { | |
311 | + | let reward = (previousRewardPerBlock * (height - lastInterestHeight)) | |
312 | + | (lastInterest + fraction(reward, scaleValue, shareTokenLocked)) | |
313 | + | } | |
314 | + | else if (if (if ((height > rewardUpdateHeight)) | |
315 | + | then (rewardUpdateHeight == poolRewardUpdateHeight) | |
316 | + | else false) | |
317 | + | then (lastInterestHeight > rewardUpdateHeight) | |
318 | + | else false) | |
319 | + | then { | |
320 | + | let reward = (currentRewardPerBlock * (height - lastInterestHeight)) | |
321 | + | (lastInterest + fraction(reward, scaleValue, shareTokenLocked)) | |
322 | + | } | |
323 | + | else { | |
324 | + | let rewardAfterLastInterestBeforeReawardUpdate = (previousRewardPerBlock * (rewardUpdateHeight - lastInterestHeight)) | |
325 | + | let interestAfterUpdate = (lastInterest + fraction(rewardAfterLastInterestBeforeReawardUpdate, scaleValue, shareTokenLocked)) | |
326 | + | let reward = (currentRewardPerBlock * (height - rewardUpdateHeight)) | |
327 | + | (interestAfterUpdate + fraction(reward, scaleValue, shareTokenLocked)) | |
328 | + | } | |
329 | + | else if ((rewardUpdateHeight > height)) | |
330 | + | then { | |
331 | + | let reward = (previousRewardPerBlock * (height - lastInterestHeight)) | |
332 | + | (lastInterest + fraction(reward, scaleValue, shareTokenLocked)) | |
333 | + | } | |
334 | + | else if ((lastInterestHeight > rewardUpdateHeight)) | |
335 | + | then { | |
336 | + | let reward = (currentRewardPerBlock * (height - lastInterestHeight)) | |
337 | + | (lastInterest + fraction(reward, scaleValue, shareTokenLocked)) | |
338 | + | } | |
339 | + | else { | |
340 | + | let rewardAfterLastInterestBeforeReawardUpdate = (previousRewardPerBlock * (rewardUpdateHeight - lastInterestHeight)) | |
341 | + | let interestAfterUpdate = (lastInterest + fraction(rewardAfterLastInterestBeforeReawardUpdate, scaleValue, shareTokenLocked)) | |
342 | + | let reward = (currentRewardPerBlock * (height - rewardUpdateHeight)) | |
343 | + | (interestAfterUpdate + fraction(reward, scaleValue, shareTokenLocked)) | |
258 | 344 | } | |
259 | 345 | ||
260 | - | let $t095349640 = { | |
261 | - | let $l = exchangers | |
262 | - | let $s = size($l) | |
263 | - | let $acc0 = $Tuple3(0, 0, base58'') | |
264 | - | func $f0_1 ($a,$i) = if (($i >= $s)) | |
265 | - | then $a | |
266 | - | else exchangeFold($a, $l[$i]) | |
267 | 346 | ||
268 | - | func $f0_2 ($a,$i) = if (($i >= $s)) | |
269 | - | then $a | |
270 | - | else throw("List size exceeds 3") | |
347 | + | func claimCalc (pool,caller,pmtAmount) = { | |
348 | + | let shareAssetId = getShareAssetId(pool) | |
349 | + | let scaleValue = calcScaleValue(SWOP, shareAssetId) | |
350 | + | let shareTokenLocked = getTotalShareTokenLocked(pool) | |
351 | + | let $t01352213587 = getLastInterestInfo(pool) | |
352 | + | let lastInterestHeight = $t01352213587._1 | |
353 | + | let lastInterest = $t01352213587._2 | |
354 | + | let $t01359213704 = rewardInfo(pool) | |
355 | + | let currentRewardPerBlock = $t01359213704._1 | |
356 | + | let rewardUpdateHeight = $t01359213704._2 | |
357 | + | let previousRewardPerBlock = $t01359213704._3 | |
358 | + | let poolRewardUpdateHeight = $t01359213704._4 | |
359 | + | let $t01370913788 = getUserInterestInfo(pool, caller) | |
360 | + | let userLastInterest = $t01370913788._1 | |
361 | + | let userShareTokensAmount = $t01370913788._2 | |
362 | + | let currentInterest = calcInterest(lastInterestHeight, rewardUpdateHeight, poolRewardUpdateHeight, lastInterest, currentRewardPerBlock, shareTokenLocked, previousRewardPerBlock, shareAssetId, scaleValue, pmtAmount) | |
363 | + | let claimAmount = fraction(userShareTokensAmount, (currentInterest - userLastInterest), scaleValue) | |
364 | + | let userNewInterest = currentInterest | |
365 | + | $Tuple4(userNewInterest, currentInterest, claimAmount, userShareTokensAmount) | |
366 | + | } | |
271 | 367 | ||
272 | - | $f0_2($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3) | |
368 | + | ||
369 | + | func calculateProtocolReward (pool) = { | |
370 | + | let $t01430614371 = getLastInterestInfo(pool) | |
371 | + | let lastInterestHeight = $t01430614371._1 | |
372 | + | let lastInterest = $t01430614371._2 | |
373 | + | let $t01437614487 = rewardInfo(pool) | |
374 | + | let currentRewardPerBlock = $t01437614487._1 | |
375 | + | let rewardUpdateHeight = $t01437614487._2 | |
376 | + | let previousRewardPerBlock = $t01437614487._3 | |
377 | + | let poolRewardUpdateHeight = $t01437614487._4 | |
378 | + | let shareTokenLocked = getTotalShareTokenLocked(pool) | |
379 | + | if (if ((shareTokenLocked == 0)) | |
380 | + | then (poolRewardUpdateHeight == 0) | |
381 | + | else false) | |
382 | + | then if ((rewardUpdateHeight > height)) | |
383 | + | then { | |
384 | + | let reward = (previousRewardPerBlock * (height - lastInterestHeight)) | |
385 | + | reward | |
386 | + | } | |
387 | + | else if ((lastInterestHeight > rewardUpdateHeight)) | |
388 | + | then { | |
389 | + | let reward = (currentRewardPerBlock * (height - lastInterestHeight)) | |
390 | + | reward | |
273 | 391 | } | |
274 | - | let exchangeCounter = $t095349640._1 | |
275 | - | let amountWithoutFee = $t095349640._2 | |
276 | - | let assetIdSend = $t095349640._3 | |
277 | - | let amountWithFee = fraction(amountWithoutFee, (feeScale6 - routingFee), feeScale6) | |
278 | - | if (if ((exchangeCounter == routingSize)) | |
279 | - | then (amountWithFee >= minAmountToReceive) | |
392 | + | else { | |
393 | + | let rewardAfterLastInterestBeforeReawardUpdate = (previousRewardPerBlock * (rewardUpdateHeight - lastInterestHeight)) | |
394 | + | let reward = (currentRewardPerBlock * (height - rewardUpdateHeight)) | |
395 | + | (reward + rewardAfterLastInterestBeforeReawardUpdate) | |
396 | + | } | |
397 | + | else if (if ((shareTokenLocked == 0)) | |
398 | + | then (poolRewardUpdateHeight != 0) | |
399 | + | else false) | |
400 | + | then if (if ((rewardUpdateHeight > height)) | |
401 | + | then (rewardUpdateHeight == poolRewardUpdateHeight) | |
402 | + | else false) | |
403 | + | then { | |
404 | + | let reward = (previousRewardPerBlock * (height - lastInterestHeight)) | |
405 | + | reward | |
406 | + | } | |
407 | + | else if (if ((height > rewardUpdateHeight)) | |
408 | + | then (rewardUpdateHeight != poolRewardUpdateHeight) | |
280 | 409 | else false) | |
281 | - | then [ScriptTransfer(i.caller, amountWithFee, assetIdSend), ScriptTransfer(moneyBoxAddress, (amountWithoutFee - amountWithFee), assetIdSend)] | |
282 | - | else throw("routing != routingSize or amountToRecieve < minAmountToReceive") | |
283 | - | } | |
284 | - | }) | |
410 | + | then { | |
411 | + | let reward = (previousRewardPerBlock * (height - lastInterestHeight)) | |
412 | + | reward | |
413 | + | } | |
414 | + | else if (if (if ((height > rewardUpdateHeight)) | |
415 | + | then (rewardUpdateHeight == poolRewardUpdateHeight) | |
416 | + | else false) | |
417 | + | then (lastInterestHeight > rewardUpdateHeight) | |
418 | + | else false) | |
419 | + | then { | |
420 | + | let reward = (currentRewardPerBlock * (height - lastInterestHeight)) | |
421 | + | reward | |
422 | + | } | |
423 | + | else { | |
424 | + | let rewardAfterLastInterestBeforeReawardUpdate = (previousRewardPerBlock * (rewardUpdateHeight - lastInterestHeight)) | |
425 | + | let reward = (currentRewardPerBlock * (height - rewardUpdateHeight)) | |
426 | + | (reward + rewardAfterLastInterestBeforeReawardUpdate) | |
427 | + | } | |
428 | + | else 0 | |
429 | + | } | |
430 | + | ||
431 | + | ||
432 | + | func checkPmtAssetIdCorrect (pool,pmtAssetId) = { | |
433 | + | let poolShareAssetId = fromBase58String(getStringValue(value(addressFromString(pool)), "share_asset_id")) | |
434 | + | if ((pmtAssetId == poolShareAssetId)) | |
435 | + | then true | |
436 | + | else false | |
437 | + | } | |
438 | + | ||
439 | + | ||
440 | + | func getUserSWOPClaimedAmount (pool,user) = valueOrElse(getInteger(this, (((pool + "_") + toString(user)) + keyUserSWOPClaimedAmount)), 0) | |
441 | + | ||
442 | + | ||
443 | + | func suspend (cause) = [BooleanEntry(keyActive, false), StringEntry(keyCause, cause)] | |
444 | + | ||
445 | + | ||
446 | + | @Callable(i) | |
447 | + | func init (earlyLP) = if (isDefined(getString(this, keySWOPid))) | |
448 | + | then throw("SWOP already initialized") | |
449 | + | else { | |
450 | + | let initAmount = 100000000000000 | |
451 | + | let SWOPissue = Issue("SWOP", "SWOP protocol token", initAmount, 8, true) | |
452 | + | let SWOPid = calculateAssetId(SWOPissue) | |
453 | + | [BooleanEntry(keyActive, true), Issue("SWOP", "SWOP protocol token", initAmount, 8, true), StringEntry(keySWOPid, toBase58String(SWOPid))] | |
454 | + | } | |
285 | 455 | ||
286 | 456 | ||
287 | 457 | ||
288 | 458 | @Callable(i) | |
289 | - | func shutdown () = valueOrElse(isAdminCall(i), if (!(active)) | |
290 | - | then throw(("DApp is already suspended. Cause: " + valueOrElse(getString(this, kCause), "the cause wasn't specified"))) | |
291 | - | else suspend("Paused by admin")) | |
459 | + | func initPoolShareFarming (pool) = if ((i.caller != this)) | |
460 | + | then throw("Only the DApp itself can call this function") | |
461 | + | else { | |
462 | + | let $t01746917572 = rewardInfo(pool) | |
463 | + | let currentReward = $t01746917572._1 | |
464 | + | let rewardUpdateHeight = $t01746917572._2 | |
465 | + | let previousRewardPerBlock = $t01746917572._3 | |
466 | + | let poolRewardUpdateHeight = $t01746917572._4 | |
467 | + | [IntegerEntry((pool + keyShareTokensLocked), 0), IntegerEntry((pool + keyLastInterest), 0), IntegerEntry((pool + keyLastInterestHeight), height)] | |
468 | + | } | |
292 | 469 | ||
293 | 470 | ||
294 | 471 | ||
295 | 472 | @Callable(i) | |
296 | - | func activate () = valueOrElse(isAdminCall(i), if (active) | |
297 | - | then throwIsActive() | |
298 | - | else [BooleanEntry(kActive, true), DeleteEntry(kCause)]) | |
473 | + | func updatePoolInterest (pool) = if ((i.caller != moneyBoxAddress)) | |
474 | + | then throw("Only the Admin itself can call this function") | |
475 | + | else if (!(isActive)) | |
476 | + | then throw("DApp is inactive at this moment") | |
477 | + | else { | |
478 | + | let $t01799018123 = claimCalc(pool, addressFromPublicKey(adminInvokePubKey), 0) | |
479 | + | let userNewInterest = $t01799018123._1 | |
480 | + | let currentInterest = $t01799018123._2 | |
481 | + | let claimAmount = $t01799018123._3 | |
482 | + | let userShareTokensAmount = $t01799018123._4 | |
483 | + | let $t01812818231 = rewardInfo(pool) | |
484 | + | let currentReward = $t01812818231._1 | |
485 | + | let rewardUpdateHeight = $t01812818231._2 | |
486 | + | let previousRewardPerBlock = $t01812818231._3 | |
487 | + | let poolRewardUpdateHeight = $t01812818231._4 | |
488 | + | [IntegerEntry((pool + keyLastInterest), userNewInterest), IntegerEntry((pool + keyLastInterestHeight), height)] | |
489 | + | } | |
490 | + | ||
491 | + | ||
492 | + | ||
493 | + | @Callable(i) | |
494 | + | func lockShareTokens (pool) = { | |
495 | + | let $t01842318498 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
496 | + | let pmtAmount = $t01842318498._1 | |
497 | + | let pmtAssetId = $t01842318498._2 | |
498 | + | let $t01850318576 = getAssetInfo(pmtAssetId) | |
499 | + | let pmtStrAssetId = $t01850318576._1 | |
500 | + | let pmtAssetName = $t01850318576._2 | |
501 | + | let pmtDecimals = $t01850318576._3 | |
502 | + | let $t01858118698 = claimCalc(pool, i.originCaller, pmtAmount) | |
503 | + | let userNewInterest = $t01858118698._1 | |
504 | + | let currentInterest = $t01858118698._2 | |
505 | + | let claimAmount = $t01858118698._3 | |
506 | + | let userShareTokensAmount = $t01858118698._4 | |
507 | + | let userShareAmountNew = (userShareTokensAmount + pmtAmount) | |
508 | + | let availableFundsNew = (userAvailableSWOP(pool, i.originCaller) + claimAmount) | |
509 | + | let totalShareAmount = getTotalShareTokenLocked(pool) | |
510 | + | let totalShareAmountNew = (totalShareAmount + pmtAmount) | |
511 | + | let userClaimedAmount = getUserSWOPClaimedAmount(pool, i.originCaller) | |
512 | + | let userClaimedAmountNew = (userClaimedAmount + claimAmount) | |
513 | + | let baseEntry = [IntegerEntry((((pool + "_") + toString(i.originCaller)) + keyUserLastInterest), userNewInterest), IntegerEntry((((pool + "_") + toString(i.originCaller)) + keyUserShareTokensLocked), userShareAmountNew), IntegerEntry((pool + keyShareTokensLocked), totalShareAmountNew), IntegerEntry((pool + keyLastInterest), currentInterest), IntegerEntry((pool + keyLastInterestHeight), height), IntegerEntry((((pool + "_") + toString(i.originCaller)) + keyUserSWOPClaimedAmount), userClaimedAmountNew), IntegerEntry((((pool + "_") + toString(i.originCaller)) + keyUserSWOPLastClaimedAmount), claimAmount), IntegerEntry((((pool + "_") + toString(i.originCaller)) + keyAvailableSWOP), availableFundsNew)] | |
514 | + | let uplp = if ((getString(Address(fromBase58String(pool)), "version") == "3.0.0")) | |
515 | + | then invoke(lpFarmingAddress, "updateUserInterest", [userShareAmountNew], nil) | |
516 | + | else 0 | |
517 | + | if ((uplp == uplp)) | |
518 | + | then if ((0 >= pmtAmount)) | |
519 | + | then throw("You can't lock token") | |
520 | + | else if (!(isActive)) | |
521 | + | then throw("DApp is inactive at this moment") | |
522 | + | else if (!(checkPmtAssetIdCorrect(pool, pmtAssetId))) | |
523 | + | then throw("Incorrect pmtAssetId") | |
524 | + | else if (if (isFirstHarvest(Address(fromBase58String(pool)))) | |
525 | + | then (getHeightFirstHarvest(Address(fromBase58String(pool))) > height) | |
526 | + | else false) | |
527 | + | then { | |
528 | + | let harvestPeriod = ((((getHeightFirstHarvest(Address(fromBase58String(pool))) - startHeight) + 1) / periodLength) - 1) | |
529 | + | let amountOfVoting = split(getStringValue(votingAddress, (((toString(i.originCaller) + "_") + pool) + "_user_pool_struc")), "_") | |
530 | + | let amountPoolStract = split(getStringValue(votingAddress, (pool + "_pool_struc")), "_") | |
531 | + | let amountActiveVoteUserPoolStract = split(valueOrElse(getString(votingAddress, (((toString(i.originCaller) + "_") + pool) + kHarvestUserPoolActiveVoteStrucVoting)), ""), "_") | |
532 | + | let amountPoolActiveVoteStract = split(valueOrElse(getString(votingAddress, (pool + kHarvestPoolActiveVoteStrucVoting)), ""), "_") | |
533 | + | let userShareTokenLocked = userShareTokensAmount | |
534 | + | let userPoolActiveVote = if ((toString(currPeriod) == amountOfVoting[2])) | |
535 | + | then valueOrElse(parseInt(amountActiveVoteUserPoolStract[0]), 0) | |
536 | + | else valueOrElse(parseInt(amountOfVoting[1]), 0) | |
537 | + | let poolActiveVote = if ((toString(currPeriod) == amountPoolStract[2])) | |
538 | + | then valueOrElse(parseInt(amountPoolActiveVoteStract[0]), 0) | |
539 | + | else valueOrElse(parseInt(amountPoolStract[1]), 0) | |
540 | + | let protocolReward = calculateProtocolReward(pool) | |
541 | + | if ((userPoolActiveVote != 0)) | |
542 | + | then { | |
543 | + | let limitShareToken = getShareLimitToken(addressFromStringValue(pool)) | |
544 | + | let shareToken = (fraction(limitShareToken, userPoolActiveVote, poolActiveVote) - userShareTokenLocked) | |
545 | + | if (if ((size(amountActiveVoteUserPoolStract) > 1)) | |
546 | + | then (valueOrElse(parseInt(amountActiveVoteUserPoolStract[1]), 0) >= harvestPeriod) | |
547 | + | else false) | |
548 | + | then throw("You can't share token") | |
549 | + | else if ((pmtAmount > limitShareToken)) | |
550 | + | then throw(("You can't share token more than " + toString(limitShareToken))) | |
551 | + | else if ((shareToken > 0)) | |
552 | + | then if ((fraction(99, (accountBalance(pmtAssetId) + pmtAmount), 100) > totalShareAmountNew)) | |
553 | + | then throw("Balance of share-token is greater than totalAmount") | |
554 | + | else if ((totalShareAmount == 0)) | |
555 | + | then (baseEntry ++ [Reissue(SWOP, protocolReward, true), ScriptTransfer(moneyBoxAddress, protocolReward, SWOP)]) | |
556 | + | else if ((shareToken >= pmtAmount)) | |
557 | + | then baseEntry | |
558 | + | else throw(("Your maximum share token is " + toString(shareToken))) | |
559 | + | else throw("You can't share token") | |
560 | + | } | |
561 | + | else throw("Your amount of token less than 0") | |
562 | + | } | |
563 | + | else baseEntry | |
564 | + | else throw("Strict value is not equal to itself.") | |
565 | + | } | |
566 | + | ||
567 | + | ||
568 | + | ||
569 | + | @Callable(i) | |
570 | + | func withdrawShareTokens (pool,shareTokensWithdrawAmount) = { | |
571 | + | let shareTokensId = fromBase58String(getStringValue(value(addressFromString(pool)), "share_asset_id")) | |
572 | + | let $t02331623427 = claimCalc(pool, i.originCaller, 1) | |
573 | + | let userNewInterest = $t02331623427._1 | |
574 | + | let currentInterest = $t02331623427._2 | |
575 | + | let claimAmount = $t02331623427._3 | |
576 | + | let userShareTokensAmount = $t02331623427._4 | |
577 | + | let userShareAmountNew = (userShareTokensAmount - shareTokensWithdrawAmount) | |
578 | + | let availableFundsNew = (userAvailableSWOP(pool, i.originCaller) + claimAmount) | |
579 | + | let totalShareAmount = getTotalShareTokenLocked(pool) | |
580 | + | let totalShareAmountNew = (totalShareAmount - shareTokensWithdrawAmount) | |
581 | + | let userClaimedAmount = getUserSWOPClaimedAmount(pool, i.originCaller) | |
582 | + | let userClaimedAmountNew = (userClaimedAmount + claimAmount) | |
583 | + | if ((shareTokensWithdrawAmount > userShareTokensAmount)) | |
584 | + | then throw("Withdraw amount more then user locked amount") | |
585 | + | else if (!(isActive)) | |
586 | + | then throw("DApp is inactive at this moment") | |
587 | + | else if ((shareTokensWithdrawAmount > userShareTokensAmount)) | |
588 | + | then throw("Withdraw amount more then user locked amount") | |
589 | + | else if ((fraction(99, (accountBalance(shareTokensId) - shareTokensWithdrawAmount), 100) > totalShareAmountNew)) | |
590 | + | then throw("Balance of share-token is greater than totalAmount") | |
591 | + | else { | |
592 | + | let uplp = if ((getString(Address(fromBase58String(pool)), "version") == "3.0.0")) | |
593 | + | then invoke(lpFarmingAddress, "updateUserInterest", [userShareAmountNew], nil) | |
594 | + | else 0 | |
595 | + | if ((uplp == uplp)) | |
596 | + | then [IntegerEntry((((pool + "_") + toString(i.originCaller)) + keyUserLastInterest), userNewInterest), IntegerEntry((((pool + "_") + toString(i.originCaller)) + keyUserShareTokensLocked), userShareAmountNew), IntegerEntry((pool + keyLastInterest), currentInterest), IntegerEntry((pool + keyLastInterestHeight), height), IntegerEntry((pool + keyShareTokensLocked), totalShareAmountNew), IntegerEntry((((pool + "_") + toString(i.originCaller)) + keyAvailableSWOP), availableFundsNew), IntegerEntry((((pool + "_") + toString(i.originCaller)) + keyUserSWOPClaimedAmount), userClaimedAmountNew), IntegerEntry((((pool + "_") + toString(i.originCaller)) + keyUserSWOPLastClaimedAmount), claimAmount), ScriptTransfer(i.caller, shareTokensWithdrawAmount, shareTokensId)] | |
597 | + | else throw("Strict value is not equal to itself.") | |
598 | + | } | |
599 | + | } | |
600 | + | ||
601 | + | ||
602 | + | ||
603 | + | @Callable(i) | |
604 | + | func claim (pool) = { | |
605 | + | let shareTokensId = fromBase58String(getStringValue(value(addressFromString(pool)), "share_asset_id")) | |
606 | + | let shareTokenLocked = getTotalShareTokenLocked(pool) | |
607 | + | let $t02568925755 = getLastInterestInfo(pool) | |
608 | + | let lastInterestHeight = $t02568925755._1 | |
609 | + | let lastInterest = $t02568925755._2 | |
610 | + | let $t02576025874 = rewardInfo(pool) | |
611 | + | let currentRewardPerBlock = $t02576025874._1 | |
612 | + | let rewardUpdateHeight = $t02576025874._2 | |
613 | + | let previousRewardPerBlock = $t02576025874._3 | |
614 | + | let poolRewardUpdateHeight = $t02576025874._4 | |
615 | + | let $t02587925984 = claimCalc(pool, i.caller, 1) | |
616 | + | let userNewInterest = $t02587925984._1 | |
617 | + | let currentInterest = $t02587925984._2 | |
618 | + | let claimAmount = $t02587925984._3 | |
619 | + | let userShareTokensAmount = $t02587925984._4 | |
620 | + | let availableFund = (userAvailableSWOP(pool, i.caller) + claimAmount) | |
621 | + | let userClaimedAmount = getUserSWOPClaimedAmount(pool, i.caller) | |
622 | + | let userClaimedAmountNew = (userClaimedAmount + claimAmount) | |
623 | + | if ((availableFund == 0)) | |
624 | + | then throw("You have 0 available SWOP") | |
625 | + | else if (!(isActive)) | |
626 | + | then throw("DApp is inactive at this moment") | |
627 | + | else if ((availableFund == 0)) | |
628 | + | then throw("You have 0 available SWOP") | |
629 | + | else if ((fraction(99, accountBalance(shareTokensId), 100) > shareTokenLocked)) | |
630 | + | then throw("Balance of share-token is greater than totalAmount") | |
631 | + | else [IntegerEntry((((pool + "_") + toString(i.caller)) + keyUserLastInterest), userNewInterest), IntegerEntry((pool + keyLastInterest), currentInterest), IntegerEntry((pool + keyLastInterestHeight), height), IntegerEntry((((pool + "_") + toString(i.caller)) + keyAvailableSWOP), 0), Reissue(SWOP, availableFund, true), IntegerEntry((((pool + "_") + toString(i.caller)) + keyUserSWOPClaimedAmount), userClaimedAmountNew), IntegerEntry((((pool + "_") + toString(i.caller)) + keyUserSWOPLastClaimedAmount), claimAmount), ScriptTransfer(i.caller, availableFund, SWOP)] | |
632 | + | } | |
633 | + | ||
634 | + | ||
635 | + | ||
636 | + | @Callable(i) | |
637 | + | func shutdown () = if (!(isActive)) | |
638 | + | then throw(("DApp is already suspended. Cause: " + valueOrElse(getString(this, keyCause), "the cause wasn't specified"))) | |
639 | + | else if (!(containsElement([adminPubKey1, adminPubKey2, adminPubKey3], i.callerPublicKey))) | |
640 | + | then throw("Only admin can call this function") | |
641 | + | else suspend("Paused by admin") | |
642 | + | ||
643 | + | ||
644 | + | ||
645 | + | @Callable(i) | |
646 | + | func activate () = if (isActive) | |
647 | + | then throw("DApp is already active") | |
648 | + | else if (!(containsElement([adminPubKey1, adminPubKey2, adminPubKey3], i.callerPublicKey))) | |
649 | + | then throw("Only admin can call this function") | |
650 | + | else [BooleanEntry(keyActive, true), DeleteEntry(keyCause)] | |
299 | 651 | ||
300 | 652 | ||
301 | 653 | @Verifier(tx) | |
302 | - | func verify () = { | |
303 | - | | |
654 | + | func verify () = match tx { | |
655 | + | case _ => | |
304 | 656 | let adminPubKey1Signed = if (sigVerify(tx.bodyBytes, tx.proofs[0], adminPubKey1)) | |
305 | 657 | then 1 | |
306 | 658 | else 0 | |
307 | 659 | let adminPubKey2Signed = if (sigVerify(tx.bodyBytes, tx.proofs[1], adminPubKey2)) | |
308 | 660 | then 1 | |
309 | 661 | else 0 | |
310 | 662 | let adminPubKey3Signed = if (sigVerify(tx.bodyBytes, tx.proofs[2], adminPubKey3)) | |
311 | 663 | then 1 | |
312 | 664 | else 0 | |
313 | 665 | (((adminPubKey1Signed + adminPubKey2Signed) + adminPubKey3Signed) >= 2) | |
314 | - | } | |
315 | - | match tx { | |
316 | - | case _ => | |
317 | - | multiSignedByAdmins | |
318 | - | } | |
319 | - | } | |
666 | + | } | |
320 | 667 |
github/deemru/w8io/169f3d6 111.62 ms ◑