Skip to content

Commit

Permalink
Merge pull request #312 from fireblocks/staking-sdk
Browse files Browse the repository at this point in the history
staking-sdk: add solana split support
  • Loading branch information
yahavamar authored Dec 1, 2024
2 parents 65d138d + e3d2c7c commit 607fd22
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/fireblocks-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ import {
ChainInfo,
CheckTermsOfServiceResponseDto,
DelegationSummaryDto,
DelegationSummaryDtoByVault,
DelegationSummaryDtoByVault, SplitRequestDto, SplitResponse,
StakeRequestDto,
StakeResponse,
StakingChain,
Expand Down Expand Up @@ -314,6 +314,12 @@ export class FireblocksSDK {
public async executeStakingClaimRewards(chainDescriptor: StakingChain, body: WithdrawRequestDto): Promise<WithdrawResponse> {
return await this.stakingApiClient.withdraw(chainDescriptor, body);
}
/**
* Execute staking split on a chain
*/
public async executeStakingSplit(chainDescriptor: StakingChain, body: SplitRequestDto): Promise<SplitResponse> {
return await this.stakingApiClient.split(chainDescriptor, body);
}
/**
* Get all staking positions, optionally filtered by chain
*/
Expand Down
8 changes: 7 additions & 1 deletion src/staking/staking-api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
ChainInfo,
CheckTermsOfServiceResponseDto, ClaimRewardsRequestDto, ClaimRewardsResponse,
DelegationSummaryDto,
DelegationSummaryDtoByVault,
DelegationSummaryDtoByVault, SplitRequestDto, SplitResponse,
StakeRequestDto, StakeResponse,
StakingChain,
StakingPosition, StakingProvider,
Expand Down Expand Up @@ -63,6 +63,12 @@ export class StakingApiClient implements StakingSDK {
body,
);
}
public async split(chainDescriptor: StakingChain, body: SplitRequestDto): Promise<SplitResponse> {
return await this.apiClient.issuePostRequest(
`${STAKING_BASE_PATH}/chains/${chainDescriptor}/split`,
body,
);
}
public async getPositions(chainDescriptor?: StakingChain): Promise<StakingPosition[]> {
const url = `${STAKING_BASE_PATH}/positions${chainDescriptor ? `?chainDescriptor=${chainDescriptor}` : ""}`;
return await this.apiClient.issueGetRequest(url);
Expand Down
7 changes: 6 additions & 1 deletion src/staking/staking-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
ChainInfo,
CheckTermsOfServiceResponseDto, ClaimRewardsRequestDto, ClaimRewardsResponse,
DelegationSummaryDto,
DelegationSummaryDtoByVault,
DelegationSummaryDtoByVault, SplitRequestDto, SplitResponse,
StakeRequestDto,
StakeResponse,
StakingChain,
Expand Down Expand Up @@ -55,6 +55,11 @@ export interface StakingSDK {
*/
claimRewards(chainDescriptor: StakingChain, body: ClaimRewardsRequestDto): Promise<ClaimRewardsResponse>;

/**
* Execute staking split on a chain
*/
split(chainDescriptor: StakingChain, body: SplitRequestDto): Promise<SplitResponse>;

/**
* Get all staking positions, optionally filtered by chain
*/
Expand Down
31 changes: 31 additions & 0 deletions src/staking/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ export type WithdrawResponse = {};

export type ClaimRewardsResponse = {};

export type SplitResponse = {
id: string;
};

export interface StakeRequestDto {
/**
* The source vault account to stake from
Expand Down Expand Up @@ -322,6 +326,33 @@ export interface ClaimRewardsRequestDto {
*/
feeLevel?: string;

/**
* The note to associate with the transactions
*/
txNote?: string;
}

export interface SplitRequestDto {
/**
* id of position to split
*/
id: string;

/**
* Amount of tokens to split
*/
amount: string;

/**
* Represents the fee for a transaction, which can be specified as a percentage value. Only one of fee/feeLevel is required
*/
fee?: string;

/**
* Represents the fee level for a transaction, which can be set as slow, medium, or fast. Only one of fee/feeLevel is required
*/
feeLevel?: string;

/**
* The note to associate with the transactions
*/
Expand Down

0 comments on commit 607fd22

Please sign in to comment.