@@ -1031,8 +1031,9 @@ describe('ExclusiveGeyser', function () {
1031
1031
} )
1032
1032
describe ( 'with insufficient balance' , function ( ) {
1033
1033
it ( 'should fail' , async function ( ) {
1034
+ // Exclusive stake condition fails first
1034
1035
await expect ( stake ( user , geyser , vault , stakingToken , stakeAmount . mul ( 2 ) ) ) . to . be . revertedWith (
1035
- 'UniversalVault: insufficient balance ' ,
1036
+ 'ExclusiveGeyser: expected exclusive stake ' ,
1036
1037
)
1037
1038
} )
1038
1039
} )
@@ -1123,7 +1124,7 @@ describe('ExclusiveGeyser', function () {
1123
1124
}
1124
1125
} )
1125
1126
it ( 'should fail' , async function ( ) {
1126
- await expect ( stake ( user , geyser , vault , stakingToken , stakeAmount . div ( quantity ) ) ) . to . be . revertedWith (
1127
+ await expect ( stake ( user , geyser , vault , stakingToken , 1 ) ) . to . be . revertedWith (
1127
1128
'Geyser: MAX_STAKES_PER_VAULT reached' ,
1128
1129
)
1129
1130
} )
@@ -1166,28 +1167,61 @@ describe('ExclusiveGeyser', function () {
1166
1167
describe ( 'non-exclusive stake' , function ( ) {
1167
1168
let otherGeyser : Contract
1168
1169
beforeEach ( async function ( ) {
1169
- const args = [
1170
+ otherGeyser = await deployGeyser ( [
1170
1171
admin . address ,
1171
1172
rewardPoolFactory . address ,
1172
1173
powerSwitchFactory . address ,
1173
1174
stakingToken . address ,
1174
1175
rewardToken . address ,
1175
1176
[ rewardScaling . floor , rewardScaling . ceiling , rewardScaling . time ] ,
1176
- ]
1177
- otherGeyser = await deployGeyser ( args , 'Geyser' )
1177
+ ] , 'Geyser' )
1178
1178
await otherGeyser . connect ( admin ) . registerVaultFactory ( vaultFactory . address )
1179
- await stake ( user , otherGeyser , vault , stakingToken , 1 )
1179
+ await stake ( user , otherGeyser , vault , stakingToken , stakeAmount )
1180
1180
} )
1181
+
1182
+
1181
1183
it ( 'should fail' , async function ( ) {
1182
1184
await expect ( stake ( user , geyser , vault , stakingToken , stakeAmount ) ) . to . be . revertedWith (
1183
1185
'ExclusiveGeyser: expected exclusive stake' ,
1184
1186
)
1187
+ expect ( await geyser . computeAvailableStakingBalance ( vault . address ) ) . to . eq ( 0 )
1188
+ expect ( await vault . checkBalances ( ) ) . to . eq ( true )
1185
1189
} )
1186
- it ( 'should not fail when there are no locks' , async function ( ) {
1187
- await unstakeAndClaim ( user , otherGeyser , vault , stakingToken , 1 )
1188
- await expect ( stake ( user , geyser , vault , stakingToken , stakeAmount ) ) . not . to . be . revertedWith (
1190
+
1191
+ it ( 'should fail' , async function ( ) {
1192
+ // Note: stakeAmount is staked in both otherGeyser and yetAnotherGeyser
1193
+ const yetAnotherGeyser = await deployGeyser ( [
1194
+ admin . address ,
1195
+ rewardPoolFactory . address ,
1196
+ powerSwitchFactory . address ,
1197
+ stakingToken . address ,
1198
+ rewardToken . address ,
1199
+ [ rewardScaling . floor , rewardScaling . ceiling , rewardScaling . time ] ,
1200
+ ] , 'Geyser' )
1201
+ await yetAnotherGeyser . connect ( admin ) . registerVaultFactory ( vaultFactory . address )
1202
+ await stake ( user , yetAnotherGeyser , vault , stakingToken , stakeAmount )
1203
+ await expect ( stake ( user , geyser , vault , stakingToken , stakeAmount ) ) . to . be . revertedWith (
1189
1204
'ExclusiveGeyser: expected exclusive stake' ,
1190
1205
)
1206
+ expect ( await geyser . computeAvailableStakingBalance ( vault . address ) ) . to . eq ( 0 )
1207
+ expect ( await vault . checkBalances ( ) ) . to . eq ( true )
1208
+ } )
1209
+
1210
+ it ( 'should NOT fail when there is some unlocked amount' , async function ( ) {
1211
+ await unstakeAndClaim ( user , otherGeyser , vault , stakingToken , 15 )
1212
+ await expect ( stake ( user , geyser , vault , stakingToken , 14 ) ) . not . to . be . reverted
1213
+ expect ( await geyser . computeAvailableStakingBalance ( vault . address ) ) . to . eq ( 1 )
1214
+ expect ( await vault . checkBalances ( ) ) . to . eq ( true )
1215
+ await expect ( stake ( user , geyser , vault , stakingToken , 1 ) ) . not . to . be . reverted
1216
+ expect ( await geyser . computeAvailableStakingBalance ( vault . address ) ) . to . eq ( 0 )
1217
+ expect ( await vault . checkBalances ( ) ) . to . eq ( true )
1218
+ } )
1219
+
1220
+ it ( 'should NOT fail when there are no locks' , async function ( ) {
1221
+ await unstakeAndClaim ( user , otherGeyser , vault , stakingToken , stakeAmount )
1222
+ await expect ( stake ( user , geyser , vault , stakingToken , stakeAmount ) ) . not . to . be . reverted
1223
+ expect ( await geyser . computeAvailableStakingBalance ( vault . address ) ) . to . eq ( 0 )
1224
+ expect ( await vault . checkBalances ( ) ) . to . eq ( true )
1191
1225
} )
1192
1226
} )
1193
1227
} )
0 commit comments