From 4410cf653e6a5de60213b68624ea663b6c8f11ca Mon Sep 17 00:00:00 2001 From: Goulin Khoge <36013798+goulinkh@users.noreply.github.com> Date: Tue, 5 Mar 2024 16:37:56 +0100 Subject: [PATCH] Add rewards restaking option to Cosmos staking tx --- src/services/atom.ts | 5 +++-- src/services/osmo.ts | 5 +++-- src/services/tia.ts | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/services/atom.ts b/src/services/atom.ts index ba9365f..e57eff7 100644 --- a/src/services/atom.ts +++ b/src/services/atom.ts @@ -27,12 +27,14 @@ export class AtomService extends Service { * @param pubkey wallet pubkey, this is different from the wallet address * @param validatorAddress validator address to delegate to * @param amountAtom how many tokens to stake in ATOM + * @param restakeRewards If enabled, the rewards will be automatically restaked */ async craftStakeTx( accountId: string, pubkey: string, validatorAddress: string, amountAtom: number, + restakeRewards: boolean = false, ): Promise { const { data } = await api.post( @@ -42,6 +44,7 @@ export class AtomService extends Service { pubkey: pubkey, validator: validatorAddress, amount_uatom: this.atomToUatom(amountAtom.toString()), + restake_rewards: restakeRewards, }); return data; @@ -75,7 +78,6 @@ export class AtomService extends Service { */ async craftRestakeRewardsTx( pubkey: string, - validatorAccount: string, validatorAddress: string, ): Promise { @@ -83,7 +85,6 @@ export class AtomService extends Service { `/v1/atom/transaction/restake-rewards`, { pubkey: pubkey, - validator_account: validatorAccount, validator_address: validatorAddress, }); return data; diff --git a/src/services/osmo.ts b/src/services/osmo.ts index f359ceb..a036710 100644 --- a/src/services/osmo.ts +++ b/src/services/osmo.ts @@ -30,12 +30,14 @@ export class OsmoService extends Service { * @param pubkey wallet pubkey, this is different from the wallet address * @param validatorAddress validator address to delegate to * @param amountOsmo how many tokens to stake in OSMO + * @param restakeRewards If enabled, the rewards will be automatically restaked */ async craftStakeTx( accountId: string, pubkey: string, validatorAddress: string, amountOsmo: number, + restakeRewards: boolean = false, ): Promise { const { data } = await api.post( @@ -45,6 +47,7 @@ export class OsmoService extends Service { pubkey: pubkey, validator: validatorAddress, amount_uosmo: this.osmoToUosmo(amountOsmo.toString()), + restake_rewards: restakeRewards, }); return data; @@ -78,7 +81,6 @@ export class OsmoService extends Service { */ async craftRestakeRewardsTx( pubkey: string, - validatorAccount: string, validatorAddress: string, ): Promise { @@ -86,7 +88,6 @@ export class OsmoService extends Service { `/v1/osmo/transaction/restake-rewards`, { pubkey: pubkey, - validator_account: validatorAccount, validator_address: validatorAddress, }); return data; diff --git a/src/services/tia.ts b/src/services/tia.ts index 08bde02..01594e3 100644 --- a/src/services/tia.ts +++ b/src/services/tia.ts @@ -26,12 +26,14 @@ export class TiaService extends Service { * @param pubkey wallet pubkey, this is different from the wallet address * @param validatorAddress validator address to delegate to * @param amountTia how many tokens to stake in TIA + * @param restakeRewards If enabled, the rewards will be automatically restaked */ async craftStakeTx( accountId: string, pubkey: string, validatorAddress: string, amountTia: number, + restakeRewards: boolean = false, ): Promise { const { data } = await api.post( @@ -41,6 +43,7 @@ export class TiaService extends Service { pubkey: pubkey, validator: validatorAddress, amount_utia: this.tiaToUtia(amountTia.toString()), + restake_rewards: restakeRewards, }); return data; @@ -74,7 +77,6 @@ export class TiaService extends Service { */ async craftRestakeRewardsTx( pubkey: string, - validatorAccount: string, validatorAddress: string, ): Promise { @@ -82,7 +84,6 @@ export class TiaService extends Service { `/v1/tia/transaction/restake-rewards`, { pubkey: pubkey, - validator_account: validatorAccount, validator_address: validatorAddress, }); return data;