Skip to content

Commit

Permalink
dope
Browse files Browse the repository at this point in the history
  • Loading branch information
Zizzamia committed Jun 13, 2024
1 parent 788f1de commit 88784b1
Showing 1 changed file with 48 additions and 3 deletions.
51 changes: 48 additions & 3 deletions site/docs/pages/swap/get-swap-quote.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,56 @@ The `getSwapQuote` function is used to get a quote for a swap between two assets
```tsx [code]
import { getSwapQuote } from '@coinbase/onchainkit/swap';

const quote = await getSwapQuote({ ... });
const fromToken: Token = {
name: 'ETH',
address: '',
symbol: 'ETH',
decimals: 18,
image: 'https://wallet-api-production.s3.amazonaws.com/uploads/tokens/eth_288.png',
chainId: 8453,
};

const toToken: Token = {
name: 'USDC',
address: '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913',
symbol: 'USDC',
decimals: 6,
image:
'https://d3r81g40ycuhqg.cloudfront.net/wallet/wais/44/2b/442b80bd16af0c0d9b22e03a16753823fe826e5bfd457292b55fa0ba8c1ba213-ZWUzYjJmZGUtMDYxNy00NDcyLTg0NjQtMWI4OGEwYjBiODE2',
chainId: 8453,
};

const quote = await getSwapQuote({
from: fromToken,
to: toToken,
amount: '0.001',
});
```

```ts [return value]
...
```json [return value]
{
"amountReference": "from",
"chainId": 8453,
"from": {
"address": "",
"chainId": 8453,
"decimals": 18,
"image": "https://wallet-api-production.s3.amazonaws.com/uploads/tokens/eth_288.png",
"name": "ETH"
},
"fromAmount": "1000000000000000",
"highPriceImpact": false,
"priceImpact": "0.16",
"slippage": "3",
"to": {
"address": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
"chainId": 8453,
"decimals": 6,
"image": "https://d3r81g40ycuhqg.cloudfront.net/wallet/wais/…-ZWUzYjJmZGUtMDYxNy00NDcyLTg0NjQtMWI4OGEwYjBiODE2",
"name": "USDC"
},
"toAmount": "3547037"
}
```

:::
Expand Down

0 comments on commit 88784b1

Please sign in to comment.