code.vegaprotocol.io/vega@v0.79.0/core/integration/features/verified/0059-STKG-auto_delegation.feature (about) 1 Feature: Auto Delegation 2 3 Background: 4 Given the following network parameters are set: 5 | name | value | 6 | reward.asset | VEGA | 7 | validators.epoch.length | 10s | 8 | validators.delegation.minAmount | 10 | 9 | reward.staking.delegation.delegatorShare | 0.883 | 10 | reward.staking.delegation.minimumValidatorStake | 100 | 11 | reward.staking.delegation.maxPayoutPerParticipant | 100000 | 12 | reward.staking.delegation.competitionLevel | 1.1 | 13 | reward.staking.delegation.minValidators | 5 | 14 | reward.staking.delegation.optimalStakeMultiplier | 5.0 | 15 | network.markPriceUpdateMaximumFrequency | 0s | 16 17 18 Given time is updated to "2021-08-26T00:00:00Z" 19 Given the average block duration is "2" 20 21 And the validators: 22 | id | staking account balance | 23 | node1 | 1000000 | 24 | node2 | 1000000 | 25 | node3 | 1000000 | 26 | node4 | 1000000 | 27 | node5 | 1000000 | 28 | node6 | 1000000 | 29 | node7 | 1000000 | 30 | node8 | 1000000 | 31 | node9 | 1000000 | 32 | node10 | 1000000 | 33 34 #set up the self delegation of the validators 35 Then the parties submit the following delegations: 36 | party | node id | amount | 37 | node1 | node1 | 10000 | 38 | node2 | node2 | 10000 | 39 | node3 | node3 | 10000 | 40 | node4 | node4 | 10000 | 41 | node5 | node5 | 10000 | 42 | node6 | node6 | 10000 | 43 | node7 | node7 | 10000 | 44 | node8 | node8 | 10000 | 45 | node9 | node9 | 10000 | 46 | node10 | node10 | 10000 | 47 48 And the parties deposit on staking account the following amount: 49 | party | asset | amount | 50 | party1 | VEGA | 10000 | 51 | party2 | VEGA | 20000 | 52 53 #complete the first epoch for the self delegation to take effect 54 Then the network moves ahead "7" blocks 55 56 Scenario: A party enters auto delegation mode by nominating all of its associated stake (0059-STKG-019) 57 Description: Once a party has delegated all of its associated stake, it enters auto delegation mode. Once it has more stake associated, it gets automatically distributed between the validators maintaining the same distribution. 58 59 When the parties submit the following delegations: 60 | party | node id | amount | 61 | party1 | node1 | 1000 | 62 | party1 | node2 | 1000 | 63 | party1 | node3 | 1000 | 64 | party1 | node4 | 1000 | 65 | party1 | node5 | 1000 | 66 | party1 | node6 | 1000 | 67 | party1 | node7 | 1000 | 68 | party1 | node8 | 1000 | 69 | party1 | node9 | 1000 | 70 | party1 | node10 | 1000 | 71 72 #advance to the end of the second epoch 73 #by now party1 is in auto delegation mode - start the next epoch 74 Then the network moves ahead "7" blocks 75 76 And the parties deposit on staking account the following amount: 77 | party | asset | amount | 78 | party1 | VEGA | 1000 | 79 80 # move to the end of the third epoch for auto delegation to take place for party1 81 When the network moves ahead "7" blocks 82 Then the parties should have the following delegation balances for epoch 3: 83 | party | node id | amount | 84 | party1 | node1 | 1100 | 85 | party1 | node2 | 1100 | 86 | party1 | node3 | 1100 | 87 | party1 | node4 | 1100 | 88 | party1 | node5 | 1100 | 89 | party1 | node6 | 1100 | 90 | party1 | node7 | 1100 | 91 | party1 | node8 | 1100 | 92 | party1 | node9 | 1100 | 93 | party1 | node10 | 1100 | 94 95 Scenario: A party dissociates VEGA token leading to undelegation proportionally to their current delegation (0059-STKG-012, 0059-STKG-018) 96 Description: Once a party dissociates VEGA tokens their delegation is adjusted automatically to reflect that in the same propotion as the delegation with respect to the amount withdrawn 97 98 When the parties submit the following delegations: 99 | party | node id | amount | 100 | party1 | node1 | 2000 | 101 | party1 | node2 | 2000 | 102 | party1 | node3 | 1000 | 103 | party1 | node4 | 1000 | 104 | party1 | node5 | 1000 | 105 | party1 | node6 | 1000 | 106 | party1 | node7 | 500 | 107 | party1 | node8 | 500 | 108 | party1 | node9 | 500 | 109 | party1 | node10 | 500 | 110 111 #advance to the end of the epoch 2 and start epoch 3 112 When the network moves ahead "7" blocks 113 Given the parties withdraw from staking account the following amount: 114 | party | asset | amount | 115 | party1 | VEGA | 5000 | 116 117 #advance to the end of epoch 3 118 When the network moves ahead "7" blocks 119 Then the parties should have the following delegation balances for epoch 3: 120 | party | node id | amount | 121 | party1 | node1 | 1000 | 122 | party1 | node2 | 1000 | 123 | party1 | node3 | 500 | 124 | party1 | node4 | 500 | 125 | party1 | node5 | 500 | 126 | party1 | node6 | 500 | 127 | party1 | node7 | 250 | 128 | party1 | node8 | 250 | 129 | party1 | node9 | 250 | 130 | party1 | node10 | 250 | 131 132 Scenario: A party enters auto delegation mode by nominating all of its associated stake, once more tokens are associated they are distributed however not in epochs when manual delegation takes place (0059-STKG-020) 133 Description: Once a party has delegated all of its associated stake, it enters auto delegation mode. In the following epoch they submit manual delegations so the auto delegation doesn't kick in. An epoch later the remaining tokens are distributed. 134 135 When the parties submit the following delegations: 136 | party | node id | amount | 137 | party1 | node1 | 1000 | 138 | party1 | node2 | 1000 | 139 | party1 | node3 | 1000 | 140 | party1 | node4 | 1000 | 141 | party1 | node5 | 1000 | 142 | party1 | node6 | 1000 | 143 | party1 | node7 | 1000 | 144 | party1 | node8 | 1000 | 145 | party1 | node9 | 1000 | 146 | party1 | node10 | 1000 | 147 148 #advance to the end of the epoch and start a new epoch 149 Given the network moves ahead "7" blocks 150 And the parties deposit on staking account the following amount: 151 | party | asset | amount | 152 | party1 | VEGA | 1500 | 153 154 And the parties submit the following delegations: 155 | party | node id | amount | 156 | party1 | node1 | 50 | 157 | party1 | node2 | 50 | 158 | party1 | node3 | 50 | 159 | party1 | node4 | 50 | 160 | party1 | node5 | 50 | 161 | party1 | node6 | 50 | 162 | party1 | node7 | 50 | 163 | party1 | node8 | 50 | 164 | party1 | node9 | 50 | 165 | party1 | node10 | 50 | 166 167 # move to the end of the epoch - auto delegation will not take place party1 because they requested to manually delegate 168 When the network moves ahead "7" blocks 169 Then the parties should have the following delegation balances for epoch 3: 170 | party | node id | amount | 171 | party1 | node1 | 1050 | 172 | party1 | node2 | 1050 | 173 | party1 | node3 | 1050 | 174 | party1 | node4 | 1050 | 175 | party1 | node5 | 1050 | 176 | party1 | node6 | 1050 | 177 | party1 | node7 | 1050 | 178 | party1 | node8 | 1050 | 179 | party1 | node9 | 1050 | 180 | party1 | node10 | 1050 | 181 182 #on the end of the next epoch however the remaining 1000 tokens will get auto delegated 183 When the network moves ahead "7" blocks 184 Then the parties should have the following delegation balances for epoch 4: 185 | party | node id | amount | 186 | party1 | node1 | 1150 | 187 | party1 | node2 | 1150 | 188 | party1 | node3 | 1150 | 189 | party1 | node4 | 1150 | 190 | party1 | node5 | 1150 | 191 | party1 | node6 | 1150 | 192 | party1 | node7 | 1150 | 193 | party1 | node8 | 1150 | 194 | party1 | node9 | 1150 | 195 | party1 | node10 | 1150 | 196 197 Scenario: A party qualifies to auto delegation by delegating all of their associated tokens however by manually undelegation they exit auto delegation mode (0059-STKG-013, STKG-0014, 0059-STKG-021) 198 Description: Once a party dissociates VEGA tokens their delegation is adjusted automatically to reflect that in the same proportion as the delegation with respect to the amount withdrawn 199 200 When the parties submit the following delegations: 201 | party | node id | amount | 202 | party1 | node1 | 2000 | 203 | party1 | node2 | 2000 | 204 | party1 | node3 | 1000 | 205 | party1 | node4 | 1000 | 206 | party1 | node5 | 1000 | 207 | party1 | node6 | 1000 | 208 | party1 | node7 | 500 | 209 | party1 | node8 | 500 | 210 | party1 | node9 | 500 | 211 | party1 | node10 | 500 | 212 213 #advance to the end of the epoch 2 and start epoch 3 214 When the network moves ahead "7" blocks" 215 216 Then the parties submit the following undelegations: 217 | party | node id | amount | when | 218 | party1 | node1 | 100 | now | 219 220 #advance to the end of epoch 3 221 When the network moves ahead "7" blocks 222 223 #as we're out of auto delegation, due to the undelegateNow, no auto delegation will take place until all amount is fully delegated again 224 Then the parties should have the following delegation balances for epoch 3: 225 | party | node id | amount | 226 | party1 | node1 | 1900 | 227 | party1 | node2 | 2000 | 228 | party1 | node3 | 1000 | 229 | party1 | node4 | 1000 | 230 | party1 | node5 | 1000 | 231 | party1 | node6 | 1000 | 232 | party1 | node7 | 500 | 233 | party1 | node8 | 500 | 234 | party1 | node9 | 500 | 235 | party1 | node10 | 500 | 236 237 #increase the stake to make it availble however it will not be distributed because auto delegation has been switched off by the undelegation 238 Then the parties deposit on staking account the following amount: 239 | party | asset | amount | 240 | party1 | VEGA | 1000 | 241 242 Then the parties submit the following delegations: 243 | party | node id | amount | 244 | party1 | node10 | 100 | 245 246 #by now we qualify again to auto delegation but we don't in this epoch due to the manual delegation 247 #end epoch3 - start and end epoch4 248 When the network moves ahead "7" blocks 249 #end epoch4 - start and end epoch5 250 When the network moves ahead "7" blocks 251 Then the parties should have the following delegation balances for epoch 5: 252 | party | node id | amount | 253 | party1 | node1 | 2090 | 254 | party1 | node2 | 2200 | 255 | party1 | node3 | 1100 | 256 | party1 | node4 | 1100 | 257 | party1 | node5 | 1100 | 258 | party1 | node6 | 1100 | 259 | party1 | node7 | 550 | 260 | party1 | node8 | 550 | 261 | party1 | node9 | 550 | 262 | party1 | node10 | 660 | 263 264 #verifying auto delegation works on recurring delegations 265 Then the parties deposit on staking account the following amount: 266 | party | asset | amount | 267 | party1 | VEGA | 1000 | 268 #end epoch5 - start and end epoch6 269 When the network moves ahead "7" blocks 270 Then the parties should have the following delegation balances for epoch 6: 271 | party | node id | amount | 272 | party1 | node1 | 2280 | 273 | party1 | node2 | 2400 | 274 | party1 | node3 | 1200 | 275 | party1 | node4 | 1200 | 276 | party1 | node5 | 1200 | 277 | party1 | node6 | 1200 | 278 | party1 | node7 | 600 | 279 | party1 | node8 | 600 | 280 | party1 | node9 | 600 | 281 | party1 | node10 | 720 |