diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 668ede14..618bdd8c 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -49,7 +49,7 @@ jobs: VITE_SENTRY_DSN_PROJECT_URI: ${{ secrets.SENTRY_DSN_PROJECT_URI }} VITE_SENTRY_DSN_PROJECT_ID: ${{ secrets.SENTRY_DSN_PROJECT_ID }} VITE_GITHUB_HASH: ${{ github.sha }} - VITE_IO_PROCESS_ID: ${{ secrets.IO_PROCESS_ID }} + VITE_ARIO_PROCESS_ID: ${{ vars.ARIO_PROCESS_ID }} # ao infra settings VITE_AO_CU_URL: ${{ vars.VITE_AO_CU_URL }} - name: Add CNAME Record diff --git a/.github/workflows/production.yml b/.github/workflows/production.yml index 21b505ba..63b3d65a 100644 --- a/.github/workflows/production.yml +++ b/.github/workflows/production.yml @@ -46,7 +46,7 @@ jobs: VITE_SENTRY_DSN_PROJECT_URI: ${{ secrets.SENTRY_DSN_PROJECT_URI }} VITE_SENTRY_DSN_PROJECT_ID: ${{ secrets.SENTRY_DSN_PROJECT_ID }} VITE_GITHUB_HASH: ${{ github.sha }} - VITE_IO_PROCESS_ID: ${{ secrets.IO_PROCESS_ID }} + VITE_ARIO_PROCESS_ID: ${{ secrets.ARIO_PROCESS_ID }} VITE_AO_CU_URL: ${{ vars.VITE_AO_CU_URL }} # Disribute to Firebase @@ -84,7 +84,7 @@ jobs: VITE_SENTRY_DSN_PROJECT_URI: ${{ secrets.SENTRY_DSN_PROJECT_URI }} VITE_SENTRY_DSN_PROJECT_ID: ${{ secrets.SENTRY_DSN_PROJECT_ID }} VITE_GITHUB_HASH: ${{ github.sha }} - VITE_IO_PROCESS_ID: ${{ secrets.IO_PROCESS_ID }} + VITE_ARIO_PROCESS_ID: ${{ vars.ARIO_PROCESS_ID }} DEPLOY_ANT_PROCESS_ID: ${{ secrets.DEPLOY_ANT_PROCESS_ID }} DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }} VITE_AO_CU_URL: ${{ vars.VITE_AO_CU_URL }} diff --git a/package.json b/package.json index 1a5bfbe4..416832cf 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "deploy": "yarn build && permaweb-deploy --ant-process ${DEPLOY_ANT_PROCESS_ID}" }, "dependencies": { - "@ar.io/sdk": "2.7.0-alpha.5", + "@ar.io/sdk": "3.0.0", "@fontsource/rubik": "^5.0.19", "@headlessui/react": "^2.2.0", "@radix-ui/react-tooltip": "^1.0.7", diff --git a/src/components/Header.tsx b/src/components/Header.tsx index 8a0b0729..c60cd7c0 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -1,4 +1,4 @@ -import { mIOToken } from '@ar.io/sdk/web'; +import { mARIOToken } from '@ar.io/sdk/web'; import { NBSP } from '@src/constants'; import useEpochCountdown from '@src/hooks/useEpochCountdown'; import useGateways from '@src/hooks/useGateways'; @@ -88,7 +88,7 @@ const Header = () => { value={ protocolBalance ? (
- {formatWithCommas(new mIOToken(protocolBalance).toIO().valueOf())}{' '} + {formatWithCommas(new mARIOToken(protocolBalance).toARIO().valueOf())}{' '} {ticker}
) : undefined diff --git a/src/components/WalletProvider.tsx b/src/components/WalletProvider.tsx index 0335dc9a..b096d12b 100644 --- a/src/components/WalletProvider.tsx +++ b/src/components/WalletProvider.tsx @@ -1,6 +1,6 @@ -import { AOProcess, IO } from '@ar.io/sdk/web'; +import { AOProcess, ARIO } from '@ar.io/sdk/web'; import { connect } from '@permaweb/aoconnect'; -import { AO_CU_URL, IO_PROCESS_ID } from '@src/constants'; +import { AO_CU_URL, ARIO_PROCESS_ID } from '@src/constants'; import { useEffectOnce } from '@src/hooks/useEffectOnce'; import { ArConnectWalletConnector } from '@src/services/wallets/ArConnectWalletConnector'; import { useGlobalState } from '@src/store'; @@ -39,10 +39,10 @@ const WalletProvider = ({ children }: { children: ReactElement }) => { const signer = wallet.signer; if (signer) { - const writeable = IO.init({ + const writeable = ARIO.init({ signer, process: new AOProcess({ - processId: IO_PROCESS_ID.toString(), + processId: ARIO_PROCESS_ID.toString(), ao: connect({ CU_URL: AO_CU_URL, }), diff --git a/src/components/modals/InstantWithdrawalModal.tsx b/src/components/modals/InstantWithdrawalModal.tsx index 76d50b1b..4d26ca66 100644 --- a/src/components/modals/InstantWithdrawalModal.tsx +++ b/src/components/modals/InstantWithdrawalModal.tsx @@ -1,4 +1,4 @@ -import { AoGateway, AoVaultData, mIOToken } from '@ar.io/sdk/web'; +import { AoGateway, AoVaultData, mARIOToken } from '@ar.io/sdk/web'; import { WRITE_OPTIONS } from '@src/constants'; import { useGlobalState } from '@src/store'; import { formatAddress, formatDateTime, formatWithCommas } from '@src/utils'; @@ -54,8 +54,8 @@ const InstantWithdrawalModal = ({ setCalculatedFeeAndAmountReturning({ penaltyRate, - fee: new mIOToken(fee).toIO().valueOf(), - amountReturning: new mIOToken(amountReturning).toIO().valueOf(), + fee: new mARIOToken(fee).toARIO().valueOf(), + amountReturning: new mARIOToken(amountReturning).toARIO().valueOf(), }); }, [setCalculatedFeeAndAmountReturning, vault]); @@ -149,7 +149,7 @@ const InstantWithdrawalModal = ({
0 ? 1 : minDelegatedStake; @@ -79,7 +79,7 @@ const OperatorStakingModal = ({ ).toFixed(4); const validators = useMemo(() => ({ - stakeAmount: validateIOAmount('Stake Amount', ticker, 1, balances?.io), + stakeAmount: validateARIOAmount('Stake Amount', ticker, 1, balances?.io), withdrawAmount: validateOperatorWithdrawAmount( 'Withdraw Amount', ticker, @@ -99,10 +99,10 @@ const OperatorStakingModal = ({ if (tab == 0 && protocolBalance && gateways && gateway && isFormValid()) { const newTotalStake = currentStake + parseFloat(amountToStake) const { EAY } = calculateOperatorRewards( - new mIOToken(protocolBalance).toIO(), + new mARIOToken(protocolBalance).toARIO(), Object.values(gateways).filter((g) => g.status == 'joined').length, gateway, - new IOToken(newTotalStake), + new ARIOToken(newTotalStake), ); setEAY(formatPercentage(EAY)); } else { diff --git a/src/components/modals/ReviewStakeModal.tsx b/src/components/modals/ReviewStakeModal.tsx index 8becf4e8..fb9bf1f1 100644 --- a/src/components/modals/ReviewStakeModal.tsx +++ b/src/components/modals/ReviewStakeModal.tsx @@ -1,4 +1,4 @@ -import { AoGatewayWithAddress, IOToken } from '@ar.io/sdk/web'; +import { AoGatewayWithAddress, ARIOToken } from '@ar.io/sdk/web'; import { log, WRITE_OPTIONS } from '@src/constants'; import { useGlobalState } from '@src/store'; import { formatAddress, formatWithCommas } from '@src/utils'; @@ -46,7 +46,7 @@ const ReviewStakeModal = ({ if(gateway.gatewayAddress === walletAddress.toString()) { const { id: txID } = await arIOWriteableSDK.increaseOperatorStake( { - increaseQty: new IOToken(amountToStake).toMIO(), + increaseQty: new ARIOToken(amountToStake).toMARIO(), }, WRITE_OPTIONS, ); @@ -58,7 +58,7 @@ const ReviewStakeModal = ({ const { id: txID } = await arIOWriteableSDK.delegateStake( { target: gateway.gatewayAddress, - stakeQty: new IOToken(amountToStake).toMIO(), + stakeQty: new ARIOToken(amountToStake).toMARIO(), }, WRITE_OPTIONS, ); diff --git a/src/components/modals/ReviewWithdrawalModal.tsx b/src/components/modals/ReviewWithdrawalModal.tsx index 63706d2a..7e319c08 100644 --- a/src/components/modals/ReviewWithdrawalModal.tsx +++ b/src/components/modals/ReviewWithdrawalModal.tsx @@ -1,4 +1,4 @@ -import { AoGatewayWithAddress, IOToken } from '@ar.io/sdk/web'; +import { AoGatewayWithAddress, ARIOToken } from '@ar.io/sdk/web'; import { log, WRITE_OPTIONS } from '@src/constants'; import { useGlobalState } from '@src/store'; import { WithdrawalType } from '@src/types'; @@ -69,7 +69,7 @@ const ReviewWithdrawalModal = ({ if (gateway.gatewayAddress === walletAddress.toString()) { const { id: txID } = await arIOWriteableSDK.decreaseOperatorStake( { - decreaseQty: new IOToken(amountToWithdraw).toMIO(), + decreaseQty: new ARIOToken(amountToWithdraw).toMARIO(), instant, }, WRITE_OPTIONS, @@ -81,7 +81,7 @@ const ReviewWithdrawalModal = ({ const { id: txID } = await arIOWriteableSDK.decreaseDelegateStake( { target: gateway.gatewayAddress, - decreaseQty: new IOToken(amountToWithdraw).toMIO(), + decreaseQty: new ARIOToken(amountToWithdraw).toMARIO(), instant, }, WRITE_OPTIONS, diff --git a/src/components/modals/StakingModal.tsx b/src/components/modals/StakingModal.tsx index c8c0287f..488f63dd 100644 --- a/src/components/modals/StakingModal.tsx +++ b/src/components/modals/StakingModal.tsx @@ -1,4 +1,4 @@ -import { mIOToken } from '@ar.io/sdk/web'; +import { mARIOToken } from '@ar.io/sdk/web'; import { Label, Radio, RadioGroup } from '@headlessui/react'; import { EAY_TOOLTIP_FORMULA, EAY_TOOLTIP_TEXT } from '@src/constants'; import useBalances from '@src/hooks/useBalances'; @@ -66,7 +66,7 @@ const StakingModal = ({ const stake = delegateStakes.stakes.find( (stake) => stake.gatewayAddress === gateway.gatewayAddress, )?.balance; - setCurrentStake(new mIOToken(stake ?? 0).toIO().valueOf()); + setCurrentStake(new mARIOToken(stake ?? 0).toARIO().valueOf()); }, [delegateStakes, gateway]); const allowDelegatedStaking = @@ -87,7 +87,7 @@ const StakingModal = ({ : '-'; const minDelegatedStake = gateway - ? new mIOToken(gateway?.settings.minDelegatedStake).toIO().valueOf() + ? new mARIOToken(gateway?.settings.minDelegatedStake).toARIO().valueOf() : 10; const minRequiredStakeToAdd = currentStake > 0 ? 1 : minDelegatedStake; diff --git a/src/components/modals/StartGatewayModal.tsx b/src/components/modals/StartGatewayModal.tsx index 179d2d0d..6a0c1ba4 100644 --- a/src/components/modals/StartGatewayModal.tsx +++ b/src/components/modals/StartGatewayModal.tsx @@ -1,4 +1,4 @@ -import { IOToken } from '@ar.io/sdk/web'; +import { ARIOToken } from '@ar.io/sdk/web'; import { WRITE_OPTIONS, log } from '@src/constants'; import { useGlobalState } from '@src/store'; import { showErrorToast } from '@src/utils/toast'; @@ -149,15 +149,15 @@ const StartGatewayModal = ({ onClose }: { onClose: () => void }) => { delegateRewardShareRatio: allowDelegatedStaking ? parseFloat(String(formState.delegatedStakingShareRatio)) : DEFAULT_DELEGATED_STAKING_REWARD_SHARE_RATIO, - minDelegatedStake: new IOToken( + minDelegatedStake: new ARIOToken( allowDelegatedStaking ? parseFloat(String(formState.minDelegatedStake)) : DEFAULT_DELEGATED_STAKING, - ).toMIO().valueOf(), + ).toMARIO().valueOf(), autoStake: true, - operatorStake: new IOToken( + operatorStake: new ARIOToken( parseFloat(String(formState.stake)), - ).toMIO().valueOf(), + ).toMARIO().valueOf(), }; // UNCOMMENT AND COMMENT OUT JOIN NETWORK FOR DEV WORK diff --git a/src/components/modals/WithdrawAllModal.tsx b/src/components/modals/WithdrawAllModal.tsx index 2933d112..a7a2eaf2 100644 --- a/src/components/modals/WithdrawAllModal.tsx +++ b/src/components/modals/WithdrawAllModal.tsx @@ -1,4 +1,4 @@ -import { AoGateway, mIOToken } from '@ar.io/sdk/web'; +import { AoGateway, mARIOToken } from '@ar.io/sdk/web'; import { WRITE_OPTIONS, log } from '@src/constants'; import { useGlobalState } from '@src/store'; import { showErrorToast } from '@src/utils/toast'; @@ -108,7 +108,7 @@ const WithdrawAllModal = ({ - {new mIOToken(stake.delegatedStake).toIO().valueOf()}{' '} + {new mARIOToken(stake.delegatedStake).toARIO().valueOf()}{' '} {ticker} @@ -122,7 +122,7 @@ const WithdrawAllModal = ({
Total Withdrawal:
- {new mIOToken(totalWithdrawalMIO).toIO().valueOf()} {ticker} + {new mARIOToken(totalWithdrawalMIO).toARIO().valueOf()} {ticker}
diff --git a/src/constants.ts b/src/constants.ts index 846fa777..3fd3d5a9 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,4 +1,4 @@ -import { ioDevnetProcessId } from '@ar.io/sdk/web'; +import { arioDevnetProcessId } from '@ar.io/sdk/web'; import * as loglevel from 'loglevel'; import Ar from 'arweave/web/ar'; @@ -17,13 +17,13 @@ export const WRITE_OPTIONS = { }; export const ARIO_DOCS_URL = 'https://docs.ar.io'; -export const IO_PROCESS_ID = new ArweaveTransactionID( - process.env.VITE_IO_PROCESS_ID ?? ioDevnetProcessId, +export const ARIO_PROCESS_ID = new ArweaveTransactionID( + process.env.VITE_ARIO_PROCESS_ID ?? arioDevnetProcessId, ); export const AO_CU_URL = - process.env.VITE_AO_CU_URL || 'https://cu.ao-testnet.xyz'; + process.env.VITE_AO_CU_URL || 'https://cu.ardrive.io'; -export const IO_PROCESS_INFO_URL = `https://www.ao.link/#/entity/${IO_PROCESS_ID.toString()}`; +export const IO_PROCESS_INFO_URL = `https://www.ao.link/#/entity/${ARIO_PROCESS_ID.toString()}`; export const DEFAULT_ARWEAVE_PROTOCOL = process.env.VITE_GATEWAY_PROTOCOL ?? 'https'; diff --git a/src/hooks/useBalances.ts b/src/hooks/useBalances.ts index 5ad8fb13..4be49813 100644 --- a/src/hooks/useBalances.ts +++ b/src/hooks/useBalances.ts @@ -1,4 +1,4 @@ -import { mIOToken } from '@ar.io/sdk/web'; +import { mARIOToken } from '@ar.io/sdk/web'; import { AR } from '@src/constants'; import { useGlobalState } from '@src/store'; import { ArweaveTransactionID } from '@src/utils/ArweaveTransactionId'; @@ -26,7 +26,7 @@ const useBalances = (walletAddress?: ArweaveTransactionID) => { ]); const arBalance = +AR.winstonToAr(winstonBalance); - const ioBalance = new mIOToken(mioBalance).toIO().valueOf(); + const ioBalance = new mARIOToken(mioBalance).toARIO().valueOf(); return { ar: arBalance, io: ioBalance }; }, diff --git a/src/hooks/useGatewayInfo.ts b/src/hooks/useGatewayInfo.ts index b9ff6047..7f9b3b4b 100644 --- a/src/hooks/useGatewayInfo.ts +++ b/src/hooks/useGatewayInfo.ts @@ -1,4 +1,4 @@ -import { mIOToken } from '@ar.io/sdk/web'; +import { mARIOToken } from '@ar.io/sdk/web'; import { useGlobalState } from '@src/store'; import { formatDateTime, formatWalletAddress, formatWithCommas } from '@src/utils'; import useGateway from './useGateway'; @@ -29,7 +29,7 @@ export const useGatewayInfo = () => { ['Joined at', formatDateTime(new Date(gateway.startTimestamp))], [ `Stake (${ticker})`, - formatWithCommas(new mIOToken(gateway.operatorStake).toIO().valueOf()), + formatWithCommas(new mARIOToken(gateway.operatorStake).toARIO().valueOf()), ], ['Status', gateway.status], ['Reward Ratio', gateway.settings.delegateRewardShareRatio], diff --git a/src/hooks/useGateways.ts b/src/hooks/useGateways.ts index feff484f..d8bf79fc 100644 --- a/src/hooks/useGateways.ts +++ b/src/hooks/useGateways.ts @@ -1,4 +1,4 @@ -import { AoGateway, AoIORead } from '@ar.io/sdk/web'; +import { AoGateway, AoARIORead } from '@ar.io/sdk/web'; import { useGlobalState } from '@src/store'; import { useQuery } from '@tanstack/react-query'; @@ -6,7 +6,7 @@ const useGateways = () => { const arIOReadSDK = useGlobalState((state) => state.arIOReadSDK); const fetchAllGateways = async ( - arIOReadSDK: AoIORead, + arIOReadSDK: AoARIORead, ): Promise> => { let cursor: string | undefined; const gateways: Record = {}; diff --git a/src/hooks/useOperatorRewards.ts b/src/hooks/useOperatorRewards.ts index 3176c56b..cb202ac2 100644 --- a/src/hooks/useOperatorRewards.ts +++ b/src/hooks/useOperatorRewards.ts @@ -1,4 +1,4 @@ -import { AoGateway, mIOToken } from '@ar.io/sdk/web'; +import { AoGateway, mARIOToken } from '@ar.io/sdk/web'; import { OperatorRewards, calculateOperatorRewards } from '@src/utils/rewards'; import { useEffect, useState } from 'react'; import useGateways from './useGateways'; @@ -16,10 +16,10 @@ const useOperatorRewards = (gateway: AoGateway | undefined) => { (g) => g.status == 'joined', ).length; const operatorRewards = calculateOperatorRewards( - new mIOToken(protocolBalance).toIO(), + new mARIOToken(protocolBalance).toARIO(), numGateways, gateway, - new mIOToken(gateway.operatorStake).toIO(), + new mARIOToken(gateway.operatorStake).toARIO(), ); setOperatorRewards(operatorRewards); } diff --git a/src/hooks/useProtocolBalance.ts b/src/hooks/useProtocolBalance.ts index 1ad50a0b..e28aed33 100644 --- a/src/hooks/useProtocolBalance.ts +++ b/src/hooks/useProtocolBalance.ts @@ -1,4 +1,4 @@ -import { IO_PROCESS_ID } from '@src/constants'; +import { ARIO_PROCESS_ID } from '@src/constants'; import { useGlobalState } from '@src/store'; import { useQuery } from '@tanstack/react-query'; @@ -10,7 +10,7 @@ const useProtocolBalance = () => { queryFn: () => { if (arIOReadSDK) { return arIOReadSDK.getBalance({ - address: IO_PROCESS_ID.toString(), + address: ARIO_PROCESS_ID.toString(), }); } throw new Error('Error: ArIO Read SDK is not initialized'); diff --git a/src/hooks/useRewardsEarned.ts b/src/hooks/useRewardsEarned.ts index addf2da4..9ced1fc6 100644 --- a/src/hooks/useRewardsEarned.ts +++ b/src/hooks/useRewardsEarned.ts @@ -1,4 +1,4 @@ -import { mIOToken } from '@ar.io/sdk/web'; +import { mARIOToken } from '@ar.io/sdk/web'; import { useEffect, useState } from 'react'; import useEpochs from './useEpochs'; @@ -27,9 +27,9 @@ const useRewardsEarned = (walletAddress?: string) => { }, 0); setRewardsEarned({ - previousEpoch: new mIOToken(previousEpochRewards).toIO().valueOf(), - totalForPastAvailableEpochs: new mIOToken(totalForPastAvailableEpochs) - .toIO() + previousEpoch: new mARIOToken(previousEpochRewards).toARIO().valueOf(), + totalForPastAvailableEpochs: new mARIOToken(totalForPastAvailableEpochs) + .toARIO() .valueOf(), }); } diff --git a/src/hooks/useRewardsInfo.ts b/src/hooks/useRewardsInfo.ts index 3bdefdb0..21d03db8 100644 --- a/src/hooks/useRewardsInfo.ts +++ b/src/hooks/useRewardsInfo.ts @@ -1,4 +1,4 @@ -import { AoGateway, IOToken, mIOToken } from '@ar.io/sdk/web'; +import { AoGateway, ARIOToken, mARIOToken } from '@ar.io/sdk/web'; import { UserRewards, calculateGatewayRewards, @@ -24,14 +24,14 @@ const useRewardsInfo = (gateway: AoGateway | undefined, userStake: number) => { ? Object.values(gateways).filter((g) => g.status == 'joined').length : 0; const gatewayRewards = calculateGatewayRewards( - new mIOToken(protocolBalance).toIO(), + new mARIOToken(protocolBalance).toARIO(), numGateways, gateway, ); const userRewards = calculateUserRewards( gatewayRewards, - new IOToken(Math.abs(userStake)), + new ARIOToken(Math.abs(userStake)), userStake < 0, ); res = userRewards; diff --git a/src/pages/Dashboard/IOTokenDistributionPanel.tsx b/src/pages/Dashboard/IOTokenDistributionPanel.tsx index 8f7756c1..a1af4b99 100644 --- a/src/pages/Dashboard/IOTokenDistributionPanel.tsx +++ b/src/pages/Dashboard/IOTokenDistributionPanel.tsx @@ -1,4 +1,4 @@ -import { AoTokenSupplyData, mIOToken } from '@ar.io/sdk/web'; +import { AoTokenSupplyData, mARIOToken } from '@ar.io/sdk/web'; import Placeholder from '@src/components/Placeholder'; import useTokenSupply from '@src/hooks/useTokenSupply'; import { useGlobalState } from '@src/store'; @@ -23,25 +23,25 @@ const calculateIODistribution = ( return [ { name: 'Protocol Balance', - value: new mIOToken(tokenSupply.protocolBalance).toIO().valueOf(), + value: new mARIOToken(tokenSupply.protocolBalance).toARIO().valueOf(), }, { name: 'Actively Staked', - value: new mIOToken(tokenSupply.staked + tokenSupply.delegated) - .toIO() + value: new mARIOToken(tokenSupply.staked + tokenSupply.delegated) + .toARIO() .valueOf(), }, { name: 'Pending Withdrawal', - value: new mIOToken(tokenSupply.withdrawn).toIO().valueOf(), + value: new mARIOToken(tokenSupply.withdrawn).toARIO().valueOf(), }, { name: 'In Circulation', - value: new mIOToken(tokenSupply.circulating).toIO().valueOf(), + value: new mARIOToken(tokenSupply.circulating).toARIO().valueOf(), }, { name: 'Locked Supply', - value: new mIOToken(tokenSupply.locked).toIO().valueOf(), + value: new mARIOToken(tokenSupply.locked).toARIO().valueOf(), }, ]; }; @@ -72,7 +72,7 @@ const IOTokenDistributionPanel = () => { data && activeIndex !== undefined ? data[activeIndex].value : tokenSupply?.total - ? new mIOToken(tokenSupply.total).toIO().valueOf() + ? new mARIOToken(tokenSupply.total).toARIO().valueOf() : TOTAL_IO, ), ); diff --git a/src/pages/Dashboard/RewardsDistributionPanel.tsx b/src/pages/Dashboard/RewardsDistributionPanel.tsx index 37675edd..d6c03e44 100644 --- a/src/pages/Dashboard/RewardsDistributionPanel.tsx +++ b/src/pages/Dashboard/RewardsDistributionPanel.tsx @@ -1,4 +1,4 @@ -import { mIOToken } from '@ar.io/sdk/web'; +import { mARIOToken } from '@ar.io/sdk/web'; import Placeholder from '@src/components/Placeholder'; import useEpochs from '@src/hooks/useEpochs'; import { useGlobalState } from '@src/store'; @@ -157,15 +157,15 @@ const RewardsDistributionPanel = () => { .filter((epoch) => epoch !== undefined) .sort((a, b) => a!.epochIndex - b!.epochIndex) .map((epoch) => { - const eligible = new mIOToken( + const eligible = new mARIOToken( epoch!.distributions.totalEligibleRewards, ) - .toIO() + .toARIO() .valueOf(); - const claimed = new mIOToken( + const claimed = new mARIOToken( epoch!.distributions.totalDistributedRewards ?? 0, ) - .toIO() + .toARIO() .valueOf(); return { epoch: epoch!.epochIndex, diff --git a/src/pages/Gateway/ActiveDelegates.tsx b/src/pages/Gateway/ActiveDelegates.tsx index e480e753..853c4041 100644 --- a/src/pages/Gateway/ActiveDelegates.tsx +++ b/src/pages/Gateway/ActiveDelegates.tsx @@ -1,4 +1,4 @@ -import { AoGatewayWithAddress, mIOToken } from '@ar.io/sdk/web'; +import { AoGatewayWithAddress, mARIOToken } from '@ar.io/sdk/web'; import AddressCell from '@src/components/AddressCell'; import Placeholder from '@src/components/Placeholder'; import TableView from '@src/components/TableView'; @@ -30,7 +30,7 @@ const ActiveDelegates = ({ gateway }: { gateway?: AoGatewayWithAddress }) => { if (gateway && gatewayDelegateStakes) { const totalDelegatedStake = gateway.totalDelegatedStake; const data = gatewayDelegateStakes.map((stake) => { - const totalStake = new mIOToken(stake.delegatedStake).toIO().valueOf(); + const totalStake = new mARIOToken(stake.delegatedStake).toARIO().valueOf(); const percentageOfTotalStake = totalDelegatedStake > 0 ? stake.delegatedStake / totalDelegatedStake @@ -84,7 +84,7 @@ const ActiveDelegates = ({ gateway }: { gateway?: AoGatewayWithAddress }) => { {gateway ? (
{formatWithCommas( - new mIOToken(gateway.totalDelegatedStake).toIO().valueOf(), + new mARIOToken(gateway.totalDelegatedStake).toARIO().valueOf(), )}{' '} {ticker}
diff --git a/src/pages/Gateway/OperatorStake.tsx b/src/pages/Gateway/OperatorStake.tsx index f268cf2c..7b9771ad 100644 --- a/src/pages/Gateway/OperatorStake.tsx +++ b/src/pages/Gateway/OperatorStake.tsx @@ -1,4 +1,4 @@ -import { AoGatewayWithAddress, mIOToken } from '@ar.io/sdk/web'; +import { AoGatewayWithAddress, mARIOToken } from '@ar.io/sdk/web'; import Button, { ButtonType } from '@src/components/Button'; import OperatorStakingModal from '@src/components/modals/OperatorStakingModal'; import Placeholder from '@src/components/Placeholder'; @@ -28,10 +28,10 @@ const OperatorStake = ({ gateway, walletAddress }: OperatorStakeProps) => { useEffect(() => { if (gateways && gateway && protocolBalance) { const rewards = calculateOperatorRewards( - new mIOToken(protocolBalance).toIO(), + new mARIOToken(protocolBalance).toARIO(), Object.values(gateways).filter((g) => g.status == 'joined').length, gateway, - new mIOToken(gateway.operatorStake).toIO(), + new mARIOToken(gateway.operatorStake).toARIO(), ); setEAY(rewards.EAY); } @@ -61,7 +61,7 @@ const OperatorStake = ({ gateway, walletAddress }: OperatorStakeProps) => { <>
{formatWithCommas( - new mIOToken(gateway?.operatorStake).toIO().valueOf(), + new mARIOToken(gateway?.operatorStake).toARIO().valueOf(), )}{' '} {ticker}{' '} {gateway?.status === 'leaving' && '(Gateway Leaving Network)'} diff --git a/src/pages/Gateway/PendingWIthdrawals.tsx b/src/pages/Gateway/PendingWIthdrawals.tsx index 5061367b..7664303a 100644 --- a/src/pages/Gateway/PendingWIthdrawals.tsx +++ b/src/pages/Gateway/PendingWIthdrawals.tsx @@ -3,7 +3,7 @@ import { AoGatewayVault, AoGatewayWithAddress, AoVaultData, - mIOToken, + mARIOToken, } from '@ar.io/sdk/web'; import Button, { ButtonType } from '@src/components/Button'; import { @@ -56,7 +56,7 @@ const PendingWithdrawals = ({ sortDescFirst: true, cell: ({ row }) => `${formatWithCommas( - new mIOToken(row.original.balance).toIO().valueOf(), + new mARIOToken(row.original.balance).toARIO().valueOf(), )} ${ticker}`, }), columnHelper.accessor('endTimestamp', { @@ -117,8 +117,8 @@ const PendingWithdrawals = ({
{formatWithCommas( - new mIOToken(gatewayVaults.reduce((a, b) => a + b.balance, 0)) - .toIO() + new mARIOToken(gatewayVaults.reduce((a, b) => a + b.balance, 0)) + .toARIO() .valueOf(), )}{' '} {ticker} diff --git a/src/pages/Gateway/PropertyDisplayPanel.tsx b/src/pages/Gateway/PropertyDisplayPanel.tsx index 3cb6d8dd..5f56f719 100644 --- a/src/pages/Gateway/PropertyDisplayPanel.tsx +++ b/src/pages/Gateway/PropertyDisplayPanel.tsx @@ -1,4 +1,4 @@ -import { AoGateway, mIOToken } from '@ar.io/sdk/web'; +import { AoGateway, mARIOToken } from '@ar.io/sdk/web'; import Button, { ButtonType } from '@src/components/Button'; import Placeholder from '@src/components/Placeholder'; import ConnectModal from '@src/components/modals/ConnectModal'; @@ -99,8 +99,8 @@ const PropertyDisplayPanel = ({ label: `Minimum Delegated Stake (${ticker}):`, value: gatewayLeaving ? 'N/A' - : new mIOToken(gateway?.settings.minDelegatedStake || 0) - .toIO() + : new mARIOToken(gateway?.settings.minDelegatedStake || 0) + .toARIO() .valueOf(), }, ] diff --git a/src/pages/Gateway/index.tsx b/src/pages/Gateway/index.tsx index 18b576d3..f57c8f95 100644 --- a/src/pages/Gateway/index.tsx +++ b/src/pages/Gateway/index.tsx @@ -1,8 +1,8 @@ /* eslint-disable tailwindcss/classnames-order */ import { AoUpdateGatewaySettingsParams, - IOToken, - mIOToken, + ARIOToken, + mARIOToken, } from '@ar.io/sdk/web'; import Button, { ButtonType } from '@src/components/Button'; import Placeholder from '@src/components/Placeholder'; @@ -225,7 +225,7 @@ const Gateway = () => { delegateRewardShareRatio: (gateway.settings.delegateRewardShareRatio || 0) + '', minDelegatedStake: - new mIOToken(gateway.settings.minDelegatedStake || 0).toIO().valueOf() + + new mARIOToken(gateway.settings.minDelegatedStake || 0).toARIO().valueOf() + '', }; setInitialState(initialState); @@ -262,8 +262,8 @@ const Gateway = () => { label: changed.label as string, minDelegatedStake: formState.allowDelegatedStaking && changed.minDelegatedStake - ? new IOToken(parseFloat(changed.minDelegatedStake as string)) - .toMIO() + ? new ARIOToken(parseFloat(changed.minDelegatedStake as string)) + .toMARIO() .valueOf() : undefined, note: changed.note as string, diff --git a/src/pages/Gateways/index.tsx b/src/pages/Gateways/index.tsx index 240c06c9..72d0e48a 100644 --- a/src/pages/Gateways/index.tsx +++ b/src/pages/Gateways/index.tsx @@ -1,4 +1,4 @@ -import { mIOToken } from '@ar.io/sdk/web'; +import { mARIOToken } from '@ar.io/sdk/web'; import AddressCell from '@src/components/AddressCell'; import Header from '@src/components/Header'; import Streak from '@src/components/Streak'; @@ -51,14 +51,14 @@ const Gateways = () => { domain: gateway.settings.fqdn, owner: owner, start: new Date(gateway.startTimestamp), - totalDelegatedStake: new mIOToken(gateway.totalDelegatedStake) - .toIO() + totalDelegatedStake: new mARIOToken(gateway.totalDelegatedStake) + .toARIO() .valueOf(), - operatorStake: new mIOToken(gateway.operatorStake).toIO().valueOf(), - totalStake: new mIOToken( + operatorStake: new mARIOToken(gateway.operatorStake).toARIO().valueOf(), + totalStake: new mARIOToken( gateway.totalDelegatedStake + gateway.operatorStake, ) - .toIO() + .toARIO() .valueOf(), status: gateway.status, endTimeStamp: gateway.endTimestamp, diff --git a/src/pages/Staking/ConnectedLandingPage.tsx b/src/pages/Staking/ConnectedLandingPage.tsx index 41ffcbbf..68ea520a 100644 --- a/src/pages/Staking/ConnectedLandingPage.tsx +++ b/src/pages/Staking/ConnectedLandingPage.tsx @@ -1,4 +1,4 @@ -import { mIOToken } from '@ar.io/sdk/web'; +import { mARIOToken } from '@ar.io/sdk/web'; import Placeholder from '@src/components/Placeholder'; import StakingModal from '@src/components/modals/StakingModal'; import useBalances from '@src/hooks/useBalances'; @@ -92,7 +92,7 @@ const ConnectedLandingPage = () => { }, 0, ); - setAmountStaking(new mIOToken(staked + withdrawing).toIO().valueOf()); + setAmountStaking(new mARIOToken(staked + withdrawing).toARIO().valueOf()); } }, [delegatedStakes]); diff --git a/src/pages/Staking/DelegateStakeTable.tsx b/src/pages/Staking/DelegateStakeTable.tsx index 71da80f0..b59eaabf 100644 --- a/src/pages/Staking/DelegateStakeTable.tsx +++ b/src/pages/Staking/DelegateStakeTable.tsx @@ -1,4 +1,4 @@ -import { mIOToken } from '@ar.io/sdk/web'; +import { mARIOToken } from '@ar.io/sdk/web'; import AddressCell from '@src/components/AddressCell'; import Button, { ButtonType } from '@src/components/Button'; import Streak from '@src/components/Streak'; @@ -84,22 +84,22 @@ const DelegateStake = () => { : -1, passedEpochCount, totalEpochCount, - totalDelegatedStake: new mIOToken( + totalDelegatedStake: new mARIOToken( gateway.totalDelegatedStake, ) - .toIO() + .toARIO() .valueOf(), - operatorStake: new mIOToken(gateway.operatorStake) - .toIO() + operatorStake: new mARIOToken(gateway.operatorStake) + .toARIO() .valueOf(), - totalStake: new mIOToken( + totalStake: new mARIOToken( gateway.totalDelegatedStake + gateway.operatorStake, ) - .toIO() + .toARIO() .valueOf(), eay: calculateGatewayRewards( - new mIOToken(protocolBalance).toIO(), + new mARIOToken(protocolBalance).toARIO(), Object.values(gateways).filter( (g) => g.status == 'joined', ).length, diff --git a/src/pages/Staking/MyStakesTable.tsx b/src/pages/Staking/MyStakesTable.tsx index 1ee30b12..d1c885dd 100644 --- a/src/pages/Staking/MyStakesTable.tsx +++ b/src/pages/Staking/MyStakesTable.tsx @@ -1,4 +1,4 @@ -import { AoGateway, AoVaultData, mIOToken } from '@ar.io/sdk/web'; +import { AoGateway, AoVaultData, mARIOToken } from '@ar.io/sdk/web'; import AddressCell from '@src/components/AddressCell'; import Button, { ButtonType } from '@src/components/Button'; import Dropdown from '@src/components/Dropdown'; @@ -154,7 +154,7 @@ const MyStakesTable = () => { header: `Current Stake (${ticker})`, sortDescFirst: true, cell: ({ row }) => { - return `${new mIOToken(row.original.delegatedStake).toIO().valueOf()}`; + return `${new mARIOToken(row.original.delegatedStake).toARIO().valueOf()}`; }, }), columnHelper.accessor('streak', { @@ -241,7 +241,7 @@ const MyStakesTable = () => { header: `Stake Withdrawing (${ticker})`, sortDescFirst: true, cell: ({ row }) => { - return `${new mIOToken(row.original.withdrawal.balance).toIO().valueOf()}`; + return `${new mARIOToken(row.original.withdrawal.balance).toARIO().valueOf()}`; }, }), columnHelperWithdrawals.accessor((row) => row.withdrawal.endTimestamp, { diff --git a/src/store/db.ts b/src/store/db.ts index 392920c7..7e4d3a46 100644 --- a/src/store/db.ts +++ b/src/store/db.ts @@ -1,5 +1,5 @@ -import { AoEpochData, AoIORead } from '@ar.io/sdk/web'; -import { IO_PROCESS_ID } from '@src/constants'; +import { AoEpochData, AoARIORead } from '@ar.io/sdk/web'; +import { ARIO_PROCESS_ID } from '@src/constants'; import { Assessment } from '@src/types'; import Dexie, { type EntityTable } from 'dexie'; @@ -11,7 +11,7 @@ export interface Observation { } // Use process ID as the database name so that cached data is unique to each process -const DB_NAME = IO_PROCESS_ID.toString(); +const DB_NAME = ARIO_PROCESS_ID.toString(); export const db = new Dexie(DB_NAME) as Dexie & { observations: EntityTable< @@ -37,7 +37,7 @@ db.version(2).stores({ db.open().catch(function (err) { console.error('Failed to open db: ', err); }); -export const getEpoch = async (arIOReadSDK: AoIORead, epochIndex: number) => { +export const getEpoch = async (arIOReadSDK: AoARIORead, epochIndex: number) => { const epoch = await db.epochs.where('epochIndex').equals(epochIndex).first(); if (epoch) { return epoch; diff --git a/src/store/index.ts b/src/store/index.ts index 2badfbce..5760335c 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -1,9 +1,9 @@ import { AOProcess, AoEpochData, - AoIORead, - AoIOWrite, - IO, + AoARIORead, + AoARIOWrite, + ARIO, } from '@ar.io/sdk/web'; import { connect } from '@permaweb/aoconnect'; import { @@ -11,7 +11,7 @@ import { DEFAULT_ARWEAVE_HOST, DEFAULT_ARWEAVE_PORT, DEFAULT_ARWEAVE_PROTOCOL, - IO_PROCESS_ID, + ARIO_PROCESS_ID as ARIO_PROCESS_ID, THEME_TYPES, } from '@src/constants'; import { ArweaveWalletConnector } from '@src/types'; @@ -24,8 +24,8 @@ export type ThemeType = (typeof THEME_TYPES)[keyof typeof THEME_TYPES]; export type GlobalState = { theme: ThemeType; arweave: Arweave; - arIOReadSDK: AoIORead; - arIOWriteableSDK?: AoIOWrite; + arIOReadSDK: AoARIORead; + arIOWriteableSDK?: AoARIOWrite; blockHeight?: number; currentEpoch?: AoEpochData; walletAddress?: ArweaveTransactionID; @@ -43,7 +43,7 @@ export type GlobalStateActions = { walletAddress?: ArweaveTransactionID, wallet?: ArweaveWalletConnector, ) => void; - setArIOWriteableSDK: (arIOWriteableSDK?: AoIOWrite) => void; + setArIOWriteableSDK: (arIOWriteableSDK?: AoARIOWrite) => void; setWalletStateInitialized: (initialized: boolean) => void; setTicker: (ticker: string) => void; setAoCongested: (congested: boolean) => void; @@ -56,9 +56,9 @@ export const initialGlobalState: GlobalState = { protocol: DEFAULT_ARWEAVE_PROTOCOL, port: DEFAULT_ARWEAVE_PORT, }), - arIOReadSDK: IO.init({ + arIOReadSDK: ARIO.init({ process: new AOProcess({ - processId: IO_PROCESS_ID.toString(), + processId: ARIO_PROCESS_ID.toString(), ao: connect({ CU_URL: AO_CU_URL, }), @@ -94,7 +94,7 @@ export class GlobalStateActionBase implements GlobalStateActions { this.set({ walletAddress, wallet }); }; - setArIOWriteableSDK = (arIOWriteableSDK?: AoIOWrite) => { + setArIOWriteableSDK = (arIOWriteableSDK?: AoARIOWrite) => { this.set({ arIOWriteableSDK }); }; diff --git a/src/utils/rewards.ts b/src/utils/rewards.ts index 736f4e8f..a6c66f6d 100644 --- a/src/utils/rewards.ts +++ b/src/utils/rewards.ts @@ -1,4 +1,4 @@ -import { AoGateway, IOToken, mIOToken } from '@ar.io/sdk/web'; +import { AoGateway, ARIOToken, mARIOToken } from '@ar.io/sdk/web'; const EPOCHS_PER_YEAR = 365; const EPOCH_DISTRIBUTION_RATIO = 0.0005; // 0.05% @@ -6,15 +6,15 @@ const GATEWAY_REWARDS_RATIO = 0.9; // 90% // const OBSERVER_REWARDS_RATIO = .05; // 5% export interface GatewayRewards { - totalDelegatedStake: IOToken; - rewardsSharedPerEpoch: IOToken; + totalDelegatedStake: ARIOToken; + rewardsSharedPerEpoch: ARIOToken; EEY: number; EAY: number; } export interface OperatorRewards { - operatorStake: IOToken; - rewardsSharedPerEpoch: IOToken; + operatorStake: ARIOToken; + rewardsSharedPerEpoch: ARIOToken; EEY: number; EAY: number; } @@ -34,10 +34,10 @@ export interface UserRewards { * user what the EAY will be.) */ export const calculateOperatorRewards = ( - protocolBalance: IOToken, + protocolBalance: ARIOToken, totalGateways: number, gateway: AoGateway, - operatorStake: IOToken, + operatorStake: ARIOToken, ): OperatorRewards => { const epochRewards = protocolBalance.valueOf() * EPOCH_DISTRIBUTION_RATIO; const baseGatewayReward = @@ -46,7 +46,7 @@ export const calculateOperatorRewards = ( const gatewayRewardShareRatio = gateway.settings.delegateRewardShareRatio / 100; - const rewardsSharedPerEpoch = new IOToken( + const rewardsSharedPerEpoch = new ARIOToken( baseGatewayReward * (1 - gatewayRewardShareRatio), ); @@ -67,7 +67,7 @@ export const calculateOperatorRewards = ( }; export const calculateGatewayRewards = ( - protocolBalance: IOToken, + protocolBalance: ARIOToken, totalGateways: number, gateway: AoGateway, ): GatewayRewards => { @@ -77,9 +77,9 @@ export const calculateGatewayRewards = ( const gatewayRewardShareRatio = gateway.settings.delegateRewardShareRatio / 100; - const totalDelegatedStake = new mIOToken(gateway.totalDelegatedStake).toIO(); + const totalDelegatedStake = new mARIOToken(gateway.totalDelegatedStake).toARIO(); - const rewardsSharedPerEpoch = new IOToken( + const rewardsSharedPerEpoch = new ARIOToken( baseGatewayReward * gatewayRewardShareRatio, ); @@ -101,7 +101,7 @@ export const calculateGatewayRewards = ( export const calculateUserRewards = ( gatewayRewards: GatewayRewards, - userDelegatedStake: IOToken, + userDelegatedStake: ARIOToken, removingStake = false, ): UserRewards => { const multiplier = removingStake ? -1 : 1; diff --git a/src/vite-env.d.ts b/src/vite-env.d.ts index d90faa2b..3571df15 100644 --- a/src/vite-env.d.ts +++ b/src/vite-env.d.ts @@ -8,7 +8,7 @@ interface ImportMetaEnv { readonly VITE_SENTRY_DSN_PROJECT_ID: string; readonly VITE_NODE_ENV: string; readonly VITE_GITHUB_HASH: string; - readonly VITE_IO_PROCESS_ID: string; + readonly VITE_ARIO_PROCESS_ID: string; readonly VITE_AO_CU_URL: string; } diff --git a/tests/utils/rewards.test.ts b/tests/utils/rewards.test.ts index 81664c2a..c0bd48dc 100644 --- a/tests/utils/rewards.test.ts +++ b/tests/utils/rewards.test.ts @@ -1,4 +1,4 @@ -import { AoGateway, IOToken } from '@ar.io/sdk/web'; +import { AoGateway, ARIOToken } from '@ar.io/sdk/web'; import { GatewayRewards, calculateGatewayRewards, @@ -8,10 +8,10 @@ import { describe('rewards.ts', () => { describe('calculateGatewayRewards', () => { it('should calculate gateway rewards correctly', () => { - const protocolBalance = new IOToken(50_000_000); + const protocolBalance = new ARIOToken(50_000_000); const totalGateways = 300; const gateway = { - totalDelegatedStake: new IOToken(50000).toMIO().valueOf(), + totalDelegatedStake: new ARIOToken(50000).toMARIO().valueOf(), settings: { delegateRewardShareRatio: 50, }, @@ -24,7 +24,7 @@ describe('rewards.ts', () => { ); expect(result.totalDelegatedStake.valueOf()).toEqual( - new IOToken(50000).valueOf(), + new ARIOToken(50000).valueOf(), ); expect(result.rewardsSharedPerEpoch.valueOf()).toBeCloseTo(37.5, 1); expect(result.EEY).toBeCloseTo(0.004); @@ -35,12 +35,12 @@ describe('rewards.ts', () => { describe('calculateUserRewards', () => { it('should calculate user rewards correctly', () => { const gatewayRewards: GatewayRewards = { - totalDelegatedStake: new IOToken(50000), - rewardsSharedPerEpoch: new IOToken(197.91), + totalDelegatedStake: new ARIOToken(50000), + rewardsSharedPerEpoch: new ARIOToken(197.91), EEY: 0.0038, EAY: 0.2058, }; - const userDelegatedStake = new IOToken(5000); + const userDelegatedStake = new ARIOToken(5000); const result = calculateUserRewards(gatewayRewards, userDelegatedStake); diff --git a/yarn.lock b/yarn.lock index 1ac0e08b..1a0ec3bc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -35,10 +35,10 @@ plimit-lit "^3.0.1" warp-contracts "1.4.45" -"@ar.io/sdk@2.7.0-alpha.5": - version "2.7.0-alpha.5" - resolved "https://registry.yarnpkg.com/@ar.io/sdk/-/sdk-2.7.0-alpha.5.tgz#d95719058d63b703fd8e551830c28399722acf18" - integrity sha512-rJczCspZIJDKLO6sZDELQohMJlKFx6kAxThSZczh38+U2K4uFzt3zB7KukLCq0hC4gQBW3ZEXitlvikSkLNqtw== +"@ar.io/sdk@3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@ar.io/sdk/-/sdk-3.0.0.tgz#68cfc4dcf32b894c7a519b8958ff9405fb71e204" + integrity sha512-EIplLoLrMnCSqRX5Z3cruGwe41b3TCfwAM0YmEC4yxFmin3hYhjvx8aNhf3jn/c0HEdGpRcESYYHvfPLUpvHpg== dependencies: "@dha-team/arbundles" "^1.0.1" "@permaweb/aoconnect" "^0.0.57"