Skip to content

Commit 9542273

Browse files
authored
Merge pull request #103 from tinymanorg/chore/tiny-1787-always-enable-swap-router
Enable swap-router as default
2 parents cfec8cf + b0662d6 commit 9542273

File tree

11 files changed

+45
-71
lines changed

11 files changed

+45
-71
lines changed

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/swap/index.d.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,24 +47,22 @@ export declare const Swap: {
4747
}) => Promise<Omit<import("./types").V1SwapExecution, "fees" | "groupID">>;
4848
};
4949
v2: {
50-
getQuote: ({ type, amount, assetIn, assetOut, network, slippage, isSwapRouterEnabled, pool }: {
50+
getQuote: ({ type, amount, assetIn, assetOut, network, slippage, pool }: {
5151
type: import("./constants").SwapType;
5252
amount: number | bigint;
5353
assetIn: import("../util/asset/assetModels").AssetWithIdAndDecimals;
5454
assetOut: import("../util/asset/assetModels").AssetWithIdAndDecimals;
5555
pool: import("..").V2PoolInfo | null;
5656
network: import("..").SupportedNetwork;
5757
slippage: number;
58-
isSwapRouterEnabled?: boolean | undefined;
5958
}) => Promise<import("./types").SwapQuote>;
60-
getFixedInputSwapQuote: ({ amount, assetIn, assetOut, isSwapRouterEnabled, network, slippage, pool }: {
59+
getFixedInputSwapQuote: ({ amount, assetIn, assetOut, network, slippage, pool }: {
6160
amount: number | bigint;
6261
assetIn: import("../util/asset/assetModels").AssetWithIdAndDecimals;
6362
assetOut: import("../util/asset/assetModels").AssetWithIdAndDecimals;
6463
network: import("..").SupportedNetwork;
6564
pool: import("..").V2PoolInfo | null;
6665
slippage: number;
67-
isSwapRouterEnabled?: boolean | undefined;
6866
}) => Promise<import("./types").SwapQuote>;
6967
getFixedInputDirectSwapQuote: ({ amount, assetIn, assetOut, pool }: {
7068
pool: import("..").V2PoolInfo;
@@ -78,14 +76,13 @@ export declare const Swap: {
7876
assetIn: import("../util/asset/assetModels").AssetWithIdAndDecimals;
7977
assetOut: import("../util/asset/assetModels").AssetWithIdAndDecimals;
8078
}) => import("./types").SwapQuote;
81-
getFixedOutputSwapQuote: ({ amount, assetIn, assetOut, isSwapRouterEnabled, network, slippage, pool }: {
79+
getFixedOutputSwapQuote: ({ amount, assetIn, assetOut, network, slippage, pool }: {
8280
amount: number | bigint;
8381
assetIn: import("../util/asset/assetModels").AssetWithIdAndDecimals;
8482
assetOut: import("../util/asset/assetModels").AssetWithIdAndDecimals;
8583
pool: import("..").V2PoolInfo | null;
8684
network: import("..").SupportedNetwork;
8785
slippage: number;
88-
isSwapRouterEnabled?: boolean | undefined;
8986
}) => Promise<import("./types").SwapQuote>;
9087
generateTxns: (params: import("./types").GenerateSwapTxnsParams) => Promise<import("..").SignerTransaction[]>;
9188
signTxns: ({ txGroup, initiatorSigner }: {

dist/swap/types.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ export type GetSwapQuoteParams = {
8787
amount: number | bigint;
8888
type: SwapType;
8989
network: SupportedNetwork;
90-
/** If `true`, the function will also check the quotes that use swap route */
91-
isSwapRouterEnabled?: boolean;
9290
/** Slippage rate. Should be given as 0.1% -> 0.001. */
9391
slippage: number;
9492
};

dist/swap/utils.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { CONTRACT_VERSION } from "../contract/constants";
22
import { InitiatorSigner, SignerTransaction } from "../util/commonTypes";
33
import { V1PoolInfo } from "../util/pool/poolTypes";
4-
import { GetSwapQuoteBySwapTypeParams, GenerateSwapTxnsParams, GetSwapQuoteParams, SwapQuote, ExecuteSwapCommonParams } from "./types";
54
import { SwapType } from "./constants";
5+
import { ExecuteSwapCommonParams, GenerateSwapTxnsParams, GetSwapQuoteBySwapTypeParams, GetSwapQuoteParams, SwapQuote } from "./types";
66
/**
77
* Gets the best quote for swap from the pools and swap router and returns the best option.
88
*/

dist/swap/v2/index.d.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,16 @@ declare function execute({ client, quote, txGroup, signedTxns }: {
2525
* @param assetOut - Asset to be received
2626
* @param amount - Amount of asset to be swapped
2727
* @param network - Network to be used
28-
* @param isSwapRouterEnabled - Whether the swap router is enabled
2928
* @returns A promise for the Swap quote
3029
*/
31-
declare function getQuote({ type, amount, assetIn, assetOut, network, slippage, isSwapRouterEnabled, pool }: {
30+
declare function getQuote({ type, amount, assetIn, assetOut, network, slippage, pool }: {
3231
type: SwapType;
3332
amount: number | bigint;
3433
assetIn: AssetWithIdAndDecimals;
3534
assetOut: AssetWithIdAndDecimals;
3635
pool: V2PoolInfo | null;
3736
network: SupportedNetwork;
3837
slippage: number;
39-
isSwapRouterEnabled?: boolean;
4038
}): Promise<SwapQuote>;
4139
declare function getFixedInputDirectSwapQuote({ amount, assetIn, assetOut, pool }: {
4240
pool: V2PoolInfo;
@@ -53,26 +51,24 @@ declare function getFixedOutputDirectSwapQuote({ amount, assetIn, assetOut, pool
5351
/**
5452
* @returns A quote for a fixed input swap. Does NOT execute any transactions.
5553
*/
56-
declare function getFixedInputSwapQuote({ amount, assetIn, assetOut, isSwapRouterEnabled, network, slippage, pool }: {
54+
declare function getFixedInputSwapQuote({ amount, assetIn, assetOut, network, slippage, pool }: {
5755
amount: number | bigint;
5856
assetIn: AssetWithIdAndDecimals;
5957
assetOut: AssetWithIdAndDecimals;
6058
network: SupportedNetwork;
6159
pool: V2PoolInfo | null;
6260
slippage: number;
63-
isSwapRouterEnabled?: boolean;
6461
}): Promise<SwapQuote>;
6562
/**
6663
* @returns A quote for a fixed output swap. Does NOT execute any transactions.
6764
*/
68-
declare function getFixedOutputSwapQuote({ amount, assetIn, assetOut, isSwapRouterEnabled, network, slippage, pool }: {
65+
declare function getFixedOutputSwapQuote({ amount, assetIn, assetOut, network, slippage, pool }: {
6966
amount: number | bigint;
7067
assetIn: AssetWithIdAndDecimals;
7168
assetOut: AssetWithIdAndDecimals;
7269
pool: V2PoolInfo | null;
7370
network: SupportedNetwork;
7471
slippage: number;
75-
isSwapRouterEnabled?: boolean;
7672
}): Promise<SwapQuote>;
7773
declare function calculateFixedInputSwap({ inputSupply, outputSupply, swapInputAmount, totalFeeShare, decimals }: {
7874
inputSupply: bigint;

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tinymanorg/tinyman-js-sdk",
3-
"version": "4.1.3",
3+
"version": "4.1.4",
44
"description": "Tinyman JS SDK",
55
"author": "Tinyman Core Team",
66
"license": "MIT",

src/liquid-stake/tAlgoClient.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ describe("TinymanTAlgoClient", () => {
126126

127127
// Check if the account has the correct amount of tALGOs
128128
expect(tAlgoAccountAsset?.amount).toBeCloseTo(expectedTAlgoAmount);
129-
}, 10000);
129+
}, 18000);
130130
it("should create burn transactions", async () => {
131131
const spy = jest.spyOn(client, "burn");
132132

src/swap/types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@ export type GetSwapQuoteParams = {
9494
amount: number | bigint;
9595
type: SwapType;
9696
network: SupportedNetwork;
97-
/** If `true`, the function will also check the quotes that use swap route */
98-
isSwapRouterEnabled?: boolean;
9997
/** Slippage rate. Should be given as 0.1% -> 0.001. */
10098
slippage: number;
10199
};

src/swap/utils.ts

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
import {CONTRACT_VERSION} from "../contract/constants";
2+
import {getAssetId} from "../util/asset/assetUtils";
23
import {InitiatorSigner, SignerTransaction} from "../util/commonTypes";
4+
import SwapQuoteError, {SwapQuoteErrorType} from "../util/error/SwapQuoteError";
35
import {V1PoolInfo} from "../util/pool/poolTypes";
46
import {
5-
GetSwapQuoteBySwapTypeParams,
7+
getBestQuote,
8+
getSwapQuoteContractVersion,
9+
isSwapQuoteErrorCausedByAmount
10+
} from "./common/utils";
11+
import {SwapType} from "./constants";
12+
import {
13+
ExecuteSwapCommonParams,
614
GenerateSwapTxnsParams,
15+
GetSwapQuoteBySwapTypeParams,
716
GetSwapQuoteParams,
817
SwapQuote,
9-
SwapQuoteType,
10-
ExecuteSwapCommonParams
18+
SwapQuoteType
1119
} from "./types";
12-
import {SwapType} from "./constants";
1320
import {SwapV1_1} from "./v1_1";
1421
import {SwapV2} from "./v2";
15-
import {
16-
getBestQuote,
17-
getSwapQuoteContractVersion,
18-
isSwapQuoteErrorCausedByAmount
19-
} from "./common/utils";
20-
import {getAssetId} from "../util/asset/assetUtils";
21-
import SwapQuoteError, {SwapQuoteErrorType} from "../util/error/SwapQuoteError";
2222

2323
/**
2424
* Gets the best quote for swap from the pools and swap router and returns the best option.
@@ -74,7 +74,7 @@ function validateQuotes(promises: Promise<SwapQuote>[]): Promise<SwapQuote[]> {
7474
export async function getFixedInputSwapQuote(
7575
params: GetSwapQuoteBySwapTypeParams
7676
): Promise<SwapQuote> {
77-
const {amount, assetIn, assetOut, isSwapRouterEnabled, pools} = params;
77+
const {amount, assetIn, assetOut, pools} = params;
7878

7979
const quotePromises: Promise<SwapQuote>[] = [];
8080

@@ -124,7 +124,6 @@ export async function getFixedInputSwapQuote(
124124
decimals: assetOut.decimals
125125
},
126126
pool: v2Pool?.info ?? null,
127-
isSwapRouterEnabled,
128127
network: params.network,
129128
slippage: params.slippage
130129
})
@@ -142,7 +141,7 @@ export async function getFixedInputSwapQuote(
142141
export async function getFixedOutputSwapQuote(
143142
params: GetSwapQuoteBySwapTypeParams
144143
): Promise<SwapQuote> {
145-
const {amount, assetIn, assetOut, pools, isSwapRouterEnabled} = params;
144+
const {amount, assetIn, assetOut, pools} = params;
146145

147146
const quotePromises: Promise<SwapQuote>[] = [];
148147

@@ -192,7 +191,6 @@ export async function getFixedOutputSwapQuote(
192191
decimals: assetOut.decimals
193192
},
194193
pool: v2Pool?.info ?? null,
195-
isSwapRouterEnabled,
196194
network: params.network,
197195
slippage: params.slippage
198196
})

0 commit comments

Comments
 (0)