tx · BCqh8ujXvQnQnAtCz4sNFA5PDjYBByjcx2eAdaY62kPk 3MvVH33KASni1qXr1BJhmuwPnYKmgwZBGaR: -0.02900000 Waves 2023.03.20 11:09 [2498075] smart account 3MvVH33KASni1qXr1BJhmuwPnYKmgwZBGaR > SELF 0.00000000 Waves
{ "type": 13, "id": "BCqh8ujXvQnQnAtCz4sNFA5PDjYBByjcx2eAdaY62kPk", "fee": 2900000, "feeAssetId": null, "timestamp": 1679299796533, "version": 2, "chainId": 84, "sender": "3MvVH33KASni1qXr1BJhmuwPnYKmgwZBGaR", "senderPublicKey": "2uEfkKMnD8wQeJcHwphftPPzFcaujs486fDaMuUyNT9w", "proofs": [ "2kRVD76HRj9e62YQbyWhrNEJfN2MgMMeYySxJawekCq1MJLQm7FXQnrdrdUaWDubhSYenjGCYHTax9uRNaXSpcKT" ], "script": "base64:BgIzCAISAwoBCBIAEgQKAgIBEgQKAgIBEgcKBQgICAgIEgASBAoCCAgSABIECgIICBIDCgEIQQAJc2VwYXJhdG9yAgJfXwASc2hhcmVBc3NldERlY2ltYWxzAAgAC3dhdmVzU3RyaW5nAgVXQVZFUwAHc2NhbGUxOACAgJC7utat8A0ADXNjYWxlMThCaWdJbnQJALYCAQUHc2NhbGUxOAEHd3JhcEVycgEDbXNnCQC5CQIJAMwIAgIWbHBfc3Rha2luZ19wb29scy5yaWRlOgkAzAgCBQNtc2cFA25pbAIBIAEIdGhyb3dFcnIBA21zZwkAAgEJAQd3cmFwRXJyAQUDbXNnARJlcnJLZXlJc05vdERlZmluZWQCB2FkZHJlc3MDa2V5CQEHd3JhcEVycgEJALkJAgkAzAgCAgptYW5kYXRvcnkgCQDMCAIJAKUIAQUHYWRkcmVzcwkAzAgCAgEuCQDMCAIFA2tleQkAzAgCAg8gaXMgbm90IGRlZmluZWQFA25pbAIAAQxnZXRTdHJPckZhaWwCB2FkZHJlc3MDa2V5CQETdmFsdWVPckVycm9yTWVzc2FnZQIJAJ0IAgUHYWRkcmVzcwUDa2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GsFByRtYXRjaDAFAnBrAwkAAQIFByRtYXRjaDACBFVuaXQIBQJ0eA9zZW5kZXJQdWJsaWNLZXkJAAIBAgtNYXRjaCBlcnJvcgkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAUPdGFyZ2V0UHVibGljS2V5lEvKcg==", "height": 2498075, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 4TfYGo5hWzJtLMsPkGW5Z8o8tu4cAwnEJBKBiSRgMEA3 Next: BfW7uvuiYv7ZhtadKk9QWfbFh287hZJWC11U6eTtnrQk Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let | |
4 | + | let separator = "__" | |
5 | 5 | ||
6 | - | let | |
6 | + | let shareAssetDecimals = 8 | |
7 | 7 | ||
8 | - | func getStringOrFail (key) = valueOrErrorMessage(getString(this, key), ("No data for this.key=" + key)) | |
8 | + | let wavesString = "WAVES" | |
9 | + | ||
10 | + | let scale18 = 1000000000000000000 | |
11 | + | ||
12 | + | let scale18BigInt = toBigInt(scale18) | |
13 | + | ||
14 | + | func wrapErr (msg) = makeString(["lp_staking_pools.ride:", msg], " ") | |
9 | 15 | ||
10 | 16 | ||
11 | - | ||
17 | + | func throwErr (msg) = throw(wrapErr(msg)) | |
12 | 18 | ||
13 | - | let poolNotExist = throw("Pool is not exist") | |
14 | 19 | ||
15 | - | let slippageTooBig = throw("Slippage is too big") | |
20 | + | func errKeyIsNotDefined (address,key) = wrapErr(makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
21 | + | ||
22 | + | ||
23 | + | func getStrOrFail (address,key) = valueOrErrorMessage(getString(address, key), errKeyIsNotDefined(address, key)) | |
24 | + | ||
25 | + | ||
26 | + | func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), errKeyIsNotDefined(address, key)) | |
27 | + | ||
28 | + | ||
29 | + | func parseAssetId (input) = if ((input == wavesString)) | |
30 | + | then unit | |
31 | + | else fromBase58String(input) | |
32 | + | ||
33 | + | ||
34 | + | func assetIdToString (input) = if ((input == unit)) | |
35 | + | then wavesString | |
36 | + | else toBase58String(value(input)) | |
37 | + | ||
38 | + | ||
39 | + | func ensurePositive (v) = if ((v >= 0)) | |
40 | + | then v | |
41 | + | else throwErr("value should be positive") | |
42 | + | ||
43 | + | ||
44 | + | func keyFactoryContract () = makeString(["%s", "factoryContract"], separator) | |
45 | + | ||
46 | + | ||
47 | + | func keyLpStakingContract () = makeString(["%s", "lpStakingContract"], separator) | |
48 | + | ||
49 | + | ||
50 | + | func keyStakingContract () = makeString(["%s", "stakingContract"], separator) | |
51 | + | ||
52 | + | ||
53 | + | func keyBoostingContract () = makeString(["%s", "boostingContract"], separator) | |
54 | + | ||
55 | + | ||
56 | + | func keySwapContract () = makeString(["%s", "swapContract"], separator) | |
57 | + | ||
58 | + | ||
59 | + | func keyAssetsStoreContract () = makeString(["%s", "assetsStoreContract"], separator) | |
60 | + | ||
61 | + | ||
62 | + | func keyUsdtAssetId () = makeString(["%s", "usdtAssetId"], separator) | |
63 | + | ||
64 | + | ||
65 | + | func keyWxAssetId () = makeString(["%s", "wxAssetId"], separator) | |
66 | + | ||
67 | + | ||
68 | + | func keyShutdown () = makeString(["%s", "shutdown"], separator) | |
69 | + | ||
70 | + | ||
71 | + | func keyMinDelay () = makeString(["%s", "minDelay"], separator) | |
72 | + | ||
73 | + | ||
74 | + | func keyLockFraction () = makeString(["%s", "lockFraction"], separator) | |
75 | + | ||
76 | + | ||
77 | + | func keyShareAssetId (baseAssetId) = makeString(["%s%s", assetIdToString(baseAssetId), "shareAssetId"], separator) | |
78 | + | ||
79 | + | ||
80 | + | func keyBaseAssetId (shareAssetId) = makeString(["%s%s", assetIdToString(shareAssetId), "baseAssetId"], separator) | |
81 | + | ||
82 | + | ||
83 | + | func keyPeriod (baseAssetId) = makeString(["%s%s", assetIdToString(baseAssetId), "period"], separator) | |
84 | + | ||
85 | + | ||
86 | + | func keyPeriodStartHeight (baseAssetId,period) = makeString(["%s%s%d", assetIdToString(baseAssetId), "periodStartHeight", toString(period)], separator) | |
87 | + | ||
88 | + | ||
89 | + | func keyBaseAssetAmountToConvert (baseAssetId) = makeString(["%s%s", assetIdToString(baseAssetId), "baseAssetAmountToConvert"], separator) | |
90 | + | ||
91 | + | ||
92 | + | func keyShareAssetAmountToConvert (baseAssetId) = makeString(["%s%s", assetIdToString(baseAssetId), "shareAssetAmountToConvert"], separator) | |
93 | + | ||
94 | + | ||
95 | + | func keyUserBaseAssetAmountToConvert (baseAssetId,userAddress) = makeString(["%s%s%s", assetIdToString(baseAssetId), toString(userAddress), "baseAssetAmountToConvert"], separator) | |
96 | + | ||
97 | + | ||
98 | + | func keyUserBaseAssetAmountToConvertPeriod (baseAssetId,userAddress) = makeString(["%s%s%s%s", assetIdToString(baseAssetId), toString(userAddress), "baseAssetAmountToConvert", "period"], separator) | |
99 | + | ||
100 | + | ||
101 | + | func keyUserShareAssetAmountToConvert (baseAssetId,userAddress) = makeString(["%s%s%s", assetIdToString(baseAssetId), toString(userAddress), "shareAssetAmountToConvert"], separator) | |
102 | + | ||
103 | + | ||
104 | + | func keyUserShareAssetAmountToConvertPeriod (baseAssetId,userAddress) = makeString(["%s%s%s%s", assetIdToString(baseAssetId), toString(userAddress), "shareAssetAmountToConvert", "period"], separator) | |
105 | + | ||
106 | + | ||
107 | + | func keyPricePeriod (baseAssetId,period) = makeString(["%s%s%d", assetIdToString(baseAssetId), "price", toString(period)], separator) | |
108 | + | ||
109 | + | ||
110 | + | func keyPriceHistory (baseAssetId) = makeString(["%s%s%s%d%d", assetIdToString(baseAssetId), "price", "history", toString(lastBlock.height), toString(lastBlock.timestamp)], separator) | |
111 | + | ||
112 | + | ||
113 | + | func keyPricePeriodPut (baseAssetId,period) = makeString(["%s%s%d%s", assetIdToString(baseAssetId), "price", toString(period), "put"], separator) | |
114 | + | ||
115 | + | ||
116 | + | func keyPricePutHistory (baseAssetId) = makeString(["%s%s%s%s%d%d", assetIdToString(baseAssetId), "price", "history", "put", toString(lastBlock.height), toString(lastBlock.timestamp)], separator) | |
117 | + | ||
118 | + | ||
119 | + | func keyPricePeriodGet (baseAssetId,period) = makeString(["%s%s%d%s", assetIdToString(baseAssetId), "price", toString(period), "get"], separator) | |
120 | + | ||
121 | + | ||
122 | + | func keyPriceGetHistory (baseAssetId) = makeString(["%s%s%s%s%d%d", assetIdToString(baseAssetId), "price", "history", "get", toString(lastBlock.height), toString(lastBlock.timestamp)], separator) | |
123 | + | ||
124 | + | ||
125 | + | func keyHistoryEntry (baseAssetId,operation,period,userAddress,txId) = makeString(["%s%s%s%s", "history", operation, toString(userAddress), toBase58String(txId), toString(height)], separator) | |
126 | + | ||
16 | 127 | ||
17 | 128 | func keyManagerPublicKey () = "%s__managerPublicKey" | |
18 | 129 | ||
19 | 130 | ||
20 | 131 | func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey" | |
21 | - | ||
22 | - | ||
23 | - | func fc () = "%s__factoryContract" | |
24 | - | ||
25 | - | ||
26 | - | let factoryContract = addressFromStringValue(getStringOrFail(fc())) | |
27 | - | ||
28 | - | func protocolFee () = makeString(["%s", "protocolFee"], SEP) | |
29 | - | ||
30 | - | ||
31 | - | func poolFee () = makeString(["%s", "poolFee"], SEP) | |
32 | - | ||
33 | - | ||
34 | - | func getStringOrFailFromAddress (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
35 | - | ||
36 | - | ||
37 | - | let keyFeeCollectorAddress = "%s__feeCollectorAddress" | |
38 | - | ||
39 | - | let feeCollectorAddress = addressFromStringValue(getStringOrFailFromAddress(factoryContract, keyFeeCollectorAddress)) | |
40 | - | ||
41 | - | func asInt (val) = match val { | |
42 | - | case valInt: Int => | |
43 | - | valInt | |
44 | - | case _ => | |
45 | - | throw("fail to cast into Int") | |
46 | - | } | |
47 | - | ||
48 | - | ||
49 | - | func dataMappingPoolAssets (internalAmountAssetStr,internalPriceAssetStr) = makeString(["%d%d", toString(internalAmountAssetStr), toString(internalPriceAssetStr)], SEP) | |
50 | 132 | ||
51 | 133 | ||
52 | 134 | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
69 | 151 | } | |
70 | 152 | ||
71 | 153 | ||
72 | - | func isManager (i) = match managerPublicKeyOrUnit() { | |
154 | + | let permissionDeniedError = throw("Permission denied") | |
155 | + | ||
156 | + | func mustThis (i) = if ((i.caller == this)) | |
157 | + | then true | |
158 | + | else permissionDeniedError | |
159 | + | ||
160 | + | ||
161 | + | func mustManager (i) = match managerPublicKeyOrUnit() { | |
73 | 162 | case pk: ByteVector => | |
74 | - | (i.callerPublicKey == pk) | |
163 | + | if ((i.callerPublicKey == pk)) | |
164 | + | then true | |
165 | + | else permissionDeniedError | |
75 | 166 | case _: Unit => | |
76 | - | (i | |
167 | + | mustThis(i) | |
77 | 168 | case _ => | |
78 | 169 | throw("Match error") | |
79 | 170 | } | |
80 | 171 | ||
81 | 172 | ||
82 | - | func mustManager (i) = if (isManager(i)) | |
173 | + | let shutdown = valueOrElse(getBoolean(keyShutdown()), false) | |
174 | + | ||
175 | + | func shutdownCheck (i) = if (if (!(shutdown)) | |
83 | 176 | then true | |
84 | - | else throw("permission denied") | |
177 | + | else mustManager(i)) | |
178 | + | then true | |
179 | + | else throw("operation is disabled") | |
85 | 180 | ||
86 | 181 | ||
87 | - | func getAccBalance (assetId) = if ((assetId == "WAVES")) | |
88 | - | then wavesBalance(this).available | |
89 | - | else assetBalance(this, fromBase58String(assetId)) | |
182 | + | let factoryContract = addressFromStringValue(getStrOrFail(this, keyFactoryContract())) | |
90 | 183 | ||
184 | + | let lpStakingContract = addressFromStringValue(getStrOrFail(this, keyLpStakingContract())) | |
91 | 185 | ||
92 | - | func getPoolAddressAndCheckPoolStatus (assetIn,assetOut) = { | |
93 | - | let lpNonReverse = { | |
94 | - | let @ = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [assetIn, assetOut], nil) | |
95 | - | if ($isInstanceOf(@, "String")) | |
186 | + | let stakingContract = addressFromStringValue(getStrOrFail(this, keyStakingContract())) | |
187 | + | ||
188 | + | let boostingContract = addressFromStringValue(getStrOrFail(this, keyBoostingContract())) | |
189 | + | ||
190 | + | let swapContract = addressFromStringValue(getStrOrFail(this, keySwapContract())) | |
191 | + | ||
192 | + | let assetsStoreContract = addressFromStringValue(getStrOrFail(this, keyAssetsStoreContract())) | |
193 | + | ||
194 | + | let usdtAssetId = parseAssetId(getStrOrFail(this, keyUsdtAssetId())) | |
195 | + | ||
196 | + | let wxAssetId = parseAssetId(getStrOrFail(this, keyWxAssetId())) | |
197 | + | ||
198 | + | let minDelayDefault = 1440 | |
199 | + | ||
200 | + | let minDelay = valueOrElse(getInteger(this, keyMinDelay()), minDelayDefault) | |
201 | + | ||
202 | + | let lockFractionMultiplier = 100000000 | |
203 | + | ||
204 | + | let lockFractionDefault = fraction(1, lockFractionMultiplier, 2) | |
205 | + | ||
206 | + | let lockFraction = valueOrElse(getInteger(this, keyLockFraction()), lockFractionDefault) | |
207 | + | ||
208 | + | func getPoolInfo (amountAssetId) = { | |
209 | + | let amountAssetIdStr = assetIdToString(amountAssetId) | |
210 | + | let priceAssetIdStr = assetIdToString(usdtAssetId) | |
211 | + | let poolInfoOption = { | |
212 | + | let @ = invoke(factoryContract, "poolInfoREADONLY", [amountAssetIdStr, priceAssetIdStr], nil) | |
213 | + | if ($isInstanceOf(@, "(Address, ByteVector)")) | |
96 | 214 | then @ | |
97 | 215 | else unit | |
98 | 216 | } | |
99 | - | let lpReverse = { | |
100 | - | let @ = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [assetOut, assetIn], nil) | |
101 | - | if ($isInstanceOf(@, "String")) | |
102 | - | then @ | |
103 | - | else unit | |
104 | - | } | |
105 | - | let $t026263103 = if ((lpNonReverse != unit)) | |
106 | - | then { | |
107 | - | let pool = { | |
108 | - | let @ = invoke(factoryContract, "getPoolAddressFromLpAssetREADONLY", [value(lpNonReverse)], nil) | |
109 | - | if ($isInstanceOf(@, "String")) | |
110 | - | then @ | |
111 | - | else throw(($getType(@) + " couldn't be cast to String")) | |
112 | - | } | |
113 | - | $Tuple2(false, pool) | |
114 | - | } | |
115 | - | else if ((lpReverse != unit)) | |
116 | - | then { | |
117 | - | let pool = { | |
118 | - | let @ = invoke(factoryContract, "getPoolAddressFromLpAssetREADONLY", [value(lpReverse)], nil) | |
119 | - | if ($isInstanceOf(@, "String")) | |
120 | - | then @ | |
121 | - | else throw(($getType(@) + " couldn't be cast to String")) | |
122 | - | } | |
123 | - | $Tuple2(true, pool) | |
124 | - | } | |
125 | - | else poolNotExist | |
126 | - | let isReverse = $t026263103._1 | |
127 | - | let pool = $t026263103._2 | |
128 | - | let poolStatus = { | |
129 | - | let @ = invoke(factoryContract, "getPoolStatusREADONLY", [pool], nil) | |
130 | - | if ($isInstanceOf(@, "Int")) | |
131 | - | then @ | |
132 | - | else throw(($getType(@) + " couldn't be cast to Int")) | |
133 | - | } | |
134 | - | let check = if ((poolStatus == 1)) | |
135 | - | then true | |
136 | - | else poolDisabled | |
137 | - | if ((check == check)) | |
138 | - | then { | |
139 | - | let poolAdr = addressFromStringValue(valueOrElse(pool, "")) | |
140 | - | $Tuple2(poolAdr, isReverse) | |
141 | - | } | |
142 | - | else throw("Strict value is not equal to itself.") | |
217 | + | poolInfoOption | |
143 | 218 | } | |
144 | 219 | ||
145 | 220 | ||
146 | - | @Callable(i) | |
147 | - | func swapCalculateREADONLY (amountIn,assetIn,assetOut) = { | |
148 | - | let prFee = value(getInteger(protocolFee())) | |
149 | - | let feeProtocolAmountCalc = fraction(toBigInt(amountIn), toBigInt(prFee), feeScale) | |
150 | - | let plFee = value(getInteger(poolFee())) | |
151 | - | let feePoolAmountCalc = fraction(toBigInt(amountIn), toBigInt(plFee), feeScale) | |
152 | - | let feeProtocolAmount = if ((toInt(feeProtocolAmountCalc) == 0)) | |
153 | - | then toBigInt(1) | |
154 | - | else feeProtocolAmountCalc | |
155 | - | let feePoolAmount = if ((toInt(feePoolAmountCalc) == 0)) | |
156 | - | then toBigInt(1) | |
157 | - | else feePoolAmountCalc | |
158 | - | let cleanAmountIn = ((toBigInt(amountIn) - feeProtocolAmount) - feePoolAmount) | |
159 | - | let $t041284206 = getPoolAddressAndCheckPoolStatus(assetIn, assetOut) | |
160 | - | let poolAdr = $t041284206._1 | |
161 | - | let isReverse = $t041284206._2 | |
162 | - | let res = { | |
163 | - | let @ = invoke(poolAdr, "calculateAmountOutForSwapREADONLY", [toInt(cleanAmountIn), isReverse, toInt(feePoolAmount)], nil) | |
221 | + | func calcPrice (lpAssetId,shareAssetId) = { | |
222 | + | let shareAssetInfo = valueOrErrorMessage(assetInfo(shareAssetId), "failed to get share asset info") | |
223 | + | let shareAssetEmission = shareAssetInfo.quantity | |
224 | + | let stakedAmount = ensurePositive(valueOrErrorMessage({ | |
225 | + | let @ = invoke(stakingContract, "stakedByUserREADONLY", [assetIdToString(lpAssetId), toString(this)], nil) | |
164 | 226 | if ($isInstanceOf(@, "Int")) | |
165 | 227 | then @ | |
166 | - | else throw(($getType(@) + " couldn't be cast to Int")) | |
167 | - | } | |
168 | - | $Tuple2(nil, res) | |
228 | + | else unit | |
229 | + | }, wrapErr("invalid stakedByUserREADONLY result"))) | |
230 | + | let price = if ((shareAssetEmission == 0)) | |
231 | + | then scale18BigInt | |
232 | + | else fraction(toBigInt(stakedAmount), scale18BigInt, toBigInt(shareAssetEmission), FLOOR) | |
233 | + | price | |
169 | 234 | } | |
170 | - | ||
171 | - | ||
172 | - | ||
173 | - | @Callable(i) | |
174 | - | func swap (amountOutMin,assetOutRaw,addressTo) = { | |
175 | - | let assetOut = if ((assetOutRaw == "")) | |
176 | - | then "WAVES" | |
177 | - | else assetOutRaw | |
178 | - | let pmt = value(i.payments[0]) | |
179 | - | let assetIn = if ((pmt.assetId == unit)) | |
180 | - | then "WAVES" | |
181 | - | else toBase58String(value(pmt.assetId)) | |
182 | - | let amountIn = value(pmt.amount) | |
183 | - | let prFee = value(getInteger(protocolFee())) | |
184 | - | let feeProtocolAmountCalc = fraction(toBigInt(amountIn), toBigInt(prFee), feeScale) | |
185 | - | let plFee = value(getInteger(poolFee())) | |
186 | - | let feePoolAmountCalc = fraction(toBigInt(amountIn), toBigInt(plFee), feeScale) | |
187 | - | let feeProtocolAmount = if ((toInt(feeProtocolAmountCalc) == 0)) | |
188 | - | then toBigInt(1) | |
189 | - | else feeProtocolAmountCalc | |
190 | - | let feePoolAmount = if ((toInt(feePoolAmountCalc) == 0)) | |
191 | - | then toBigInt(1) | |
192 | - | else feePoolAmountCalc | |
193 | - | let cleanAmountIn = ((toBigInt(amountIn) - feeProtocolAmount) - feePoolAmount) | |
194 | - | let checks = [if ((size(i.payments) == 1)) | |
195 | - | then true | |
196 | - | else throw("exactly 1 payment are expected")] | |
197 | - | if ((checks == checks)) | |
198 | - | then { | |
199 | - | let $t054525530 = getPoolAddressAndCheckPoolStatus(assetIn, assetOut) | |
200 | - | let poolAdr = $t054525530._1 | |
201 | - | let isReverse = $t054525530._2 | |
202 | - | let assetInAttachedPayment = if ((assetIn == "WAVES")) | |
203 | - | then unit | |
204 | - | else fromBase58String(assetIn) | |
205 | - | let totalGetRaw = { | |
206 | - | let @ = invoke(poolAdr, "calculateAmountOutForSwapAndSendTokens", [toInt(cleanAmountIn), isReverse, amountOutMin, addressTo, toInt(feePoolAmount)], [AttachedPayment(assetInAttachedPayment, toInt(cleanAmountIn))]) | |
207 | - | if ($isInstanceOf(@, "Int")) | |
208 | - | then @ | |
209 | - | else throw(($getType(@) + " couldn't be cast to Int")) | |
210 | - | } | |
211 | - | $Tuple2([ScriptTransfer(feeCollectorAddress, toInt(feeProtocolAmount), assetInAttachedPayment), ScriptTransfer(poolAdr, toInt(feePoolAmount), assetInAttachedPayment)], totalGetRaw) | |
212 | - | } | |
213 | - | else throw("Strict value is not equal to itself.") | |
214 | - | } | |
215 | - | ||
216 | 235 | ||
217 | 236 | ||
218 | 237 | @Callable(i) | |
235 | 254 | let pm = pendingManagerPublicKeyOrUnit() | |
236 | 255 | let hasPM = if (isDefined(pm)) | |
237 | 256 | then true | |
238 | - | else | |
257 | + | else throwErr("no pending manager") | |
239 | 258 | if ((hasPM == hasPM)) | |
240 | 259 | then { | |
241 | 260 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
242 | 261 | then true | |
243 | - | else | |
262 | + | else throwErr("you are not pending manager") | |
244 | 263 | if ((checkPM == checkPM)) | |
245 | 264 | then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())] | |
265 | + | else throw("Strict value is not equal to itself.") | |
266 | + | } | |
267 | + | else throw("Strict value is not equal to itself.") | |
268 | + | } | |
269 | + | ||
270 | + | ||
271 | + | ||
272 | + | @Callable(i) | |
273 | + | func emit (assetId,amount) = { | |
274 | + | let checkCaller = mustThis(i) | |
275 | + | if ((checkCaller == checkCaller)) | |
276 | + | then { | |
277 | + | let isReissuable = true | |
278 | + | $Tuple2([Reissue(assetId, amount, isReissuable)], amount) | |
279 | + | } | |
280 | + | else throw("Strict value is not equal to itself.") | |
281 | + | } | |
282 | + | ||
283 | + | ||
284 | + | ||
285 | + | @Callable(i) | |
286 | + | func burn (assetId,amount) = { | |
287 | + | let checkCaller = mustThis(i) | |
288 | + | if ((checkCaller == checkCaller)) | |
289 | + | then $Tuple2([Burn(assetId, amount)], amount) | |
290 | + | else throw("Strict value is not equal to itself.") | |
291 | + | } | |
292 | + | ||
293 | + | ||
294 | + | ||
295 | + | @Callable(i) | |
296 | + | func create (baseAssetIdStr,shareAssetIdStr,shareAssetName,shareAssetDescription,shareAssetLogo) = { | |
297 | + | let shareAssetLabel = "STAKING_LP" | |
298 | + | let baseAssetId = parseAssetId(baseAssetIdStr) | |
299 | + | let checks = [mustManager(i), if (isDefined(getPoolInfo(baseAssetId))) | |
300 | + | then true | |
301 | + | else throwErr("invalid base asset")] | |
302 | + | if ((checks == checks)) | |
303 | + | then { | |
304 | + | let commonState = [IntegerEntry(keyPeriod(baseAssetId), 0)] | |
305 | + | if ((shareAssetIdStr == "")) | |
306 | + | then { | |
307 | + | let shareAssetIssueAmount = 1 | |
308 | + | let shareAssetIssueAction = Issue(shareAssetName, shareAssetDescription, shareAssetIssueAmount, shareAssetDecimals, true) | |
309 | + | let calculatedShareAssetId = calculateAssetId(shareAssetIssueAction) | |
310 | + | let shareAssetBurnAction = Burn(calculatedShareAssetId, shareAssetIssueAmount) | |
311 | + | let calculatedShareAssetIdStr = toBase58String(calculatedShareAssetId) | |
312 | + | let createOrUpdate = invoke(assetsStoreContract, "createOrUpdate", [calculatedShareAssetIdStr, shareAssetLogo, false], nil) | |
313 | + | if ((createOrUpdate == createOrUpdate)) | |
314 | + | then { | |
315 | + | let addLabel = invoke(assetsStoreContract, "addLabel", [calculatedShareAssetIdStr, shareAssetLabel], nil) | |
316 | + | if ((addLabel == addLabel)) | |
317 | + | then $Tuple2((commonState ++ [shareAssetIssueAction, shareAssetBurnAction, StringEntry(keyShareAssetId(baseAssetId), calculatedShareAssetIdStr), StringEntry(keyBaseAssetId(calculatedShareAssetId), baseAssetIdStr)]), calculatedShareAssetIdStr) | |
318 | + | else throw("Strict value is not equal to itself.") | |
319 | + | } | |
320 | + | else throw("Strict value is not equal to itself.") | |
321 | + | } | |
322 | + | else { | |
323 | + | let shareAssetId = fromBase58String(shareAssetIdStr) | |
324 | + | let shareAssetInfo = valueOrErrorMessage(assetInfo(shareAssetId), wrapErr("invalid share asset id")) | |
325 | + | let checkIssuer = if ((shareAssetInfo.issuer == lpStakingContract)) | |
326 | + | then true | |
327 | + | else throwErr("invalid share asset id issuer") | |
328 | + | if ((checkIssuer == checkIssuer)) | |
329 | + | then $Tuple2((commonState ++ [StringEntry(keyShareAssetId(baseAssetId), shareAssetIdStr), StringEntry(keyBaseAssetId(shareAssetId), baseAssetIdStr)]), shareAssetIdStr) | |
330 | + | else throw("Strict value is not equal to itself.") | |
331 | + | } | |
332 | + | } | |
333 | + | else throw("Strict value is not equal to itself.") | |
334 | + | } | |
335 | + | ||
336 | + | ||
337 | + | ||
338 | + | @Callable(i) | |
339 | + | func put () = { | |
340 | + | let pmt = if ((size(i.payments) == 1)) | |
341 | + | then i.payments[0] | |
342 | + | else throwErr("exactly 1 payment is expected") | |
343 | + | let baseAssetId = pmt.assetId | |
344 | + | let userAddress = i.caller | |
345 | + | let checks = [shutdownCheck(i), if (isDefined(getString(keyShareAssetId(baseAssetId)))) | |
346 | + | then true | |
347 | + | else throwErr("invalid asset")] | |
348 | + | if ((checks == checks)) | |
349 | + | then { | |
350 | + | let $t01192312026 = valueOrErrorMessage(getPoolInfo(baseAssetId), wrapErr("invalid asset")) | |
351 | + | let poolAddress = $t01192312026._1 | |
352 | + | let lpAssetId = $t01192312026._2 | |
353 | + | let period = value(getInteger(keyPeriod(baseAssetId))) | |
354 | + | let userBaseAssetAmountToConvertPeriodOption = getInteger(keyUserBaseAssetAmountToConvertPeriod(baseAssetId, userAddress)) | |
355 | + | let claimShareAssetInvocation = if ((userBaseAssetAmountToConvertPeriodOption == unit)) | |
356 | + | then unit | |
357 | + | else { | |
358 | + | let userBaseAssetAmountToConvertPeriod = value(userBaseAssetAmountToConvertPeriodOption) | |
359 | + | if ((userBaseAssetAmountToConvertPeriod == period)) | |
360 | + | then unit | |
361 | + | else invoke(this, "claimShareAsset", [assetIdToString(baseAssetId), toString(userAddress)], nil) | |
362 | + | } | |
363 | + | if ((claimShareAssetInvocation == claimShareAssetInvocation)) | |
364 | + | then { | |
365 | + | let baseAssetAmountToConvert = valueOrElse(getInteger(keyBaseAssetAmountToConvert(baseAssetId)), 0) | |
366 | + | let userBaseAssetAmountToConvert = valueOrElse(getInteger(keyUserBaseAssetAmountToConvert(baseAssetId, userAddress)), 0) | |
367 | + | $Tuple2([IntegerEntry(keyBaseAssetAmountToConvert(baseAssetId), (baseAssetAmountToConvert + pmt.amount)), IntegerEntry(keyUserBaseAssetAmountToConvert(baseAssetId, userAddress), (userBaseAssetAmountToConvert + pmt.amount)), IntegerEntry(keyUserBaseAssetAmountToConvertPeriod(baseAssetId, userAddress), period), IntegerEntry(keyHistoryEntry(baseAssetId, "put", period, userAddress, i.transactionId), pmt.amount)], unit) | |
368 | + | } | |
369 | + | else throw("Strict value is not equal to itself.") | |
370 | + | } | |
371 | + | else throw("Strict value is not equal to itself.") | |
372 | + | } | |
373 | + | ||
374 | + | ||
375 | + | ||
376 | + | @Callable(i) | |
377 | + | func claimShareAsset (baseAssetIdStr,userAddressStr) = { | |
378 | + | let checks = [shutdownCheck(i)] | |
379 | + | if ((checks == checks)) | |
380 | + | then { | |
381 | + | let userAddress = if ((userAddressStr == "")) | |
382 | + | then i.caller | |
383 | + | else { | |
384 | + | let checkCaller = mustThis(i) | |
385 | + | if ((checkCaller == checkCaller)) | |
386 | + | then valueOrErrorMessage(addressFromString(userAddressStr), wrapErr("invalid user address")) | |
387 | + | else throw("Strict value is not equal to itself.") | |
388 | + | } | |
389 | + | if ((userAddress == userAddress)) | |
390 | + | then { | |
391 | + | let baseAssetId = parseAssetId(baseAssetIdStr) | |
392 | + | let shareAssetId = value(parseAssetId(valueOrErrorMessage(getString(keyShareAssetId(baseAssetId)), wrapErr("invalid base asset id")))) | |
393 | + | if ((shareAssetId == shareAssetId)) | |
394 | + | then { | |
395 | + | let period = valueOrErrorMessage(getInteger(keyPeriod(baseAssetId)), wrapErr("invalid period")) | |
396 | + | if ((period == period)) | |
397 | + | then { | |
398 | + | let userBaseAssetAmountToConvert = valueOrElse(getInteger(keyUserBaseAssetAmountToConvert(baseAssetId, userAddress)), 0) | |
399 | + | let checkAmountToConvert = if ((userBaseAssetAmountToConvert > 0)) | |
400 | + | then true | |
401 | + | else throwErr("nothing to claim") | |
402 | + | if ((checkAmountToConvert == checkAmountToConvert)) | |
403 | + | then { | |
404 | + | let userBaseAssetAmountToConvertPeriod = valueOrErrorMessage(getInteger(keyUserBaseAssetAmountToConvertPeriod(baseAssetId, userAddress)), wrapErr("failed to get period")) | |
405 | + | let checkPeriod = if ((period > userBaseAssetAmountToConvertPeriod)) | |
406 | + | then true | |
407 | + | else throwErr("invalid period") | |
408 | + | if ((checkPeriod == checkPeriod)) | |
409 | + | then { | |
410 | + | let price = toBigInt(valueOrErrorMessage(getBinary(keyPricePeriodPut(baseAssetId, userBaseAssetAmountToConvertPeriod)), wrapErr("failed to get price"))) | |
411 | + | let shareAssetAmount = toInt(fraction(toBigInt(userBaseAssetAmountToConvert), scale18BigInt, price)) | |
412 | + | $Tuple2([IntegerEntry(keyUserBaseAssetAmountToConvert(baseAssetId, userAddress), 0), DeleteEntry(keyUserBaseAssetAmountToConvertPeriod(baseAssetId, userAddress)), ScriptTransfer(userAddress, shareAssetAmount, shareAssetId), IntegerEntry(keyHistoryEntry(baseAssetId, "claimShareAsset", period, userAddress, i.transactionId), shareAssetAmount)], unit) | |
413 | + | } | |
414 | + | else throw("Strict value is not equal to itself.") | |
415 | + | } | |
416 | + | else throw("Strict value is not equal to itself.") | |
417 | + | } | |
418 | + | else throw("Strict value is not equal to itself.") | |
419 | + | } | |
420 | + | else throw("Strict value is not equal to itself.") | |
421 | + | } | |
422 | + | else throw("Strict value is not equal to itself.") | |
423 | + | } | |
424 | + | else throw("Strict value is not equal to itself.") | |
425 | + | } | |
426 | + | ||
427 | + | ||
428 | + | ||
429 | + | @Callable(i) | |
430 | + | func get () = { | |
431 | + | let checks = [shutdownCheck(i)] | |
432 | + | if ((checks == checks)) | |
433 | + | then { | |
434 | + | let pmt = if ((size(i.payments) == 1)) | |
435 | + | then i.payments[0] | |
436 | + | else throwErr("exactly 1 payment is expected") | |
437 | + | let shareAssetId = pmt.assetId | |
438 | + | let baseAssetId = value(parseAssetId(valueOrErrorMessage(getString(keyBaseAssetId(shareAssetId)), wrapErr("invalid share asset id")))) | |
439 | + | if ((baseAssetId == baseAssetId)) | |
440 | + | then { | |
441 | + | let userAddress = i.caller | |
442 | + | let $t01582915932 = valueOrErrorMessage(getPoolInfo(baseAssetId), wrapErr("invalid asset")) | |
443 | + | let poolAddress = $t01582915932._1 | |
444 | + | let lpAssetId = $t01582915932._2 | |
445 | + | let period = value(getInteger(keyPeriod(baseAssetId))) | |
446 | + | let userShareAssetAmountToConvertPeriodOption = getInteger(keyUserShareAssetAmountToConvertPeriod(baseAssetId, userAddress)) | |
447 | + | let claimBaseAssetInvocation = if ((userShareAssetAmountToConvertPeriodOption == unit)) | |
448 | + | then unit | |
449 | + | else { | |
450 | + | let userShareAssetAmountToConvertPeriod = value(userShareAssetAmountToConvertPeriodOption) | |
451 | + | if ((userShareAssetAmountToConvertPeriod == period)) | |
452 | + | then unit | |
453 | + | else invoke(this, "claimBaseAsset", [assetIdToString(baseAssetId), toString(userAddress)], nil) | |
454 | + | } | |
455 | + | if ((claimBaseAssetInvocation == claimBaseAssetInvocation)) | |
456 | + | then { | |
457 | + | let shareAssetAmountToConvert = valueOrElse(getInteger(keyShareAssetAmountToConvert(baseAssetId)), 0) | |
458 | + | let userShareAssetAmountToConvert = valueOrElse(getInteger(keyUserShareAssetAmountToConvert(baseAssetId, userAddress)), 0) | |
459 | + | $Tuple2([IntegerEntry(keyShareAssetAmountToConvert(baseAssetId), (shareAssetAmountToConvert + pmt.amount)), IntegerEntry(keyUserShareAssetAmountToConvert(baseAssetId, userAddress), (userShareAssetAmountToConvert + pmt.amount)), IntegerEntry(keyUserShareAssetAmountToConvertPeriod(baseAssetId, userAddress), period), IntegerEntry(keyHistoryEntry(baseAssetId, "get", period, userAddress, i.transactionId), pmt.amount)], unit) | |
460 | + | } | |
461 | + | else throw("Strict value is not equal to itself.") | |
462 | + | } | |
463 | + | else throw("Strict value is not equal to itself.") | |
464 | + | } | |
465 | + | else throw("Strict value is not equal to itself.") | |
466 | + | } | |
467 | + | ||
468 | + | ||
469 | + | ||
470 | + | @Callable(i) | |
471 | + | func claimBaseAsset (baseAssetIdStr,userAddressStr) = { | |
472 | + | let checks = [shutdownCheck(i)] | |
473 | + | if ((checks == checks)) | |
474 | + | then { | |
475 | + | let userAddress = if ((userAddressStr == "")) | |
476 | + | then i.caller | |
477 | + | else { | |
478 | + | let checkCaller = mustThis(i) | |
479 | + | if ((checkCaller == checkCaller)) | |
480 | + | then valueOrErrorMessage(addressFromString(userAddressStr), wrapErr("invalid user address")) | |
481 | + | else throw("Strict value is not equal to itself.") | |
482 | + | } | |
483 | + | if ((userAddress == userAddress)) | |
484 | + | then { | |
485 | + | let baseAssetId = parseAssetId(baseAssetIdStr) | |
486 | + | let shareAssetId = value(parseAssetId(valueOrErrorMessage(getString(keyShareAssetId(baseAssetId)), wrapErr("invalid base asset id")))) | |
487 | + | if ((shareAssetId == shareAssetId)) | |
488 | + | then { | |
489 | + | let period = valueOrErrorMessage(getInteger(keyPeriod(baseAssetId)), wrapErr("invalid period")) | |
490 | + | if ((period == period)) | |
491 | + | then { | |
492 | + | let userShareAssetAmountToConvert = valueOrElse(getInteger(keyUserShareAssetAmountToConvert(baseAssetId, userAddress)), 0) | |
493 | + | let checkAmountToConvert = if ((userShareAssetAmountToConvert > 0)) | |
494 | + | then true | |
495 | + | else throwErr("nothing to claim") | |
496 | + | if ((checkAmountToConvert == checkAmountToConvert)) | |
497 | + | then { | |
498 | + | let userShareAssetAmountToConvertPeriod = valueOrErrorMessage(getInteger(keyUserShareAssetAmountToConvertPeriod(baseAssetId, userAddress)), wrapErr("failed to get period")) | |
499 | + | let checkPeriod = if ((period > userShareAssetAmountToConvertPeriod)) | |
500 | + | then true | |
501 | + | else throwErr("invalid period") | |
502 | + | if ((checkPeriod == checkPeriod)) | |
503 | + | then { | |
504 | + | let price = toBigInt(valueOrErrorMessage(getBinary(keyPricePeriodGet(baseAssetId, userShareAssetAmountToConvertPeriod)), wrapErr("failed to get price"))) | |
505 | + | let baseAssetAmount = toInt(fraction(toBigInt(userShareAssetAmountToConvert), price, scale18BigInt)) | |
506 | + | $Tuple2([IntegerEntry(keyUserShareAssetAmountToConvert(baseAssetId, userAddress), 0), DeleteEntry(keyUserShareAssetAmountToConvertPeriod(baseAssetId, userAddress)), ScriptTransfer(userAddress, baseAssetAmount, baseAssetId), IntegerEntry(keyHistoryEntry(baseAssetId, "claimBaseAsset", period, userAddress, i.transactionId), baseAssetAmount)], unit) | |
507 | + | } | |
508 | + | else throw("Strict value is not equal to itself.") | |
509 | + | } | |
510 | + | else throw("Strict value is not equal to itself.") | |
511 | + | } | |
512 | + | else throw("Strict value is not equal to itself.") | |
513 | + | } | |
514 | + | else throw("Strict value is not equal to itself.") | |
515 | + | } | |
516 | + | else throw("Strict value is not equal to itself.") | |
517 | + | } | |
518 | + | else throw("Strict value is not equal to itself.") | |
519 | + | } | |
520 | + | ||
521 | + | ||
522 | + | ||
523 | + | @Callable(i) | |
524 | + | func finalize (baseAssetIdStr) = { | |
525 | + | let checks = [shutdownCheck(i)] | |
526 | + | if ((checks == checks)) | |
527 | + | then { | |
528 | + | let baseAssetId = parseAssetId(baseAssetIdStr) | |
529 | + | let shareAssetId = value(parseAssetId(valueOrErrorMessage(getString(keyShareAssetId(baseAssetId)), wrapErr("invalid base asset id")))) | |
530 | + | if ((shareAssetId == shareAssetId)) | |
531 | + | then { | |
532 | + | let shareAssetInfo = valueOrErrorMessage(assetInfo(shareAssetId), wrapErr("invalid share asset id")) | |
533 | + | let period = valueOrErrorMessage(getInteger(keyPeriod(baseAssetId)), wrapErr("invalid period")) | |
534 | + | if ((period == period)) | |
535 | + | then { | |
536 | + | let periodStartHeightOption = getInteger(keyPeriodStartHeight(baseAssetId, period)) | |
537 | + | let checkDelay = if ((periodStartHeightOption == unit)) | |
538 | + | then unit | |
539 | + | else { | |
540 | + | let delay = (height - value(periodStartHeightOption)) | |
541 | + | let blocksToWait = max([0, (minDelay - delay)]) | |
542 | + | if ((blocksToWait == 0)) | |
543 | + | then unit | |
544 | + | else throwErr(makeString(["finalization will be possible in ", toString(blocksToWait), " blocks"], "")) | |
545 | + | } | |
546 | + | if ((checkDelay == checkDelay)) | |
547 | + | then { | |
548 | + | let $t02008920274 = valueOrErrorMessage(getPoolInfo(baseAssetId), wrapErr("invalid asset")) | |
549 | + | let poolAddress = $t02008920274._1 | |
550 | + | let lpAssetId = $t02008920274._2 | |
551 | + | let stakingReward = valueOrErrorMessage({ | |
552 | + | let @ = invoke(stakingContract, "claimWxDoNotThrow", [assetIdToString(lpAssetId)], nil) | |
553 | + | if ($isInstanceOf(@, "Int")) | |
554 | + | then @ | |
555 | + | else unit | |
556 | + | }, wrapErr("invalid claimWx result")) | |
557 | + | if ((stakingReward == stakingReward)) | |
558 | + | then { | |
559 | + | let baseAssetAmountToConvert = valueOrElse(getInteger(keyBaseAssetAmountToConvert(baseAssetId)), 0) | |
560 | + | let shareAssetAmountToConvert = valueOrElse(getInteger(keyShareAssetAmountToConvert(baseAssetId)), 0) | |
561 | + | let checkFinalizationIsRequired = { | |
562 | + | let isFinalizationRequired = if (if ((stakingReward > 0)) | |
563 | + | then true | |
564 | + | else (baseAssetAmountToConvert > 0)) | |
565 | + | then true | |
566 | + | else (shareAssetAmountToConvert > 0) | |
567 | + | if (isFinalizationRequired) | |
568 | + | then true | |
569 | + | else throwErr("nothing to finalize") | |
570 | + | } | |
571 | + | if ((checkFinalizationIsRequired == checkFinalizationIsRequired)) | |
572 | + | then { | |
573 | + | let useStakingReward = if ((stakingReward > 0)) | |
574 | + | then { | |
575 | + | let lockPart = fraction(stakingReward, lockFraction, lockFractionMultiplier) | |
576 | + | let convertPart = (stakingReward - lockPart) | |
577 | + | let r = invoke(boostingContract, "userMaxDurationREADONLY", [toString(this)], nil) | |
578 | + | let lock = if ((lockPart > 0)) | |
579 | + | then match r { | |
580 | + | case _ => | |
581 | + | if (if (if ($isInstanceOf($match0._1, "String")) | |
582 | + | then $isInstanceOf($match0._2, "Int") | |
583 | + | else false) | |
584 | + | then $isInstanceOf($match0, "(String, Int)") | |
585 | + | else false) | |
586 | + | then { | |
587 | + | let function = $match0._1 | |
588 | + | let duration = $match0._2 | |
589 | + | if ((lockPart > 0)) | |
590 | + | then invoke(boostingContract, function, [duration], [AttachedPayment(wxAssetId, lockPart)]) | |
591 | + | else unit | |
592 | + | } | |
593 | + | else throwErr("invalid lock params") | |
594 | + | } | |
595 | + | else unit | |
596 | + | if ((lock == lock)) | |
597 | + | then { | |
598 | + | let convertedAmount = if ((convertPart > 0)) | |
599 | + | then { | |
600 | + | let inAssetId = wxAssetId | |
601 | + | let minimumToReceive = 0 | |
602 | + | let outAssetIdStr = assetIdToString(usdtAssetId) | |
603 | + | let targetAddress = toString(this) | |
604 | + | valueOrErrorMessage({ | |
605 | + | let @ = invoke(swapContract, "swap", [minimumToReceive, outAssetIdStr, targetAddress], [AttachedPayment(inAssetId, convertPart)]) | |
606 | + | if ($isInstanceOf(@, "Int")) | |
607 | + | then @ | |
608 | + | else unit | |
609 | + | }, wrapErr("invalid swap result")) | |
610 | + | } | |
611 | + | else 0 | |
612 | + | if ((convertedAmount == convertedAmount)) | |
613 | + | then { | |
614 | + | let lpAssetAmount = if ((convertedAmount > 0)) | |
615 | + | then { | |
616 | + | let minOutAmount = 0 | |
617 | + | let autoStake = true | |
618 | + | valueOrErrorMessage({ | |
619 | + | let @ = invoke(poolAddress, "putOneTknV2", [minOutAmount, autoStake], [AttachedPayment(usdtAssetId, convertedAmount)]) | |
620 | + | if ($isInstanceOf(@, "Int")) | |
621 | + | then @ | |
622 | + | else unit | |
623 | + | }, wrapErr("invalid putOneTknV2 result")) | |
624 | + | } | |
625 | + | else 0 | |
626 | + | if ((lpAssetAmount == lpAssetAmount)) | |
627 | + | then lpAssetAmount | |
628 | + | else throw("Strict value is not equal to itself.") | |
629 | + | } | |
630 | + | else throw("Strict value is not equal to itself.") | |
631 | + | } | |
632 | + | else throw("Strict value is not equal to itself.") | |
633 | + | } | |
634 | + | else unit | |
635 | + | if ((useStakingReward == useStakingReward)) | |
636 | + | then { | |
637 | + | let getActions = if ((shareAssetAmountToConvert > 0)) | |
638 | + | then { | |
639 | + | let price = calcPrice(lpAssetId, shareAssetId) | |
640 | + | if ((price == price)) | |
641 | + | then { | |
642 | + | let unstakeAmount = toInt(fraction(toBigInt(shareAssetAmountToConvert), price, scale18BigInt, FLOOR)) | |
643 | + | let baseAssetAmount = { | |
644 | + | let outAssetId = baseAssetId | |
645 | + | let minOutAmount = 0 | |
646 | + | valueOrErrorMessage({ | |
647 | + | let @ = invoke(poolAddress, "unstakeAndGetOneTknV2", [unstakeAmount, assetIdToString(outAssetId), minOutAmount], nil) | |
648 | + | if ($isInstanceOf(@, "Int")) | |
649 | + | then @ | |
650 | + | else unit | |
651 | + | }, wrapErr("invalid unstakeAndGetOneTknV2 result")) | |
652 | + | } | |
653 | + | if ((baseAssetAmount == baseAssetAmount)) | |
654 | + | then { | |
655 | + | let shareAssetBurn = if ((shareAssetInfo.issuer == this)) | |
656 | + | then invoke(this, "burn", [shareAssetId, shareAssetAmountToConvert], nil) | |
657 | + | else throwErr("invalid share asset issuer") | |
658 | + | if ((shareAssetBurn == shareAssetBurn)) | |
659 | + | then { | |
660 | + | let priceGet = fraction(toBigInt(baseAssetAmount), scale18BigInt, toBigInt(shareAssetAmountToConvert), FLOOR) | |
661 | + | let priceGetUpdateActions = [BinaryEntry(keyPricePeriodGet(baseAssetId, period), toBytes(priceGet)), StringEntry(keyPriceGetHistory(baseAssetId), toString(priceGet))] | |
662 | + | priceGetUpdateActions | |
663 | + | } | |
664 | + | else throw("Strict value is not equal to itself.") | |
665 | + | } | |
666 | + | else throw("Strict value is not equal to itself.") | |
667 | + | } | |
668 | + | else throw("Strict value is not equal to itself.") | |
669 | + | } | |
670 | + | else nil | |
671 | + | if ((getActions == getActions)) | |
672 | + | then { | |
673 | + | let putActions = if ((baseAssetAmountToConvert > 0)) | |
674 | + | then { | |
675 | + | let lpAssetAmount = { | |
676 | + | let minOutAmount = 0 | |
677 | + | let autoStake = true | |
678 | + | valueOrErrorMessage({ | |
679 | + | let @ = invoke(poolAddress, "putOneTknV2", [minOutAmount, autoStake], [AttachedPayment(baseAssetId, baseAssetAmountToConvert)]) | |
680 | + | if ($isInstanceOf(@, "Int")) | |
681 | + | then @ | |
682 | + | else unit | |
683 | + | }, wrapErr("invalid putOneTknV2 result")) | |
684 | + | } | |
685 | + | if ((lpAssetAmount == lpAssetAmount)) | |
686 | + | then { | |
687 | + | let price = calcPrice(lpAssetId, shareAssetId) | |
688 | + | if ((price == price)) | |
689 | + | then { | |
690 | + | let shareAssetAmount = toInt(fraction(toBigInt(lpAssetAmount), scale18BigInt, price, FLOOR)) | |
691 | + | let shareAssetReissue = if ((shareAssetInfo.issuer == this)) | |
692 | + | then invoke(this, "emit", [shareAssetId, shareAssetAmount], nil) | |
693 | + | else throwErr("invalid share asset issuer") | |
694 | + | if ((shareAssetReissue == shareAssetReissue)) | |
695 | + | then { | |
696 | + | let pricePut = fraction(toBigInt(baseAssetAmountToConvert), scale18BigInt, toBigInt(shareAssetAmount)) | |
697 | + | let pricePutUpdateActions = [BinaryEntry(keyPricePeriodPut(baseAssetId, period), toBytes(pricePut)), StringEntry(keyPricePutHistory(baseAssetId), toString(pricePut))] | |
698 | + | pricePutUpdateActions | |
699 | + | } | |
700 | + | else throw("Strict value is not equal to itself.") | |
701 | + | } | |
702 | + | else throw("Strict value is not equal to itself.") | |
703 | + | } | |
704 | + | else throw("Strict value is not equal to itself.") | |
705 | + | } | |
706 | + | else nil | |
707 | + | if ((putActions == putActions)) | |
708 | + | then { | |
709 | + | let newPeriod = (period + 1) | |
710 | + | let lastPrice = calcPrice(lpAssetId, shareAssetId) | |
711 | + | let actions = (([IntegerEntry(keyPeriod(baseAssetId), newPeriod), IntegerEntry(keyPeriodStartHeight(baseAssetId, newPeriod), height), IntegerEntry(keyShareAssetAmountToConvert(baseAssetId), 0), IntegerEntry(keyBaseAssetAmountToConvert(baseAssetId), 0), BinaryEntry(keyPricePeriod(baseAssetId, period), toBytes(lastPrice)), StringEntry(keyPriceHistory(baseAssetId), toString(lastPrice))] ++ putActions) ++ getActions) | |
712 | + | $Tuple2(actions, toBytes(lastPrice)) | |
713 | + | } | |
714 | + | else throw("Strict value is not equal to itself.") | |
715 | + | } | |
716 | + | else throw("Strict value is not equal to itself.") | |
717 | + | } | |
718 | + | else throw("Strict value is not equal to itself.") | |
719 | + | } | |
720 | + | else throw("Strict value is not equal to itself.") | |
721 | + | } | |
722 | + | else throw("Strict value is not equal to itself.") | |
723 | + | } | |
724 | + | else throw("Strict value is not equal to itself.") | |
725 | + | } | |
726 | + | else throw("Strict value is not equal to itself.") | |
727 | + | } | |
246 | 728 | else throw("Strict value is not equal to itself.") | |
247 | 729 | } | |
248 | 730 | else throw("Strict value is not equal to itself.") |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let | |
4 | + | let separator = "__" | |
5 | 5 | ||
6 | - | let | |
6 | + | let shareAssetDecimals = 8 | |
7 | 7 | ||
8 | - | func getStringOrFail (key) = valueOrErrorMessage(getString(this, key), ("No data for this.key=" + key)) | |
8 | + | let wavesString = "WAVES" | |
9 | + | ||
10 | + | let scale18 = 1000000000000000000 | |
11 | + | ||
12 | + | let scale18BigInt = toBigInt(scale18) | |
13 | + | ||
14 | + | func wrapErr (msg) = makeString(["lp_staking_pools.ride:", msg], " ") | |
9 | 15 | ||
10 | 16 | ||
11 | - | ||
17 | + | func throwErr (msg) = throw(wrapErr(msg)) | |
12 | 18 | ||
13 | - | let poolNotExist = throw("Pool is not exist") | |
14 | 19 | ||
15 | - | let slippageTooBig = throw("Slippage is too big") | |
20 | + | func errKeyIsNotDefined (address,key) = wrapErr(makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
21 | + | ||
22 | + | ||
23 | + | func getStrOrFail (address,key) = valueOrErrorMessage(getString(address, key), errKeyIsNotDefined(address, key)) | |
24 | + | ||
25 | + | ||
26 | + | func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), errKeyIsNotDefined(address, key)) | |
27 | + | ||
28 | + | ||
29 | + | func parseAssetId (input) = if ((input == wavesString)) | |
30 | + | then unit | |
31 | + | else fromBase58String(input) | |
32 | + | ||
33 | + | ||
34 | + | func assetIdToString (input) = if ((input == unit)) | |
35 | + | then wavesString | |
36 | + | else toBase58String(value(input)) | |
37 | + | ||
38 | + | ||
39 | + | func ensurePositive (v) = if ((v >= 0)) | |
40 | + | then v | |
41 | + | else throwErr("value should be positive") | |
42 | + | ||
43 | + | ||
44 | + | func keyFactoryContract () = makeString(["%s", "factoryContract"], separator) | |
45 | + | ||
46 | + | ||
47 | + | func keyLpStakingContract () = makeString(["%s", "lpStakingContract"], separator) | |
48 | + | ||
49 | + | ||
50 | + | func keyStakingContract () = makeString(["%s", "stakingContract"], separator) | |
51 | + | ||
52 | + | ||
53 | + | func keyBoostingContract () = makeString(["%s", "boostingContract"], separator) | |
54 | + | ||
55 | + | ||
56 | + | func keySwapContract () = makeString(["%s", "swapContract"], separator) | |
57 | + | ||
58 | + | ||
59 | + | func keyAssetsStoreContract () = makeString(["%s", "assetsStoreContract"], separator) | |
60 | + | ||
61 | + | ||
62 | + | func keyUsdtAssetId () = makeString(["%s", "usdtAssetId"], separator) | |
63 | + | ||
64 | + | ||
65 | + | func keyWxAssetId () = makeString(["%s", "wxAssetId"], separator) | |
66 | + | ||
67 | + | ||
68 | + | func keyShutdown () = makeString(["%s", "shutdown"], separator) | |
69 | + | ||
70 | + | ||
71 | + | func keyMinDelay () = makeString(["%s", "minDelay"], separator) | |
72 | + | ||
73 | + | ||
74 | + | func keyLockFraction () = makeString(["%s", "lockFraction"], separator) | |
75 | + | ||
76 | + | ||
77 | + | func keyShareAssetId (baseAssetId) = makeString(["%s%s", assetIdToString(baseAssetId), "shareAssetId"], separator) | |
78 | + | ||
79 | + | ||
80 | + | func keyBaseAssetId (shareAssetId) = makeString(["%s%s", assetIdToString(shareAssetId), "baseAssetId"], separator) | |
81 | + | ||
82 | + | ||
83 | + | func keyPeriod (baseAssetId) = makeString(["%s%s", assetIdToString(baseAssetId), "period"], separator) | |
84 | + | ||
85 | + | ||
86 | + | func keyPeriodStartHeight (baseAssetId,period) = makeString(["%s%s%d", assetIdToString(baseAssetId), "periodStartHeight", toString(period)], separator) | |
87 | + | ||
88 | + | ||
89 | + | func keyBaseAssetAmountToConvert (baseAssetId) = makeString(["%s%s", assetIdToString(baseAssetId), "baseAssetAmountToConvert"], separator) | |
90 | + | ||
91 | + | ||
92 | + | func keyShareAssetAmountToConvert (baseAssetId) = makeString(["%s%s", assetIdToString(baseAssetId), "shareAssetAmountToConvert"], separator) | |
93 | + | ||
94 | + | ||
95 | + | func keyUserBaseAssetAmountToConvert (baseAssetId,userAddress) = makeString(["%s%s%s", assetIdToString(baseAssetId), toString(userAddress), "baseAssetAmountToConvert"], separator) | |
96 | + | ||
97 | + | ||
98 | + | func keyUserBaseAssetAmountToConvertPeriod (baseAssetId,userAddress) = makeString(["%s%s%s%s", assetIdToString(baseAssetId), toString(userAddress), "baseAssetAmountToConvert", "period"], separator) | |
99 | + | ||
100 | + | ||
101 | + | func keyUserShareAssetAmountToConvert (baseAssetId,userAddress) = makeString(["%s%s%s", assetIdToString(baseAssetId), toString(userAddress), "shareAssetAmountToConvert"], separator) | |
102 | + | ||
103 | + | ||
104 | + | func keyUserShareAssetAmountToConvertPeriod (baseAssetId,userAddress) = makeString(["%s%s%s%s", assetIdToString(baseAssetId), toString(userAddress), "shareAssetAmountToConvert", "period"], separator) | |
105 | + | ||
106 | + | ||
107 | + | func keyPricePeriod (baseAssetId,period) = makeString(["%s%s%d", assetIdToString(baseAssetId), "price", toString(period)], separator) | |
108 | + | ||
109 | + | ||
110 | + | func keyPriceHistory (baseAssetId) = makeString(["%s%s%s%d%d", assetIdToString(baseAssetId), "price", "history", toString(lastBlock.height), toString(lastBlock.timestamp)], separator) | |
111 | + | ||
112 | + | ||
113 | + | func keyPricePeriodPut (baseAssetId,period) = makeString(["%s%s%d%s", assetIdToString(baseAssetId), "price", toString(period), "put"], separator) | |
114 | + | ||
115 | + | ||
116 | + | func keyPricePutHistory (baseAssetId) = makeString(["%s%s%s%s%d%d", assetIdToString(baseAssetId), "price", "history", "put", toString(lastBlock.height), toString(lastBlock.timestamp)], separator) | |
117 | + | ||
118 | + | ||
119 | + | func keyPricePeriodGet (baseAssetId,period) = makeString(["%s%s%d%s", assetIdToString(baseAssetId), "price", toString(period), "get"], separator) | |
120 | + | ||
121 | + | ||
122 | + | func keyPriceGetHistory (baseAssetId) = makeString(["%s%s%s%s%d%d", assetIdToString(baseAssetId), "price", "history", "get", toString(lastBlock.height), toString(lastBlock.timestamp)], separator) | |
123 | + | ||
124 | + | ||
125 | + | func keyHistoryEntry (baseAssetId,operation,period,userAddress,txId) = makeString(["%s%s%s%s", "history", operation, toString(userAddress), toBase58String(txId), toString(height)], separator) | |
126 | + | ||
16 | 127 | ||
17 | 128 | func keyManagerPublicKey () = "%s__managerPublicKey" | |
18 | 129 | ||
19 | 130 | ||
20 | 131 | func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey" | |
21 | - | ||
22 | - | ||
23 | - | func fc () = "%s__factoryContract" | |
24 | - | ||
25 | - | ||
26 | - | let factoryContract = addressFromStringValue(getStringOrFail(fc())) | |
27 | - | ||
28 | - | func protocolFee () = makeString(["%s", "protocolFee"], SEP) | |
29 | - | ||
30 | - | ||
31 | - | func poolFee () = makeString(["%s", "poolFee"], SEP) | |
32 | - | ||
33 | - | ||
34 | - | func getStringOrFailFromAddress (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
35 | - | ||
36 | - | ||
37 | - | let keyFeeCollectorAddress = "%s__feeCollectorAddress" | |
38 | - | ||
39 | - | let feeCollectorAddress = addressFromStringValue(getStringOrFailFromAddress(factoryContract, keyFeeCollectorAddress)) | |
40 | - | ||
41 | - | func asInt (val) = match val { | |
42 | - | case valInt: Int => | |
43 | - | valInt | |
44 | - | case _ => | |
45 | - | throw("fail to cast into Int") | |
46 | - | } | |
47 | - | ||
48 | - | ||
49 | - | func dataMappingPoolAssets (internalAmountAssetStr,internalPriceAssetStr) = makeString(["%d%d", toString(internalAmountAssetStr), toString(internalPriceAssetStr)], SEP) | |
50 | 132 | ||
51 | 133 | ||
52 | 134 | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
53 | 135 | case s: String => | |
54 | 136 | fromBase58String(s) | |
55 | 137 | case _: Unit => | |
56 | 138 | unit | |
57 | 139 | case _ => | |
58 | 140 | throw("Match error") | |
59 | 141 | } | |
60 | 142 | ||
61 | 143 | ||
62 | 144 | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { | |
63 | 145 | case s: String => | |
64 | 146 | fromBase58String(s) | |
65 | 147 | case _: Unit => | |
66 | 148 | unit | |
67 | 149 | case _ => | |
68 | 150 | throw("Match error") | |
69 | 151 | } | |
70 | 152 | ||
71 | 153 | ||
72 | - | func isManager (i) = match managerPublicKeyOrUnit() { | |
154 | + | let permissionDeniedError = throw("Permission denied") | |
155 | + | ||
156 | + | func mustThis (i) = if ((i.caller == this)) | |
157 | + | then true | |
158 | + | else permissionDeniedError | |
159 | + | ||
160 | + | ||
161 | + | func mustManager (i) = match managerPublicKeyOrUnit() { | |
73 | 162 | case pk: ByteVector => | |
74 | - | (i.callerPublicKey == pk) | |
163 | + | if ((i.callerPublicKey == pk)) | |
164 | + | then true | |
165 | + | else permissionDeniedError | |
75 | 166 | case _: Unit => | |
76 | - | (i | |
167 | + | mustThis(i) | |
77 | 168 | case _ => | |
78 | 169 | throw("Match error") | |
79 | 170 | } | |
80 | 171 | ||
81 | 172 | ||
82 | - | func mustManager (i) = if (isManager(i)) | |
173 | + | let shutdown = valueOrElse(getBoolean(keyShutdown()), false) | |
174 | + | ||
175 | + | func shutdownCheck (i) = if (if (!(shutdown)) | |
83 | 176 | then true | |
84 | - | else throw("permission denied") | |
177 | + | else mustManager(i)) | |
178 | + | then true | |
179 | + | else throw("operation is disabled") | |
85 | 180 | ||
86 | 181 | ||
87 | - | func getAccBalance (assetId) = if ((assetId == "WAVES")) | |
88 | - | then wavesBalance(this).available | |
89 | - | else assetBalance(this, fromBase58String(assetId)) | |
182 | + | let factoryContract = addressFromStringValue(getStrOrFail(this, keyFactoryContract())) | |
90 | 183 | ||
184 | + | let lpStakingContract = addressFromStringValue(getStrOrFail(this, keyLpStakingContract())) | |
91 | 185 | ||
92 | - | func getPoolAddressAndCheckPoolStatus (assetIn,assetOut) = { | |
93 | - | let lpNonReverse = { | |
94 | - | let @ = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [assetIn, assetOut], nil) | |
95 | - | if ($isInstanceOf(@, "String")) | |
186 | + | let stakingContract = addressFromStringValue(getStrOrFail(this, keyStakingContract())) | |
187 | + | ||
188 | + | let boostingContract = addressFromStringValue(getStrOrFail(this, keyBoostingContract())) | |
189 | + | ||
190 | + | let swapContract = addressFromStringValue(getStrOrFail(this, keySwapContract())) | |
191 | + | ||
192 | + | let assetsStoreContract = addressFromStringValue(getStrOrFail(this, keyAssetsStoreContract())) | |
193 | + | ||
194 | + | let usdtAssetId = parseAssetId(getStrOrFail(this, keyUsdtAssetId())) | |
195 | + | ||
196 | + | let wxAssetId = parseAssetId(getStrOrFail(this, keyWxAssetId())) | |
197 | + | ||
198 | + | let minDelayDefault = 1440 | |
199 | + | ||
200 | + | let minDelay = valueOrElse(getInteger(this, keyMinDelay()), minDelayDefault) | |
201 | + | ||
202 | + | let lockFractionMultiplier = 100000000 | |
203 | + | ||
204 | + | let lockFractionDefault = fraction(1, lockFractionMultiplier, 2) | |
205 | + | ||
206 | + | let lockFraction = valueOrElse(getInteger(this, keyLockFraction()), lockFractionDefault) | |
207 | + | ||
208 | + | func getPoolInfo (amountAssetId) = { | |
209 | + | let amountAssetIdStr = assetIdToString(amountAssetId) | |
210 | + | let priceAssetIdStr = assetIdToString(usdtAssetId) | |
211 | + | let poolInfoOption = { | |
212 | + | let @ = invoke(factoryContract, "poolInfoREADONLY", [amountAssetIdStr, priceAssetIdStr], nil) | |
213 | + | if ($isInstanceOf(@, "(Address, ByteVector)")) | |
96 | 214 | then @ | |
97 | 215 | else unit | |
98 | 216 | } | |
99 | - | let lpReverse = { | |
100 | - | let @ = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [assetOut, assetIn], nil) | |
101 | - | if ($isInstanceOf(@, "String")) | |
102 | - | then @ | |
103 | - | else unit | |
104 | - | } | |
105 | - | let $t026263103 = if ((lpNonReverse != unit)) | |
106 | - | then { | |
107 | - | let pool = { | |
108 | - | let @ = invoke(factoryContract, "getPoolAddressFromLpAssetREADONLY", [value(lpNonReverse)], nil) | |
109 | - | if ($isInstanceOf(@, "String")) | |
110 | - | then @ | |
111 | - | else throw(($getType(@) + " couldn't be cast to String")) | |
112 | - | } | |
113 | - | $Tuple2(false, pool) | |
114 | - | } | |
115 | - | else if ((lpReverse != unit)) | |
116 | - | then { | |
117 | - | let pool = { | |
118 | - | let @ = invoke(factoryContract, "getPoolAddressFromLpAssetREADONLY", [value(lpReverse)], nil) | |
119 | - | if ($isInstanceOf(@, "String")) | |
120 | - | then @ | |
121 | - | else throw(($getType(@) + " couldn't be cast to String")) | |
122 | - | } | |
123 | - | $Tuple2(true, pool) | |
124 | - | } | |
125 | - | else poolNotExist | |
126 | - | let isReverse = $t026263103._1 | |
127 | - | let pool = $t026263103._2 | |
128 | - | let poolStatus = { | |
129 | - | let @ = invoke(factoryContract, "getPoolStatusREADONLY", [pool], nil) | |
130 | - | if ($isInstanceOf(@, "Int")) | |
131 | - | then @ | |
132 | - | else throw(($getType(@) + " couldn't be cast to Int")) | |
133 | - | } | |
134 | - | let check = if ((poolStatus == 1)) | |
135 | - | then true | |
136 | - | else poolDisabled | |
137 | - | if ((check == check)) | |
138 | - | then { | |
139 | - | let poolAdr = addressFromStringValue(valueOrElse(pool, "")) | |
140 | - | $Tuple2(poolAdr, isReverse) | |
141 | - | } | |
142 | - | else throw("Strict value is not equal to itself.") | |
217 | + | poolInfoOption | |
143 | 218 | } | |
144 | 219 | ||
145 | 220 | ||
146 | - | @Callable(i) | |
147 | - | func swapCalculateREADONLY (amountIn,assetIn,assetOut) = { | |
148 | - | let prFee = value(getInteger(protocolFee())) | |
149 | - | let feeProtocolAmountCalc = fraction(toBigInt(amountIn), toBigInt(prFee), feeScale) | |
150 | - | let plFee = value(getInteger(poolFee())) | |
151 | - | let feePoolAmountCalc = fraction(toBigInt(amountIn), toBigInt(plFee), feeScale) | |
152 | - | let feeProtocolAmount = if ((toInt(feeProtocolAmountCalc) == 0)) | |
153 | - | then toBigInt(1) | |
154 | - | else feeProtocolAmountCalc | |
155 | - | let feePoolAmount = if ((toInt(feePoolAmountCalc) == 0)) | |
156 | - | then toBigInt(1) | |
157 | - | else feePoolAmountCalc | |
158 | - | let cleanAmountIn = ((toBigInt(amountIn) - feeProtocolAmount) - feePoolAmount) | |
159 | - | let $t041284206 = getPoolAddressAndCheckPoolStatus(assetIn, assetOut) | |
160 | - | let poolAdr = $t041284206._1 | |
161 | - | let isReverse = $t041284206._2 | |
162 | - | let res = { | |
163 | - | let @ = invoke(poolAdr, "calculateAmountOutForSwapREADONLY", [toInt(cleanAmountIn), isReverse, toInt(feePoolAmount)], nil) | |
221 | + | func calcPrice (lpAssetId,shareAssetId) = { | |
222 | + | let shareAssetInfo = valueOrErrorMessage(assetInfo(shareAssetId), "failed to get share asset info") | |
223 | + | let shareAssetEmission = shareAssetInfo.quantity | |
224 | + | let stakedAmount = ensurePositive(valueOrErrorMessage({ | |
225 | + | let @ = invoke(stakingContract, "stakedByUserREADONLY", [assetIdToString(lpAssetId), toString(this)], nil) | |
164 | 226 | if ($isInstanceOf(@, "Int")) | |
165 | 227 | then @ | |
166 | - | else throw(($getType(@) + " couldn't be cast to Int")) | |
167 | - | } | |
168 | - | $Tuple2(nil, res) | |
228 | + | else unit | |
229 | + | }, wrapErr("invalid stakedByUserREADONLY result"))) | |
230 | + | let price = if ((shareAssetEmission == 0)) | |
231 | + | then scale18BigInt | |
232 | + | else fraction(toBigInt(stakedAmount), scale18BigInt, toBigInt(shareAssetEmission), FLOOR) | |
233 | + | price | |
169 | 234 | } | |
170 | - | ||
171 | - | ||
172 | - | ||
173 | - | @Callable(i) | |
174 | - | func swap (amountOutMin,assetOutRaw,addressTo) = { | |
175 | - | let assetOut = if ((assetOutRaw == "")) | |
176 | - | then "WAVES" | |
177 | - | else assetOutRaw | |
178 | - | let pmt = value(i.payments[0]) | |
179 | - | let assetIn = if ((pmt.assetId == unit)) | |
180 | - | then "WAVES" | |
181 | - | else toBase58String(value(pmt.assetId)) | |
182 | - | let amountIn = value(pmt.amount) | |
183 | - | let prFee = value(getInteger(protocolFee())) | |
184 | - | let feeProtocolAmountCalc = fraction(toBigInt(amountIn), toBigInt(prFee), feeScale) | |
185 | - | let plFee = value(getInteger(poolFee())) | |
186 | - | let feePoolAmountCalc = fraction(toBigInt(amountIn), toBigInt(plFee), feeScale) | |
187 | - | let feeProtocolAmount = if ((toInt(feeProtocolAmountCalc) == 0)) | |
188 | - | then toBigInt(1) | |
189 | - | else feeProtocolAmountCalc | |
190 | - | let feePoolAmount = if ((toInt(feePoolAmountCalc) == 0)) | |
191 | - | then toBigInt(1) | |
192 | - | else feePoolAmountCalc | |
193 | - | let cleanAmountIn = ((toBigInt(amountIn) - feeProtocolAmount) - feePoolAmount) | |
194 | - | let checks = [if ((size(i.payments) == 1)) | |
195 | - | then true | |
196 | - | else throw("exactly 1 payment are expected")] | |
197 | - | if ((checks == checks)) | |
198 | - | then { | |
199 | - | let $t054525530 = getPoolAddressAndCheckPoolStatus(assetIn, assetOut) | |
200 | - | let poolAdr = $t054525530._1 | |
201 | - | let isReverse = $t054525530._2 | |
202 | - | let assetInAttachedPayment = if ((assetIn == "WAVES")) | |
203 | - | then unit | |
204 | - | else fromBase58String(assetIn) | |
205 | - | let totalGetRaw = { | |
206 | - | let @ = invoke(poolAdr, "calculateAmountOutForSwapAndSendTokens", [toInt(cleanAmountIn), isReverse, amountOutMin, addressTo, toInt(feePoolAmount)], [AttachedPayment(assetInAttachedPayment, toInt(cleanAmountIn))]) | |
207 | - | if ($isInstanceOf(@, "Int")) | |
208 | - | then @ | |
209 | - | else throw(($getType(@) + " couldn't be cast to Int")) | |
210 | - | } | |
211 | - | $Tuple2([ScriptTransfer(feeCollectorAddress, toInt(feeProtocolAmount), assetInAttachedPayment), ScriptTransfer(poolAdr, toInt(feePoolAmount), assetInAttachedPayment)], totalGetRaw) | |
212 | - | } | |
213 | - | else throw("Strict value is not equal to itself.") | |
214 | - | } | |
215 | - | ||
216 | 235 | ||
217 | 236 | ||
218 | 237 | @Callable(i) | |
219 | 238 | func setManager (pendingManagerPublicKey) = { | |
220 | 239 | let checkCaller = mustManager(i) | |
221 | 240 | if ((checkCaller == checkCaller)) | |
222 | 241 | then { | |
223 | 242 | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
224 | 243 | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
225 | 244 | then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)] | |
226 | 245 | else throw("Strict value is not equal to itself.") | |
227 | 246 | } | |
228 | 247 | else throw("Strict value is not equal to itself.") | |
229 | 248 | } | |
230 | 249 | ||
231 | 250 | ||
232 | 251 | ||
233 | 252 | @Callable(i) | |
234 | 253 | func confirmManager () = { | |
235 | 254 | let pm = pendingManagerPublicKeyOrUnit() | |
236 | 255 | let hasPM = if (isDefined(pm)) | |
237 | 256 | then true | |
238 | - | else | |
257 | + | else throwErr("no pending manager") | |
239 | 258 | if ((hasPM == hasPM)) | |
240 | 259 | then { | |
241 | 260 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
242 | 261 | then true | |
243 | - | else | |
262 | + | else throwErr("you are not pending manager") | |
244 | 263 | if ((checkPM == checkPM)) | |
245 | 264 | then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())] | |
265 | + | else throw("Strict value is not equal to itself.") | |
266 | + | } | |
267 | + | else throw("Strict value is not equal to itself.") | |
268 | + | } | |
269 | + | ||
270 | + | ||
271 | + | ||
272 | + | @Callable(i) | |
273 | + | func emit (assetId,amount) = { | |
274 | + | let checkCaller = mustThis(i) | |
275 | + | if ((checkCaller == checkCaller)) | |
276 | + | then { | |
277 | + | let isReissuable = true | |
278 | + | $Tuple2([Reissue(assetId, amount, isReissuable)], amount) | |
279 | + | } | |
280 | + | else throw("Strict value is not equal to itself.") | |
281 | + | } | |
282 | + | ||
283 | + | ||
284 | + | ||
285 | + | @Callable(i) | |
286 | + | func burn (assetId,amount) = { | |
287 | + | let checkCaller = mustThis(i) | |
288 | + | if ((checkCaller == checkCaller)) | |
289 | + | then $Tuple2([Burn(assetId, amount)], amount) | |
290 | + | else throw("Strict value is not equal to itself.") | |
291 | + | } | |
292 | + | ||
293 | + | ||
294 | + | ||
295 | + | @Callable(i) | |
296 | + | func create (baseAssetIdStr,shareAssetIdStr,shareAssetName,shareAssetDescription,shareAssetLogo) = { | |
297 | + | let shareAssetLabel = "STAKING_LP" | |
298 | + | let baseAssetId = parseAssetId(baseAssetIdStr) | |
299 | + | let checks = [mustManager(i), if (isDefined(getPoolInfo(baseAssetId))) | |
300 | + | then true | |
301 | + | else throwErr("invalid base asset")] | |
302 | + | if ((checks == checks)) | |
303 | + | then { | |
304 | + | let commonState = [IntegerEntry(keyPeriod(baseAssetId), 0)] | |
305 | + | if ((shareAssetIdStr == "")) | |
306 | + | then { | |
307 | + | let shareAssetIssueAmount = 1 | |
308 | + | let shareAssetIssueAction = Issue(shareAssetName, shareAssetDescription, shareAssetIssueAmount, shareAssetDecimals, true) | |
309 | + | let calculatedShareAssetId = calculateAssetId(shareAssetIssueAction) | |
310 | + | let shareAssetBurnAction = Burn(calculatedShareAssetId, shareAssetIssueAmount) | |
311 | + | let calculatedShareAssetIdStr = toBase58String(calculatedShareAssetId) | |
312 | + | let createOrUpdate = invoke(assetsStoreContract, "createOrUpdate", [calculatedShareAssetIdStr, shareAssetLogo, false], nil) | |
313 | + | if ((createOrUpdate == createOrUpdate)) | |
314 | + | then { | |
315 | + | let addLabel = invoke(assetsStoreContract, "addLabel", [calculatedShareAssetIdStr, shareAssetLabel], nil) | |
316 | + | if ((addLabel == addLabel)) | |
317 | + | then $Tuple2((commonState ++ [shareAssetIssueAction, shareAssetBurnAction, StringEntry(keyShareAssetId(baseAssetId), calculatedShareAssetIdStr), StringEntry(keyBaseAssetId(calculatedShareAssetId), baseAssetIdStr)]), calculatedShareAssetIdStr) | |
318 | + | else throw("Strict value is not equal to itself.") | |
319 | + | } | |
320 | + | else throw("Strict value is not equal to itself.") | |
321 | + | } | |
322 | + | else { | |
323 | + | let shareAssetId = fromBase58String(shareAssetIdStr) | |
324 | + | let shareAssetInfo = valueOrErrorMessage(assetInfo(shareAssetId), wrapErr("invalid share asset id")) | |
325 | + | let checkIssuer = if ((shareAssetInfo.issuer == lpStakingContract)) | |
326 | + | then true | |
327 | + | else throwErr("invalid share asset id issuer") | |
328 | + | if ((checkIssuer == checkIssuer)) | |
329 | + | then $Tuple2((commonState ++ [StringEntry(keyShareAssetId(baseAssetId), shareAssetIdStr), StringEntry(keyBaseAssetId(shareAssetId), baseAssetIdStr)]), shareAssetIdStr) | |
330 | + | else throw("Strict value is not equal to itself.") | |
331 | + | } | |
332 | + | } | |
333 | + | else throw("Strict value is not equal to itself.") | |
334 | + | } | |
335 | + | ||
336 | + | ||
337 | + | ||
338 | + | @Callable(i) | |
339 | + | func put () = { | |
340 | + | let pmt = if ((size(i.payments) == 1)) | |
341 | + | then i.payments[0] | |
342 | + | else throwErr("exactly 1 payment is expected") | |
343 | + | let baseAssetId = pmt.assetId | |
344 | + | let userAddress = i.caller | |
345 | + | let checks = [shutdownCheck(i), if (isDefined(getString(keyShareAssetId(baseAssetId)))) | |
346 | + | then true | |
347 | + | else throwErr("invalid asset")] | |
348 | + | if ((checks == checks)) | |
349 | + | then { | |
350 | + | let $t01192312026 = valueOrErrorMessage(getPoolInfo(baseAssetId), wrapErr("invalid asset")) | |
351 | + | let poolAddress = $t01192312026._1 | |
352 | + | let lpAssetId = $t01192312026._2 | |
353 | + | let period = value(getInteger(keyPeriod(baseAssetId))) | |
354 | + | let userBaseAssetAmountToConvertPeriodOption = getInteger(keyUserBaseAssetAmountToConvertPeriod(baseAssetId, userAddress)) | |
355 | + | let claimShareAssetInvocation = if ((userBaseAssetAmountToConvertPeriodOption == unit)) | |
356 | + | then unit | |
357 | + | else { | |
358 | + | let userBaseAssetAmountToConvertPeriod = value(userBaseAssetAmountToConvertPeriodOption) | |
359 | + | if ((userBaseAssetAmountToConvertPeriod == period)) | |
360 | + | then unit | |
361 | + | else invoke(this, "claimShareAsset", [assetIdToString(baseAssetId), toString(userAddress)], nil) | |
362 | + | } | |
363 | + | if ((claimShareAssetInvocation == claimShareAssetInvocation)) | |
364 | + | then { | |
365 | + | let baseAssetAmountToConvert = valueOrElse(getInteger(keyBaseAssetAmountToConvert(baseAssetId)), 0) | |
366 | + | let userBaseAssetAmountToConvert = valueOrElse(getInteger(keyUserBaseAssetAmountToConvert(baseAssetId, userAddress)), 0) | |
367 | + | $Tuple2([IntegerEntry(keyBaseAssetAmountToConvert(baseAssetId), (baseAssetAmountToConvert + pmt.amount)), IntegerEntry(keyUserBaseAssetAmountToConvert(baseAssetId, userAddress), (userBaseAssetAmountToConvert + pmt.amount)), IntegerEntry(keyUserBaseAssetAmountToConvertPeriod(baseAssetId, userAddress), period), IntegerEntry(keyHistoryEntry(baseAssetId, "put", period, userAddress, i.transactionId), pmt.amount)], unit) | |
368 | + | } | |
369 | + | else throw("Strict value is not equal to itself.") | |
370 | + | } | |
371 | + | else throw("Strict value is not equal to itself.") | |
372 | + | } | |
373 | + | ||
374 | + | ||
375 | + | ||
376 | + | @Callable(i) | |
377 | + | func claimShareAsset (baseAssetIdStr,userAddressStr) = { | |
378 | + | let checks = [shutdownCheck(i)] | |
379 | + | if ((checks == checks)) | |
380 | + | then { | |
381 | + | let userAddress = if ((userAddressStr == "")) | |
382 | + | then i.caller | |
383 | + | else { | |
384 | + | let checkCaller = mustThis(i) | |
385 | + | if ((checkCaller == checkCaller)) | |
386 | + | then valueOrErrorMessage(addressFromString(userAddressStr), wrapErr("invalid user address")) | |
387 | + | else throw("Strict value is not equal to itself.") | |
388 | + | } | |
389 | + | if ((userAddress == userAddress)) | |
390 | + | then { | |
391 | + | let baseAssetId = parseAssetId(baseAssetIdStr) | |
392 | + | let shareAssetId = value(parseAssetId(valueOrErrorMessage(getString(keyShareAssetId(baseAssetId)), wrapErr("invalid base asset id")))) | |
393 | + | if ((shareAssetId == shareAssetId)) | |
394 | + | then { | |
395 | + | let period = valueOrErrorMessage(getInteger(keyPeriod(baseAssetId)), wrapErr("invalid period")) | |
396 | + | if ((period == period)) | |
397 | + | then { | |
398 | + | let userBaseAssetAmountToConvert = valueOrElse(getInteger(keyUserBaseAssetAmountToConvert(baseAssetId, userAddress)), 0) | |
399 | + | let checkAmountToConvert = if ((userBaseAssetAmountToConvert > 0)) | |
400 | + | then true | |
401 | + | else throwErr("nothing to claim") | |
402 | + | if ((checkAmountToConvert == checkAmountToConvert)) | |
403 | + | then { | |
404 | + | let userBaseAssetAmountToConvertPeriod = valueOrErrorMessage(getInteger(keyUserBaseAssetAmountToConvertPeriod(baseAssetId, userAddress)), wrapErr("failed to get period")) | |
405 | + | let checkPeriod = if ((period > userBaseAssetAmountToConvertPeriod)) | |
406 | + | then true | |
407 | + | else throwErr("invalid period") | |
408 | + | if ((checkPeriod == checkPeriod)) | |
409 | + | then { | |
410 | + | let price = toBigInt(valueOrErrorMessage(getBinary(keyPricePeriodPut(baseAssetId, userBaseAssetAmountToConvertPeriod)), wrapErr("failed to get price"))) | |
411 | + | let shareAssetAmount = toInt(fraction(toBigInt(userBaseAssetAmountToConvert), scale18BigInt, price)) | |
412 | + | $Tuple2([IntegerEntry(keyUserBaseAssetAmountToConvert(baseAssetId, userAddress), 0), DeleteEntry(keyUserBaseAssetAmountToConvertPeriod(baseAssetId, userAddress)), ScriptTransfer(userAddress, shareAssetAmount, shareAssetId), IntegerEntry(keyHistoryEntry(baseAssetId, "claimShareAsset", period, userAddress, i.transactionId), shareAssetAmount)], unit) | |
413 | + | } | |
414 | + | else throw("Strict value is not equal to itself.") | |
415 | + | } | |
416 | + | else throw("Strict value is not equal to itself.") | |
417 | + | } | |
418 | + | else throw("Strict value is not equal to itself.") | |
419 | + | } | |
420 | + | else throw("Strict value is not equal to itself.") | |
421 | + | } | |
422 | + | else throw("Strict value is not equal to itself.") | |
423 | + | } | |
424 | + | else throw("Strict value is not equal to itself.") | |
425 | + | } | |
426 | + | ||
427 | + | ||
428 | + | ||
429 | + | @Callable(i) | |
430 | + | func get () = { | |
431 | + | let checks = [shutdownCheck(i)] | |
432 | + | if ((checks == checks)) | |
433 | + | then { | |
434 | + | let pmt = if ((size(i.payments) == 1)) | |
435 | + | then i.payments[0] | |
436 | + | else throwErr("exactly 1 payment is expected") | |
437 | + | let shareAssetId = pmt.assetId | |
438 | + | let baseAssetId = value(parseAssetId(valueOrErrorMessage(getString(keyBaseAssetId(shareAssetId)), wrapErr("invalid share asset id")))) | |
439 | + | if ((baseAssetId == baseAssetId)) | |
440 | + | then { | |
441 | + | let userAddress = i.caller | |
442 | + | let $t01582915932 = valueOrErrorMessage(getPoolInfo(baseAssetId), wrapErr("invalid asset")) | |
443 | + | let poolAddress = $t01582915932._1 | |
444 | + | let lpAssetId = $t01582915932._2 | |
445 | + | let period = value(getInteger(keyPeriod(baseAssetId))) | |
446 | + | let userShareAssetAmountToConvertPeriodOption = getInteger(keyUserShareAssetAmountToConvertPeriod(baseAssetId, userAddress)) | |
447 | + | let claimBaseAssetInvocation = if ((userShareAssetAmountToConvertPeriodOption == unit)) | |
448 | + | then unit | |
449 | + | else { | |
450 | + | let userShareAssetAmountToConvertPeriod = value(userShareAssetAmountToConvertPeriodOption) | |
451 | + | if ((userShareAssetAmountToConvertPeriod == period)) | |
452 | + | then unit | |
453 | + | else invoke(this, "claimBaseAsset", [assetIdToString(baseAssetId), toString(userAddress)], nil) | |
454 | + | } | |
455 | + | if ((claimBaseAssetInvocation == claimBaseAssetInvocation)) | |
456 | + | then { | |
457 | + | let shareAssetAmountToConvert = valueOrElse(getInteger(keyShareAssetAmountToConvert(baseAssetId)), 0) | |
458 | + | let userShareAssetAmountToConvert = valueOrElse(getInteger(keyUserShareAssetAmountToConvert(baseAssetId, userAddress)), 0) | |
459 | + | $Tuple2([IntegerEntry(keyShareAssetAmountToConvert(baseAssetId), (shareAssetAmountToConvert + pmt.amount)), IntegerEntry(keyUserShareAssetAmountToConvert(baseAssetId, userAddress), (userShareAssetAmountToConvert + pmt.amount)), IntegerEntry(keyUserShareAssetAmountToConvertPeriod(baseAssetId, userAddress), period), IntegerEntry(keyHistoryEntry(baseAssetId, "get", period, userAddress, i.transactionId), pmt.amount)], unit) | |
460 | + | } | |
461 | + | else throw("Strict value is not equal to itself.") | |
462 | + | } | |
463 | + | else throw("Strict value is not equal to itself.") | |
464 | + | } | |
465 | + | else throw("Strict value is not equal to itself.") | |
466 | + | } | |
467 | + | ||
468 | + | ||
469 | + | ||
470 | + | @Callable(i) | |
471 | + | func claimBaseAsset (baseAssetIdStr,userAddressStr) = { | |
472 | + | let checks = [shutdownCheck(i)] | |
473 | + | if ((checks == checks)) | |
474 | + | then { | |
475 | + | let userAddress = if ((userAddressStr == "")) | |
476 | + | then i.caller | |
477 | + | else { | |
478 | + | let checkCaller = mustThis(i) | |
479 | + | if ((checkCaller == checkCaller)) | |
480 | + | then valueOrErrorMessage(addressFromString(userAddressStr), wrapErr("invalid user address")) | |
481 | + | else throw("Strict value is not equal to itself.") | |
482 | + | } | |
483 | + | if ((userAddress == userAddress)) | |
484 | + | then { | |
485 | + | let baseAssetId = parseAssetId(baseAssetIdStr) | |
486 | + | let shareAssetId = value(parseAssetId(valueOrErrorMessage(getString(keyShareAssetId(baseAssetId)), wrapErr("invalid base asset id")))) | |
487 | + | if ((shareAssetId == shareAssetId)) | |
488 | + | then { | |
489 | + | let period = valueOrErrorMessage(getInteger(keyPeriod(baseAssetId)), wrapErr("invalid period")) | |
490 | + | if ((period == period)) | |
491 | + | then { | |
492 | + | let userShareAssetAmountToConvert = valueOrElse(getInteger(keyUserShareAssetAmountToConvert(baseAssetId, userAddress)), 0) | |
493 | + | let checkAmountToConvert = if ((userShareAssetAmountToConvert > 0)) | |
494 | + | then true | |
495 | + | else throwErr("nothing to claim") | |
496 | + | if ((checkAmountToConvert == checkAmountToConvert)) | |
497 | + | then { | |
498 | + | let userShareAssetAmountToConvertPeriod = valueOrErrorMessage(getInteger(keyUserShareAssetAmountToConvertPeriod(baseAssetId, userAddress)), wrapErr("failed to get period")) | |
499 | + | let checkPeriod = if ((period > userShareAssetAmountToConvertPeriod)) | |
500 | + | then true | |
501 | + | else throwErr("invalid period") | |
502 | + | if ((checkPeriod == checkPeriod)) | |
503 | + | then { | |
504 | + | let price = toBigInt(valueOrErrorMessage(getBinary(keyPricePeriodGet(baseAssetId, userShareAssetAmountToConvertPeriod)), wrapErr("failed to get price"))) | |
505 | + | let baseAssetAmount = toInt(fraction(toBigInt(userShareAssetAmountToConvert), price, scale18BigInt)) | |
506 | + | $Tuple2([IntegerEntry(keyUserShareAssetAmountToConvert(baseAssetId, userAddress), 0), DeleteEntry(keyUserShareAssetAmountToConvertPeriod(baseAssetId, userAddress)), ScriptTransfer(userAddress, baseAssetAmount, baseAssetId), IntegerEntry(keyHistoryEntry(baseAssetId, "claimBaseAsset", period, userAddress, i.transactionId), baseAssetAmount)], unit) | |
507 | + | } | |
508 | + | else throw("Strict value is not equal to itself.") | |
509 | + | } | |
510 | + | else throw("Strict value is not equal to itself.") | |
511 | + | } | |
512 | + | else throw("Strict value is not equal to itself.") | |
513 | + | } | |
514 | + | else throw("Strict value is not equal to itself.") | |
515 | + | } | |
516 | + | else throw("Strict value is not equal to itself.") | |
517 | + | } | |
518 | + | else throw("Strict value is not equal to itself.") | |
519 | + | } | |
520 | + | ||
521 | + | ||
522 | + | ||
523 | + | @Callable(i) | |
524 | + | func finalize (baseAssetIdStr) = { | |
525 | + | let checks = [shutdownCheck(i)] | |
526 | + | if ((checks == checks)) | |
527 | + | then { | |
528 | + | let baseAssetId = parseAssetId(baseAssetIdStr) | |
529 | + | let shareAssetId = value(parseAssetId(valueOrErrorMessage(getString(keyShareAssetId(baseAssetId)), wrapErr("invalid base asset id")))) | |
530 | + | if ((shareAssetId == shareAssetId)) | |
531 | + | then { | |
532 | + | let shareAssetInfo = valueOrErrorMessage(assetInfo(shareAssetId), wrapErr("invalid share asset id")) | |
533 | + | let period = valueOrErrorMessage(getInteger(keyPeriod(baseAssetId)), wrapErr("invalid period")) | |
534 | + | if ((period == period)) | |
535 | + | then { | |
536 | + | let periodStartHeightOption = getInteger(keyPeriodStartHeight(baseAssetId, period)) | |
537 | + | let checkDelay = if ((periodStartHeightOption == unit)) | |
538 | + | then unit | |
539 | + | else { | |
540 | + | let delay = (height - value(periodStartHeightOption)) | |
541 | + | let blocksToWait = max([0, (minDelay - delay)]) | |
542 | + | if ((blocksToWait == 0)) | |
543 | + | then unit | |
544 | + | else throwErr(makeString(["finalization will be possible in ", toString(blocksToWait), " blocks"], "")) | |
545 | + | } | |
546 | + | if ((checkDelay == checkDelay)) | |
547 | + | then { | |
548 | + | let $t02008920274 = valueOrErrorMessage(getPoolInfo(baseAssetId), wrapErr("invalid asset")) | |
549 | + | let poolAddress = $t02008920274._1 | |
550 | + | let lpAssetId = $t02008920274._2 | |
551 | + | let stakingReward = valueOrErrorMessage({ | |
552 | + | let @ = invoke(stakingContract, "claimWxDoNotThrow", [assetIdToString(lpAssetId)], nil) | |
553 | + | if ($isInstanceOf(@, "Int")) | |
554 | + | then @ | |
555 | + | else unit | |
556 | + | }, wrapErr("invalid claimWx result")) | |
557 | + | if ((stakingReward == stakingReward)) | |
558 | + | then { | |
559 | + | let baseAssetAmountToConvert = valueOrElse(getInteger(keyBaseAssetAmountToConvert(baseAssetId)), 0) | |
560 | + | let shareAssetAmountToConvert = valueOrElse(getInteger(keyShareAssetAmountToConvert(baseAssetId)), 0) | |
561 | + | let checkFinalizationIsRequired = { | |
562 | + | let isFinalizationRequired = if (if ((stakingReward > 0)) | |
563 | + | then true | |
564 | + | else (baseAssetAmountToConvert > 0)) | |
565 | + | then true | |
566 | + | else (shareAssetAmountToConvert > 0) | |
567 | + | if (isFinalizationRequired) | |
568 | + | then true | |
569 | + | else throwErr("nothing to finalize") | |
570 | + | } | |
571 | + | if ((checkFinalizationIsRequired == checkFinalizationIsRequired)) | |
572 | + | then { | |
573 | + | let useStakingReward = if ((stakingReward > 0)) | |
574 | + | then { | |
575 | + | let lockPart = fraction(stakingReward, lockFraction, lockFractionMultiplier) | |
576 | + | let convertPart = (stakingReward - lockPart) | |
577 | + | let r = invoke(boostingContract, "userMaxDurationREADONLY", [toString(this)], nil) | |
578 | + | let lock = if ((lockPart > 0)) | |
579 | + | then match r { | |
580 | + | case _ => | |
581 | + | if (if (if ($isInstanceOf($match0._1, "String")) | |
582 | + | then $isInstanceOf($match0._2, "Int") | |
583 | + | else false) | |
584 | + | then $isInstanceOf($match0, "(String, Int)") | |
585 | + | else false) | |
586 | + | then { | |
587 | + | let function = $match0._1 | |
588 | + | let duration = $match0._2 | |
589 | + | if ((lockPart > 0)) | |
590 | + | then invoke(boostingContract, function, [duration], [AttachedPayment(wxAssetId, lockPart)]) | |
591 | + | else unit | |
592 | + | } | |
593 | + | else throwErr("invalid lock params") | |
594 | + | } | |
595 | + | else unit | |
596 | + | if ((lock == lock)) | |
597 | + | then { | |
598 | + | let convertedAmount = if ((convertPart > 0)) | |
599 | + | then { | |
600 | + | let inAssetId = wxAssetId | |
601 | + | let minimumToReceive = 0 | |
602 | + | let outAssetIdStr = assetIdToString(usdtAssetId) | |
603 | + | let targetAddress = toString(this) | |
604 | + | valueOrErrorMessage({ | |
605 | + | let @ = invoke(swapContract, "swap", [minimumToReceive, outAssetIdStr, targetAddress], [AttachedPayment(inAssetId, convertPart)]) | |
606 | + | if ($isInstanceOf(@, "Int")) | |
607 | + | then @ | |
608 | + | else unit | |
609 | + | }, wrapErr("invalid swap result")) | |
610 | + | } | |
611 | + | else 0 | |
612 | + | if ((convertedAmount == convertedAmount)) | |
613 | + | then { | |
614 | + | let lpAssetAmount = if ((convertedAmount > 0)) | |
615 | + | then { | |
616 | + | let minOutAmount = 0 | |
617 | + | let autoStake = true | |
618 | + | valueOrErrorMessage({ | |
619 | + | let @ = invoke(poolAddress, "putOneTknV2", [minOutAmount, autoStake], [AttachedPayment(usdtAssetId, convertedAmount)]) | |
620 | + | if ($isInstanceOf(@, "Int")) | |
621 | + | then @ | |
622 | + | else unit | |
623 | + | }, wrapErr("invalid putOneTknV2 result")) | |
624 | + | } | |
625 | + | else 0 | |
626 | + | if ((lpAssetAmount == lpAssetAmount)) | |
627 | + | then lpAssetAmount | |
628 | + | else throw("Strict value is not equal to itself.") | |
629 | + | } | |
630 | + | else throw("Strict value is not equal to itself.") | |
631 | + | } | |
632 | + | else throw("Strict value is not equal to itself.") | |
633 | + | } | |
634 | + | else unit | |
635 | + | if ((useStakingReward == useStakingReward)) | |
636 | + | then { | |
637 | + | let getActions = if ((shareAssetAmountToConvert > 0)) | |
638 | + | then { | |
639 | + | let price = calcPrice(lpAssetId, shareAssetId) | |
640 | + | if ((price == price)) | |
641 | + | then { | |
642 | + | let unstakeAmount = toInt(fraction(toBigInt(shareAssetAmountToConvert), price, scale18BigInt, FLOOR)) | |
643 | + | let baseAssetAmount = { | |
644 | + | let outAssetId = baseAssetId | |
645 | + | let minOutAmount = 0 | |
646 | + | valueOrErrorMessage({ | |
647 | + | let @ = invoke(poolAddress, "unstakeAndGetOneTknV2", [unstakeAmount, assetIdToString(outAssetId), minOutAmount], nil) | |
648 | + | if ($isInstanceOf(@, "Int")) | |
649 | + | then @ | |
650 | + | else unit | |
651 | + | }, wrapErr("invalid unstakeAndGetOneTknV2 result")) | |
652 | + | } | |
653 | + | if ((baseAssetAmount == baseAssetAmount)) | |
654 | + | then { | |
655 | + | let shareAssetBurn = if ((shareAssetInfo.issuer == this)) | |
656 | + | then invoke(this, "burn", [shareAssetId, shareAssetAmountToConvert], nil) | |
657 | + | else throwErr("invalid share asset issuer") | |
658 | + | if ((shareAssetBurn == shareAssetBurn)) | |
659 | + | then { | |
660 | + | let priceGet = fraction(toBigInt(baseAssetAmount), scale18BigInt, toBigInt(shareAssetAmountToConvert), FLOOR) | |
661 | + | let priceGetUpdateActions = [BinaryEntry(keyPricePeriodGet(baseAssetId, period), toBytes(priceGet)), StringEntry(keyPriceGetHistory(baseAssetId), toString(priceGet))] | |
662 | + | priceGetUpdateActions | |
663 | + | } | |
664 | + | else throw("Strict value is not equal to itself.") | |
665 | + | } | |
666 | + | else throw("Strict value is not equal to itself.") | |
667 | + | } | |
668 | + | else throw("Strict value is not equal to itself.") | |
669 | + | } | |
670 | + | else nil | |
671 | + | if ((getActions == getActions)) | |
672 | + | then { | |
673 | + | let putActions = if ((baseAssetAmountToConvert > 0)) | |
674 | + | then { | |
675 | + | let lpAssetAmount = { | |
676 | + | let minOutAmount = 0 | |
677 | + | let autoStake = true | |
678 | + | valueOrErrorMessage({ | |
679 | + | let @ = invoke(poolAddress, "putOneTknV2", [minOutAmount, autoStake], [AttachedPayment(baseAssetId, baseAssetAmountToConvert)]) | |
680 | + | if ($isInstanceOf(@, "Int")) | |
681 | + | then @ | |
682 | + | else unit | |
683 | + | }, wrapErr("invalid putOneTknV2 result")) | |
684 | + | } | |
685 | + | if ((lpAssetAmount == lpAssetAmount)) | |
686 | + | then { | |
687 | + | let price = calcPrice(lpAssetId, shareAssetId) | |
688 | + | if ((price == price)) | |
689 | + | then { | |
690 | + | let shareAssetAmount = toInt(fraction(toBigInt(lpAssetAmount), scale18BigInt, price, FLOOR)) | |
691 | + | let shareAssetReissue = if ((shareAssetInfo.issuer == this)) | |
692 | + | then invoke(this, "emit", [shareAssetId, shareAssetAmount], nil) | |
693 | + | else throwErr("invalid share asset issuer") | |
694 | + | if ((shareAssetReissue == shareAssetReissue)) | |
695 | + | then { | |
696 | + | let pricePut = fraction(toBigInt(baseAssetAmountToConvert), scale18BigInt, toBigInt(shareAssetAmount)) | |
697 | + | let pricePutUpdateActions = [BinaryEntry(keyPricePeriodPut(baseAssetId, period), toBytes(pricePut)), StringEntry(keyPricePutHistory(baseAssetId), toString(pricePut))] | |
698 | + | pricePutUpdateActions | |
699 | + | } | |
700 | + | else throw("Strict value is not equal to itself.") | |
701 | + | } | |
702 | + | else throw("Strict value is not equal to itself.") | |
703 | + | } | |
704 | + | else throw("Strict value is not equal to itself.") | |
705 | + | } | |
706 | + | else nil | |
707 | + | if ((putActions == putActions)) | |
708 | + | then { | |
709 | + | let newPeriod = (period + 1) | |
710 | + | let lastPrice = calcPrice(lpAssetId, shareAssetId) | |
711 | + | let actions = (([IntegerEntry(keyPeriod(baseAssetId), newPeriod), IntegerEntry(keyPeriodStartHeight(baseAssetId, newPeriod), height), IntegerEntry(keyShareAssetAmountToConvert(baseAssetId), 0), IntegerEntry(keyBaseAssetAmountToConvert(baseAssetId), 0), BinaryEntry(keyPricePeriod(baseAssetId, period), toBytes(lastPrice)), StringEntry(keyPriceHistory(baseAssetId), toString(lastPrice))] ++ putActions) ++ getActions) | |
712 | + | $Tuple2(actions, toBytes(lastPrice)) | |
713 | + | } | |
714 | + | else throw("Strict value is not equal to itself.") | |
715 | + | } | |
716 | + | else throw("Strict value is not equal to itself.") | |
717 | + | } | |
718 | + | else throw("Strict value is not equal to itself.") | |
719 | + | } | |
720 | + | else throw("Strict value is not equal to itself.") | |
721 | + | } | |
722 | + | else throw("Strict value is not equal to itself.") | |
723 | + | } | |
724 | + | else throw("Strict value is not equal to itself.") | |
725 | + | } | |
726 | + | else throw("Strict value is not equal to itself.") | |
727 | + | } | |
246 | 728 | else throw("Strict value is not equal to itself.") | |
247 | 729 | } | |
248 | 730 | else throw("Strict value is not equal to itself.") | |
249 | 731 | } | |
250 | 732 | ||
251 | 733 | ||
252 | 734 | @Verifier(tx) | |
253 | 735 | func verify () = { | |
254 | 736 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
255 | 737 | case pk: ByteVector => | |
256 | 738 | pk | |
257 | 739 | case _: Unit => | |
258 | 740 | tx.senderPublicKey | |
259 | 741 | case _ => | |
260 | 742 | throw("Match error") | |
261 | 743 | } | |
262 | 744 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
263 | 745 | } | |
264 | 746 |
github/deemru/w8io/169f3d6 88.36 ms ◑