Skip to content

Commit

Permalink
fix(SDK): add getAmountToSendFromPools & getAmountToBeReceivedFromPools
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonKozAllB committed Jan 10, 2024
1 parent 4e41981 commit 17191b5
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 2 deletions.
54 changes: 54 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,33 @@ export class AllbridgeCoreSdk {
);
}

/**
* Calculates the amount of tokens to be received as a result of transfer based on passed pool state.
* @param amountToSendFloat the amount of tokens that will be sent
* @param sourceChainToken selected token on the source chain
* @param destinationChainToken selected token on the destination chain
* @param sourcePool source token pool state
* @param destinationPool destination token pool state
* @param messenger Optional. selected messenger
*/
getAmountToBeReceivedFromPools(
amountToSendFloat: BigSource,
sourceChainToken: TokenWithChainDetails,
destinationChainToken: TokenWithChainDetails,
sourcePool: PoolInfo,
destinationPool: PoolInfo,
messenger?: Messenger
): string {
return this.service.getAmountToBeReceivedFromPools(
amountToSendFloat,
sourceChainToken,
destinationChainToken,
sourcePool,
destinationPool,
messenger
);
}

/**
* Calculates the amount of tokens to send based on requested tokens amount be received as a result of transfer.
* @param amountToBeReceivedFloat the amount of tokens that should be received
Expand Down Expand Up @@ -356,6 +383,33 @@ export class AllbridgeCoreSdk {
);
}

/**
* Calculates the amount of tokens to send based on requested tokens amount be received as a result of transfer based on passed pool state.
* @param amountToBeReceivedFloat the amount of tokens that should be received
* @param sourceChainToken selected token on the source chain
* @param destinationChainToken selected token on the destination chain
* @param sourcePool source token pool state
* @param destinationPool destination token pool state
* @param messenger Optional. selected messenger
*/
getAmountToSendFromPools(
amountToBeReceivedFloat: BigSource,
sourceChainToken: TokenWithChainDetails,
destinationChainToken: TokenWithChainDetails,
sourcePool: PoolInfo,
destinationPool: PoolInfo,
messenger?: Messenger
): string {
return this.service.getAmountToSendFromPools(
amountToBeReceivedFloat,
sourceChainToken,
destinationChainToken,
sourcePool,
destinationPool,
messenger
);
}

/**
* Fetches possible ways to pay the transfer gas fee.
* @param sourceChainToken selected token on the source chain
Expand Down
4 changes: 2 additions & 2 deletions src/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ export class AllbridgeCoreSdkService {
);
}

private getAmountToBeReceivedFromPools(
getAmountToBeReceivedFromPools(
amountToSendFloat: number | string | Big,
sourceChainToken: TokenWithChainDetails,
destinationChainToken: TokenWithChainDetails,
Expand Down Expand Up @@ -381,7 +381,7 @@ export class AllbridgeCoreSdkService {
);
}

private getAmountToSendFromPools(
getAmountToSendFromPools(
amountToBeReceivedFloat: number | string | Big,
sourceChainToken: TokenWithChainDetails,
destinationChainToken: TokenWithChainDetails,
Expand Down

0 comments on commit 17191b5

Please sign in to comment.