Skip to content

Commit 707c493

Browse files
authored
Merge pull request #1736 from balancednetwork/feat/add-baln-migration
Add baln migration
2 parents ea3a999 + b27008b commit 707c493

File tree

23 files changed

+2100
-2022
lines changed

23 files changed

+2100
-2022
lines changed

apps/web/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
"@reach/tabs": "0.18.0",
2323
"@reduxjs/toolkit": "2.2.0",
2424
"@sentry/react": "9.26.0",
25-
"@sodax/dapp-kit": "0.0.1-rc.27",
26-
"@sodax/sdk": "0.0.1-rc.37",
27-
"@sodax/types": "0.0.1-rc.16",
25+
"@sodax/dapp-kit": "0.0.1-rc.29",
26+
"@sodax/sdk": "0.0.1-rc.43",
27+
"@sodax/types": "0.0.1-rc.18",
2828
"@sodax/wallet-sdk-core": "0.0.1-rc.2",
2929
"@tanstack/react-query": "5.29.2",
3030
"@uniswap/token-lists": "1.0.0-beta.30",

apps/web/src/app/components/CurrencyInputPanel/index.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ const StyledTokenName = styled.span`
6868
font-weight: bold;
6969
`;
7070

71-
const NumberInput = styled.input<{ bg?: string; $active?: boolean; $showDollarValue: boolean }>`
71+
const NumberInput = styled.input<{ bg?: string; $active?: boolean; $showDollarValue: boolean; disabled?: boolean }>`
7272
flex: 1;
7373
width: 100%;
7474
height: ${({ $showDollarValue }) => ($showDollarValue ? '50px' : '43px')};
7575
text-align: right;
7676
border-radius: 0 10px 10px 0;
7777
border: ${({ theme, bg = 'bg2' }) => `2px solid ${theme.colors[bg]}`};
7878
background-color: ${({ theme, bg = 'bg2' }) => `${theme.colors[bg]}`};
79-
color: #ffffff;
79+
color: ${({ disabled, theme }) => (disabled ? theme.colors.text2 : '#ffffff')};
8080
padding: ${({ $showDollarValue }) => ($showDollarValue ? '1px 15px 20px' : '7px 15px')};
8181
outline: none;
8282
transition: all 0.3s ease;
@@ -88,7 +88,7 @@ const NumberInput = styled.input<{ bg?: string; $active?: boolean; $showDollarVa
8888
8989
&:hover,
9090
&:focus {
91-
border: 2px solid #2ca9b7;
91+
border: ${({ disabled }) => (disabled ? '2px solid transparent' : '2px solid #2ca9b7')};
9292
}
9393
9494
${({ $active }) => $active && 'border-bottom-right-radius: 0;'}
@@ -116,6 +116,7 @@ interface CurrencyInputPanelProps {
116116
showCommunityListControl?: boolean;
117117
showDollarValue?: boolean;
118118
showWarning?: boolean;
119+
disabled?: boolean;
119120

120121
// cross chain stuff
121122
xChainId?: XChainId;
@@ -141,6 +142,7 @@ export default function CurrencyInputPanel({
141142
showCommunityListControl = true,
142143
showDollarValue = true,
143144
showWarning = false,
145+
disabled = false,
144146

145147
// cross chain stuff
146148
xChainId = '0x1.icon',
@@ -281,6 +283,7 @@ export default function CurrencyInputPanel({
281283
onChange={event => {
282284
enforcer(event.target.value.replace(/,/g, '.'));
283285
}}
286+
disabled={disabled}
284287
// universal input options
285288
inputMode="decimal"
286289
title="Token Amount"

apps/web/src/app/components/home/BBaln/BBalnSlider.tsx

Lines changed: 0 additions & 231 deletions
Original file line numberDiff line numberDiff line change
@@ -476,90 +476,6 @@ export default function BBalnSlider({
476476
<Typography variant={titleVariant} paddingRight={'7px'} paddingBottom={isSmallScreen ? '5px' : '0'}>
477477
{title}{' '}
478478
</Typography>
479-
<Typography padding="0 3px 2px 0" style={titleVariant === 'h4' ? { transform: 'translateY(1px)' } : {}}>
480-
{simple ? (
481-
<>
482-
{earningPower &&
483-
balnTotal?.isGreaterThan(1) &&
484-
(numberOfPositions || dynamicBBalnAmount.isGreaterThan(0) || isAdjusting) && (
485-
<span style={{ marginRight: '8px' }}>{earningPower.toFixed(0)}%</span>
486-
)}
487-
<Tooltip
488-
show={showGlobalTooltip || tooltipHovered}
489-
offset={isSuperExtraSmallScreen ? [0, 66] : isSmallScreen ? [0, 40] : [0, 10]}
490-
text={
491-
<>
492-
{!isAdjusting && <EarningPowerTooltipContent />}
493-
{(isAdjusting || numberOfPositions || dynamicBBalnAmount.isGreaterThan(0)) && (
494-
<Typography mt={!isAdjusting ? 3 : 0}>
495-
You have{' '}
496-
<strong>
497-
{dynamicBBalnAmount.dp(dynamicBBalnAmount.isGreaterThan(100) ? 0 : 2).toFormat()} bBALN
498-
</strong>
499-
. {numberOfPositions ? maxRewardNoticeContent : ''}
500-
</Typography>
501-
)}
502-
</>
503-
}
504-
placement="top"
505-
forcePlacement={true}
506-
width={280}
507-
strategy="absolute"
508-
>
509-
<QuestionWrapper
510-
onMouseEnter={() => handleGlobalHover(true)}
511-
onMouseLeave={() => handleGlobalHover(false)}
512-
onTouchStart={() => handleGlobalHover(true)}
513-
onTouchCancel={() => handleGlobalHover(false)}
514-
style={{ transform: 'translateY(1px)' }}
515-
>
516-
<QuestionIcon width={14} />
517-
</QuestionWrapper>
518-
</Tooltip>
519-
</>
520-
) : (
521-
<>
522-
<Tooltip
523-
text={maxRewardNoticeContent}
524-
width={215}
525-
show={
526-
!!showMaxRewardsNotice &&
527-
!!numberOfPositions &&
528-
isAdjusting &&
529-
maxRewardThreshold.isGreaterThan(0)
530-
}
531-
placement="top-start"
532-
forcePlacement={true}
533-
strategy="absolute"
534-
offset={[-18, 20]}
535-
>
536-
{isAdjusting ? dynamicBBalnAmount.dp(2).toFormat() : bBalnAmount.dp(2).toFormat()}
537-
</Tooltip>
538-
{' bBALN'}
539-
<QuestionHelper
540-
text={
541-
<>
542-
<Trans>
543-
Lock up BALN to hold voting power and boost your earning potential by up to 2.5 x.
544-
</Trans>
545-
<Typography mt={2}>
546-
<Trans>
547-
The longer you lock up BALN, the more bBALN (Boosted BALN) you'll receive; the amount will
548-
decrease over time.
549-
</Trans>
550-
</Typography>
551-
{showMaxRewardsNotice && !isAdjusting && numberOfPositions && (
552-
<>
553-
<Divider my={2} />
554-
<Typography fontWeight={700}>{maxRewardNoticeContent}</Typography>
555-
</>
556-
)}
557-
</>
558-
}
559-
/>
560-
</>
561-
)}
562-
</Typography>
563479
</Flex>
564480

565481
{stakedBalance?.isEqualTo(0) && balnTotal?.isGreaterThan(1) && (
@@ -601,153 +517,6 @@ export default function BBalnSlider({
601517
</ButtonsWrap>
602518
)}
603519
</Flex>
604-
605-
{stakedBalance?.isGreaterThan(0) ? (
606-
<UnstakePrompt stakedBalance={stakedBalance} availableBalance={balnBalanceAvailable} />
607-
) : balnTotal?.isGreaterThan(1) ? (
608-
<>
609-
<SliderWrap sliderBg={sliderBg} $sliderMargin={sliderMargin}>
610-
{lockupNotice && (
611-
<Typography className={`lockup-notice${isAdjusting ? '' : ' show'}`}>{lockupNotice}</Typography>
612-
)}
613-
{shouldShowLock && isAdjusting && (
614-
<Box style={{ position: 'relative' }}>
615-
{simple ? (
616-
<StyledThreshold
617-
position={lockbarPercentPosition}
618-
flipTextDirection={lockbarPercentPosition < 50}
619-
>
620-
<MetaData as="dl" style={{ textAlign: 'right' }}>
621-
<dd>Locked</dd>
622-
</MetaData>
623-
</StyledThreshold>
624-
) : (
625-
<Threshold position={lockbarPercentPosition} flipTextDirection={lockbarPercentPosition < 50}>
626-
<MetaData as="dl" style={{ textAlign: 'right' }}>
627-
<dd>Locked</dd>
628-
</MetaData>
629-
</Threshold>
630-
)}
631-
</Box>
632-
)}
633-
634-
<Box
635-
margin="10px 0"
636-
className={balnSliderAmount.isLessThan(beforeBalnAmount) ? 'withdraw-warning' : ''}
637-
>
638-
<Nouislider
639-
disabled={!isAdjusting}
640-
id="slider-bbaln"
641-
start={[Number(lockedBalnAmount?.toFixed(0) || 0)]}
642-
connect={[true, false]}
643-
step={1}
644-
range={{
645-
min: [0],
646-
max: [balnTotal ? balnTotal.dp(0, BigNumber.ROUND_DOWN).toNumber() : 1],
647-
}}
648-
instanceRef={instance => {
649-
if (instance) {
650-
sliderInstance.current = instance;
651-
}
652-
}}
653-
onSlide={onSlide}
654-
/>
655-
</Box>
656-
657-
<Flex justifyContent="space-between" flexWrap={'wrap'} marginTop={isAdjusting ? '15px' : ''}>
658-
<Flex alignItems="center">
659-
{isAdjusting ? (
660-
<BalnPreviewInput
661-
type="text"
662-
disabled={!isAdjusting}
663-
value={balnSliderAmount.toNumber()}
664-
onChange={handleBBalnInputChange}
665-
/>
666-
) : (
667-
<Typography paddingRight={'5px'}>{balnSliderAmount.toFormat()}</Typography>
668-
)}
669-
670-
<Typography paddingRight={'15px'}>
671-
{' '}
672-
/ {balnTotal ? balnTotal.dp(0, BigNumber.ROUND_DOWN).toFormat(0) : '-'} BALN
673-
</Typography>
674-
</Flex>
675-
676-
{/* Show unlocked date */}
677-
{hasLockExpired && lockedBalnAmount?.greaterThan(0) && !isAdjusting && (
678-
<Typography>{t`Available since ${formatDate(lockedUntil)}`}</Typography>
679-
)}
680-
681-
{/* Show selected or locked time period */}
682-
{(bBalnAmount?.isGreaterThan(0) || isAdjusting) && (
683-
<Typography paddingTop={isAdjusting ? '5px' : '0'}>
684-
{shouldBoost ? (
685-
<>
686-
{t`Locked until`}{' '}
687-
{isAdjusting ? (
688-
<>
689-
<ClickAwayListener onClickAway={closeDropdown}>
690-
<div>
691-
<UnderlineTextWithArrow
692-
onClick={handlePeriodDropdownToggle}
693-
text={formatDate(
694-
getClosestUnixWeekStart(
695-
new Date(
696-
new Date().setDate(new Date().getDate() + (selectedPeriod.weeks * 7 - 7)),
697-
).getTime(),
698-
),
699-
)}
700-
arrowRef={periodArrowRef}
701-
/>
702-
703-
<DropdownPopper
704-
show={Boolean(periodDropdownAnchor)}
705-
anchorEl={periodDropdownAnchor}
706-
placement="bottom-end"
707-
>
708-
<MenuList>
709-
{availablePeriods
710-
.filter(
711-
(period, index) =>
712-
index === 0 || comparePeriods(period, availablePeriods[index - 1]) !== 0,
713-
)
714-
.map(period => (
715-
<MenuItem
716-
key={period.weeks}
717-
onClick={() => handleLockingPeriodChange(period)}
718-
>
719-
{period.name}
720-
</MenuItem>
721-
))}
722-
</MenuList>
723-
</DropdownPopper>
724-
</div>
725-
</ClickAwayListener>
726-
</>
727-
) : (
728-
formatDate(lockedUntil)
729-
)}
730-
</>
731-
) : (
732-
isAdjusting && (
733-
<Typography fontSize={14} color="#fb6a6a">
734-
{t`Pay a ${getFormattedNumber(
735-
earlyWithdrawPenalty || 0,
736-
'number2',
737-
)} BALN fee to unlock early.`}
738-
</Typography>
739-
)
740-
)}
741-
</Typography>
742-
)}
743-
</Flex>
744-
</SliderWrap>
745-
</>
746-
) : (
747-
<Typography fontSize={14} opacity={0.75} mt={6}>
748-
<Trans>Earn or buy BALN, then lock it up here to boost your rewards.</Trans>
749-
</Typography>
750-
)}
751520
</>
752521
) : (
753522
<>

0 commit comments

Comments
 (0)