Skip to content

feat(order): Create an ordering class for limit and recurring orders #105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 29 commits into from
May 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ad78924
feat(order): Create an ordering class for limit and recurring orders
gulcinuras May 12, 2025
39e2ce1
fix(client): Remove nullableBaseClient and use generic types instead …
gulcinuras May 12, 2025
2da9982
fix(order): Improve code readability, add descriptions in jsdoc format
gulcinuras May 16, 2025
a0d0198
fix(order): Rename collect method, add convertStandardTransactionsToS…
gulcinuras May 16, 2025
b2ef99a
Add protected tag for convertStandardTransactionsToSignerTransactions…
gulcinuras May 16, 2025
1dcbaba
Improve consistency of function names and descriptions
gulcinuras May 16, 2025
7283496
chore(order): Get a build
gulcinuras May 16, 2025
4b3d3b2
Convert convertStandardTransactionsToSignerTransactions method from p…
gulcinuras May 16, 2025
8ba6cc5
Get a build
gulcinuras May 16, 2025
3c3d24f
fix(order/types): Fix expected asset amount types
gulcinuras May 16, 2025
02a34b4
fix(base-client): Make appId public
gulcinuras May 16, 2025
a35d923
Merge branch 'main' into feat/order-client
gulcinuras May 19, 2025
0aa94aa
fix(order): If the asset is algo, set shouldOptIn to false without ch…
gulcinuras May 19, 2025
78962d7
Merge branch 'main' into feat/order-client
gulcinuras May 20, 2025
b7b1404
fix(order-type): Rename enum
gulcinuras May 21, 2025
a3d8360
fix(order): Update order contract
gulcinuras May 22, 2025
ecd681d
fix(order-app): Improve update method
gulcinuras May 22, 2025
f863f2c
Use the account address directly instead of getting it by variable
gulcinuras May 22, 2025
d101ab2
fix(order): Update create_application app args
gulcinuras May 23, 2025
038bea0
Update ordering client
gulcinuras May 23, 2025
e29771d
fix(order): Update txn fee amount and get order per amount instead of…
gulcinuras May 23, 2025
d0a4fe2
fix(order): Update the contracts and sdk functions
gulcinuras May 26, 2025
622f5a9
fix(order): Unify order structs
gulcinuras May 26, 2025
3cc8ede
Merge branch 'main' into feat/order-client
gulcinuras May 26, 2025
419aa8a
fix(order): Add mainnet app ids
gulcinuras May 27, 2025
f62fe95
remove console log
gulcinuras May 27, 2025
63cc668
fix(order): Use version of type bigint
gulcinuras May 27, 2025
6d43da5
chore(order): Remove unused util functions and bump up the app version
gulcinuras May 28, 2025
a537363
feat(examples): Write examples for order transactions
gulcinuras May 28, 2025
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
1 change: 0 additions & 1 deletion dist/governance/util/utils.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export declare function intToBytes(num: number, length?: number): Uint8Array;
export declare function areBuffersEqual(buf1: Uint8Array, buf2: Uint8Array): boolean;
export declare function bytesToInt(buffer: Uint8Array): number;
export declare function sum(values: number[]): number;
5 changes: 3 additions & 2 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export type { InitiatorSigner, SignerTransaction, SupportedNetwork } from "./uti
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/common/utils";
export { applySlippageToAmount, ASSET_OPT_IN_PROCESS_TXN_COUNT, convertFromBaseUnits, convertToBaseUnits, getTxnGroupID, sendAndWaitRawTransaction, sumUpTxnFees, joinByteArrays } from "./util/util";
export { applySlippageToAmount, ASSET_OPT_IN_PROCESS_TXN_COUNT, convertFromBaseUnits, convertToBaseUnits, getTxnGroupID, sendAndWaitRawTransaction, sumUpTxnFees, joinByteArrays, intToBytes } from "./util/util";
export { generateOptIntoAssetTxns } from "./util/asset/assetUtils";
export type { AssetWithIdAndAmount, TinymanAnalyticsApiAsset } from "./util/asset/assetModels";
export { ALGO_ASSET, ALGO_ASSET_ID, POOL_TOKEN_UNIT_NAME } from "./util/asset/assetConstants";
Expand Down Expand Up @@ -48,7 +48,8 @@ export { TinymanTAlgoClient } from "./liquid-stake/tAlgoClient";
export { ProposalVote } from "./governance/proposal-voting/constants";
export { generateProposalMetadata } from "./governance/proposal-voting/transactions";
export type { GenerateProposalMetadataPayload } from "./governance/proposal-voting/types";
export { intToBytes } from "./governance/util/utils";
export { AccountState } from "./governance/vault/storage";
export { getStartTimestampOfWeek } from "./governance/vault/utils";
export { calculateTinyPower, combineAndRegroupTxns, generateCidFromProposalMetadata } from "./governance/utils";
export { OrderingClient } from "./order/index";
export type { PutTriggerOrderParams, PutRecurringOrderParams, OrderType } from "./order/types";
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/liquid-stake/stAlgoClient.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import algosdk from "algosdk";
import TinymanBaseClient from "../util/client/base/baseClient";
import { SupportedNetwork } from "../util/commonTypes";
declare class TinymanSTAlgoClient extends TinymanBaseClient {
import TinymanBaseClient from "../util/client/base/baseClient";
declare class TinymanSTAlgoClient extends TinymanBaseClient<number, algosdk.Address> {
vaultAppId: number;
constructor(algod: algosdk.Algodv2, network: SupportedNetwork);
increaseStake(amount: bigint, userAddress: string): Promise<algosdk.Transaction[]>;
Expand Down
4 changes: 2 additions & 2 deletions dist/liquid-stake/tAlgoClient.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import algosdk from "algosdk";
import TinymanBaseClient from "../util/client/base/baseClient";
import { SupportedNetwork } from "../util/commonTypes";
declare class TinymanTAlgoClient extends TinymanBaseClient {
import TinymanBaseClient from "../util/client/base/baseClient";
declare class TinymanTAlgoClient extends TinymanBaseClient<number, algosdk.Address> {
constructor(algod: algosdk.Algodv2, network: SupportedNetwork);
sync(userAddress: string): Promise<algosdk.Transaction[]>;
mint(amount: bigint, userAddress: string): Promise<algosdk.Transaction[]>;
Expand Down
27 changes: 27 additions & 0 deletions dist/order/constants.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { StructDefinition } from "../util/client/base/types";
import { SupportedNetwork } from "../util/commonTypes";
import { OrderStruct } from "./types";
declare const TOTAL_ORDER_COUNT_KEY: Uint8Array;
declare const GOVERNOR_ORDER_FEE_RATE_KEY: Uint8Array;
declare const GOVERNOR_FEE_RATE_POWER_THRESHOLD_KEY: Uint8Array;
declare const ORDER_FEE_RATE_KEY: Uint8Array;
declare const APP_LATEST_VERSION_KEY: Uint8Array;
declare const APP_VERSION_KEY: Uint8Array;
declare const ORDER_STRUCTS: Record<OrderStruct, StructDefinition>;
declare const ORDER_APP_GLOBAL_SCHEMA: {
numUint: number;
numByteSlice: number;
};
declare const ORDER_APP_LOCAL_SCHEMA: {
numUint: number;
numByteSlice: number;
};
declare const ORDER_APP_EXTRA_PAGES = 3;
declare const REGISTRY_APP_ID: Record<SupportedNetwork, number>;
declare const VAULT_APP_ID: Record<SupportedNetwork, number>;
declare const ROUTER_APP_ID: Record<SupportedNetwork, number>;
declare const MINIMUM_BALANCE_REQUIREMENT_PER_APP = 100000;
declare const MINIMUM_PUT_ORDER_TRANSACTION_COUNT = 5;
declare const APPROVAL_PROGRAM = "CoASY3JlYXRlX2FwcGxpY2F0aW9ugBJ1cGRhdGVfYXBwbGljYXRpb26AC3Bvc3RfdXBkYXRlgAxhc3NldF9vcHRfaW6AEXB1dF90cmlnZ2VyX29yZGVygBRjYW5jZWxfdHJpZ2dlcl9vcmRlcoAbc3RhcnRfZXhlY3V0ZV90cmlnZ2VyX29yZGVygBllbmRfZXhlY3V0ZV90cmlnZ2VyX29yZGVygBNwdXRfcmVjdXJyaW5nX29yZGVygBZjYW5jZWxfcmVjdXJyaW5nX29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AB6IAI6BBLIQNIGyADSAshQ0grISNIOyEYEAsgGIAIiJNYQ1hTWGiABpgQayEIEAsgGAD3JlZ2lzdHJ5X2FwcF9pZGSyGIAKZW1pdF9ldmVudLIaNIayGjSFsho0hLIaiABFiTWHNYiBADWJNIcUQQAMNIhgNIh4CTWJQgAJNIg0h3AASDWJNImJNIoURIEBNYqJNIqNAwABAAMACQCxibGBAjWKibaJNIpBAAGJs4mzgQA1iok=";
declare const CLEAR_PROGRAM = "CoEBQw==";
export { ORDER_APP_EXTRA_PAGES, ORDER_APP_GLOBAL_SCHEMA, ORDER_APP_LOCAL_SCHEMA, REGISTRY_APP_ID, ORDER_STRUCTS, TOTAL_ORDER_COUNT_KEY, VAULT_APP_ID, MINIMUM_BALANCE_REQUIREMENT_PER_APP, GOVERNOR_ORDER_FEE_RATE_KEY, GOVERNOR_FEE_RATE_POWER_THRESHOLD_KEY, ORDER_FEE_RATE_KEY, MINIMUM_PUT_ORDER_TRANSACTION_COUNT, APPROVAL_PROGRAM, CLEAR_PROGRAM, ROUTER_APP_ID, APP_LATEST_VERSION_KEY, APP_VERSION_KEY };
104 changes: 104 additions & 0 deletions dist/order/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import algosdk, { Algodv2, Transaction } from "algosdk";
import { OrderType, PutTriggerOrderParams, PutRecurringOrderParams } from "./types";
import { SupportedNetwork } from "../util/commonTypes";
import TinymanBaseClient from "../util/client/base/baseClient";
declare class OrderingClient extends TinymanBaseClient<number | null, algosdk.Address | null> {
registryAppId: number;
registryApplicationAddress: string;
vaultAppId: number;
vaultApplicationAddress: string;
routerAppId: number;
routerApplicationAddress: string;
userAddress: string;
private constructor();
private static getRegistryEntryBoxName;
private static getOrderApplicationId;
/**
* Initializes the OrderingClient by fetching the personal app id from global state.
* Until the user creates an application, the app id will be set as null
*/
static initializeOrderingClient(algod: Algodv2, network: SupportedNetwork, userAddress: string): Promise<OrderingClient>;
/**
* Compares the contracts between the user's order app and the latest available contract.
*
* @returns A boolean indicating if the order app needs to be updated.
*/
shouldUpdateOrderingApp(): Promise<boolean>;
/**
* Prepares transactions to update the ordering app using the latest contracts.
* @returns A promise that resolves the transaction array.
*/
prepareUpdateOrderingAppTransactions(): Promise<Transaction[]>;
calculateCreateOrderAppMinBalanceIncreaseAmount(): bigint;
/**
* Prepares transactions to create the order app for a user.
* @param userAddress - The address of the user.
* @returns A promise that resolves the transaction array.
*/
prepareCreateOrderAppTransactions(userAddress: string): Promise<algosdk.Transaction[]>;
checkOrderAppAvailability(orderAppId?: number): Promise<void>;
getPutTriggerOrderTransactionFee({ assetInId, assetOutId, type }: {
assetInId: number;
assetOutId: number;
type: OrderType;
}): Promise<bigint>;
/**
* Prepares an array of transactions to place a limit order.
*
* @param {PutTriggerOrderParams} params - The parameters for the put order operation.
* @param params.assetInId - The ID of the input asset.
* @param params.assetOutId - The ID of the output asset.
* @param params.assetInAmount - The amount of the input asset in base units.
* @param params.assetOutAmount - The amount of the output asset in base units.
* @param params.isPartialAllowed - Whether partial fills are allowed.
* @param params.duration - The duration of the order in seconds.
* @param [params.orderAppId] - (Optional) The application ID for the order.
* @returns A promise that resolves the transaction array.
*/
preparePutTriggerOrderTransactions({ assetInId, assetOutId, assetInAmount, assetOutAmount, isPartialAllowed, duration }: PutTriggerOrderParams): Promise<algosdk.Transaction[]>;
/**
* Prepares an array of transactions to place a recurring order.
*
* @param {PutRecurringOrderParams} params - The parameters for the recurring order.
* @param params.amount - The amount per order to be used for the recurring order.
* @param params.assetId - The ID of the asset being used for the order.
* @param params.targetAssetId - The ID of the target asset for the order.
* @param params.targetRecurrence - The number of times the order should recur.
* @param params.interval - The interval between each recurrence in seconds.
* @param params.maxTargetPrice - (Optional) The maximum price per unit of the target asset to be accepted.
* @param params.minTargetPrice - (Optional) The minimum price per unit of the target asset to be accepted.
* @returns A promise that resolves the transaction array.
*/
preparePutRecurringOrderTransactions({ amount, assetId, targetAssetId, targetRecurrence, interval, maxTargetPrice, minTargetPrice }: PutRecurringOrderParams): Promise<algosdk.Transaction[]>;
/**
* Prepares an array of transactions to cancel an order.
*
* @param orderId - The ID of the order to cancel.
* @param type - The type of the order to cancel.
* @returns A promise that resolves the transaction array.
*/
prepareCancelOrderTransactions(orderId: number, type: OrderType): Promise<algosdk.Transaction[]>;
/**
* Prepares an array of transactions to claim the collected target amount for an order.
* @param orderId - The ID of the order for which to claim the collected target amount.
* @param type - The type of the order (OrderType.Trigger or OrderType.Recurring).
* @returns A promise that resolves the transaction array.
*/
prepareClaimCollectedTargetAmount(orderId: number, type: OrderType): Promise<algosdk.Transaction[]>;
/**
* Gets the platform fee rate based on the provided tiny power from the global state.
*
* @param tinyPower - The tiny power to check against the threshold.
* @returns The platform fee rate.
*/
getPlatformFeeRate(tinyPower: number | null): Promise<bigint>;
private getOrderCount;
private getOrderBoxName;
private getRegistryEntryBoxName;
private prepareOrderAppAssetOptInTransaction;
private prepareOrderAppAssetOptinTransactionsIfNeeded;
private getAssetsToOptInToOrderingClient;
private getLatestOrderAppVersion;
private getAppVersionBoxName;
}
export { OrderingClient };
27 changes: 27 additions & 0 deletions dist/order/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
export interface PutTriggerOrderParams {
assetInId: number;
assetOutId: number;
assetInAmount: bigint;
assetOutAmount: bigint;
isPartialAllowed: boolean;
duration: number;
orderAppId?: number;
}
export interface PutRecurringOrderParams {
assetId: number;
amount: bigint;
targetAssetId: number;
targetRecurrence: number;
interval: number;
minTargetPrice: number;
maxTargetPrice: number;
}
export declare enum OrderType {
Trigger = "trigger_order",
Recurring = "recurring_order"
}
export declare enum OrderStruct {
Trigger = "TriggerOrder",
Recurring = "RecurringOrder",
Entry = "Entry"
}
4 changes: 4 additions & 0 deletions dist/order/utils.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { joinByteArrays } from "../util/util";
declare function createPaddedByteArray(elements: number[], length?: number, paddingValue?: number, byteSize?: number): Uint8Array;
declare function computeSHA512(fileArrayBuffer: Uint8Array): Promise<string>;
export { computeSHA512, createPaddedByteArray, joinByteArrays };
32 changes: 32 additions & 0 deletions dist/util/client/base/appClient.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Algodv2 } from "algosdk";
import { StructDefinition } from "./types";
import TinymanBaseClient from "./baseClient";
import { SupportedNetwork } from "../../commonTypes";
/**
* Abstract client for Tinyman applications that may not have an app ID initially
* This class overrides the base non-nullable properties to allow null values
*/
declare abstract class TinymanNullableAppClient extends TinymanBaseClient {
constructor(algod: Algodv2, appId: number | null, network: SupportedNetwork, structs?: Record<string, StructDefinition>);
/**
* Helper method to check if the app ID is available
*/
protected isAppIdAvailable(): boolean;
/**
* Helper method that throws an error if the app ID is not available
*/
protected requireAppId(): void;
/**
* Override getGlobal to add null check
*/
protected getGlobal(key: Uint8Array, defaultValue?: any, appId?: number): Promise<any>;
/**
* Override boxExists to add null check
*/
protected boxExists(boxName: Uint8Array, appId?: number): Promise<boolean>;
/**
* Override getBox to add null check
*/
protected getBox(boxName: Uint8Array, structName: string, appId?: number): Promise<import("./utils").Struct | null>;
}
export default TinymanNullableAppClient;
Loading