@@ -137,7 +137,7 @@ export class Deployer {
137
137
async instantiateOracle ( init_params ?: WasmOracleCustomInitParams ) {
138
138
const msg : OracleInstantiateMsg = {
139
139
owner : this . deployerAddress ,
140
- base_denom : this . config . baseAssetDenom ,
140
+ base_denom : this . config . oracleBaseDenom ,
141
141
custom_init : init_params ,
142
142
}
143
143
await this . instantiate ( 'oracle' , this . storage . codeIds . oracle ! , msg )
@@ -151,15 +151,16 @@ export class Deployer {
151
151
safety_fund_denom : this . config . safetyFundDenom ,
152
152
fee_collector_denom : this . config . feeCollectorDenom ,
153
153
channel_id : this . config . channelId ,
154
- timeout_seconds : this . config . rewardCollectorTimeoutSeconds ,
154
+ timeout_seconds : this . config . rewardsCollectorTimeoutSeconds ,
155
155
slippage_tolerance : this . config . slippage_tolerance ,
156
+ neutron_ibc_config : this . config . rewardsCollectorNeutronIbcConfig ,
156
157
}
157
158
await this . instantiate ( 'rewards-collector' , this . storage . codeIds [ 'rewards-collector' ] ! , msg )
158
159
}
159
160
160
161
async instantiateSwapper ( ) {
161
162
const msg : SwapperInstantiateMsg = {
162
- owner : this . storage . owner ! ,
163
+ owner : this . deployerAddress ,
163
164
}
164
165
165
166
await this . instantiate ( 'swapper' , this . storage . codeIds . swapper ! , msg )
@@ -302,6 +303,8 @@ export class Deployer {
302
303
printYellow ( `Twap snapshots recorded for denoms: ${ denoms . join ( ',' ) } .` )
303
304
}
304
305
async setOracle ( oracleConfig : OracleConfig ) {
306
+ printBlue ( `Setting oracle price source: ${ JSON . stringify ( oracleConfig ) } ` )
307
+
305
308
const msg = {
306
309
set_price_source : oracleConfig ,
307
310
}
@@ -317,7 +320,7 @@ export class Deployer {
317
320
} ) ) as { price : number ; denom : string }
318
321
319
322
printGreen (
320
- `${ this . config . chainId } :: ${ oracleConfig . denom } oracle price : ${ JSON . stringify (
323
+ `${ this . config . chainId } :: ${ oracleConfig . denom } oracle price: ${ JSON . stringify (
321
324
oracleResult ,
322
325
) } `,
323
326
)
@@ -421,62 +424,74 @@ export class Deployer {
421
424
const coins = [
422
425
{
423
426
denom : this . config . atomDenom ,
424
- amount : '2000000 ' ,
427
+ amount : '20000 ' ,
425
428
} ,
426
429
]
427
- await this . client . sendTokens (
428
- this . deployerAddress ,
429
- this . storage . addresses [ 'rewards-collector' ] ! ,
430
- coins ,
431
- 'auto' ,
432
- )
433
-
434
- // Check contract balance before swap
435
- const atomBalanceBefore = await this . client . getBalance (
436
- this . storage . addresses [ 'rewards-collector' ] ! ,
437
- this . config . atomDenom ,
438
- )
439
- const baseAssetBalanceBefore = await this . client . getBalance (
440
- this . storage . addresses [ 'rewards-collector' ] ! ,
441
- this . config . baseAssetDenom ,
442
- )
443
- printYellow (
444
- `Rewards Collector balance:
445
- ${ atomBalanceBefore . amount } ${ atomBalanceBefore . denom }
446
- ${ baseAssetBalanceBefore . amount } ${ baseAssetBalanceBefore . denom } ` ,
447
- )
448
430
449
- // Execute swap
450
- const msg = {
451
- swap_asset : {
452
- denom : this . config . atomDenom ,
453
- } ,
454
- }
455
- await this . client . execute (
431
+ const deployerAtomBalance = await this . client . getBalance (
456
432
this . deployerAddress ,
457
- this . storage . addresses [ 'rewards-collector' ] ! ,
458
- msg ,
459
- 'auto' ,
460
- )
461
- // Check contract balance after swap
462
- const atomBalanceAfter = await this . client . getBalance (
463
- this . storage . addresses [ 'rewards-collector' ] ! ,
464
433
this . config . atomDenom ,
465
434
)
466
- const baseAssetBalanceAfter = await this . client . getBalance (
467
- this . storage . addresses [ 'rewards-collector' ] ! ,
468
- this . config . baseAssetDenom ,
469
- )
470
- printYellow (
471
- `Swap executed. Rewards Collector balance:
472
- ${ atomBalanceAfter . amount } ${ atomBalanceAfter . denom } ,
473
- ${ baseAssetBalanceAfter . amount } ${ baseAssetBalanceAfter . denom } ` ,
474
- )
475
435
476
- // swapped all atom balance
477
- assert . equal ( Number ( atomBalanceAfter . amount ) , 0 )
478
- // base asset balance should be greater after swap
479
- assert ( Number ( baseAssetBalanceAfter . amount ) > Number ( baseAssetBalanceBefore . amount ) )
436
+ if ( Number ( deployerAtomBalance . amount ) < Number ( coins [ 0 ] . amount ) ) {
437
+ printRed (
438
+ `not enough ATOM tokens to complete rewards-collector swap action, ${ this . deployerAddress } has ${ deployerAtomBalance . amount } ATOM but needs ${ coins [ 0 ] . amount } .` ,
439
+ )
440
+ } else {
441
+ await this . client . sendTokens (
442
+ this . deployerAddress ,
443
+ this . storage . addresses [ 'rewards-collector' ] ! ,
444
+ coins ,
445
+ 'auto' ,
446
+ )
447
+
448
+ // Check contract balance before swap
449
+ const atomBalanceBefore = await this . client . getBalance (
450
+ this . storage . addresses [ 'rewards-collector' ] ! ,
451
+ this . config . atomDenom ,
452
+ )
453
+ const baseAssetBalanceBefore = await this . client . getBalance (
454
+ this . storage . addresses [ 'rewards-collector' ] ! ,
455
+ this . config . baseAssetDenom ,
456
+ )
457
+ printYellow (
458
+ `Rewards Collector balance:
459
+ ${ atomBalanceBefore . amount } ${ atomBalanceBefore . denom }
460
+ ${ baseAssetBalanceBefore . amount } ${ baseAssetBalanceBefore . denom } ` ,
461
+ )
462
+
463
+ // Execute swap
464
+ const msg = {
465
+ swap_asset : {
466
+ denom : this . config . atomDenom ,
467
+ } ,
468
+ }
469
+ await this . client . execute (
470
+ this . deployerAddress ,
471
+ this . storage . addresses [ 'rewards-collector' ] ! ,
472
+ msg ,
473
+ 'auto' ,
474
+ )
475
+ // Check contract balance after swap
476
+ const atomBalanceAfter = await this . client . getBalance (
477
+ this . storage . addresses [ 'rewards-collector' ] ! ,
478
+ this . config . atomDenom ,
479
+ )
480
+ const baseAssetBalanceAfter = await this . client . getBalance (
481
+ this . storage . addresses [ 'rewards-collector' ] ! ,
482
+ this . config . baseAssetDenom ,
483
+ )
484
+ printYellow (
485
+ `Swap executed. Rewards Collector balance:
486
+ ${ atomBalanceAfter . amount } ${ atomBalanceAfter . denom } ,
487
+ ${ baseAssetBalanceAfter . amount } ${ baseAssetBalanceAfter . denom } ` ,
488
+ )
489
+
490
+ // swapped all atom balance
491
+ assert . equal ( Number ( atomBalanceAfter . amount ) , 0 )
492
+ // base asset balance should be greater after swap
493
+ assert ( Number ( baseAssetBalanceAfter . amount ) > Number ( baseAssetBalanceBefore . amount ) )
494
+ }
480
495
}
481
496
482
497
async updateIncentivesContractOwner ( ) {
@@ -494,7 +509,7 @@ export class Deployer {
494
509
{
495
510
config : { } ,
496
511
} ,
497
- ) ) as { proposed_new_owner : string ; prefix : string }
512
+ ) ) as { proposed_new_owner : string }
498
513
499
514
printRed ( `${ incentivesConfig . proposed_new_owner } ` )
500
515
assert . equal ( incentivesConfig . proposed_new_owner , this . config . multisigAddr )
@@ -520,7 +535,7 @@ export class Deployer {
520
535
{
521
536
config : { } ,
522
537
} ,
523
- ) ) as { proposed_new_owner : string ; prefix : string }
538
+ ) ) as { proposed_new_owner : string }
524
539
525
540
assert . equal ( redbankConfig . proposed_new_owner , this . config . multisigAddr )
526
541
}
@@ -537,7 +552,7 @@ export class Deployer {
537
552
printYellow ( 'Owner updated to Mutlisig for Oracle' )
538
553
const oracleConfig = ( await this . client . queryContractSmart ( this . storage . addresses . oracle ! , {
539
554
config : { } ,
540
- } ) ) as { proposed_new_owner : string ; prefix : string }
555
+ } ) ) as { proposed_new_owner : string }
541
556
542
557
assert . equal ( oracleConfig . proposed_new_owner , this . config . multisigAddr )
543
558
}
@@ -562,11 +577,28 @@ export class Deployer {
562
577
{
563
578
config : { } ,
564
579
} ,
565
- ) ) as { proposed_new_owner : string ; prefix : string }
580
+ ) ) as { proposed_new_owner : string }
566
581
567
582
assert . equal ( rewardsConfig . proposed_new_owner , this . config . multisigAddr )
568
583
}
569
584
585
+ async updateSwapperContractOwner ( ) {
586
+ const msg = {
587
+ update_owner : {
588
+ propose_new_owner : {
589
+ proposed : this . storage . owner ,
590
+ } ,
591
+ } ,
592
+ }
593
+ await this . client . execute ( this . deployerAddress , this . storage . addresses . swapper ! , msg , 'auto' )
594
+ printYellow ( 'Owner updated to Mutlisig for Swapper' )
595
+ const swapperConfig = ( await this . client . queryContractSmart ( this . storage . addresses . swapper ! , {
596
+ owner : { } ,
597
+ } ) ) as { proposed : string }
598
+
599
+ assert . equal ( swapperConfig . proposed , this . config . multisigAddr )
600
+ }
601
+
570
602
async updateAddressProviderContractOwner ( ) {
571
603
const msg = {
572
604
update_owner : {
@@ -587,7 +619,7 @@ export class Deployer {
587
619
{
588
620
config : { } ,
589
621
} ,
590
- ) ) as { proposed_new_owner : string ; prefix : string }
622
+ ) ) as { proposed_new_owner : string }
591
623
592
624
assert . equal ( addressProviderConfig . proposed_new_owner , this . config . multisigAddr )
593
625
}
0 commit comments