Skip to content

Commit

Permalink
Improve UX of some examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian-S-A-W committed Jan 8, 2024
1 parent ba3833d commit 28bd5c4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
3 changes: 3 additions & 0 deletions v3-sdk/minting-position/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions v3-sdk/offchain-simulations/README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
14 changes: 10 additions & 4 deletions v3-sdk/offchain-simulations/src/example/Example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ const Example = () => {
const [txState, setTxState] = useState<TransactionState>(TransactionState.New)
const [blockNumber, setBlockNumber] = useState<number>(0)

const [fetching, setFetching] = useState<boolean>()

// Listen for new blocks and update the wallet
useOnBlockUpdated(async (blockNumber: number) => {
refreshBalances()
Expand Down Expand Up @@ -67,7 +69,9 @@ const Example = () => {
}, [refreshBalances])

const onInitializePools = useCallback(async () => {
setFetching(true)
setPools(await initializePools())
setFetching(false)
}, [])

const onCreateTrade = useCallback(async () => {
Expand Down Expand Up @@ -110,10 +114,12 @@ const Example = () => {
</button>
{pools === undefined && <h3>{`Initialize Pools to simulate trade`}</h3>}
{pools !== undefined && <h3>{`Pools initialized successfully`}</h3>}
<button onClick={onInitializePools} disabled={getProvider() === null}>
<p>Initialize Pools</p>
</button>

{!fetching && (
<button onClick={onInitializePools} disabled={getProvider() === null}>
<p>Initialize Pools</p>
</button>
)}
{fetching && <h3>Fetching...</h3>}
<button onClick={onCreateTrade} disabled={pools === undefined}>
<p>Create Trade offchain</p>
</button>
Expand Down
2 changes: 1 addition & 1 deletion v3-sdk/quoting/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface ExampleConfig {

export const CurrentConfig: ExampleConfig = {
rpc: {
mainnet: 'https://mainnet.infura.io/v3/0ac57a06f2994538829c14745750d721',
mainnet: '',
},
tokens: {
in: USDC_TOKEN,
Expand Down

0 comments on commit 28bd5c4

Please sign in to comment.