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

staking-sdk: add solana split support #312

Merged
merged 1 commit into from
Dec 1, 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
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
Loading