Skip to content

Commit

Permalink
fix: consider erc20 decimals for the output token (#21)
Browse files Browse the repository at this point in the history
* fix: get erc20 decimals from the contract

* fix: consider erc20 decimals for the output token

* fix: get default decimal from chain config
  • Loading branch information
aramalipoor authored Dec 15, 2022
1 parent 795f40f commit c4dd793
Show file tree
Hide file tree
Showing 15 changed files with 156 additions and 371 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const balanceRampCustomDataResolve: BalanceResolver = async (
return {
idempotencyKey: txUniqueHash,
outputTokenAddress: requiredAmounts[0]?.token,
outputDecimals: 18,
outputDecimals: requiredAmounts[0]?.decimals,
outputAmount: BigNumber.from(requiredAmounts[0]?.value).toString(),
estimatedGasPrice: estimatedGasPrice?.toString(),
estimatedMaxFeePerGas: estimatedMaxFeePerGas?.toString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const balanceRampNativeValueResolve: BalanceResolver = async (
return {
idempotencyKey: txUniqueHash,
outputTokenAddress: '0x0000000000000000000000000000000000000000',
outputDecimals: 18,
outputDecimals: 18, // TODO get from chain info for stupid chains
outputAmount: txValue.toString(),
estimatedGasPrice: estimatedGasPrice?.toString(),
estimatedMaxFeePerGas: estimatedMaxFeePerGas?.toString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ export class BalanceRampClient {

if (
!message.toLowerCase().includes('insufficient funds') &&
!message.toLowerCase().includes('exceeds allowance')
!message.toLowerCase().includes('exceeds allowance') &&
!message.toLowerCase().includes('exceeds balance')
) {
throw e;
}
Expand Down Expand Up @@ -474,7 +475,7 @@ export class BalanceRampClient {
outputTokenAddress:
requiredBalance.outputTokenAddress || ethers.constants.AddressZero,
outputAmount: requiredBalance.outputAmount?.toString() || '',
outputDecimals: requiredBalance.outputDecimals || '18',
outputDecimals: requiredBalance.outputDecimals,
requiresKyc:
requiredBalance.requiresKyc || this.config.requiresKyc || false,
inputCurrency:
Expand Down

This file was deleted.

Loading

0 comments on commit c4dd793

Please sign in to comment.