From 28bd5c4ee3b6497984d8d37b74ceddbe180ecfd5 Mon Sep 17 00:00:00 2001 From: Florian Winkler Date: Mon, 8 Jan 2024 15:16:33 +0100 Subject: [PATCH 1/3] Improve UX of some examples --- v3-sdk/minting-position/README.md | 3 +++ v3-sdk/offchain-simulations/README.md | 6 ++++++ .../offchain-simulations/src/example/Example.tsx | 14 ++++++++++---- v3-sdk/quoting/src/config.ts | 2 +- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/v3-sdk/minting-position/README.md b/v3-sdk/minting-position/README.md index ee3b1a51..8457cbbd 100644 --- a/v3-sdk/minting-position/README.md +++ b/v3-sdk/minting-position/README.md @@ -6,6 +6,9 @@ This is an example of minting a position in a liquidity pool that includes runni The core functionality of this example can be found in [`mintPosition`](./src/libs/positions.ts#L27). +Make sure your wallet holds enough of each required currency. +If you are using a local chain, you can use the trading examples to quickly get the tokens required. + ## Configuration This application can be configured to interact with: diff --git a/v3-sdk/offchain-simulations/README.md b/v3-sdk/offchain-simulations/README.md index 2e879c71..f43b3abc 100644 --- a/v3-sdk/offchain-simulations/README.md +++ b/v3-sdk/offchain-simulations/README.md @@ -1,6 +1,12 @@ +# Offchain Simulations + ## Overview This is an example of initializing Pools with tickdata and simulating trades offchain. +This example makes an extremely high amount of requests and needs a very fast RPC endpoint to work properly. +Be aware of the costs associated. + +If the example does not seem to work, you are most likely ratelimited by your RPC provider. ## Configuration diff --git a/v3-sdk/offchain-simulations/src/example/Example.tsx b/v3-sdk/offchain-simulations/src/example/Example.tsx index a3d06a0a..2cc40131 100644 --- a/v3-sdk/offchain-simulations/src/example/Example.tsx +++ b/v3-sdk/offchain-simulations/src/example/Example.tsx @@ -36,6 +36,8 @@ const Example = () => { const [txState, setTxState] = useState(TransactionState.New) const [blockNumber, setBlockNumber] = useState(0) + const [fetching, setFetching] = useState() + // Listen for new blocks and update the wallet useOnBlockUpdated(async (blockNumber: number) => { refreshBalances() @@ -67,7 +69,9 @@ const Example = () => { }, [refreshBalances]) const onInitializePools = useCallback(async () => { + setFetching(true) setPools(await initializePools()) + setFetching(false) }, []) const onCreateTrade = useCallback(async () => { @@ -110,10 +114,12 @@ const Example = () => { {pools === undefined &&

{`Initialize Pools to simulate trade`}

} {pools !== undefined &&

{`Pools initialized successfully`}

} - - + {!fetching && ( + + )} + {fetching &&

Fetching...

} diff --git a/v3-sdk/quoting/src/config.ts b/v3-sdk/quoting/src/config.ts index 89db1e27..995bedf9 100644 --- a/v3-sdk/quoting/src/config.ts +++ b/v3-sdk/quoting/src/config.ts @@ -19,7 +19,7 @@ export interface ExampleConfig { export const CurrentConfig: ExampleConfig = { rpc: { - mainnet: 'https://mainnet.infura.io/v3/0ac57a06f2994538829c14745750d721', + mainnet: '', }, tokens: { in: USDC_TOKEN, From 91e656e1a24fa12133bd7499ccd07848cd303e2a Mon Sep 17 00:00:00 2001 From: Florian Winkler Date: Mon, 8 Jan 2024 20:42:10 +0100 Subject: [PATCH 2/3] Show mainnet rpc warning only if on mainnet environment --- v3-sdk/collecting-fees/src/example/Example.tsx | 12 ++++++++---- v3-sdk/minting-position/src/example/Example.tsx | 9 ++++++--- v3-sdk/offchain-simulations/src/example/Example.tsx | 9 ++++++--- v3-sdk/trading/src/example/Example.tsx | 9 ++++++--- 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/v3-sdk/collecting-fees/src/example/Example.tsx b/v3-sdk/collecting-fees/src/example/Example.tsx index 61f453dd..84467f50 100644 --- a/v3-sdk/collecting-fees/src/example/Example.tsx +++ b/v3-sdk/collecting-fees/src/example/Example.tsx @@ -92,9 +92,12 @@ const Example = () => { return (
- {CurrentConfig.rpc.mainnet === '' && ( -

Please set your mainnet RPC URL in config.ts

- )} + {CurrentConfig.rpc.mainnet === '' && + CurrentConfig.env === Environment.PRODUCTION && ( +

+ Please set your mainnet RPC URL in config.ts +

+ )} {CurrentConfig.env === Environment.WALLET_EXTENSION && getProvider() === null && (

@@ -122,7 +125,8 @@ const Example = () => { disabled={ txState === TransactionState.Sending || getProvider() === null || - CurrentConfig.rpc.mainnet === '' + (CurrentConfig.rpc.mainnet === '' && + CurrentConfig.env === Environment.PRODUCTION) }>

Mint Position

diff --git a/v3-sdk/minting-position/src/example/Example.tsx b/v3-sdk/minting-position/src/example/Example.tsx index f58ccd34..dc7528cb 100644 --- a/v3-sdk/minting-position/src/example/Example.tsx +++ b/v3-sdk/minting-position/src/example/Example.tsx @@ -80,9 +80,12 @@ const Example = () => { return (
- {CurrentConfig.rpc.mainnet === '' && ( -

Please set your mainnet RPC URL in config.ts

- )} + {CurrentConfig.rpc.mainnet === '' && + CurrentConfig.env === Environment.MAINNET && ( +

+ Please set your mainnet RPC URL in config.ts +

+ )} {CurrentConfig.env === Environment.WALLET_EXTENSION && getProvider() === null && (

diff --git a/v3-sdk/offchain-simulations/src/example/Example.tsx b/v3-sdk/offchain-simulations/src/example/Example.tsx index 2cc40131..828bc846 100644 --- a/v3-sdk/offchain-simulations/src/example/Example.tsx +++ b/v3-sdk/offchain-simulations/src/example/Example.tsx @@ -91,9 +91,12 @@ const Example = () => { return (
- {CurrentConfig.rpc.mainnet === '' && ( -

Please set your mainnet RPC URL in config.ts

- )} + {CurrentConfig.rpc.mainnet === '' && + CurrentConfig.env === Environment.MAINNET && ( +

+ Please set your mainnet RPC URL in config.ts +

+ )} {CurrentConfig.env === Environment.WALLET_EXTENSION && getProvider() === null && (

diff --git a/v3-sdk/trading/src/example/Example.tsx b/v3-sdk/trading/src/example/Example.tsx index 7608f4d9..d300c3a5 100644 --- a/v3-sdk/trading/src/example/Example.tsx +++ b/v3-sdk/trading/src/example/Example.tsx @@ -73,9 +73,12 @@ const Example = () => { return (
- {CurrentConfig.rpc.mainnet === '' && ( -

Please set your mainnet RPC URL in config.ts

- )} + {CurrentConfig.rpc.mainnet === '' && + CurrentConfig.env === Environment.MAINNET && ( +

+ Please set your mainnet RPC URL in config.ts +

+ )} {CurrentConfig.env === Environment.WALLET_EXTENSION && getProvider() === null && (

From 64c53fe8778153cf9a446d548de5232bee45c4bb Mon Sep 17 00:00:00 2001 From: Florian Winkler Date: Mon, 8 Jan 2024 20:49:42 +0100 Subject: [PATCH 3/3] Remove default fork url from range order --- v3-sdk/range-order/README.md | 2 +- v3-sdk/range-order/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/v3-sdk/range-order/README.md b/v3-sdk/range-order/README.md index 22097e53..839b3d7c 100644 --- a/v3-sdk/range-order/README.md +++ b/v3-sdk/range-order/README.md @@ -41,7 +41,7 @@ The [configuration](./src/config.ts) includes control of the environment as well ### Run your local chain -1. Run `yarn start:chain` in a separate terminal session to start up a copy of the mainnet blockchain locally +1. Run `yarn start:chain ` in a separate terminal session to start up a copy of the mainnet blockchain locally ### Setup your wallet diff --git a/v3-sdk/range-order/package.json b/v3-sdk/range-order/package.json index d65afdf6..28b51a8a 100644 --- a/v3-sdk/range-order/package.json +++ b/v3-sdk/range-order/package.json @@ -19,7 +19,7 @@ "build": "react-scripts build", "lint": "yarn eslint .", "install:chain": "curl -L https://foundry.paradigm.xyz | bash && clear && echo $0 | exec && foundryup", - "start:chain": "anvil --fork-url https://mainnet.infura.io/v3/0ac57a06f2994538829c14745750d721" + "start:chain": "anvil --chain-id 1 --fork-url" }, "eslintConfig": { "extends": [