tx · ALtUDyXosYHwARe1G5sRnpKYLVNDfYnUXRkQW9Ky5wH6 3MwLW8P5yh5T2xML9QqFuVxkVkm9RXqnzXh: -0.00800000 Waves 2022.11.30 20:59 [2340169] smart account 3MwLW8P5yh5T2xML9QqFuVxkVkm9RXqnzXh > SELF 0.00000000 Waves
{ "type": 13, "id": "ALtUDyXosYHwARe1G5sRnpKYLVNDfYnUXRkQW9Ky5wH6", "fee": 800000, "feeAssetId": null, "timestamp": 1669831201779, "version": 2, "chainId": 84, "sender": "3MwLW8P5yh5T2xML9QqFuVxkVkm9RXqnzXh", "senderPublicKey": "HscGVyJG5M3NMHWKfQbucCBsFLGPi8VmTxTAmcBbaWTa", "proofs": [ "5YnD4PU9JcKb4KJXbnBY6Ror1hxSLmkvkfqrXdipvjcWLgELAgDhqWcXKJTamu5XoQKpU3MPQpa9rA8dFWQZnvXa" ], "script": "base64:BgIOCAISAwoBCBIDCgEIEgASAAZTY2FsZTYAwIQ9AAZTY2FsZTgAgMLXLwAHU2NhbGUxNgkAaAIFBlNjYWxlOAUGU2NhbGU4AAp2YWxpZGF0b3JzCQDMCAICIzNOQW1xR2p4UkJSUG9SSFpVVXF2aGlOUzZheG5HcGluTEhDBQNuaWwAB2Fzc2V0SWQCLEhIbWFGUXBVb2J3S3h6ano0RUNhQlB0b0Y2OWt1akt3VTJjb3phVXpUc2d2AAtwdXp6bGVQb29scwkAzAgCAiMzTjZTdEpkZ21UZkFSc1JObjlYdDVyRFlFczNwcjRLR3kxdgUDbmlsAQpnZXRCYWxhbmNlAQdhc3NldElkBAckbWF0Y2gwBQdhc3NldElkAwkAAQIFByRtYXRjaDACBFVuaXQEAXgFByRtYXRjaDAICQDvBwEFBHRoaXMJYXZhaWxhYmxlCQDwBwIFBHRoaXMJAQV2YWx1ZQEFB2Fzc2V0SWQBCXRyeUdldEludAIHYWRkcmVzcwNrZXkEByRtYXRjaDAJAJoIAgUHYWRkcmVzcwUDa2V5AwkAAQIFByRtYXRjaDACA0ludAQ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Bvb2wBAnR4AQZ2ZXJpZnkACQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwAACAUCdHgPc2VuZGVyUHVibGljS2V5dzrfdw==", "height": 2340169, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: G3MuSEZ7UCSPQw5t9jCEnG9uKotau9x64PZjbQtw6Po Next: 9R6erxBzUKkVB27ngEBAaafaT1pWM9JJMBou7jjts4fs Diff:
Old | New | Differences | |
---|---|---|---|
45 | 45 | } | |
46 | 46 | ||
47 | 47 | ||
48 | - | func getPuzzlePoolSuppliedAmount (poolId) = if ((poolId == "")) | |
49 | - | then 0 | |
50 | - | else { | |
51 | - | let balance = assetBalance(Address(fromBase58String(poolId)), fromBase58String(assetId)) | |
52 | - | balance | |
53 | - | } | |
48 | + | func getPuzzlePoolSuppliedAmount (poolId) = { | |
49 | + | let balance = assetBalance(Address(fromBase58String(poolId)), fromBase58String(assetId)) | |
50 | + | balance | |
51 | + | } | |
54 | 52 | ||
55 | 53 | ||
56 | 54 | func getTotalSuppliedAmount () = { | |
108 | 106 | } | |
109 | 107 | ||
110 | 108 | ||
109 | + | func withdrawResult () = { | |
110 | + | let currentPool = tryGetStr(this, "currentPool") | |
111 | + | if ((currentPool == "")) | |
112 | + | then throw(("Cannot find pool with id " + currentPool)) | |
113 | + | else { | |
114 | + | let amount = getPuzzlePoolSuppliedAmount(currentPool) | |
115 | + | let tx = withdrawFromPuzzlePool(currentPool, amount) | |
116 | + | if ((tx == tx)) | |
117 | + | then tx | |
118 | + | else throw("Strict value is not equal to itself.") | |
119 | + | } | |
120 | + | } | |
121 | + | ||
122 | + | ||
111 | 123 | func stakeResult (user,amount) = { | |
112 | 124 | let sAmount = fraction(amount, Scale8, calculateSRate()) | |
113 | 125 | (recalcResult(sAmount) ++ [IntegerEntry((user + "_staked"), (tryGetInt(this, (user + "_staked")) + sAmount))]) | |
114 | 126 | } | |
127 | + | ||
128 | + | ||
129 | + | @Callable(i) | |
130 | + | func init (poolId) = { | |
131 | + | let currentPool = tryGetStr(this, "currentPool") | |
132 | + | if ((indexOf(validators, toString(i.caller)) == unit)) | |
133 | + | then throw("Access denied") | |
134 | + | else if ((currentPool == "")) | |
135 | + | then [StringEntry("currentPool", poolId)] | |
136 | + | else nil | |
137 | + | } | |
138 | + | ||
115 | 139 | ||
116 | 140 | ||
117 | 141 | @Callable(i) | |
122 | 146 | else if ((currentPool == poolId)) | |
123 | 147 | then throw(("Already supplied to" + currentPool)) | |
124 | 148 | else { | |
125 | - | let amount = getPuzzlePoolSuppliedAmount(currentPool) | |
126 | - | let tx = if ((amount > 0)) | |
127 | - | then withdrawFromPuzzlePool(currentPool, amount) | |
128 | - | else "" | |
129 | - | if ((tx == tx)) | |
149 | + | let withdrawTx = withdrawResult() | |
150 | + | if ((withdrawTx == withdrawTx)) | |
130 | 151 | then (supplyResult(poolId) ++ recalcResult(0)) | |
131 | 152 | else throw("Strict value is not equal to itself.") | |
132 | 153 | } |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let Scale6 = 1000000 | |
5 | 5 | ||
6 | 6 | let Scale8 = 100000000 | |
7 | 7 | ||
8 | 8 | let Scale16 = (Scale8 * Scale8) | |
9 | 9 | ||
10 | 10 | let validators = ["3NAmqGjxRBRPoRHZUUqvhiNS6axnGpinLHC"] | |
11 | 11 | ||
12 | 12 | let assetId = "HHmaFQpUobwKxzjz4ECaBPtoF69kujKwU2cozaUzTsgv" | |
13 | 13 | ||
14 | 14 | let puzzlePools = ["3N6StJdgmTfARsRNn9Xt5rDYEs3pr4KGy1v"] | |
15 | 15 | ||
16 | 16 | func getBalance (assetId) = match assetId { | |
17 | 17 | case x: Unit => | |
18 | 18 | wavesBalance(this).available | |
19 | 19 | case _ => | |
20 | 20 | assetBalance(this, value(assetId)) | |
21 | 21 | } | |
22 | 22 | ||
23 | 23 | ||
24 | 24 | func tryGetInt (address,key) = match getInteger(address, key) { | |
25 | 25 | case b: Int => | |
26 | 26 | b | |
27 | 27 | case _ => | |
28 | 28 | 0 | |
29 | 29 | } | |
30 | 30 | ||
31 | 31 | ||
32 | 32 | func tryGetStr (address,key) = match getString(address, key) { | |
33 | 33 | case b: String => | |
34 | 34 | b | |
35 | 35 | case _ => | |
36 | 36 | "" | |
37 | 37 | } | |
38 | 38 | ||
39 | 39 | ||
40 | 40 | func getAssetString (assetId) = match assetId { | |
41 | 41 | case b: ByteVector => | |
42 | 42 | toBase58String(b) | |
43 | 43 | case _ => | |
44 | 44 | "WAVES" | |
45 | 45 | } | |
46 | 46 | ||
47 | 47 | ||
48 | - | func getPuzzlePoolSuppliedAmount (poolId) = if ((poolId == "")) | |
49 | - | then 0 | |
50 | - | else { | |
51 | - | let balance = assetBalance(Address(fromBase58String(poolId)), fromBase58String(assetId)) | |
52 | - | balance | |
53 | - | } | |
48 | + | func getPuzzlePoolSuppliedAmount (poolId) = { | |
49 | + | let balance = assetBalance(Address(fromBase58String(poolId)), fromBase58String(assetId)) | |
50 | + | balance | |
51 | + | } | |
54 | 52 | ||
55 | 53 | ||
56 | 54 | func getTotalSuppliedAmount () = { | |
57 | 55 | let currentPool = tryGetStr(this, "currentPool") | |
58 | 56 | if ((currentPool == "")) | |
59 | 57 | then throw(("Cannot find pool with id " + currentPool)) | |
60 | 58 | else getPuzzlePoolSuppliedAmount(currentPool) | |
61 | 59 | } | |
62 | 60 | ||
63 | 61 | ||
64 | 62 | func withdrawFromPuzzlePool (poolId,amount) = { | |
65 | 63 | let poolAddress = Address(fromBase58String(poolId)) | |
66 | 64 | let withdrawTx = if ((amount > 0)) | |
67 | 65 | then invoke(poolAddress, "withdraw", [assetId, amount], nil) | |
68 | 66 | else "" | |
69 | 67 | if ((withdrawTx == withdrawTx)) | |
70 | 68 | then withdrawTx | |
71 | 69 | else throw("Strict value is not equal to itself.") | |
72 | 70 | } | |
73 | 71 | ||
74 | 72 | ||
75 | 73 | func calculateSRate () = { | |
76 | 74 | let lastCheckSRate = tryGetInt(this, "global_lastCheckSRate") | |
77 | 75 | let stakedAmount = tryGetInt(this, "global_staked") | |
78 | 76 | let lastCheckHeight = tryGetInt(this, "global_lastCheckSRateHeight") | |
79 | 77 | let blocks = (height - lastCheckHeight) | |
80 | 78 | let stakingEmission = (getTotalSuppliedAmount() - fraction(stakedAmount, lastCheckSRate, Scale8)) | |
81 | 79 | if ((stakedAmount == 0)) | |
82 | 80 | then Scale8 | |
83 | 81 | else { | |
84 | 82 | let sRate = (lastCheckSRate + fraction((blocks * Scale8), stakingEmission, stakedAmount)) | |
85 | 83 | if ((Scale8 > sRate)) | |
86 | 84 | then Scale8 | |
87 | 85 | else sRate | |
88 | 86 | } | |
89 | 87 | } | |
90 | 88 | ||
91 | 89 | ||
92 | 90 | func recalcResult (stakedChange) = { | |
93 | 91 | let stakedAmount = tryGetInt(this, "global_staked") | |
94 | 92 | let sRate = calculateSRate() | |
95 | 93 | [IntegerEntry("global_staked", (stakedAmount + stakedChange)), IntegerEntry("global_lastCheckSRate", sRate), IntegerEntry("global_lastCheckSRateHeight", height)] | |
96 | 94 | } | |
97 | 95 | ||
98 | 96 | ||
99 | 97 | func supplyResult (poolId) = if ((indexOf(puzzlePools, poolId) == unit)) | |
100 | 98 | then throw(("Unknown poolId " + poolId)) | |
101 | 99 | else { | |
102 | 100 | let assetBytes = fromBase58String(assetId) | |
103 | 101 | let balance = getBalance(assetBytes) | |
104 | 102 | let inv = invoke(Address(fromBase58String(poolId)), "supply", nil, [AttachedPayment(assetBytes, balance)]) | |
105 | 103 | if ((inv == inv)) | |
106 | 104 | then [StringEntry("currentPool", poolId)] | |
107 | 105 | else throw("Strict value is not equal to itself.") | |
108 | 106 | } | |
109 | 107 | ||
110 | 108 | ||
109 | + | func withdrawResult () = { | |
110 | + | let currentPool = tryGetStr(this, "currentPool") | |
111 | + | if ((currentPool == "")) | |
112 | + | then throw(("Cannot find pool with id " + currentPool)) | |
113 | + | else { | |
114 | + | let amount = getPuzzlePoolSuppliedAmount(currentPool) | |
115 | + | let tx = withdrawFromPuzzlePool(currentPool, amount) | |
116 | + | if ((tx == tx)) | |
117 | + | then tx | |
118 | + | else throw("Strict value is not equal to itself.") | |
119 | + | } | |
120 | + | } | |
121 | + | ||
122 | + | ||
111 | 123 | func stakeResult (user,amount) = { | |
112 | 124 | let sAmount = fraction(amount, Scale8, calculateSRate()) | |
113 | 125 | (recalcResult(sAmount) ++ [IntegerEntry((user + "_staked"), (tryGetInt(this, (user + "_staked")) + sAmount))]) | |
114 | 126 | } | |
127 | + | ||
128 | + | ||
129 | + | @Callable(i) | |
130 | + | func init (poolId) = { | |
131 | + | let currentPool = tryGetStr(this, "currentPool") | |
132 | + | if ((indexOf(validators, toString(i.caller)) == unit)) | |
133 | + | then throw("Access denied") | |
134 | + | else if ((currentPool == "")) | |
135 | + | then [StringEntry("currentPool", poolId)] | |
136 | + | else nil | |
137 | + | } | |
138 | + | ||
115 | 139 | ||
116 | 140 | ||
117 | 141 | @Callable(i) | |
118 | 142 | func rebalance (poolId) = { | |
119 | 143 | let currentPool = tryGetStr(this, "currentPool") | |
120 | 144 | if ((indexOf(validators, toString(i.caller)) == unit)) | |
121 | 145 | then throw("Access denied") | |
122 | 146 | else if ((currentPool == poolId)) | |
123 | 147 | then throw(("Already supplied to" + currentPool)) | |
124 | 148 | else { | |
125 | - | let amount = getPuzzlePoolSuppliedAmount(currentPool) | |
126 | - | let tx = if ((amount > 0)) | |
127 | - | then withdrawFromPuzzlePool(currentPool, amount) | |
128 | - | else "" | |
129 | - | if ((tx == tx)) | |
149 | + | let withdrawTx = withdrawResult() | |
150 | + | if ((withdrawTx == withdrawTx)) | |
130 | 151 | then (supplyResult(poolId) ++ recalcResult(0)) | |
131 | 152 | else throw("Strict value is not equal to itself.") | |
132 | 153 | } | |
133 | 154 | } | |
134 | 155 | ||
135 | 156 | ||
136 | 157 | ||
137 | 158 | @Callable(i) | |
138 | 159 | func stake () = { | |
139 | 160 | let user = toString(i.caller) | |
140 | 161 | let amount = i.payments[0].amount | |
141 | 162 | let currentPool = tryGetStr(this, "currentPool") | |
142 | 163 | if (if ((0 >= amount)) | |
143 | 164 | then true | |
144 | 165 | else (i.payments[0].assetId != fromBase58String(assetId))) | |
145 | 166 | then throw("invalid token attached") | |
146 | 167 | else if ((currentPool == "")) | |
147 | 168 | then throw("Pool not initialized") | |
148 | 169 | else (stakeResult(user, amount) ++ supplyResult(currentPool)) | |
149 | 170 | } | |
150 | 171 | ||
151 | 172 | ||
152 | 173 | @Verifier(tx) | |
153 | 174 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
154 | 175 |
github/deemru/w8io/169f3d6 52.66 ms ◑