Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rewards restaking option to Cosmos staking tx #91

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/services/atom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<CosmosTx> {

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

Expand Down Expand Up @@ -75,15 +78,13 @@ export class AtomService extends Service {
*/
async craftRestakeRewardsTx(
pubkey: string,
validatorAccount: string,
validatorAddress: string,
): Promise<CosmosTx> {

const { data } = await api.post<CosmosTx>(
`/v1/atom/transaction/restake-rewards`,
{
pubkey: pubkey,
validator_account: validatorAccount,
validator_address: validatorAddress,
});
return data;
Expand Down
5 changes: 3 additions & 2 deletions src/services/osmo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<CosmosTx> {

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

Expand Down Expand Up @@ -78,15 +81,13 @@ export class OsmoService extends Service {
*/
async craftRestakeRewardsTx(
pubkey: string,
validatorAccount: string,
validatorAddress: string,
): Promise<CosmosTx> {

const { data } = await api.post<CosmosTx>(
`/v1/osmo/transaction/restake-rewards`,
{
pubkey: pubkey,
validator_account: validatorAccount,
validator_address: validatorAddress,
});
return data;
Expand Down
5 changes: 3 additions & 2 deletions src/services/tia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<CosmosTx> {

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

Expand Down Expand Up @@ -74,15 +77,13 @@ export class TiaService extends Service {
*/
async craftRestakeRewardsTx(
pubkey: string,
validatorAccount: string,
validatorAddress: string,
): Promise<CosmosTx> {

const { data } = await api.post<CosmosTx>(
`/v1/tia/transaction/restake-rewards`,
{
pubkey: pubkey,
validator_account: validatorAccount,
validator_address: validatorAddress,
});
return data;
Expand Down
Loading