Skip to content

Commit 4dbd718

Browse files
authored
Merge pull request #67 from Hipo/v2
V2
2 parents 0bfce76 + aca757f commit 4dbd718

File tree

145 files changed

+6534
-2771
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

145 files changed

+6534
-2771
lines changed

README.md

Lines changed: 107 additions & 475 deletions
Large diffs are not rendered by default.

dist/add-liquidity/constants.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export declare const ADD_LIQUIDITY_APP_CALL_ARGUMENTS: {
2+
v1_1: Uint8Array[];
3+
v2: {
4+
INITIAL_LIQUIDITY: Uint8Array[];
5+
SINGLE_ASSET_MODE: Uint8Array[];
6+
FLEXIBLE_MODE: Uint8Array[];
7+
};
8+
};

dist/add-liquidity/index.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import * as AddLiquidityV1_1 from "./v1_1";
2+
import * as AddLiquidityV2 from "./v2";
3+
export declare const AddLiquidity: {
4+
v1_1: typeof AddLiquidityV1_1;
5+
v2: typeof AddLiquidityV2;
6+
};

dist/add-liquidity/util.d.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { CONTRACT_VERSION } from "../contract/constants";
2+
import { V2AddLiquidityType } from "./v2/constants";
3+
/**
4+
* @returns the total fee that will be paid by the user
5+
* for the add liquidity transaction with given parameters
6+
*/
7+
declare function getAddLiquidityTotalFee(params: {
8+
version: typeof CONTRACT_VERSION.V1_1;
9+
} | {
10+
version: typeof CONTRACT_VERSION.V2;
11+
type: V2AddLiquidityType;
12+
}): number;
13+
export { getAddLiquidityTotalFee };
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export declare enum V1_1AddLiquidityTxnIndices {
2+
FEE_TXN = 0,
3+
VALIDATOR_APP_CALL_TXN = 1,
4+
ASSET1_IN_TXN = 2,
5+
ASSET2_IN_TXN = 3,
6+
LIQUDITY_OUT_TXN = 4
7+
}
8+
export declare const V1_1_ADD_LIQUIDITY_PROCESS_TXN_COUNT = 5;
9+
export declare const V1_1_ADD_LIQUIDITY_TOTAL_FEE: number;

dist/add-liquidity/v1_1/index.d.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { SignerTransaction, InitiatorSigner, SupportedNetwork } from "../../util/commonTypes";
2+
import { PoolReserves, V1PoolInfo } from "../../util/pool/poolTypes";
3+
import { V1_1AddLiquidityQuote, V1_1AddLiquidityExecution } from "./types";
4+
/**
5+
* Get a quote for how many liquidity tokens a deposit of asset1In and asset2In is worth at this
6+
* moment. This does not execute any transactions.
7+
*
8+
* @param params.pool Information for the pool.
9+
* @param params.reserves Pool reserves.
10+
* @param params.asset1In The quantity of the first asset being deposited.
11+
* @param params.asset2In The quantity of the second asset being deposited.
12+
*/
13+
export declare function getQuote({ pool, reserves, asset1In, asset2In }: {
14+
pool: V1PoolInfo;
15+
reserves: PoolReserves;
16+
asset1In: number | bigint;
17+
asset2In: number | bigint;
18+
}): V1_1AddLiquidityQuote;
19+
export declare function generateTxns({ client, network, poolAddress, asset1In, asset2In, poolTokenOut, slippage, initiatorAddr }: {
20+
client: any;
21+
network: SupportedNetwork;
22+
poolAddress: string;
23+
asset1In: AssetWithIdAndAmount;
24+
asset2In: AssetWithIdAndAmount;
25+
poolTokenOut: AssetWithIdAndAmount;
26+
slippage: number;
27+
initiatorAddr: string;
28+
}): Promise<SignerTransaction[]>;
29+
export declare function signTxns({ pool, txGroup, initiatorSigner }: {
30+
pool: V1PoolInfo;
31+
txGroup: SignerTransaction[];
32+
initiatorSigner: InitiatorSigner;
33+
}): Promise<Uint8Array[]>;
34+
/**
35+
* Execute adding liquidity operation with the desired quantities.
36+
*
37+
* @param params.client An Algodv2 client.
38+
* @param params.pool Information for the pool.
39+
* @param params.initiatorAddr The address of the account performing the add liquidity operation.
40+
*/
41+
export declare function execute({ client, pool, txGroup, signedTxns, initiatorAddr }: {
42+
client: any;
43+
pool: V1PoolInfo;
44+
txGroup: SignerTransaction[];
45+
signedTxns: Uint8Array[];
46+
initiatorAddr: string;
47+
}): Promise<V1_1AddLiquidityExecution>;

dist/add-liquidity/v1_1/types.d.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/** An object containing information about an add liquidity quote. */
2+
export interface V1_1AddLiquidityQuote {
3+
/** The round that this quote is based on. */
4+
round: number;
5+
/** The ID of the first input asset in this quote. */
6+
asset1ID: number;
7+
/** The quantity of the first input asset in this quote. */
8+
asset1In: bigint;
9+
/** The ID of the second input asset in this quote. */
10+
asset2ID: number;
11+
/** The quantity of the second input asset in this quote. */
12+
asset2In: bigint;
13+
/** The ID of the pool token output in this quote. */
14+
poolTokenID: number;
15+
/** The amount of the pool token output in this quote. */
16+
poolTokenOut: bigint;
17+
/** The share of the total liquidity in this quote. */
18+
share: number;
19+
}
20+
/** An object containing information about a successfully executed add liquidity transaction. */
21+
export interface V1_1AddLiquidityExecution {
22+
/** The round that the add liquidity occurred in. */
23+
round: number;
24+
/**
25+
* The total amount of transaction fees that were spent (in microAlgos) to execute the add liquidity and,
26+
* if applicable, redeem transactions.
27+
*/
28+
fees: number;
29+
/** The ID of the output pool token asset. */
30+
poolTokenID: number;
31+
/** The quantity of the output pool token asset. */
32+
poolTokenOut?: bigint;
33+
excessAmount?: {
34+
/** Excess amount for the current add liquidity */
35+
excessAmountForAddingLiquidity: bigint;
36+
/** Total excess amount accumulated for the pool asset */
37+
totalExcessAmount: bigint;
38+
};
39+
/** The ID of the transaction. */
40+
txnID: string;
41+
/** The group ID for the transaction group. */
42+
groupID: string;
43+
}

dist/add-liquidity/v2/common.d.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import AlgodClient from "algosdk/dist/types/src/client/v2/algod/algod";
2+
import { InitiatorSigner, SignerTransaction } from "../../util/commonTypes";
3+
import { V2PoolInfo } from "../../util/pool/poolTypes";
4+
import { V2AddLiquidityExecution } from "./types";
5+
export declare function signTxns({ txGroup, initiatorSigner }: {
6+
txGroup: SignerTransaction[];
7+
initiatorSigner: InitiatorSigner;
8+
}): Promise<Uint8Array[]>;
9+
/**
10+
* Execute an add liquidity operation with the desired quantities.
11+
*
12+
* @param params.client An Algodv2 client.
13+
* @param params.pool Information for the pool.
14+
* @param params.txGroup The transaction group to execute.
15+
*/
16+
export declare function execute({ client, pool, txGroup, signedTxns }: {
17+
client: AlgodClient;
18+
pool: V2PoolInfo;
19+
txGroup: SignerTransaction[];
20+
signedTxns: Uint8Array[];
21+
}): Promise<V2AddLiquidityExecution>;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
export declare enum V2AddLiquidityType {
2+
SINGLE = "single",
3+
FLEXIBLE = "flexible",
4+
INITIAL = "initial"
5+
}
6+
export declare const V2AddLiquidityTxnIndices: {
7+
flexible: {
8+
ASSET1_IN_TXN: number;
9+
ASSET2_IN_TXN: number;
10+
VALIDATOR_APP_CALL_TXN: number;
11+
};
12+
single: {
13+
ASSET_IN_TXN: number;
14+
VALIDATOR_APP_CALL_TXN: number;
15+
};
16+
initial: {
17+
ASSET1_IN_TXN: number;
18+
ASSET2_IN_TXN: number;
19+
VALIDATOR_APP_CALL_TXN: number;
20+
};
21+
};
22+
export declare const V2_ADD_LIQUIDITY_INNER_TXN_COUNT: Record<V2AddLiquidityType, number>;
23+
/**
24+
* Number of transactions in the add liquidity transaction group (excluding inner transactions)
25+
*/
26+
export declare const V2_ADD_LIQUIDITY_TXN_COUNT: Record<V2AddLiquidityType, number>;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import AlgodClient from "algosdk/dist/types/src/client/v2/algod/algod";
2+
import { SignerTransaction, SupportedNetwork } from "../../util/commonTypes";
3+
import { V2PoolInfo } from "../../util/pool/poolTypes";
4+
import { V2FlexibleAddLiquidityQuote } from "./types";
5+
export * from "./common";
6+
/**
7+
* Get a quote for how many liquidity tokens a deposit of asset1In and asset2In is worth at this
8+
* moment. This does not execute any transactions.
9+
*
10+
* @param params.pool Information for the pool.
11+
* @param params.reserves Pool reserves.
12+
* @param params.asset1In The quantity of the first asset being deposited.
13+
* @param params.asset2In The quantity of the second asset being deposited.
14+
* @param params.slippage The maximum slippage allowed for the swap.
15+
*/
16+
export declare function getQuote({ pool, slippage, asset1, asset2 }: {
17+
pool: V2PoolInfo;
18+
asset1: AssetWithAmountAndDecimals;
19+
asset2: AssetWithAmountAndDecimals;
20+
slippage?: number;
21+
}): V2FlexibleAddLiquidityQuote;
22+
export declare function generateTxns({ client, network, poolAddress, asset1In, asset2In, poolTokenOut, initiatorAddr, minPoolTokenAssetAmount }: {
23+
client: AlgodClient;
24+
network: SupportedNetwork;
25+
poolAddress: string;
26+
asset1In: AssetWithIdAndAmount;
27+
asset2In: AssetWithIdAndAmount;
28+
poolTokenOut: AssetWithIdAndAmount;
29+
initiatorAddr: string;
30+
minPoolTokenAssetAmount: bigint;
31+
}): Promise<SignerTransaction[]>;

0 commit comments

Comments
 (0)