Skip to content
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
53 changes: 53 additions & 0 deletions DEPLOY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Deploying Axis to a new chain

## Order of ceremony

The following actions need to be carried out in order to add a new chain to Axis:

1. Deploy the smart contracts to the new chain
2. [Add the new chain config](https://github.com/Axis-Fi/subgraph/?tab=readme-ov-file#adding-a-new-chain) to the subgraph repo
3. [Deploy](https://github.com/Axis-Fi/subgraph/?tab=readme-ov-file#deploy-guide) the subgraph
4. Obtain an RPC URL for the new chain from your RPC provider (e.g. Alchemy)
5. Add the new chain and deployment configuration to the [deployments](https://github.com/Axis-Fi/ui-libs/blob/main/packages/deployments/README.md#adding-a-new-chain-deployment) package
6. Add a cloak watcher to the [cloak](https://github.com/Axis-Fi/cloak) package
7. Confirm the new [deployments](https://github.com/Axis-Fi/ui-libs/blob/main/packages/deployments/README.md#adding-a-new-chain-deployment) package has been published to NPM
8. Consume the new [deployments package version](https://github.com/Axis-Fi/ui-libs/blob/main/packages/deployments/package.json) inside [launchpad](./apps/dapp/package.json) and [standalone](https://github.com/Axis-Fi/standalone-ui/blob/main/apps/dapp/package.json)
9. Test the `launchpad` and `standalone` dapp using the new chain: `pnpm dev`

## Deploy the smart contracts

Each chain requires the Axis smart contracts to be deployed. This is handled from the respective contract repos:

- [axis-core](https://github.com/Axis-Fi/axis-core)
- [axis-periphery](https://github.com/Axis-Fi/axis-periphery/)
- [axis-registry](https://github.com/Axis-Fi/axis-registry)

## Add the new chain to the subgraph

The subgraph needs to be updated to include the new chain. This is achieved by updating the `networks.json` file in the [subgraph](https://github.com/Axis-Fi/subgraph) package.

See the subgraph [README](https://github.com/Axis-Fi/subgraph/?tab=readme-ov-file#adding-a-new-chain) for more information.

## Deploy the subgraph

Once the the new chain config has been added to the subgraph repo, the new subgraph can be deployed. This is done by following the subgraph [README](https://github.com/Axis-Fi/subgraph/?tab=readme-ov-file#deploy-guide).

## Obtain an RPC URL for the new chain

This is a manual process. The RPC URL for the new chain needs to be obtained from your RPC provider (Alchemy, Infura, etc.). Axis currently uses Alchemy.

## Add the new chain to the deployments package

The [deployments package](https://github.com/Axis-Fi/deployments) needs to be updated to include the new chain.

See the deployments [README](https://github.com/Axis-Fi/deployments/?tab=readme-ov-file#adding-a-new-chain) for how to do this.

## Add a cloak watcher to the cloak package

The cloak package needs to be updated to include the new chain. This is achieved by updating the `cloak.json` file in the [cloak](https://github.com/Axis-Fi/cloak) package.

See the cloak [README](https://github.com/Axis-Fi/cloak/?tab=readme-ov-file#adding-a-new-chain) for more information.

## Update and test

Make sure you've updated `launchpad` and `standalone` `@axis-finance/deployments` dependency to the new published version, then run `pnpm i` to install the new dependencies, and `pnpm dev` to test the dapp using the new chain.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ This Turborepo includes the following packages and applications:
- `packages/ui`: Axis UI component library (shadcn + tailwind)
- `config/tailwind-config`: Shared TailwindCSS configs

# Deploying Axis to a new chain

To deploy Axis to a new chain, please follow the instructions in the [DEPLOY.md](./DEPLOY.md) file.

## Contributing

Thank you for your interest in contributing to Axis `launchpad`! Please read our [CONTRIBUTION.md](./CONTRIBUTING.md) guide to understand our development process and how to contribute effectively.
14 changes: 7 additions & 7 deletions apps/dapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
"dependencies": {
"@axis-finance/abis": "0.0.3",
"@axis-finance/auto-signer-provider": "^0.0.1",
"@axis-finance/cloak": "0.0.19",
"@axis-finance/curator-api": "0.0.32",
"@axis-finance/deployments": "0.0.15",
"@axis-finance/env": "0.0.19",
"@axis-finance/sdk": "0.0.42",
"@axis-finance/subgraph-client": "0.0.11",
"@axis-finance/types": "0.0.22",
"@axis-finance/cloak": "0.0.20",
"@axis-finance/curator-api": "0.0.33",
"@axis-finance/deployments": "0.0.16",
"@axis-finance/env": "0.0.20",
"@axis-finance/sdk": "0.0.43",
"@axis-finance/subgraph-client": "0.0.12",
"@axis-finance/types": "0.0.23",
"@fleek-platform/sdk": "^3.5.1",
"@helia/verified-fetch": "^2.3.1",
"@openzeppelin/merkle-tree": "^1.0.6",
Expand Down
Binary file added apps/dapp/public/bsc.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions apps/dapp/public/monad.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/dapp/public/sonic-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions apps/dapp/src/modules/auction/bid-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export function BidList(props: BidListProps) {
const [onlyUserBids, setOnlyUserBids] = React.useState(false);
const { index: bidIndex } = useBidIndex(
props.auction,
BigInt(bidToRefund?.bidId ?? -1),
bidToRefund?.bidId ? BigInt(bidToRefund.bidId) : undefined,
);

const mappedBids = React.useMemo(
Expand Down Expand Up @@ -181,9 +181,9 @@ export function BidList(props: BidListProps) {
const isLoading = refund.isPending || refundReceipt.isLoading;

const handleRefund = (bidId?: string) => {
if (bidId === undefined || bidIndex === undefined)
if (bidId === undefined || bidIndex === undefined) {
throw new Error("Unable to get bidId for refund");

}
refund.writeContract({
abi: auctionHouse.abi,
address: auctionHouse.address,
Expand All @@ -200,7 +200,7 @@ export function BidList(props: BidListProps) {
id: "actions",
cell: (info) => {
const bid = info.row.original;
const isLive = props.auction.status === "live";
const isLive = true;
if (!address || !isLive) return;
if (bid.bidder.toLowerCase() !== address.toLowerCase()) return;
if (bid.status === "claimed" && !bid.settledAmountOut) return;
Expand Down
44 changes: 32 additions & 12 deletions apps/dapp/src/modules/auction/hooks/use-bid-index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@ import { Auction } from "@axis-finance/types";
import React from "react";
import { useReadContract } from "wagmi";

export function useBidIndex(auction: Auction, bidId: bigint = -1n) {
const abi = axisContracts.abis.batchCatalogue;
const BID_COUNT = 500n;

export function useBidIndex(auction: Auction, bidId?: bigint) {
const address = axisContracts.addresses[auction.chainId].batchCatalogue;
const abi = axisContracts.abis.batchCatalogue;
const [startingIndex, setStartingIndex] = React.useState(0n);
const BID_COUNT = 100n;

const numBidsQuery = useReadContract({
address,
abi,
functionName: "getNumBids",
args: [BigInt(auction.lotId)],
query: {
enabled: bidId !== undefined,
},
});

const bidsQuery = useReadContract({
Expand All @@ -27,17 +31,33 @@ export function useBidIndex(auction: Auction, bidId: bigint = -1n) {
});

React.useEffect(() => {
if (
bidsQuery.isSuccess &&
startingIndex + BID_COUNT < (numBidsQuery.data ?? 0n)
) {
// Update query args to trigger a re-read
setStartingIndex((index) => index + BID_COUNT);
}
}, [bidsQuery.isSuccess]);
if (!bidsQuery.isSuccess) return;

const isBidIdFound =
bidsQuery.data.findIndex((b: bigint) => b === bidId) !== -1;

const noMoreBidsToSearch = startingIndex + BID_COUNT >= numBidsQuery.data!;

if (isBidIdFound || noMoreBidsToSearch) return;

// Update query args to trigger a re-read
setStartingIndex((index) => index + BID_COUNT);
}, [
bidId,
bidsQuery.data,
bidsQuery.isSuccess,
numBidsQuery.data,
startingIndex,
]);

const batchIndex =
bidId !== undefined && bidsQuery.data ? bidsQuery.data.indexOf(bidId) : -1;

const index =
batchIndex !== -1 ? startingIndex + BigInt(batchIndex) : undefined;

return {
index: bidsQuery.data?.findIndex((b: bigint) => b === bidId),
index,
...bidsQuery,
};
}
76 changes: 38 additions & 38 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading