Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:exof support on baklava #106

Merged
merged 4 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/config/exchanges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,22 @@ export const BaklavaExchanges: Exchange[] = [
'0x6f90ac394b1F45290d3023e4Ba0203005cAF2A4B',
],
},
{
providerAddr: '0xFF9a3da00F42839CD6D33AD7adf50bCc97B41411',
id: '0x269dcbdbc07fff1a4aaab9c7c03b3f629cd9bbed49aa0efebab874e4da1ffd07',
assets: [
'0x64c1D812673E93Bc036AdC3D547d9950696DA5Af',
'0xdDc9bE57f553fe75752D61606B94CBD7e0264eF8',
],
},
{
providerAddr: '0xFF9a3da00F42839CD6D33AD7adf50bCc97B41411',
id: '0x66c5917862c8dc589e789d43752aa17ad251126276ce88ea20d89865e67bdabe',
assets: [
'0x64c1D812673E93Bc036AdC3D547d9950696DA5Af',
'0x6f90ac394b1F45290d3023e4Ba0203005cAF2A4B',
],
},
]
export const CeloExchanges: Exchange[] = [
{
Expand Down
12 changes: 12 additions & 0 deletions src/config/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export enum TokenId {
cREAL = 'cREAL',
axlUSDC = 'axlUSDC',
axlEUROC = 'axlEUROC',
eXOF = 'eXOF',
}

export const NativeStableTokenIds = [TokenId.cUSD, TokenId.cEUR, TokenId.cREAL]
Expand Down Expand Up @@ -71,6 +72,13 @@ export const axlEUROC: Token = Object.freeze({
color: Color.usdcBlue, // TODO: Change to EUROC
decimals: 6,
})
export const eXOF: Token = Object.freeze({
id: TokenId.eXOF,
symbol: TokenId.eXOF,
name: 'eXOF',
color: Color.usdcBlue, // TODO: Change to EUROC
decimals: 18,
})

export const Tokens: Record<TokenId, Token> = {
CELO,
Expand All @@ -79,6 +87,7 @@ export const Tokens: Record<TokenId, Token> = {
cREAL,
axlUSDC,
axlEUROC,
eXOF,
}

export const TokenAddresses: Record<ChainId, Record<TokenId, Address>> = Object.freeze({
Expand All @@ -89,6 +98,7 @@ export const TokenAddresses: Record<ChainId, Record<TokenId, Address>> = Object.
[TokenId.cREAL]: '0xE4D517785D091D3c54818832dB6094bcc2744545',
[TokenId.axlUSDC]: '0x87D61dA3d668797786D73BC674F053f87111570d',
[TokenId.axlEUROC]: '0x6e673502c5b55F3169657C004e5797fFE5be6653',
[TokenId.eXOF]: '',
},
[ChainId.Baklava]: {
[TokenId.CELO]: '0xdDc9bE57f553fe75752D61606B94CBD7e0264eF8',
Expand All @@ -97,6 +107,7 @@ export const TokenAddresses: Record<ChainId, Record<TokenId, Address>> = Object.
[TokenId.cREAL]: '0x6a0EEf2bed4C30Dc2CB42fe6c5f01F80f7EF16d1',
[TokenId.axlUSDC]: '0xD4079B322c392D6b196f90AA4c439fC2C16d6770',
[TokenId.axlEUROC]: '0x6f90ac394b1F45290d3023e4Ba0203005cAF2A4B',
[TokenId.eXOF]: '0x64c1D812673E93Bc036AdC3D547d9950696DA5Af',
},
[ChainId.Celo]: {
[TokenId.CELO]: '0x471EcE3750Da237f93B8E339c536989b8978a438',
Expand All @@ -105,6 +116,7 @@ export const TokenAddresses: Record<ChainId, Record<TokenId, Address>> = Object.
[TokenId.cREAL]: '0xe8537a3d056DA446677B9E9d6c5dB704EaAb4787',
[TokenId.axlUSDC]: '0xEB466342C4d449BC9f53A865D5Cb90586f405215',
[TokenId.axlEUROC]: '0x061cc5a2C863E0C1Cb404006D559dB18A34C762d',
[TokenId.eXOF]: '',
},
})

Expand Down
5 changes: 4 additions & 1 deletion src/features/swap/SwapConfirm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ export function SwapConfirmCard({ formValues }: Props) {
return
}
const rateBN = new BigNumber(rate)
if (rateBN.lt(MIN_EXCHANGE_RATE) || rateBN.gt(MAX_EXCHANGE_RATE)) {
if (
((toTokenId || fromTokenId) !== 'eXOF' && rateBN.lt(MIN_EXCHANGE_RATE)) ||
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Temporary fix to allow testing while we decide if we should keep this rate range check

rateBN.gt(MAX_EXCHANGE_RATE)
) {
toast.error('Rate seems incorrect')
return
}
Expand Down
12 changes: 8 additions & 4 deletions src/features/swap/SwapForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -234,17 +234,21 @@ function AmountField({
}

function ReverseTokenButton() {
const { values, setFieldValue } = useFormikContext<SwapFormValues>()
const { values, setValues } = useFormikContext<SwapFormValues>()
const { fromTokenId, toTokenId } = values

const onClickReverse = () => {
setFieldValue('fromTokenId', toTokenId)
setFieldValue('toTokenId', fromTokenId)
const onClickReverse = async () => {
setValues({
...values,
toTokenId: fromTokenId,
fromTokenId: toTokenId,
})
}

return (
<button
title="Swap inputs"
type="button"
onClick={onClickReverse}
className="flex items-center justify-center rounded-full border h-[36px] w-[36px] border-primary-dark dark:border-none dark:bg-[#545457] text-primary-dark dark:text-white"
>
Expand Down