Skip to content

Commit 4410cf6

Browse files
committed
Add rewards restaking option to Cosmos staking tx
1 parent eaf9ab3 commit 4410cf6

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

src/services/atom.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@ export class AtomService extends Service {
2727
* @param pubkey wallet pubkey, this is different from the wallet address
2828
* @param validatorAddress validator address to delegate to
2929
* @param amountAtom how many tokens to stake in ATOM
30+
* @param restakeRewards If enabled, the rewards will be automatically restaked
3031
*/
3132
async craftStakeTx(
3233
accountId: string,
3334
pubkey: string,
3435
validatorAddress: string,
3536
amountAtom: number,
37+
restakeRewards: boolean = false,
3638
): Promise<CosmosTx> {
3739

3840
const { data } = await api.post<CosmosTx>(
@@ -42,6 +44,7 @@ export class AtomService extends Service {
4244
pubkey: pubkey,
4345
validator: validatorAddress,
4446
amount_uatom: this.atomToUatom(amountAtom.toString()),
47+
restake_rewards: restakeRewards,
4548
});
4649
return data;
4750

@@ -75,15 +78,13 @@ export class AtomService extends Service {
7578
*/
7679
async craftRestakeRewardsTx(
7780
pubkey: string,
78-
validatorAccount: string,
7981
validatorAddress: string,
8082
): Promise<CosmosTx> {
8183

8284
const { data } = await api.post<CosmosTx>(
8385
`/v1/atom/transaction/restake-rewards`,
8486
{
8587
pubkey: pubkey,
86-
validator_account: validatorAccount,
8788
validator_address: validatorAddress,
8889
});
8990
return data;

src/services/osmo.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@ export class OsmoService extends Service {
3030
* @param pubkey wallet pubkey, this is different from the wallet address
3131
* @param validatorAddress validator address to delegate to
3232
* @param amountOsmo how many tokens to stake in OSMO
33+
* @param restakeRewards If enabled, the rewards will be automatically restaked
3334
*/
3435
async craftStakeTx(
3536
accountId: string,
3637
pubkey: string,
3738
validatorAddress: string,
3839
amountOsmo: number,
40+
restakeRewards: boolean = false,
3941
): Promise<CosmosTx> {
4042

4143
const { data } = await api.post<CosmosTx>(
@@ -45,6 +47,7 @@ export class OsmoService extends Service {
4547
pubkey: pubkey,
4648
validator: validatorAddress,
4749
amount_uosmo: this.osmoToUosmo(amountOsmo.toString()),
50+
restake_rewards: restakeRewards,
4851
});
4952
return data;
5053

@@ -78,15 +81,13 @@ export class OsmoService extends Service {
7881
*/
7982
async craftRestakeRewardsTx(
8083
pubkey: string,
81-
validatorAccount: string,
8284
validatorAddress: string,
8385
): Promise<CosmosTx> {
8486

8587
const { data } = await api.post<CosmosTx>(
8688
`/v1/osmo/transaction/restake-rewards`,
8789
{
8890
pubkey: pubkey,
89-
validator_account: validatorAccount,
9091
validator_address: validatorAddress,
9192
});
9293
return data;

src/services/tia.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@ export class TiaService extends Service {
2626
* @param pubkey wallet pubkey, this is different from the wallet address
2727
* @param validatorAddress validator address to delegate to
2828
* @param amountTia how many tokens to stake in TIA
29+
* @param restakeRewards If enabled, the rewards will be automatically restaked
2930
*/
3031
async craftStakeTx(
3132
accountId: string,
3233
pubkey: string,
3334
validatorAddress: string,
3435
amountTia: number,
36+
restakeRewards: boolean = false,
3537
): Promise<CosmosTx> {
3638

3739
const { data } = await api.post<CosmosTx>(
@@ -41,6 +43,7 @@ export class TiaService extends Service {
4143
pubkey: pubkey,
4244
validator: validatorAddress,
4345
amount_utia: this.tiaToUtia(amountTia.toString()),
46+
restake_rewards: restakeRewards,
4447
});
4548
return data;
4649

@@ -74,15 +77,13 @@ export class TiaService extends Service {
7477
*/
7578
async craftRestakeRewardsTx(
7679
pubkey: string,
77-
validatorAccount: string,
7880
validatorAddress: string,
7981
): Promise<CosmosTx> {
8082

8183
const { data } = await api.post<CosmosTx>(
8284
`/v1/tia/transaction/restake-rewards`,
8385
{
8486
pubkey: pubkey,
85-
validator_account: validatorAccount,
8687
validator_address: validatorAddress,
8788
});
8889
return data;

0 commit comments

Comments
 (0)