Skip to content

Commit

Permalink
Merge pull request #4836 from cowprotocol/release/2024-08-26
Browse files Browse the repository at this point in the history
chore(release):2024 08 26
  • Loading branch information
alfetopito authored Aug 27, 2024
2 parents 12191b4 + a2375e6 commit b6c27c1
Show file tree
Hide file tree
Showing 112 changed files with 7,743 additions and 922 deletions.
4 changes: 2 additions & 2 deletions apps/cow-fi/pages/careers/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@ export default function Page({ siteConfigData, jobsData }: PageProps) {
fullWidth
>
<TopicCardInner contentAlign="left" height="100%">
<TopicTitle fontSize={34}>💸 Refer a friend and earn 6,000 in USDC or USD!</TopicTitle>
<TopicTitle fontSize={34}>💸 Refer a friend and earn up to 6,000 in USDC or USD!</TopicTitle>

<TopicDescription fontSize={24} fontWeight={Font.weight.regular} margin="0 0 24px">
Know someone who is looking not just for a job, but for a great opportunity to grow? Refer them to
earn $6,000 in USD or USDC.{' '}
earn up to $6,000 in USD or USDC.{' '}
</TopicDescription>
<Link
linkType={LinkType.TopicButton}
Expand Down
30 changes: 20 additions & 10 deletions apps/cow-fi/pages/careers/refer-to-earn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@ export default function Page({ siteConfigData }: PageProps) {
<BodyContent>
<h2>
Know someone who is not just looking for a job but for a great opportunity to grow? Refer them to us to
earn $6,000 in USDC or USD.
earn up to $6,000 in USDC or USD.
</h2>
<p>
We will reward you with a referral bonus of <b>6,000 USDC or USD</b> per placement. Your referral is
successful and paid once the Candidate clears <b>their first 3 months</b> of work in their new role.
We will reward you with a referral bonus of up to <b>6,000 USDC or USD</b> per placement. The referral
bonus amount can vary for each role. You can find the exact amount listed in the job description on our
website at <a href="https://cow.fi/careers">https://cow.fi/careers</a>. Your referral is successful and
paid once the Candidate clears <b>their first 6 months</b> of work in their new role.
</p>

<p>
Expand Down Expand Up @@ -89,15 +91,15 @@ export default function Page({ siteConfigData }: PageProps) {
someone else first, the Referrer is not eligible.
</li>
<li>
If two or more Referrers refer the same Candidate, then only the <b>first</b> Referrer provided by
such Candidate will be eligible for the referral bonus. We will let the Referrers know.
If two or more Referrers refer the same Candidate, only the <b>first</b> Referrer provided by such
Candidate will be eligible for the referral bonus. We will let the Referrers know.
</li>
<li>There is no limit to the number of referrals that a Referrer can make.</li>
</ul>

<h4>Candidates Eligibility</h4>
<ul>
<li>Any individual (or entity) who is not the Referrer, or a current or former contractor of CoW.</li>
<li>Any individual (or entity) who is not the Referrer or a current or former contractor of CoW.</li>
<li>
Any individual who is not bound by non-compete agreements or any other similar agreements that would
prohibit CoW from engaging with them.
Expand All @@ -106,6 +108,12 @@ export default function Page({ siteConfigData }: PageProps) {

<h4>Referral Procedures</h4>
<ul>
<li>
The referrer should reach out to a CoW core team member or directly contact the People department via
email at <a href="mailto:[email protected]">[email protected]</a>, LinkedIn, or Telegram. When reaching out,
the Referrer must include the candidate's name, surname, and email or LinkedIn profile. The Referrer
is responsible for ensuring that the Candidate has given consent to share this information.
</li>
<li>
To apply for a specific role at CoW, <b>Candidates</b> are required to submit their application
through the official website: <a href="https://cow.fi/careers">https://cow.fi/careers</a>.{' '}
Expand All @@ -130,10 +138,12 @@ export default function Page({ siteConfigData }: PageProps) {
<h4>Referral bonus and invoice</h4>
<ul>
<li>
The Referrer becomes eligible to receive the full referral bonus of five thousand USDC or USD (6,000)
after three (3) months from the Candidate&apos;s start date, provided that the Candidate remains
providing services to CoW during this period. The Referrer can decide if they want to be paid in USDC
or USD.
The Referrer becomes eligible to receive the full referral bonus up to six thousand USDC or USD
(6,000) after six (6) months from the Candidate's start date, provided that the Candidate remains
providing services to CoW during this period. The referral bonus amount can vary for each role. You
can find the exact amount listed in the job description on our website at{' '}
<a href="https://cow.fi/careers">https://cow.fi/careers</a>. The Referrer can decide if they want to
be paid in USDC or USD.
</li>
<li>
The referral bonus is excl. VAT (VAT can be added), but net of any other tax, such as, income tax or
Expand Down
12 changes: 12 additions & 0 deletions apps/cow-fi/styles/CoWDAOFonts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ const FONT_STUDIO_FEIXEN_SERIF_BOLD = require('@cowprotocol/assets/fonts/StudioF
const FONT_STUDIO_FEIXEN_SERIF_MEDIUM = require('@cowprotocol/assets/fonts/StudioFeixenSerif-Medium.woff2')
const FONT_STUDIO_FEIXEN_SERIF_REGULAR = require('@cowprotocol/assets/fonts/StudioFeixenSerif-Regular.woff2')
const FONT_STUDIO_FEIXEN_SERIF_BOOK = require('@cowprotocol/assets/fonts/StudioFeixenSerif-Book.woff2')
const FONT_STUDIO_FEIXEN_MONO_REGULAR = require('@cowprotocol/assets/fonts/StudioFeixenMono-Regular.woff2')
const FONT_STUDIO_FEIXEN_MONO_BOLD = require('@cowprotocol/assets/fonts/StudioFeixenMono-Bold.woff2')
const FONT_STUDIO_FEIXEN_MONO_BOOK = require('@cowprotocol/assets/fonts/StudioFeixenMono-Book.woff2')
const FONT_STUDIO_FEIXEN_MONO_SEMIBOLD = require('@cowprotocol/assets/fonts/StudioFeixenMono-Semibold.woff2')
const FONT_STUDIO_FEIXEN_MONO_LIGHT = require('@cowprotocol/assets/fonts/StudioFeixenMono-Light.woff2')
const FONT_STUDIO_FEIXEN_MONO_ULTRALIGHT = require('@cowprotocol/assets/fonts/StudioFeixenMono-Ultralight.woff2')

export const CoWDAOFonts = {
FONT_STUDIO_FEIXEN_BOLD,
Expand All @@ -36,4 +42,10 @@ export const CoWDAOFonts = {
FONT_STUDIO_FEIXEN_SERIF_MEDIUM,
FONT_STUDIO_FEIXEN_SERIF_REGULAR,
FONT_STUDIO_FEIXEN_SERIF_BOOK,
FONT_STUDIO_FEIXEN_MONO_REGULAR,
FONT_STUDIO_FEIXEN_MONO_BOLD,
FONT_STUDIO_FEIXEN_MONO_BOOK,
FONT_STUDIO_FEIXEN_MONO_SEMIBOLD,
FONT_STUDIO_FEIXEN_MONO_LIGHT,
FONT_STUDIO_FEIXEN_MONO_ULTRALIGHT,
}
17 changes: 15 additions & 2 deletions apps/cowswap-frontend/src/api/cowProtocol/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {
} from '@cowprotocol/common-utils'
import {
Address,
SupportedChainId as ChainId,
CompetitionOrderStatus,
CowEnv,
EnrichedOrder,
NativePriceResponse,
Expand All @@ -19,7 +21,6 @@ import {
OrderQuoteSideKindSell,
PartialApiContext,
SigningScheme,
SupportedChainId as ChainId,
TotalSurplus,
Trade,
} from '@cowprotocol/cow-sdk'
Expand All @@ -31,7 +32,7 @@ import { LegacyFeeQuoteParams as FeeQuoteParams } from 'legacy/state/price/types
import { getAppData } from 'modules/appData'

import { ApiErrorCodes } from './errors/OperatorError'
import QuoteApiError, { QuoteApiErrorDetails, mapOperatorErrorToQuoteError } from './errors/QuoteError'
import QuoteApiError, { mapOperatorErrorToQuoteError, QuoteApiErrorDetails } from './errors/QuoteError'
import { getIsOrderBookTypedError } from './getIsOrderBookTypedError'

function getProfileUrl(): Partial<Record<ChainId, string>> {
Expand Down Expand Up @@ -224,6 +225,18 @@ export async function getSurplusData(chainId: ChainId, address: string): Promise
return orderBookApi.getTotalSurplus(address, { chainId })
}

export async function getOrderCompetitionStatus(
chainId: ChainId,
orderId: string
): Promise<CompetitionOrderStatus | undefined> {
try {
return await orderBookApi.getOrderCompetitionStatus(orderId, { chainId })
} catch (e) {
console.debug(`[getOrderCompetitionStatus] Non successful response:`, e?.message || e)
return
}
}

export type ProfileData = {
totalTrades: number
totalReferrals: number
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { useAtom } from 'jotai'
import { useLayoutEffect, useRef } from 'react'

import { ordersProgressBarCountdown } from './atoms'
import { OrdersProgressBarCountdown } from './types'

export function ProgressBarV2ExecutingOrdersUpdater(): null {
useCountdownUpdater()

return null
}

function useCountdownUpdater() {
const [allCountdowns, setCountdowns] = useAtom(ordersProgressBarCountdown)

// Use a ref to not restart the updater on every change
const countdownsRef = useRef(allCountdowns)
// Important! Update the ref on every re-render
countdownsRef.current = allCountdowns

useLayoutEffect(() => {
function updateCountdowns() {
const countdowns = countdownsRef.current

const orderIds = Object.keys(countdowns)
if (!orderIds.length || orderIds.every((orderId) => !countdowns[orderId])) {
// Skip update if there are no countdowns or none of them are truthy
return
}

const newCountdowns = orderIds.reduce<OrdersProgressBarCountdown>((acc, orderId) => {
const value = countdowns[orderId]

// Decrement counter
acc[orderId] = value && value - 1 >= 0 ? value - 1 : value

return acc
}, {})

setCountdowns(newCountdowns)
}

const timer = setInterval(updateCountdowns, 1000)

return () => clearInterval(timer)
}, [setCountdowns])
}
163 changes: 163 additions & 0 deletions apps/cowswap-frontend/src/common/hooks/orderProgressBarV2/atoms.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
import { atom } from 'jotai'

import { deepEqual } from '@cowprotocol/common-utils'

import {
OrderProgressBarState,
OrderProgressBarStepName,
OrdersProgressBarCountdown,
OrdersProgressBarState,
} from './types'

/**
* Base Atom for orders progress bar state
*/
export const ordersProgressBarStateAtom = atom<OrdersProgressBarState>({})

/**
* Derived atom exposing only the countdown
*/
export const ordersProgressBarCountdown = atom(
(get) => {
const fullState = get(ordersProgressBarStateAtom)

return Object.keys(fullState).reduce<OrdersProgressBarCountdown>((acc, orderId) => {
const countdown = fullState[orderId].countdown
if (countdown) {
acc[orderId] = countdown
}
return acc
}, {})
},
(get, set, countdowns: OrdersProgressBarCountdown) => {
const fullState = { ...get(ordersProgressBarStateAtom) }
Object.keys(countdowns).forEach((orderId) => {
fullState[orderId].countdown = countdowns[orderId]
})
set(ordersProgressBarStateAtom, fullState)
}
)

type UpdateOrderProgressBarCountdownParams = {
orderId: string
value: number | null
}

/**
* Derived write-only atom for updating a single countdown at a time
*/
export const updateOrderProgressBarCountdown = atom(
null,
(get, set, { orderId, value }: UpdateOrderProgressBarCountdownParams) => {
const fullState = get(ordersProgressBarStateAtom)

const singleOrderState = { ...fullState[orderId] }
const currentValue = singleOrderState.countdown

if (currentValue === value) {
return
}

if (value === null) {
delete singleOrderState.countdown
} else {
singleOrderState.countdown = value
}

set(ordersProgressBarStateAtom, { ...fullState, [orderId]: singleOrderState })
}
)

type UpdateOrderProgressBarStepNameParams = {
orderId: string
value: OrderProgressBarStepName
}

/**
* Derived write-only atom for updating a single progressBarStepName at a time
*/
export const updateOrderProgressBarStepName = atom(
null,
(get, set, { orderId, value }: UpdateOrderProgressBarStepNameParams) => {
const fullState = get(ordersProgressBarStateAtom)

const singleOrderState = { ...fullState[orderId] }
const currentValue = singleOrderState.progressBarStepName

if (currentValue === value) {
return
}

// Keep track of previous status
singleOrderState.previousStepName = singleOrderState.progressBarStepName
// Update current status
singleOrderState.progressBarStepName = value
// Keep track when state was changed
singleOrderState.lastTimeChangedSteps = Date.now()

set(ordersProgressBarStateAtom, { ...fullState, [orderId]: singleOrderState })
}
)

type UpdateOrderProgressBarBackendInfoParams = {
orderId: string
value: Pick<OrderProgressBarState, 'backendApiStatus' | 'solverCompetition'>
}

/**
* Derived write-only atom for updating a single order backendApiStatus and solverCompetition
*/
export const updateOrderProgressBarBackendInfo = atom(
null,
(get, set, { orderId, value: { backendApiStatus, solverCompetition } }: UpdateOrderProgressBarBackendInfoParams) => {
const fullState = get(ordersProgressBarStateAtom)

const singleOrderState = { ...fullState[orderId] }
const currentBackendApiStatus = singleOrderState.backendApiStatus
const currentSolverCompetition = singleOrderState.solverCompetition

const backendApiStatusChanged = currentBackendApiStatus !== backendApiStatus

const solverCompetitionChanged =
(!currentSolverCompetition && !!solverCompetition) ||
(!!currentSolverCompetition && !solverCompetition) ||
(!!currentSolverCompetition && !!solverCompetition && !deepEqual(currentSolverCompetition, solverCompetition))

if (!backendApiStatusChanged && !solverCompetitionChanged) {
return
}

singleOrderState.previousBackendApiStatus = currentBackendApiStatus
singleOrderState.backendApiStatus = backendApiStatus

// Only update solver competition if changed and not falsy
if (solverCompetitionChanged && solverCompetition) {
singleOrderState.solverCompetition = solverCompetition
}

set(ordersProgressBarStateAtom, {
...fullState,
[orderId]: singleOrderState,
})
}
)

/**
* Derived write-only atom for setting cancellationTriggered
*
* Can only set it to true, since there's no way to cancel a cancellation once requested
*/
export const setOrderProgressBarCancellationTriggered = atom(null, (get, set, orderId: string) => {
const fullState = get(ordersProgressBarStateAtom)

const singleState = { ...fullState[orderId] }

if (singleState.cancellationTriggered) {
// Already triggered, nothing to do here
return
}

singleState.cancellationTriggered = true

set(ordersProgressBarStateAtom, { ...fullState, [orderId]: singleState })
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './useOrderProgressBarV2Props'
export * from './types'
export * from './ProgressBarV2ExecutingOrdersUpdater'
Loading

0 comments on commit b6c27c1

Please sign in to comment.