Skip to content

Commit

Permalink
feat: add ARM route, missing mainnet address WIP 🚧
Browse files Browse the repository at this point in the history
  • Loading branch information
toniocodo committed Aug 1, 2024
1 parent 52034fb commit cfafdf9
Show file tree
Hide file tree
Showing 6 changed files with 422 additions and 39 deletions.
46 changes: 35 additions & 11 deletions libs/defi/oeth/src/redeem/components/RedeemActionCard.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { alpha, Card, Stack, SvgIcon, Typography } from '@mui/material';
import { ValueLabel } from '@origin/shared/components';
import { OETH } from '@origin/shared/icons';
import { routeEq, useSwapState } from '@origin/shared/providers';
import {
routeEq,
useHandleSelectSwapRoute,
useIsSwapRouteAvailable,
useSwapState,
} from '@origin/shared/providers';
import { isNilOrEmpty } from '@origin/shared/utils';
import { useIntl } from 'react-intl';

Expand Down Expand Up @@ -29,15 +34,23 @@ export const RedeemActionCard = ({
selectedSwapRoute,
swapRoutes,
swapActions,
estimatedSwapRoutes,
},
] = useSwapState();
const handleSelectSwapRoute = useHandleSelectSwapRoute();

const route = swapRoutes.find((r) =>
routeEq({ tokenIn, tokenOut, action }, r),
) as SwapRoute<OethRedeemAction, Meta>;
const { data: isRouteAvailable, isLoading: isRouteAvailableLoading } =
useIsSwapRouteAvailable(route);
const estimatedRoute = estimatedSwapRoutes.find((r) => routeEq(route, r));
const isSelected = routeEq({ tokenIn, tokenOut, action }, selectedSwapRoute);
const isComingSoon =
(route as SwapRoute<OethRedeemAction, Meta>)?.meta?.comingSoon ?? false;
const routeLabel = swapActions[action].routeLabel;
const isDisabled =
!isRouteAvailable || isRouteAvailableLoading || isComingSoon;

return (
<Card
Expand All @@ -48,18 +61,29 @@ export const RedeemActionCard = ({
border: '1px solid',
borderColor: 'divider',
backgroundColor: 'background.highlight',
...(amountIn > 0n &&
!isComingSoon && {
cursor: 'pointer',
'&:hover': {
borderColor: 'primary.main',
},
}),
...(isSelected && {
borderColor: 'primary.main',
}),
...(isDisabled
? { opacity: 0.5, cursor: 'default' }
: isSelected
? {
borderColor: 'primary.main',
backgroundColor: 'background.highlight',
}
: amountIn > 0n
? {
cursor: 'pointer',
'&:hover': {
borderColor: 'primary.main',
},
}
: {}),
...rest?.sx,
}}
role="button"
onClick={() => {
if (!isDisabled && estimatedRoute && amountIn > 0n) {
handleSelectSwapRoute(estimatedRoute);
}
}}
>
{isComingSoon && (
<Stack
Expand Down
1 change: 0 additions & 1 deletion libs/defi/oeth/src/redeem/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export const redeemRoutes: SwapRoute<OethRedeemAction, Meta>[] = [
meta: {
icon: ARM,
waitTime: defineMessage({ defaultMessage: '~1 min' }),
comingSoon: true,
},
},
{
Expand Down
191 changes: 191 additions & 0 deletions libs/shared/contracts/src/abis/ARM.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
export const ARMABI = [
{
inputs: [
{ internalType: 'address', name: '_oeth', type: 'address' },
{ internalType: 'address', name: '_weth', type: 'address' },
{ internalType: 'address', name: '_oethVault', type: 'address' },
],
stateMutability: 'nonpayable',
type: 'constructor',
},
{
anonymous: false,
inputs: [
{
indexed: false,
internalType: 'address',
name: 'previousAdmin',
type: 'address',
},
{
indexed: false,
internalType: 'address',
name: 'newAdmin',
type: 'address',
},
],
name: 'AdminChanged',
type: 'event',
},
{
anonymous: false,
inputs: [
{
indexed: false,
internalType: 'address',
name: 'previousAdmin',
type: 'address',
},
{
indexed: false,
internalType: 'address',
name: 'newAdmin',
type: 'address',
},
],
name: 'OperatorChanged',
type: 'event',
},
{
inputs: [{ internalType: 'uint256', name: 'requestId', type: 'uint256' }],
name: 'claimWithdrawal',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{ internalType: 'uint256[]', name: 'requestIds', type: 'uint256[]' },
],
name: 'claimWithdrawals',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [],
name: 'oethVault',
outputs: [{ internalType: 'address', name: '', type: 'address' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'operator',
outputs: [{ internalType: 'address', name: '', type: 'address' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'owner',
outputs: [{ internalType: 'address', name: '', type: 'address' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [{ internalType: 'uint256', name: 'amount', type: 'uint256' }],
name: 'requestWithdrawal',
outputs: [
{ internalType: 'uint256', name: 'requestId', type: 'uint256' },
{ internalType: 'uint256', name: 'queued', type: 'uint256' },
],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [{ internalType: 'address', name: 'newOperator', type: 'address' }],
name: 'setOperator',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [{ internalType: 'address', name: 'newOwner', type: 'address' }],
name: 'setOwner',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{ internalType: 'uint256', name: 'amountIn', type: 'uint256' },
{ internalType: 'uint256', name: 'amountOutMin', type: 'uint256' },
{ internalType: 'address[]', name: 'path', type: 'address[]' },
{ internalType: 'address', name: 'to', type: 'address' },
{ internalType: 'uint256', name: 'deadline', type: 'uint256' },
],
name: 'swapExactTokensForTokens',
outputs: [
{ internalType: 'uint256[]', name: 'amounts', type: 'uint256[]' },
],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{ internalType: 'contract IERC20', name: 'inToken', type: 'address' },
{ internalType: 'contract IERC20', name: 'outToken', type: 'address' },
{ internalType: 'uint256', name: 'amountIn', type: 'uint256' },
{ internalType: 'uint256', name: 'amountOutMin', type: 'uint256' },
{ internalType: 'address', name: 'to', type: 'address' },
],
name: 'swapExactTokensForTokens',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{ internalType: 'uint256', name: 'amountOut', type: 'uint256' },
{ internalType: 'uint256', name: 'amountInMax', type: 'uint256' },
{ internalType: 'address[]', name: 'path', type: 'address[]' },
{ internalType: 'address', name: 'to', type: 'address' },
{ internalType: 'uint256', name: 'deadline', type: 'uint256' },
],
name: 'swapTokensForExactTokens',
outputs: [
{ internalType: 'uint256[]', name: 'amounts', type: 'uint256[]' },
],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{ internalType: 'contract IERC20', name: 'inToken', type: 'address' },
{ internalType: 'contract IERC20', name: 'outToken', type: 'address' },
{ internalType: 'uint256', name: 'amountOut', type: 'uint256' },
{ internalType: 'uint256', name: 'amountInMax', type: 'uint256' },
{ internalType: 'address', name: 'to', type: 'address' },
],
name: 'swapTokensForExactTokens',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [],
name: 'token0',
outputs: [{ internalType: 'contract IERC20', name: '', type: 'address' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'token1',
outputs: [{ internalType: 'contract IERC20', name: '', type: 'address' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{ internalType: 'address', name: 'token', type: 'address' },
{ internalType: 'address', name: 'to', type: 'address' },
{ internalType: 'uint256', name: 'amount', type: 'uint256' },
],
name: 'transferToken',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
] as const;
8 changes: 8 additions & 0 deletions libs/shared/contracts/src/contracts.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { arbitrum, mainnet } from 'wagmi/chains';

import { ARMABI } from './abis/ARM';
import { CCIPEvm2EvmOnRamp } from './abis/CCIPEvm2EvmOnRamp';
import { CCIPRouterABI } from './abis/CCIPRouter';
import { ChainlinkOracleABI } from './abis/ChainlinkOracle';
Expand Down Expand Up @@ -33,6 +34,12 @@ import { xOGNGovernanceABI } from './abis/xOGNGovernance';

export const contracts = {
mainnet: {
ARM: {
address: '0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D', // TODO update address when available
chainId: mainnet.id,
abi: ARMABI,
name: 'ARM',
},
// Chainlink CCIP
ccipRouter: {
address: '0x80226fc0Ee2b096224EeAc085Bb9a8cba1146f7D',
Expand Down Expand Up @@ -93,6 +100,7 @@ export const contracts = {
name: 'lrtConfig',
},
// OETH

OETHCurvePool: {
address: '0x94B17476A93b3262d87B9a326965D1E91f9c13E7',
chainId: mainnet.id,
Expand Down
1 change: 1 addition & 0 deletions libs/shared/contracts/src/whales.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ export const whales = {
wOETH: '0xC460B0b6c9b578A4Cb93F99A691e16dB96Ee5833',
OUSD: '0x70fCE97d671E81080CA3ab4cc7A59aAc2E117137',
wOUSD: '0x3dD413Fd4D03b1d8fD2C9Ed34553F7DeC3B26F5C',
WETH: '0xF04a5cC80B1E94C69B48f5ee68a08CD2F09A7c3E',
},
} as const;
Loading

0 comments on commit cfafdf9

Please sign in to comment.