Skip to content

Commit

Permalink
fix/prod build (#85)
Browse files Browse the repository at this point in the history
* fixes for prod build

* fixes after review
  • Loading branch information
Sorizen authored Aug 19, 2024
1 parent 9ad92eb commit f1834dd
Show file tree
Hide file tree
Showing 12 changed files with 102 additions and 55 deletions.
2 changes: 1 addition & 1 deletion src/common/AppButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ $button-transition: var(--transition-duration-fast)
--app-button-flat-text-focused: var(--primary-main);
--app-button-flat-text-active: var(--primary-main);
--app-button-flat-border: #{toRem(1)} solid #494949;
--app-button-flat-border: #{toRem(1)} solid var(--border-tertiary-main);
--app-button-flat-border-hover: #{toRem(1)} solid var(--primary-main);
--app-button-flat-border-focused: var(--app-button-flat-border-hover);
--app-button-flat-border-active: var(--app-button-flat-border-hover);
Expand Down
2 changes: 1 addition & 1 deletion src/common/AppTabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const updateTab = (tab: Tab) => {
display: grid;
place-items: center;
padding: toRem(16) toRem(24);
border: toRem(1) solid #494949;
border: toRem(1) solid var(--border-tertiary-main);
color: $color;
cursor: pointer;
transition: var(--transition-duration-fast) var(--transition-timing-default);
Expand Down
2 changes: 1 addition & 1 deletion src/common/InfoBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ withDefaults(
display: grid;
grid-gap: toRem(8);
padding-top: toRem(16);
border-top: toRem(2) solid #494949;
border-top: toRem(2) solid var(--border-tertiary-main);
@include respond-to(medium) {
margin-top: toRem(16);
Expand Down
4 changes: 2 additions & 2 deletions src/common/InfoCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ withDefaults(
.info-card__footer {
display: flex;
align-items: center;
border-top: toRem(1) solid #494949;
border-top: toRem(1) solid var(--border-tertiary-main);
}
.info-card .info-card__show-more-btn {
Expand All @@ -173,7 +173,7 @@ withDefaults(
.info-card__edit-btn-wrp {
flex-basis: toRem(111);
border-left: toRem(1) solid #494949;
border-left: toRem(1) solid var(--border-tertiary-main);
}
.info-card .info-card__edit-btn {
Expand Down
17 changes: 12 additions & 5 deletions src/common/InfoDashboard/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@
/>
</div>
</template>
<ul v-if="indicators?.length" class="info-dashboard__indicators">
<ul
v-if="indicators?.length"
class="info-dashboard__indicators"
:class="{ 'info-dashboard__indicators--border': isChartShown }"
>
<li
v-for="(indicator, idx) in indicators"
:key="idx"
Expand Down Expand Up @@ -349,7 +353,7 @@ watch(
.info-dashboard__app-chart-wrp {
margin-top: toRem(16);
border-top: toRem(2) solid #494949;
border-top: toRem(2) solid var(--border-tertiary-main);
width: 100%;
}
Expand All @@ -365,12 +369,15 @@ watch(
}
.info-dashboard__indicators {
margin-top: toRem(16);
width: 100%;
display: grid;
grid-gap: toRem(8);
padding-top: toRem(24);
border-top: toRem(2) solid #494949;
&--border {
margin-top: toRem(16);
padding-top: toRem(24);
border-top: toRem(2) solid var(--border-tertiary-main);
}
}
.info-dashboard__indicator {
Expand Down
117 changes: 74 additions & 43 deletions src/composables/use-pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { errors } from '@/errors'
const MULTIPLIER_SCALE = 21 //digits
const REWARDS_DIVIDER = 10000

// TODO: REFACTOR
export const usePool = (poolId: Ref<number>) => {
let _currentUserRewardUpdateIntervalId: NodeJS.Timeout

Expand Down Expand Up @@ -120,34 +121,44 @@ export const usePool = (poolId: Ref<number>) => {
)
}

const fetchPoolData = async (): Promise<Erc1967ProxyType.PoolData> => {
const poolDataResponses = await Promise.all([
erc1967ProxyContract.value.poolsData(poolId.value),
erc1967ProxyContract.value.pools(poolId.value),
erc1967ProxyContract.value.totalDepositedInPublicPools(),
])
const fetchPoolData = async (): Promise<
Erc1967ProxyType.PoolData | Mor1967ProxyType.PoolData
> => {
const [poolsDataResponse, poolsResponse, totalDepositedInPublicPools] =
await Promise.all([
erc1967ProxyContract.value.poolsData(poolId.value),
erc1967ProxyContract.value.pools(poolId.value),
erc1967ProxyContract.value.totalDepositedInPublicPools(),
])

// TODO: refactor
const isTotalVirtualDepositedDefined =
'totalVirtualDeposited' in poolsDataResponse
const totalDeposited =
totalDepositedInPublicPools ??
(isTotalVirtualDepositedDefined
? (poolsDataResponse as unknown as Erc1967ProxyType.PoolData)
.totalVirtualDeposited
: ethers.BigNumber.from(0))

return {
claimLockPeriod: poolDataResponses[1].claimLockPeriod,
decreaseInterval: poolDataResponses[1].decreaseInterval,
initialReward: poolDataResponses[1].initialReward,
isPublic: poolDataResponses[1].isPublic,
lastUpdate: poolDataResponses[0].lastUpdate,
minimalStake: poolDataResponses[1].minimalStake,
rate: poolDataResponses[0].rate,
payoutStart: poolDataResponses[1].payoutStart,
rewardDecrease: poolDataResponses[1].rewardDecrease,
totalDeposited:
poolDataResponses[2] ?? poolDataResponses[0].totalVirtualDeposited,
withdrawLockPeriod: poolDataResponses[1].withdrawLockPeriod,
withdrawLockPeriodAfterStake:
poolDataResponses[1].withdrawLockPeriodAfterStake,
}
claimLockPeriod: poolsResponse.claimLockPeriod,
decreaseInterval: poolsResponse.decreaseInterval,
initialReward: poolsResponse.initialReward,
isPublic: poolsResponse.isPublic,
lastUpdate: poolsDataResponse.lastUpdate,
minimalStake: poolsResponse.minimalStake,
payoutStart: poolsResponse.payoutStart,
rate: poolsDataResponse.rate,
rewardDecrease: poolsResponse.rewardDecrease,
totalDeposited,
withdrawLockPeriod: poolsResponse.withdrawLockPeriod,
withdrawLockPeriodAfterStake: poolsResponse.withdrawLockPeriodAfterStake,
} as Erc1967ProxyType.PoolData | Mor1967ProxyType.PoolData
}

const fetchUserPoolData = async (): Promise<Erc1967ProxyType.UserData> => {
const fetchUserPoolData = async (): Promise<
Erc1967ProxyType.UserData | Mor1967ProxyType.UserData
> => {
if (!web3ProvidersStore.provider.selectedAddress)
throw new errors.UserAddressError()

Expand All @@ -156,15 +167,30 @@ export const usePool = (poolId: Ref<number>) => {
poolId.value,
)

const isClaimLockEndDefined = 'claimLockEnd' in response
const claimLockEnd = isClaimLockEndDefined
? response.claimLockEnd
: ethers.BigNumber.from(0)

const isClaimLockStartDefined = 'claimLockStart' in response
const claimLockStart = isClaimLockStartDefined
? response.claimLockStart
: ethers.BigNumber.from(0)

const isVirtualDepositedDefined = 'virtualDeposited' in response
const virtualDeposited = isVirtualDepositedDefined
? response.virtualDeposited
: ethers.BigNumber.from(0)

return {
claimLockEnd: response?.claimLockEnd ?? ethers.BigNumber.from(0),
claimLockStart: response?.claimLockStart ?? ethers.BigNumber.from(0),
claimLockEnd,
claimLockStart,
deposited: response.deposited,
lastStake: response.lastStake,
pendingRewards: response.pendingRewards,
rate: response.rate,
virtualDeposited: response?.virtualDeposited ?? ethers.BigNumber.from(0),
}
virtualDeposited,
} as Erc1967ProxyType.UserData | Mor1967ProxyType.UserData
}

const humanizeRewards = (reward: BigNumber) => {
Expand All @@ -176,19 +202,23 @@ export const usePool = (poolId: Ref<number>) => {
const fetchExpectedMultiplier = async (lockPeriod: string) => {
try {
if (!lockPeriod) return

const lockStart = new Time().isAfter(
userPoolData.value?.claimLockStart?.toString(),
)
? new Time().timestamp
: userPoolData.value?.claimLockStart?.toString()
const multiplier =
//eslint-disable-next-line max-len
await erc1967ProxyContract.value?.getClaimLockPeriodMultiplier(
poolId.value,
lockStart,
lockPeriod || 0,
)
expectedRewardsMultiplier.value = humanizeRewards(multiplier)

if ('getClaimLockPeriodMultiplier' in erc1967ProxyContract.value) {
const multiplier =
await erc1967ProxyContract.value.getClaimLockPeriodMultiplier(
poolId.value,
lockStart || 0,
lockPeriod || 0,
)

expectedRewardsMultiplier.value = humanizeRewards(multiplier)
}
} catch (error) {
ErrorHandler.processWithoutFeedback(error)
}
Expand Down Expand Up @@ -216,14 +246,15 @@ export const usePool = (poolId: Ref<number>) => {
isUserDataUpdating.value = true

try {
const response =
// eslint-disable-next-line max-len
await erc1967ProxyContract.value?.getCurrentUserMultiplier(
poolId.value,
web3ProvidersStore.provider.selectedAddress,
)

rewardsMultiplier.value = humanizeRewards(response)
if ('getCurrentUserMultiplier' in erc1967ProxyContract.value) {
const response =
await erc1967ProxyContract.value.getCurrentUserMultiplier(
poolId.value,
web3ProvidersStore.provider.selectedAddress,
)

rewardsMultiplier.value = humanizeRewards(response)
}
} catch (e) {
ErrorHandler.processWithoutFeedback(e)
}
Expand Down
4 changes: 3 additions & 1 deletion src/forms/DepositForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
</template>
</input-field>
<datetime-field
v-if="isMultiplierShown"
v-model="form.lockPeriod"
position="top"
:placeholder="$t(`deposit-form.lock-period-placeholder`)"
Expand Down Expand Up @@ -256,11 +257,12 @@ const submit = async (action: ACTIONS): Promise<void> => {
tx = await approveByCurrency(balanceOfForm.value.value.currency)
} else {
const amountInDecimals = parseUnits(form.amount, 'ether')
tx =
await web3ProvidersStore.erc1967ProxyContract.signerBased.value.stake(
props.poolId,
amountInDecimals,
form.lockPeriod || 0,
...(isMultiplierShown.value ? [form.lockPeriod || 0] : []),
)
emit('stake-tx-sent')
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/HomePage/views/PublicPoolView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ watch(
<style lang="scss" scoped>
.public-pool-view__bar-slot-wrp {
margin-top: toRem(16);
border-top: toRem(2) solid #494949;
border-top: toRem(2) solid var(--border-tertiary-main);
padding-top: toRem(30);
@include respond-to(medium) {
Expand Down
2 changes: 2 additions & 0 deletions src/pages/Mor20Ecosystem/ProtocolCreationPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ watch(
display: flex;
flex-direction: column;
align-items: center;
max-height: 80vh;
overflow-y: auto;
}
.protocol-creation-page__modal-success-mark {
Expand Down
2 changes: 2 additions & 0 deletions src/styles/_app-colors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,7 @@ $border-secondary-light: #e0e0ec;
$border-secondary-main: #c4c4d0;
$border-secondary-dark: #a9abb4;

$border-tertiary-main: #494949;

/* backdrop colors */
$backdrop-modal: rgba(#000000, 0.5);
2 changes: 2 additions & 0 deletions src/styles/variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@
--border-secondary-main: #{$border-secondary-main};
--border-secondary-dark: #{$border-secondary-dark};

--border-tertiary-main: #{$border-tertiary-main};

/* common colors */
--backdrop-modal: #{$backdrop-modal};

Expand Down
1 change: 1 addition & 0 deletions src/types/erc1967-proxy.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export type PoolData = {
totalDeposited: BigNumber
withdrawLockPeriod: BigNumber
withdrawLockPeriodAfterStake: BigNumber
totalVirtualDeposited: BigNumber
}

export type UserData = {
Expand Down

0 comments on commit f1834dd

Please sign in to comment.