Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import SwapQuoteError from "./util/error/SwapQuoteError";
export type { InitiatorSigner, SignerTransaction, SupportedNetwork } from "./util/commonTypes";
export { BASE_MINIMUM_BALANCE, MINIMUM_ADD_LIQUIDITY_AMOUNT, MINIMUM_BALANCE_REQUIRED_PER_APP, MINIMUM_BALANCE_REQUIRED_PER_ASSET, MINIMUM_BALANCE_REQUIRED_PER_BYTE_SCHEMA, MINIMUM_BALANCE_REQUIRED_PER_INT_SCHEMA_VALUE } from "./util/constant";
export * from "./swap/v2/router";
export * from "./swap/router";
export * from "./swap/common/utils";
export { applySlippageToAmount, ASSET_OPT_IN_PROCESS_TXN_COUNT, convertFromBaseUnits, convertToBaseUnits, getTxnGroupID, sendAndWaitRawTransaction, sumUpTxnFees, joinByteArrays, intToBytes } from "./util/util";
export { generateOptIntoAssetTxns } from "./util/asset/assetUtils";
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions dist/swap/router/constants.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { SupportedNetwork } from "../../util/commonTypes";
import { SwapType } from "../constants";
export declare const SWAP_ROUTER_APP_ID: Record<SupportedNetwork, number>;
/**
* Inner txn counts according to the swap type
*/
export declare const SWAP_ROUTER_INNER_TXN_COUNT: Record<SwapType, number>;
export declare enum V2SwapRouterSwapAppCallArgsIndices {
TxnType = 0,
InputAmount = 1,
OutputAmount = 2,
Routes = 3,
Pools = 4,
Swaps = 5
}
export declare enum V2SwapRouterAppCallArgsTxnType {
Swap = "swap",
AssetOptIn = "asset_opt_in",
Noop = "noop"
}
export declare const SWAP_ROUTER_SWAP_APP_CALL_ARGS_LENGTH = 6;
File renamed without changes.
20 changes: 20 additions & 0 deletions dist/swap/router/swap-router.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import algosdk, { Algodv2 } from "algosdk";
import { SupportedNetwork } from "../../util/commonTypes";
import { SwapType } from "../constants";
import { SwapRouterResponse } from "../types";
export declare function generateSwapRouterTxns({ initiatorAddr, client, route }: {
client: Algodv2;
initiatorAddr: string;
route: SwapRouterResponse;
}): Promise<{
txn: algosdk.Transaction;
signers: string[];
}[]>;
export declare function getSwapRoute({ amount, assetInID, assetOutID, swapType, network, slippage }: {
assetInID: number;
assetOutID: number;
swapType: SwapType;
amount: number | bigint;
network: SupportedNetwork;
slippage: string;
}): Promise<SwapRouterResponse>;
23 changes: 23 additions & 0 deletions dist/swap/router/util.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { SupportedNetwork } from "../../util/commonTypes";
import { SwapRouterResponse } from "../types";
declare function getSwapRouteRate(route: Pick<SwapRouterResponse, "input_asset" | "output_asset" | "input_amount" | "output_amount">): number;
declare function getSwapRouterAppID(network: SupportedNetwork): number;
declare function getAssetOutFromSwapRoute(route: Pick<SwapRouterResponse, "output_asset" | "output_amount">): {
asset: Pick<import("../..").TinymanAnalyticsApiAsset, "id" | "decimals" | "name" | "unit_name">;
amount: bigint;
};
declare function getAssetInFromSwapRoute(route: Pick<SwapRouterResponse, "input_asset" | "input_amount">): {
asset: Pick<import("../..").TinymanAnalyticsApiAsset, "id" | "decimals" | "name" | "unit_name">;
amount: bigint;
};
declare function getAssetInAndOutFromSwapRoute(route: Pick<SwapRouterResponse, "input_asset" | "output_asset" | "input_amount" | "output_amount">): {
assetIn: {
asset: Pick<import("../..").TinymanAnalyticsApiAsset, "id" | "decimals" | "name" | "unit_name">;
amount: bigint;
};
assetOut: {
asset: Pick<import("../..").TinymanAnalyticsApiAsset, "id" | "decimals" | "name" | "unit_name">;
amount: bigint;
};
};
export { getAssetInAndOutFromSwapRoute, getAssetInFromSwapRoute, getAssetOutFromSwapRoute, getSwapRouterAppID, getSwapRouteRate };
21 changes: 21 additions & 0 deletions dist/swap/router/v2/constants.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { SupportedNetwork } from "../../../util/commonTypes";
import { SwapType } from "../../constants";
export declare const SWAP_ROUTER_APP_ID: Record<SupportedNetwork, number>;
/**
* Inner txn counts according to the swap type
*/
export declare const SWAP_ROUTER_INNER_TXN_COUNT: Record<SwapType, number>;
export declare enum V2SwapRouterSwapAppCallArgsIndices {
TxnType = 0,
InputAmount = 1,
OutputAmount = 2,
Routes = 3,
Pools = 4,
Swaps = 5
}
export declare enum V2SwapRouterAppCallArgsTxnType {
Swap = "swap",
AssetOptIn = "asset_opt_in",
Noop = "noop"
}
export declare const SWAP_ROUTER_SWAP_APP_CALL_ARGS_LENGTH = 6;
2 changes: 2 additions & 0 deletions dist/swap/router/v2/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./swap-router";
export * from "./util";
21 changes: 21 additions & 0 deletions dist/swap/router/v2/swap-router.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import algosdk, { Algodv2, SuggestedParams } from "algosdk";
import { SupportedNetwork } from "../../../util/commonTypes";
import { SwapType } from "../../constants";
import { SwapRouterResponse, SwapRouterTransactionRecipe } from "../../types";
export declare function generateSwapRouterTxns({ initiatorAddr, client, route }: {
client: Algodv2;
initiatorAddr: string;
route: SwapRouterResponse;
}): Promise<{
txn: algosdk.Transaction;
signers: string[];
}[]>;
export declare function generateSwapRouterTxnFromRecipe(recipe: SwapRouterTransactionRecipe, suggestedParams: SuggestedParams, userAddress: string): algosdk.Transaction;
export declare function getSwapRoute({ amount, assetInID, assetOutID, swapType, network, slippage }: {
assetInID: number;
assetOutID: number;
swapType: SwapType;
amount: number | bigint;
network: SupportedNetwork;
slippage: number;
}): Promise<SwapRouterResponse>;
23 changes: 23 additions & 0 deletions dist/swap/router/v2/util.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { SupportedNetwork } from "../../../util/commonTypes";
import { SwapRouterResponse } from "../../types";
declare function getSwapRouteRate(route: Pick<SwapRouterResponse, "asset_in" | "asset_out" | "input_amount" | "output_amount">): number;
declare function getSwapRouterAppID(network: SupportedNetwork): number;
declare function getAssetOutFromSwapRoute(route: Pick<SwapRouterResponse, "asset_out" | "output_amount">): {
asset: Pick<import("../../..").TinymanAnalyticsApiAsset, "id" | "decimals" | "name" | "unit_name">;
amount: bigint;
};
declare function getAssetInFromSwapRoute(route: Pick<SwapRouterResponse, "asset_in" | "input_amount">): {
asset: Pick<import("../../..").TinymanAnalyticsApiAsset, "id" | "decimals" | "name" | "unit_name">;
amount: bigint;
};
declare function getAssetInAndOutFromSwapRoute(route: Pick<SwapRouterResponse, "asset_in" | "asset_out" | "input_amount" | "output_amount">): {
assetIn: {
asset: Pick<import("../../..").TinymanAnalyticsApiAsset, "id" | "decimals" | "name" | "unit_name">;
amount: bigint;
};
assetOut: {
asset: Pick<import("../../..").TinymanAnalyticsApiAsset, "id" | "decimals" | "name" | "unit_name">;
amount: bigint;
};
};
export { getAssetInAndOutFromSwapRoute, getAssetInFromSwapRoute, getAssetOutFromSwapRoute, getSwapRouterAppID, getSwapRouteRate };
20 changes: 20 additions & 0 deletions dist/swap/router/v3/swap-router.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import algosdk, { Algodv2 } from "algosdk";
import { SupportedNetwork } from "../../../util/commonTypes";
import { SwapType } from "../../constants";
import { SwapRouterResponseV3 } from "../../types";
export declare function generateSwapRouterTxns({ initiatorAddr, client, route }: {
client: Algodv2;
initiatorAddr: string;
route: SwapRouterResponseV3;
}): Promise<{
txn: algosdk.Transaction;
signers: string[];
}[]>;
export declare function getSwapRoute({ amount, assetInID, assetOutID, swapType, network, slippage }: {
assetInID: number;
assetOutID: number;
swapType: SwapType;
amount: number | bigint;
network: SupportedNetwork;
slippage: string;
}): Promise<SwapRouterResponseV3>;
65 changes: 36 additions & 29 deletions dist/swap/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,41 +41,16 @@ export interface SwapRoutePool {
asset_2: SwapRouteAsset;
version: "2.0";
}
export interface FetchSwapRouteQuotesPayload {
asset_in_id: string;
asset_out_id: string;
input_amount?: string;
output_amount?: string;
swap_type: SwapType;
slippage: number;
}
export type SwapRouterResponse = Pick<FetchSwapRouteQuotesPayload, "swap_type"> & {
asset_in: Pick<TinymanAnalyticsApiAsset, "id" | "decimals" | "name" | "unit_name">;
asset_out: Pick<TinymanAnalyticsApiAsset, "id" | "decimals" | "name" | "unit_name">;
price_impact: string | null;
status: {
round_number: string;
round_datetime: string;
};
transaction_count: number | null;
transactions: SwapRouterTransactionRecipe[] | null;
transaction_fee: string | null;
swap_fee: string | null;
input_amount: string | null;
output_amount: string | null;
asset_ids: number[] | null;
pool_ids: string[] | null;
};
export interface SwapRouterTransactionRecipe {
type: TransactionType;
receiver?: string;
receiver: string;
app_id: number;
asset_id: number;
amount: number;
args: string[] | null;
accounts?: string[];
assets?: number[];
apps?: number[];
accounts: string[];
assets: number[];
apps: number[];
}
export type GetSwapQuoteParams = {
assetIn: Pick<TinymanAnalyticsApiAsset, "id" | "decimals">;
Expand Down Expand Up @@ -154,3 +129,35 @@ export interface ExecuteSwapCommonParams {
txGroup: SignerTransaction[];
signedTxns: Uint8Array[];
}
export interface FetchSwapRouteQuotesPayload {
input_asset_id: string;
output_asset_id: string;
input_amount?: string;
output_amount?: string;
swap_type: SwapType;
slippage: string;
}
export interface SwapRouterResponse {
swap_type: SwapType;
input_amount: string;
output_amount: string;
slippage: string;
input_asset: Pick<TinymanAnalyticsApiAsset, "id" | "decimals" | "name" | "unit_name">;
output_asset: Pick<TinymanAnalyticsApiAsset, "id" | "decimals" | "name" | "unit_name">;
input_amount_arg: string;
output_amount_arg: string;
input_amount_mapping: string[];
pool_mapping: string[][];
asset_mapping: number[][];
asset_in_algo_price: string;
price_impact: string;
transactions: SwapRouterTransactionRecipe[];
transaction_fee: string;
transaction_fee_in_input_asset: string;
swap_fee: string;
swap_fee_algo_price: string;
status: {
round_number: string;
round_datetime: string;
};
}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tinymanorg/tinyman-js-sdk",
"version": "5.1.3",
"version": "5.1.4",
"description": "Tinyman JS SDK",
"author": "Tinyman Core Team",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export {
MINIMUM_BALANCE_REQUIRED_PER_INT_SCHEMA_VALUE
} from "./util/constant";

export * from "./swap/v2/router";
export * from "./swap/router";

export * from "./swap/common/utils";

Expand Down
2 changes: 1 addition & 1 deletion src/swap/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
getAssetInFromSwapRoute,
getAssetOutFromSwapRoute,
getSwapRouteRate
} from "../v2/router/util";
} from "../router/util";
import {getV2SwapTotalFee} from "../v2/util";

function calculateSwapRate({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {SupportedNetwork} from "../../../util/commonTypes";
import {SwapType} from "../../constants";
import {SupportedNetwork} from "../../util/commonTypes";
import {SwapType} from "../constants";

export const SWAP_ROUTER_APP_ID: Record<SupportedNetwork, number> = {
testnet: 184778019,
mainnet: 1083651166
mainnet: 3119560942
};

/**
Expand Down
2 changes: 2 additions & 0 deletions src/swap/router/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./swap-router";
export * from "./util";
Loading