Skip to content

Commit

Permalink
TOL s7 promo added
Browse files Browse the repository at this point in the history
  • Loading branch information
unixvb committed Dec 5, 2024
1 parent 3135f16 commit 0f1b445
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 3 deletions.
12 changes: 12 additions & 0 deletions src/components/swap-form/swap-details/swap-details.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,22 @@
font-size: 14px;
}

.zero_fee {
height: unset;
padding: 2px var(--half-step);
border-radius: var(--step);
font-size: 12px;
line-height: unset;
color: rgb(var(--green-color));
background-color: rgba(var(--green-color), 0.25);
}

.toggle_button {
flex: 1;
display: flex;
justify-content: flex-end;
align-items: center;
gap: var(--step);
cursor: pointer;
}

Expand Down
5 changes: 5 additions & 0 deletions src/components/swap-form/swap-details/swap-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from '../../../store/swap-routes/swap-routes-selectors';
import {formatNumber} from '../../../utils/format-number.utils';
import {getClassName} from '../../../utils/style.utils';
import {isTolFeePromo} from '../../../utils/tol-fee.utils';
import {Skeleton} from '../../skeleton/skeleton';

interface Props extends Omit<SwapDetailsHeaderProps, 'routesLength'> {
Expand All @@ -27,6 +28,7 @@ export const SwapDetails: FC<Props> = ({

const isRoutesLoading = useIsRoutesLoadingSelector();
const swapDisplayData = useSwapDisplayDataSelector();
const isTolPromo = isTolFeePromo(inputAsset.address, outputAsset.address);

const data = useMemo(() => {
if (swapDisplayData.routes.length === 0) {
Expand Down Expand Up @@ -78,6 +80,9 @@ export const SwapDetails: FC<Props> = ({
className={styles.toggle_button}
onClick={toggleAccordion}
>
{isTolPromo && (
<p className={styles.zero_fee}>0% fee</p>
)}
<ChevronDownIcon
className={getClassName(
styles.chevron,
Expand Down
21 changes: 18 additions & 3 deletions src/store/swap-routes/swap-routes-epics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {DEBOUNCE_DUE_TIME} from '../../globals';
import {RootState} from '../index';
import {emptyBestRouteResponse} from './swap-routes-state';
import {sentryCatchError} from '../../utils/sentry.utils';
import {isTolFeePromo} from '../../utils/tol-fee.utils';

const loadSwapRoutesEpic: Epic<Action, Action, RootState> = (action$, state$) =>
action$.pipe(
Expand All @@ -28,15 +29,28 @@ const loadSwapRoutesEpic: Epic<Action, Action, RootState> = (action$, state$) =>
);
}

const maxDepth =
let maxDepth =
payload.inputAssetAddress === payload.outputAssetAddress
? RiskTolerance.Risky
: payload.riskTolerance;
let maxSplits = payload.maxSplits;
const maxSlippage = Number(state.settings.maxSlippage);
const referralAddress =
state.wallet.pointsState.walletPoints.data.refParent ??
state.wallet.pointsState.refWallet ??
undefined;
let partnerId: string | undefined = undefined;

if (
isTolFeePromo(
payload.inputAssetAddress,
payload.outputAssetAddress
)
) {
maxDepth = RiskTolerance.Safe;
maxSplits = 1;
partnerId = 'TolS7Promo';
}

return from(
getBestRoute({
Expand All @@ -45,9 +59,10 @@ const loadSwapRoutesEpic: Epic<Action, Action, RootState> = (action$, state$) =>
outputAssetAddress: payload.outputAssetAddress,
senderAddress: payload.senderAddress,
maxDepth,
maxSplits: payload.maxSplits,
maxSplits,
maxSlippage,
referralAddress
referralAddress,
partnerId
})
).pipe(
map(response =>
Expand Down
26 changes: 26 additions & 0 deletions src/utils/tol-fee.utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {TON, USDT} from '../globals';

const AquaUSD = 'EQAWDyxARSl3ol2G1RMLMwepr3v6Ter5ls3jiAlheKshgg0K';
const wsTON = 'EQB0SoxuGDx5qjVt0P_bPICFeWdFLBmVopHhjgfs0q-wsTON';
const DONE = 'EQCgGUMB_u1Gkrskw2o407Ig8ymQmfkxWuPW2d4INuQoPFJO';
const stTON = 'EQDNhy-nxYFgUqzfUzImBEP67JqsyMIcyk2S5_RwNNEYku0k';
const hTON = 'EQDPdq8xjAhytYqfGSX8KcFWIReCufsB9Wdg0pLlYSO_h76w';

const FEE_FREE_PAIRS = [
[AquaUSD, USDT],
[TON, wsTON],
[DONE, USDT],
[TON, stTON],
[TON, hTON]
];

export const isTolFeePromo = (
inputAssetAddress: string,
outputAssetAddress: string
) =>
inputAssetAddress !== outputAssetAddress &&
FEE_FREE_PAIRS.some(
pair =>
pair.includes(inputAssetAddress) &&
pair.includes(outputAssetAddress)
);

0 comments on commit 0f1b445

Please sign in to comment.