Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
maxima-net committed Aug 29, 2022
1 parent ae2d44c commit 1bf7e45
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/blockchain/atomexProtocolV1/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { isAtomexProtocolV1 } from './guards';
export { getRedeemRewardInNativeToken } from './utlis';
export { getRedeemRewardInNativeToken, getRedeemRewardInToken } from './utlis';

export type { AtomexProtocolV1 } from './atomexProtocolV1';
export type { AtomexProtocolV1Options } from './options';
Expand Down
9 changes: 9 additions & 0 deletions src/blockchain/atomexProtocolV1/utlis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,12 @@ export const getRedeemRewardInNativeToken = (nativeTokenPriceInUsd: BigNumber, r

return result;
};

export const getRedeemRewardInToken = (nativeTokenPriceInUsd: BigNumber, nativeTokenPriceInCurrency: BigNumber, redeemFee: BigNumber): FeesInfo => {
const inNativeToken = getRedeemRewardInNativeToken(nativeTokenPriceInUsd, redeemFee);

return {
estimated: inNativeToken.estimated.multipliedBy(nativeTokenPriceInCurrency),
max: inNativeToken.max.multipliedBy(nativeTokenPriceInCurrency)
};
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type BigNumber from 'bignumber.js';

import { getRedeemRewardInNativeToken } from '../../blockchain/atomexProtocolV1';
import { getRedeemRewardInToken } from '../../blockchain/atomexProtocolV1';
import type {
AtomexBlockchainProvider,
AtomexProtocolV1InitiateParameters, AtomexProtocolV1RedeemParameters, AtomexProtocolV1RefundParameters,
Expand Down Expand Up @@ -38,12 +38,7 @@ export class ERC20EthereumWeb3AtomexProtocolV1 extends Web3AtomexProtocolV1 {
}

async getRedeemReward(nativeTokenPriceInUsd: BigNumber, nativeTokenPriceInCurrency: BigNumber, redeemFee: BigNumber): Promise<FeesInfo> {
const inNativeToken = getRedeemRewardInNativeToken(nativeTokenPriceInUsd, redeemFee);

return {
estimated: inNativeToken.estimated.multipliedBy(nativeTokenPriceInCurrency),
max: inNativeToken.max.multipliedBy(nativeTokenPriceInCurrency)
};
return getRedeemRewardInToken(nativeTokenPriceInUsd, nativeTokenPriceInCurrency, redeemFee);
}

getRedeemFees(params: Partial<AtomexProtocolV1InitiateParameters>): Promise<FeesInfo> {
Expand Down
9 changes: 2 additions & 7 deletions src/tezos/atomexProtocol/fa12TezosTaquitoAtomexProtocolV1.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type BigNumber from 'bignumber.js';

import { getRedeemRewardInNativeToken } from '../../blockchain/atomexProtocolV1';
import { getRedeemRewardInToken } from '../../blockchain/atomexProtocolV1';
import type {
AtomexBlockchainProvider,
AtomexProtocolV1InitiateParameters, AtomexProtocolV1RedeemParameters, AtomexProtocolV1RefundParameters,
Expand Down Expand Up @@ -38,12 +38,7 @@ export class FA12TezosTaquitoAtomexProtocolV1 extends TaquitoAtomexProtocolV1 {
}

async getRedeemReward(nativeTokenPriceInUsd: BigNumber, nativeTokenPriceInCurrency: BigNumber, redeemFee: BigNumber): Promise<FeesInfo> {
const inNativeToken = getRedeemRewardInNativeToken(nativeTokenPriceInUsd, redeemFee);

return {
estimated: inNativeToken.estimated.multipliedBy(nativeTokenPriceInCurrency),
max: inNativeToken.max.multipliedBy(nativeTokenPriceInCurrency)
};
return getRedeemRewardInToken(nativeTokenPriceInUsd, nativeTokenPriceInCurrency, redeemFee);
}

getRedeemFees(params: Partial<AtomexProtocolV1InitiateParameters>): Promise<FeesInfo> {
Expand Down
9 changes: 2 additions & 7 deletions src/tezos/atomexProtocol/fa2TezosTaquitoAtomexProtocolV1.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type BigNumber from 'bignumber.js';

import { getRedeemRewardInNativeToken } from '../../blockchain/atomexProtocolV1';
import { getRedeemRewardInToken } from '../../blockchain/atomexProtocolV1';
import type {
AtomexBlockchainProvider,
AtomexProtocolV1InitiateParameters, AtomexProtocolV1RedeemParameters, AtomexProtocolV1RefundParameters,
Expand Down Expand Up @@ -38,12 +38,7 @@ export class FA2TezosTaquitoAtomexProtocolV1 extends TaquitoAtomexProtocolV1 {
}

async getRedeemReward(nativeTokenPriceInUsd: BigNumber, nativeTokenPriceInCurrency: BigNumber, redeemFee: BigNumber): Promise<FeesInfo> {
const inNativeToken = getRedeemRewardInNativeToken(nativeTokenPriceInUsd, redeemFee);

return {
estimated: inNativeToken.estimated.multipliedBy(nativeTokenPriceInCurrency),
max: inNativeToken.max.multipliedBy(nativeTokenPriceInCurrency)
};
return getRedeemRewardInToken(nativeTokenPriceInUsd, nativeTokenPriceInCurrency, redeemFee);
}

getRedeemFees(params: Partial<AtomexProtocolV1InitiateParameters>): Promise<FeesInfo> {
Expand Down

0 comments on commit 1bf7e45

Please sign in to comment.