Skip to content

Commit 3d34cd3

Browse files
committed
fix: types
1 parent 3f1108c commit 3d34cd3

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

src/api/buildSwapTransaction.test.ts

+10-9
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ import type { BuildSwapTransaction } from './types';
1111
*/
1212
import { getAPIParamsForToken } from './utils/getAPIParamsForToken';
1313
import { getSwapTransaction } from './utils/getSwapTransaction';
14+
import type { Address } from 'viem';
1415

1516
vi.mock('@/core/network/request');
1617

17-
const testFromAddress = '0x6Cd01c0F55ce9E0Bf78f5E90f72b4345b16d515d';
18+
const testFromAddress: Address = '0x6Cd01c0F55ce9E0Bf78f5E90f72b4345b16d515d';
1819
const testAmount = '3305894409732200';
1920
const testAmountReference = 'from' as const;
2021

@@ -26,7 +27,7 @@ describe('buildSwapTransaction', () => {
2627
it('should return a swap', async () => {
2728
const mockParams = {
2829
useAggregator: true,
29-
fromAddress: testFromAddress as `0x${string}`,
30+
fromAddress: testFromAddress ,
3031
amountReference: testAmountReference,
3132
from: ETH_TOKEN,
3233
to: DEGEN_TOKEN,
@@ -122,7 +123,7 @@ describe('buildSwapTransaction', () => {
122123
it('should return a swap with useAggregator=false', async () => {
123124
const mockParams = {
124125
useAggregator: false,
125-
fromAddress: testFromAddress as `0x${string}`,
126+
fromAddress: testFromAddress,
126127
amountReference: testAmountReference,
127128
from: ETH_TOKEN,
128129
to: DEGEN_TOKEN,
@@ -204,7 +205,7 @@ describe('buildSwapTransaction', () => {
204205
it('should return an error for an unsupported amount reference', async () => {
205206
const mockParams = {
206207
useAggregator: true,
207-
fromAddress: testFromAddress as `0x${string}`,
208+
fromAddress: testFromAddress,
208209
amountReference: 'to' as const,
209210
from: ETH_TOKEN,
210211
to: DEGEN_TOKEN,
@@ -222,7 +223,7 @@ describe('buildSwapTransaction', () => {
222223
const mockParams = {
223224
useAggregator: true,
224225
maxSlippage: '3',
225-
fromAddress: testFromAddress as `0x${string}`,
226+
fromAddress: testFromAddress,
226227
amountReference: testAmountReference,
227228
from: DEGEN_TOKEN,
228229
to: ETH_TOKEN,
@@ -311,7 +312,7 @@ describe('buildSwapTransaction', () => {
311312
it('should return an error if sendRequest fails', async () => {
312313
const mockParams = {
313314
useAggregator: true,
314-
fromAddress: testFromAddress as `0x${string}`,
315+
fromAddress: testFromAddress,
315316
amountReference: testAmountReference,
316317
from: ETH_TOKEN,
317318
to: DEGEN_TOKEN,
@@ -337,7 +338,7 @@ describe('buildSwapTransaction', () => {
337338
it('should return an error object from buildSwapTransaction', async () => {
338339
const mockParams = {
339340
useAggregator: true,
340-
fromAddress: testFromAddress as `0x${string}`,
341+
fromAddress: testFromAddress,
341342
amountReference: testAmountReference,
342343
from: ETH_TOKEN,
343344
to: DEGEN_TOKEN,
@@ -368,7 +369,7 @@ describe('buildSwapTransaction', () => {
368369
it('should return an error object from buildSwapTransaction for invalid `amount` input', async () => {
369370
const mockParams = {
370371
useAggregator: true,
371-
fromAddress: testFromAddress as `0x${string}`,
372+
fromAddress: testFromAddress,
372373
amountReference: testAmountReference,
373374
from: ETH_TOKEN,
374375
to: DEGEN_TOKEN,
@@ -387,7 +388,7 @@ describe('buildSwapTransaction', () => {
387388
const mockParams = {
388389
useAggregator: true,
389390
maxSlippage: '3',
390-
fromAddress: testFromAddress as `0x${string}`,
391+
fromAddress: testFromAddress,
391392
amountReference: testAmountReference,
392393
from: ETH_TOKEN,
393394
to: DEGEN_TOKEN,

src/buy/utils/getBuyQuote.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ export async function getBuyQuote({
3131
let response: GetSwapQuoteResponse | undefined;
3232
// only fetch quote if the from and to tokens are different
3333
if (to?.symbol !== from?.symbol) {
34-
// we are trying to swap from the token we are buying "to" the token we are selling
35-
// instead of using amountRefence: 'to', we can use amountRefence: 'from'
36-
// and then swap to and from to get the quote
34+
// switching to and from here
35+
// instead of getting a quote for how much of X do we need to sell to get the input token amount
36+
// we can get a quote for how much of X we will recieve if we sell the input token amount
3737
response = await getSwapQuote({
3838
amount,
3939
amountReference: 'from',

0 commit comments

Comments
 (0)