@loyal-labs/private-transactions 0.2.8 → 0.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -35
- package/dist/index.d.ts +66 -2
- package/dist/index.js +2349 -350
- package/dist/src/LoyalPrivateTransactionsClient.d.ts +15 -3
- package/dist/src/actions/shieldTokens.d.ts +69 -0
- package/dist/src/actions/undelegateDeposit.d.ts +25 -0
- package/dist/src/actions/unshieldTokens.d.ts +62 -0
- package/dist/src/checks/enshureChecks.d.ts +5 -0
- package/dist/src/constants.d.ts +1 -1
- package/dist/src/enumerate-deposits.d.ts +23 -0
- package/dist/src/fee-estimate.d.ts +25 -0
- package/dist/src/idl/telegram_private_transfer.d.ts +119 -3
- package/dist/src/instructions/closeDeposit.d.ts +4 -0
- package/dist/src/instructions/closePermission.d.ts +2 -0
- package/dist/src/instructions/closeUsernameDeposit.d.ts +4 -0
- package/dist/src/instructions/createPermission.d.ts +4 -0
- package/dist/src/instructions/delegateDeposit.d.ts +4 -0
- package/dist/src/instructions/initializeDeposit.d.ts +4 -0
- package/dist/src/instructions/initializeUsernameDeposit.d.ts +4 -0
- package/dist/src/instructions/modifyBalance.d.ts +4 -0
- package/dist/src/instructions/undelegateDeposit.d.ts +4 -0
- package/dist/src/instructions/undelegatePermission.d.ts +2 -0
- package/dist/src/kamino.d.ts +1 -1
- package/dist/src/rent-estimate.d.ts +46 -0
- package/dist/src/transaction-debug.d.ts +40 -0
- package/dist/src/types.d.ts +182 -2
- package/dist/src/utils.d.ts +7 -0
- package/dist/src/wsol.d.ts +14 -0
- package/package.json +6 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Connection, PublicKey } from "@solana/web3.js";
|
|
2
2
|
import { Program } from "@coral-xyz/anchor";
|
|
3
3
|
import type { TelegramPrivateTransfer } from "./idl/telegram_private_transfer.ts";
|
|
4
|
-
import type { WalletLike, ClientConfig, DepositData, UsernameDepositData, InitializeDepositParams, ModifyBalanceParams, ModifyBalanceResult, GetKaminoShieldedBalanceQuoteParams, GetKaminoCollateralSharesForLiquidityAmountParams, KaminoReserveSnapshot, KaminoShieldedBalanceQuote, CreatePermissionParams, CreateUsernamePermissionParams, DelegateDepositParams, DelegateUsernameDepositParams, UndelegateDepositParams, UndelegateUsernameDepositParams, TransferDepositParams, TransferToUsernameDepositParams, InitializeUsernameDepositParams, ClaimUsernameDepositToDepositParams, DelegationStatusResponse } from "./types";
|
|
4
|
+
import type { WalletLike, ClientConfig, DepositData, UsernameDepositData, InitializeDepositParams, CloseDepositParams, CloseUsernameDepositParams, ModifyBalanceParams, ModifyBalanceResult, GetKaminoShieldedBalanceQuoteParams, GetKaminoCollateralSharesForLiquidityAmountParams, KaminoReserveSnapshot, KaminoShieldedBalanceQuote, BuildShieldFlowTransactionPlanParams, BuildShieldTokensTransactionPlanParams, BuildUnshieldTokensTransactionPlanParams, ExecuteShieldFlowTransactionPlanParams, ExecuteShieldTokensTransactionPlanParams, ExecuteUnshieldTokensTransactionPlanParams, EstimateShieldFlowFeeParams, EstimateShieldTokensFeeParams, EstimateUnshieldTokensFeeParams, ShieldFlowExecutionResult, ShieldFlowFeeEstimate, ShieldFlowPlan, ShieldTokensClientParams, UnshieldTokensClientParams, CreatePermissionParams, CreateUsernamePermissionParams, DelegateDepositParams, DelegateUsernameDepositParams, UndelegateDepositParams, UndelegateUsernameDepositParams, TransferDepositParams, TransferToUsernameDepositParams, InitializeUsernameDepositParams, ClaimUsernameDepositToDepositParams, DelegationStatusResponse } from "./types";
|
|
5
5
|
export declare function waitForAccountOwnerChange(connection: Connection, account: PublicKey, expectedOwner: PublicKey, timeoutMs?: number, intervalMs?: number): {
|
|
6
6
|
wait: () => Promise<void>;
|
|
7
7
|
cancel: () => Promise<void>;
|
|
@@ -44,11 +44,24 @@ export declare class LoyalPrivateTransactionsClient {
|
|
|
44
44
|
* Verifies TEE RPC integrity and obtains an auth token automatically.
|
|
45
45
|
*/
|
|
46
46
|
static fromConfig(config: ClientConfig): Promise<LoyalPrivateTransactionsClient>;
|
|
47
|
+
shieldTokens(params: ShieldTokensClientParams): Promise<string>;
|
|
48
|
+
unshieldTokens(params: UnshieldTokensClientParams): Promise<string>;
|
|
49
|
+
buildShieldFlowTransactionPlan(params: BuildShieldFlowTransactionPlanParams): Promise<ShieldFlowPlan>;
|
|
50
|
+
buildShieldTokensTransactionPlan(params: BuildShieldTokensTransactionPlanParams): Promise<ShieldFlowPlan>;
|
|
51
|
+
buildUnshieldTokensTransactionPlan(params: BuildUnshieldTokensTransactionPlanParams): Promise<ShieldFlowPlan>;
|
|
52
|
+
estimateShieldFlowFee(params: EstimateShieldFlowFeeParams): Promise<ShieldFlowFeeEstimate>;
|
|
53
|
+
estimateShieldTokensFee(params: EstimateShieldTokensFeeParams): Promise<ShieldFlowFeeEstimate>;
|
|
54
|
+
estimateUnshieldTokensFee(params: EstimateUnshieldTokensFeeParams): Promise<ShieldFlowFeeEstimate>;
|
|
55
|
+
executeShieldFlowTransactionPlan(params: ExecuteShieldFlowTransactionPlanParams): Promise<ShieldFlowExecutionResult>;
|
|
56
|
+
executeShieldTokensTransactionPlan(params: ExecuteShieldTokensTransactionPlanParams): Promise<ShieldFlowExecutionResult>;
|
|
57
|
+
executeUnshieldTokensTransactionPlan(params: ExecuteUnshieldTokensTransactionPlanParams): Promise<ShieldFlowExecutionResult>;
|
|
47
58
|
/**
|
|
48
59
|
* Initialize a deposit account for a user and token mint
|
|
49
60
|
*/
|
|
50
61
|
initializeDeposit(params: InitializeDepositParams): Promise<string>;
|
|
51
62
|
initializeUsernameDeposit(params: InitializeUsernameDepositParams): Promise<string>;
|
|
63
|
+
closeDeposit(params: CloseDepositParams): Promise<string>;
|
|
64
|
+
closeUsernameDeposit(params: CloseUsernameDepositParams): Promise<string>;
|
|
52
65
|
/**
|
|
53
66
|
* Modify the balance of a user's deposit account
|
|
54
67
|
*/
|
|
@@ -57,7 +70,7 @@ export declare class LoyalPrivateTransactionsClient {
|
|
|
57
70
|
/**
|
|
58
71
|
* Create a permission for a deposit account (required for PER)
|
|
59
72
|
*/
|
|
60
|
-
createPermission(params: CreatePermissionParams): Promise<string
|
|
73
|
+
createPermission(params: CreatePermissionParams): Promise<string>;
|
|
61
74
|
/**
|
|
62
75
|
* Create a permission for a username-based deposit account
|
|
63
76
|
*/
|
|
@@ -138,7 +151,6 @@ export declare class LoyalPrivateTransactionsClient {
|
|
|
138
151
|
* Get the program ID
|
|
139
152
|
*/
|
|
140
153
|
getProgramId(): PublicKey;
|
|
141
|
-
private validateUsername;
|
|
142
154
|
private permissionAccountExists;
|
|
143
155
|
private isAccountAlreadyInUse;
|
|
144
156
|
private ensureNotDelegated;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { type AccountInfo, type PublicKey, type TransactionInstruction } from "@solana/web3.js";
|
|
2
|
+
import type { FeeEstimateCluster, InstructionCheck, RpcOptions } from "../types";
|
|
3
|
+
import type { TelegramPrivateTransfer } from "../idl/telegram_private_transfer";
|
|
4
|
+
import type { Program } from "@coral-xyz/anchor";
|
|
5
|
+
export type LabeledTransactionInstruction = {
|
|
6
|
+
label: string;
|
|
7
|
+
ix: TransactionInstruction;
|
|
8
|
+
rentLamports?: number;
|
|
9
|
+
nativeLamports?: number;
|
|
10
|
+
};
|
|
11
|
+
export type LabeledTransactionPlan = {
|
|
12
|
+
label: string;
|
|
13
|
+
cluster: FeeEstimateCluster;
|
|
14
|
+
instructions: LabeledTransactionInstruction[];
|
|
15
|
+
checks: InstructionCheck[];
|
|
16
|
+
};
|
|
17
|
+
export type ShieldTokensInstructionPlan = {
|
|
18
|
+
instructions: LabeledTransactionInstruction[];
|
|
19
|
+
checks: InstructionCheck[];
|
|
20
|
+
needsUndelegate: boolean;
|
|
21
|
+
context: {
|
|
22
|
+
isNativeSol: boolean;
|
|
23
|
+
validator: PublicKey;
|
|
24
|
+
depositPda: PublicKey;
|
|
25
|
+
permissionPda: PublicKey;
|
|
26
|
+
depositAccountInfo: AccountInfo<Buffer> | null;
|
|
27
|
+
permissionAccountInfo: AccountInfo<Buffer> | null;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export type ShieldTokensTransactionPlan = {
|
|
31
|
+
preUndelegateTransaction: LabeledTransactionPlan | null;
|
|
32
|
+
baseTransaction: LabeledTransactionPlan;
|
|
33
|
+
context: ShieldTokensInstructionPlan["context"];
|
|
34
|
+
};
|
|
35
|
+
export declare function labelTransactionInstructions(prefix: string, instructions: TransactionInstruction[]): LabeledTransactionInstruction[];
|
|
36
|
+
export declare function buildShieldTokensInstructionPlan(params: {
|
|
37
|
+
user: PublicKey;
|
|
38
|
+
payer: PublicKey;
|
|
39
|
+
tokenMint: PublicKey;
|
|
40
|
+
amount: bigint;
|
|
41
|
+
baseProgram: Program<TelegramPrivateTransfer>;
|
|
42
|
+
perProgram: Program<TelegramPrivateTransfer>;
|
|
43
|
+
validator?: PublicKey;
|
|
44
|
+
}): Promise<ShieldTokensInstructionPlan>;
|
|
45
|
+
export declare function buildShieldTokensTransactionPlan(params: {
|
|
46
|
+
user: PublicKey;
|
|
47
|
+
payer: PublicKey;
|
|
48
|
+
tokenMint: PublicKey;
|
|
49
|
+
amount: bigint;
|
|
50
|
+
baseProgram: Program<TelegramPrivateTransfer>;
|
|
51
|
+
perProgram: Program<TelegramPrivateTransfer>;
|
|
52
|
+
validator?: PublicKey;
|
|
53
|
+
sessionToken?: PublicKey | null;
|
|
54
|
+
magicProgram?: PublicKey;
|
|
55
|
+
magicContext?: PublicKey;
|
|
56
|
+
}): Promise<ShieldTokensTransactionPlan>;
|
|
57
|
+
export declare function shieldTokens(params: {
|
|
58
|
+
user: PublicKey;
|
|
59
|
+
payer: PublicKey;
|
|
60
|
+
tokenMint: PublicKey;
|
|
61
|
+
amount: bigint;
|
|
62
|
+
baseProgram: Program<TelegramPrivateTransfer>;
|
|
63
|
+
perProgram: Program<TelegramPrivateTransfer>;
|
|
64
|
+
validator?: PublicKey;
|
|
65
|
+
sessionToken?: PublicKey | null;
|
|
66
|
+
magicProgram?: PublicKey;
|
|
67
|
+
magicContext?: PublicKey;
|
|
68
|
+
rpcOptions?: RpcOptions;
|
|
69
|
+
}): Promise<string>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Program } from "@coral-xyz/anchor";
|
|
2
|
+
import { type PublicKey, type TransactionInstruction } from "@solana/web3.js";
|
|
3
|
+
import type { InstructionCheck, RpcOptions, UndelegateDepositParams } from "../types";
|
|
4
|
+
import type { TelegramPrivateTransfer } from "../idl/telegram_private_transfer";
|
|
5
|
+
export type PlannedUndelegateDepositTransaction = {
|
|
6
|
+
label: string;
|
|
7
|
+
instructions: {
|
|
8
|
+
ix: TransactionInstruction;
|
|
9
|
+
}[];
|
|
10
|
+
checks: InstructionCheck[];
|
|
11
|
+
};
|
|
12
|
+
export declare function sendPlannedUndelegateDepositTransaction(params: {
|
|
13
|
+
baseProgram: Program<TelegramPrivateTransfer>;
|
|
14
|
+
perProgram: Program<TelegramPrivateTransfer>;
|
|
15
|
+
transaction: PlannedUndelegateDepositTransaction;
|
|
16
|
+
user: PublicKey;
|
|
17
|
+
tokenMint: PublicKey;
|
|
18
|
+
rpcOptions?: RpcOptions;
|
|
19
|
+
}): Promise<string>;
|
|
20
|
+
/**
|
|
21
|
+
* Undelegate a deposit account from the ephemeral rollup.
|
|
22
|
+
* Waits for both base and ephemeral connections to confirm the deposit
|
|
23
|
+
* is owned by PROGRAM_ID before returning.
|
|
24
|
+
*/
|
|
25
|
+
export declare function undelegateDeposit(baseProgram: Program<TelegramPrivateTransfer>, perProgram: Program<TelegramPrivateTransfer>, params: UndelegateDepositParams): Promise<string>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { type PublicKey } from "@solana/web3.js";
|
|
2
|
+
import type { Program } from "@coral-xyz/anchor";
|
|
3
|
+
import type { TelegramPrivateTransfer } from "../idl/telegram_private_transfer";
|
|
4
|
+
import type { InstructionCheck, RpcOptions } from "../types";
|
|
5
|
+
import { type LabeledTransactionInstruction, type LabeledTransactionPlan } from "./shieldTokens";
|
|
6
|
+
export type UnshieldTokensInstructionPlan = {
|
|
7
|
+
instructions: LabeledTransactionInstruction[];
|
|
8
|
+
checks: InstructionCheck[];
|
|
9
|
+
needsUndelegate: boolean;
|
|
10
|
+
shouldRedelegate: boolean;
|
|
11
|
+
context: {
|
|
12
|
+
isNativeSol: boolean;
|
|
13
|
+
validator: PublicKey;
|
|
14
|
+
depositPda: PublicKey;
|
|
15
|
+
currentDepositAmount: bigint | null;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export type UnshieldTokensTransactionPlan = {
|
|
19
|
+
preUndelegateTransaction: LabeledTransactionPlan | null;
|
|
20
|
+
baseTransaction: LabeledTransactionPlan;
|
|
21
|
+
shouldRedelegate: boolean;
|
|
22
|
+
context: UnshieldTokensInstructionPlan["context"];
|
|
23
|
+
};
|
|
24
|
+
export declare function buildUnshieldTokensInstructionPlan(params: {
|
|
25
|
+
user: PublicKey;
|
|
26
|
+
payer: PublicKey;
|
|
27
|
+
tokenMint: PublicKey;
|
|
28
|
+
amount: bigint;
|
|
29
|
+
baseProgram: Program<TelegramPrivateTransfer>;
|
|
30
|
+
perProgram: Program<TelegramPrivateTransfer>;
|
|
31
|
+
validator?: PublicKey;
|
|
32
|
+
}): Promise<UnshieldTokensInstructionPlan>;
|
|
33
|
+
export declare function buildUnshieldTokensTransactionPlan(params: {
|
|
34
|
+
user: PublicKey;
|
|
35
|
+
payer: PublicKey;
|
|
36
|
+
tokenMint: PublicKey;
|
|
37
|
+
amount: bigint;
|
|
38
|
+
baseProgram: Program<TelegramPrivateTransfer>;
|
|
39
|
+
perProgram: Program<TelegramPrivateTransfer>;
|
|
40
|
+
validator?: PublicKey;
|
|
41
|
+
sessionToken?: PublicKey | null;
|
|
42
|
+
magicProgram?: PublicKey;
|
|
43
|
+
magicContext?: PublicKey;
|
|
44
|
+
}): Promise<UnshieldTokensTransactionPlan>;
|
|
45
|
+
/**
|
|
46
|
+
* Unshield tokens: move from a Loyal private deposit back to a regular wallet.
|
|
47
|
+
* If the deposit is delegated, this first commits it back to base, then sends
|
|
48
|
+
* one base transaction for withdraw/native-SOL close/redelegate.
|
|
49
|
+
*/
|
|
50
|
+
export declare function unshieldTokens(params: {
|
|
51
|
+
user: PublicKey;
|
|
52
|
+
payer: PublicKey;
|
|
53
|
+
tokenMint: PublicKey;
|
|
54
|
+
amount: bigint;
|
|
55
|
+
baseProgram: Program<TelegramPrivateTransfer>;
|
|
56
|
+
perProgram: Program<TelegramPrivateTransfer>;
|
|
57
|
+
validator?: PublicKey;
|
|
58
|
+
sessionToken?: PublicKey | null;
|
|
59
|
+
magicProgram?: PublicKey;
|
|
60
|
+
magicContext?: PublicKey;
|
|
61
|
+
rpcOptions?: RpcOptions;
|
|
62
|
+
}): Promise<string>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AccountInfo, Connection, PublicKey } from "@solana/web3.js";
|
|
2
|
+
import type { InstructionCheck } from "../types";
|
|
3
|
+
export declare function processEnsureChecks(baseConnection: Connection, perConnection: Connection, ensure: InstructionCheck[]): Promise<void>;
|
|
4
|
+
export declare function getMultipleAccountsInfoWithRetry(connection: Connection, accounts: PublicKey[], label: string): Promise<(AccountInfo<Buffer> | null)[]>;
|
|
5
|
+
export declare function runEnsureFetchWithRetry<T>(label: string, task: () => Promise<T>): Promise<T>;
|
package/dist/src/constants.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare const ER_VALIDATOR_MAINNET: PublicKey;
|
|
|
9
9
|
*/
|
|
10
10
|
export declare const ER_VALIDATOR: PublicKey;
|
|
11
11
|
export declare function getErValidatorForSolanaEnv(env: string): PublicKey;
|
|
12
|
-
export declare function getErValidatorForRpcEndpoint(
|
|
12
|
+
export declare function getErValidatorForRpcEndpoint(perRpcEndpoint: string): PublicKey;
|
|
13
13
|
export declare function getKaminoModifyBalanceAccountsForTokenMint(tokenMint: PublicKey): KaminoModifyBalanceAccounts | null;
|
|
14
14
|
/**
|
|
15
15
|
* Telegram Private Transfer program ID
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type Connection, PublicKey } from "@solana/web3.js";
|
|
2
|
+
import type { DepositData } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Enumerate every Deposit account belonging to `user` across the base program
|
|
5
|
+
* and (optionally) the ephemeral program. Read-only — no signer required.
|
|
6
|
+
*
|
|
7
|
+
* Three sources are merged:
|
|
8
|
+
* 1. Base, owned by the deposit program — undelegated deposits (Anchor).
|
|
9
|
+
* 2. Base, owned by the delegation program — delegated deposits whose data
|
|
10
|
+
* bytes are still readable on base. Required when no authenticated
|
|
11
|
+
* ephemeral connection is available (e.g. browser wallet UI).
|
|
12
|
+
* 3. Ephemeral, owned by the deposit program — delegated deposits with the
|
|
13
|
+
* live balance (Anchor). Wins over (2) for the same PDA when present.
|
|
14
|
+
*
|
|
15
|
+
* Used by wallet UIs to discover shielded holdings even when the user has no
|
|
16
|
+
* matching base-chain token balance — e.g. after fully shielding an SPL mint,
|
|
17
|
+
* where Helius `getAssetsByOwner` no longer surfaces it.
|
|
18
|
+
*/
|
|
19
|
+
export declare function enumerateDepositsByUser(args: {
|
|
20
|
+
user: PublicKey;
|
|
21
|
+
baseConnection: Connection;
|
|
22
|
+
ephemeralConnection?: Connection;
|
|
23
|
+
}): Promise<DepositData[]>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type Commitment, type Connection, type PublicKey, type TransactionInstruction } from "@solana/web3.js";
|
|
2
|
+
import type { FeeEstimateCluster, InstructionCostEstimate, ShieldFlowTransactionFeeEstimate } from "./types";
|
|
3
|
+
export type FeeEstimateInstructionPlan = {
|
|
4
|
+
label: string;
|
|
5
|
+
ix: TransactionInstruction;
|
|
6
|
+
rentLamports?: number;
|
|
7
|
+
nativeLamports?: number;
|
|
8
|
+
};
|
|
9
|
+
export type FeeEstimateTransactionPlan = {
|
|
10
|
+
label: string;
|
|
11
|
+
cluster: FeeEstimateCluster;
|
|
12
|
+
connection: Connection;
|
|
13
|
+
feePayer: PublicKey;
|
|
14
|
+
instructions: FeeEstimateInstructionPlan[];
|
|
15
|
+
};
|
|
16
|
+
export declare function estimatePlannedTransactionFees(params: {
|
|
17
|
+
transactions: FeeEstimateTransactionPlan[];
|
|
18
|
+
commitment?: Commitment;
|
|
19
|
+
}): Promise<{
|
|
20
|
+
transactions: ShieldFlowTransactionFeeEstimate[];
|
|
21
|
+
instructions: InstructionCostEstimate[];
|
|
22
|
+
totalFeeLamports: number;
|
|
23
|
+
totalRentLamports: number;
|
|
24
|
+
totalNativeLamports: number;
|
|
25
|
+
}>;
|
|
@@ -94,6 +94,107 @@ export type TelegramPrivateTransfer = {
|
|
|
94
94
|
}
|
|
95
95
|
];
|
|
96
96
|
},
|
|
97
|
+
{
|
|
98
|
+
"name": "closeDeposit";
|
|
99
|
+
"docs": [
|
|
100
|
+
"Closes an empty user deposit account and returns its rent to the deposit owner."
|
|
101
|
+
];
|
|
102
|
+
"discriminator": [
|
|
103
|
+
200,
|
|
104
|
+
19,
|
|
105
|
+
254,
|
|
106
|
+
192,
|
|
107
|
+
15,
|
|
108
|
+
110,
|
|
109
|
+
209,
|
|
110
|
+
179
|
|
111
|
+
];
|
|
112
|
+
"accounts": [
|
|
113
|
+
{
|
|
114
|
+
"name": "user";
|
|
115
|
+
"writable": true;
|
|
116
|
+
"signer": true;
|
|
117
|
+
"relations": [
|
|
118
|
+
"deposit"
|
|
119
|
+
];
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"name": "deposit";
|
|
123
|
+
"writable": true;
|
|
124
|
+
"pda": {
|
|
125
|
+
"seeds": [
|
|
126
|
+
{
|
|
127
|
+
"kind": "const";
|
|
128
|
+
"value": [
|
|
129
|
+
100,
|
|
130
|
+
101,
|
|
131
|
+
112,
|
|
132
|
+
111,
|
|
133
|
+
115,
|
|
134
|
+
105,
|
|
135
|
+
116,
|
|
136
|
+
95,
|
|
137
|
+
118,
|
|
138
|
+
50
|
|
139
|
+
];
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"kind": "account";
|
|
143
|
+
"path": "user";
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"kind": "account";
|
|
147
|
+
"path": "tokenMint";
|
|
148
|
+
}
|
|
149
|
+
];
|
|
150
|
+
};
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"name": "tokenMint";
|
|
154
|
+
"relations": [
|
|
155
|
+
"deposit"
|
|
156
|
+
];
|
|
157
|
+
}
|
|
158
|
+
];
|
|
159
|
+
"args": [];
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"name": "closeUsernameDeposit";
|
|
163
|
+
"docs": [
|
|
164
|
+
"Closes an empty username deposit account after verified username ownership."
|
|
165
|
+
];
|
|
166
|
+
"discriminator": [
|
|
167
|
+
238,
|
|
168
|
+
181,
|
|
169
|
+
185,
|
|
170
|
+
209,
|
|
171
|
+
149,
|
|
172
|
+
161,
|
|
173
|
+
124,
|
|
174
|
+
79
|
|
175
|
+
];
|
|
176
|
+
"accounts": [
|
|
177
|
+
{
|
|
178
|
+
"name": "authority";
|
|
179
|
+
"writable": true;
|
|
180
|
+
"signer": true;
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
"name": "deposit";
|
|
184
|
+
"writable": true;
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
"name": "tokenMint";
|
|
188
|
+
"relations": [
|
|
189
|
+
"deposit"
|
|
190
|
+
];
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
"name": "session";
|
|
194
|
+
}
|
|
195
|
+
];
|
|
196
|
+
"args": [];
|
|
197
|
+
},
|
|
97
198
|
{
|
|
98
199
|
"name": "createPermission";
|
|
99
200
|
"docs": [
|
|
@@ -806,10 +907,20 @@ export type TelegramPrivateTransfer = {
|
|
|
806
907
|
{
|
|
807
908
|
"name": "modifyBalance";
|
|
808
909
|
"docs": [
|
|
809
|
-
"Modifies
|
|
910
|
+
"Modifies a user's deposit balance and the backing vault position for the given mint.",
|
|
911
|
+
"",
|
|
912
|
+
"For non-USDC mints, this is a direct vault transfer: if `args.increase` is true, `args.amount`",
|
|
913
|
+
"is transferred from the user's token account to the vault token account and added to",
|
|
914
|
+
"`deposit.amount`. If false, `args.amount` is transferred from the vault token account back to",
|
|
915
|
+
"the user's token account and subtracted from `deposit.amount`.",
|
|
810
916
|
"",
|
|
811
|
-
"
|
|
812
|
-
"If
|
|
917
|
+
"For USDC, liquidity is routed through Kamino Lending instead of being left idle in the vault.",
|
|
918
|
+
"If `args.increase` is true, `args.amount` USDC is transferred into the vault token account,",
|
|
919
|
+
"supplied to the configured Kamino reserve, and `deposit.amount` is increased by the Kamino",
|
|
920
|
+
"reserve collateral shares (kTokens) minted to the vault. If false, `args.amount` is",
|
|
921
|
+
"interpreted as the Kamino share amount to redeem; the reserve returns the corresponding USDC",
|
|
922
|
+
"at the current exchange rate, that USDC is transferred from the vault token account to the",
|
|
923
|
+
"user's token account, and `deposit.amount` is decreased by the burned share amount."
|
|
813
924
|
];
|
|
814
925
|
"discriminator": [
|
|
815
926
|
148,
|
|
@@ -1646,6 +1757,11 @@ export type TelegramPrivateTransfer = {
|
|
|
1646
1757
|
"code": 6013;
|
|
1647
1758
|
"name": "invalidAmount";
|
|
1648
1759
|
"msg": "Invalid amount";
|
|
1760
|
+
},
|
|
1761
|
+
{
|
|
1762
|
+
"code": 6014;
|
|
1763
|
+
"name": "nonZeroDeposit";
|
|
1764
|
+
"msg": "Deposit account must have zero amount before it can be closed";
|
|
1649
1765
|
}
|
|
1650
1766
|
];
|
|
1651
1767
|
"types": [
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Program } from "@coral-xyz/anchor";
|
|
2
|
+
import type { CheckedTransactionInstruction, CloseDepositParams } from "../types";
|
|
3
|
+
import type { TelegramPrivateTransfer } from "../idl/telegram_private_transfer";
|
|
4
|
+
export declare function closeDepositIx(program: Program<TelegramPrivateTransfer>, params: CloseDepositParams): Promise<CheckedTransactionInstruction>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Program } from "@coral-xyz/anchor";
|
|
2
|
+
import type { CheckedTransactionInstruction, CloseUsernameDepositParams } from "../types";
|
|
3
|
+
import type { TelegramPrivateTransfer } from "../idl/telegram_private_transfer";
|
|
4
|
+
export declare function closeUsernameDepositIx(program: Program<TelegramPrivateTransfer>, params: CloseUsernameDepositParams): Promise<CheckedTransactionInstruction>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Program } from "@coral-xyz/anchor";
|
|
2
|
+
import type { TelegramPrivateTransfer } from "../idl/telegram_private_transfer";
|
|
3
|
+
import type { CheckedTransactionInstruction, CreatePermissionParams } from "../types";
|
|
4
|
+
export declare function createPermissionIx(program: Program<TelegramPrivateTransfer>, params: CreatePermissionParams): Promise<CheckedTransactionInstruction>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Program } from "@coral-xyz/anchor";
|
|
2
|
+
import type { CheckedTransactionInstruction, DelegateDepositParams } from "../types";
|
|
3
|
+
import type { TelegramPrivateTransfer } from "../idl/telegram_private_transfer";
|
|
4
|
+
export declare function delegateDepositIx(program: Program<TelegramPrivateTransfer>, params: DelegateDepositParams): Promise<CheckedTransactionInstruction>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Program } from "@coral-xyz/anchor";
|
|
2
|
+
import type { TelegramPrivateTransfer } from "../idl/telegram_private_transfer";
|
|
3
|
+
import type { CheckedTransactionInstruction, InitializeDepositParams } from "../types";
|
|
4
|
+
export declare function initializeDepositIx(program: Program<TelegramPrivateTransfer>, params: InitializeDepositParams): Promise<CheckedTransactionInstruction>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Program } from "@coral-xyz/anchor";
|
|
2
|
+
import type { CheckedTransactionInstruction, InitializeUsernameDepositParams } from "../types";
|
|
3
|
+
import type { TelegramPrivateTransfer } from "../idl/telegram_private_transfer";
|
|
4
|
+
export declare function initializeUsernameDepositIx(program: Program<TelegramPrivateTransfer>, params: InitializeUsernameDepositParams): Promise<CheckedTransactionInstruction>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type Program } from "@coral-xyz/anchor";
|
|
2
|
+
import type { CheckedTransactionInstruction, ModifyBalanceParams } from "../types";
|
|
3
|
+
import type { TelegramPrivateTransfer } from "../idl/telegram_private_transfer";
|
|
4
|
+
export declare function modifyBalanceIx(program: Program<TelegramPrivateTransfer>, params: ModifyBalanceParams): Promise<CheckedTransactionInstruction>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Program } from "@coral-xyz/anchor";
|
|
2
|
+
import type { TelegramPrivateTransfer } from "../idl/telegram_private_transfer";
|
|
3
|
+
import type { CheckedTransactionInstruction, UndelegateDepositParams } from "../types";
|
|
4
|
+
export declare function undelegateDepositIx(perProgram: Program<TelegramPrivateTransfer>, params: UndelegateDepositParams): Promise<CheckedTransactionInstruction>;
|
package/dist/src/kamino.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Connection, PublicKey } from "@solana/web3.js";
|
|
|
2
2
|
import { type KaminoModifyBalanceAccounts } from "./constants";
|
|
3
3
|
import type { KaminoPositionYieldInfo, KaminoReserveSnapshot } from "./types";
|
|
4
4
|
export declare function parseKaminoReserveSnapshotFromAccountData(args: {
|
|
5
|
-
data: Buffer;
|
|
5
|
+
data: Buffer | Uint8Array;
|
|
6
6
|
reserve: PublicKey;
|
|
7
7
|
tokenMint: PublicKey;
|
|
8
8
|
}): KaminoReserveSnapshot;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Connection, PublicKey } from "@solana/web3.js";
|
|
2
|
+
export declare const MAGICBLOCK_UNDELEGATE_SESSION_FEE_LAMPORTS = 300000;
|
|
3
|
+
export declare const DEPOSIT_ACCOUNT_SIZE: number;
|
|
4
|
+
export declare const VAULT_ACCOUNT_SIZE: number;
|
|
5
|
+
export declare const PERMISSION_ACCOUNT_SIZE = 567;
|
|
6
|
+
export declare const DELEGATION_RECORD_ACCOUNT_SIZE: number;
|
|
7
|
+
export type RentAccountEstimate = {
|
|
8
|
+
address: PublicKey;
|
|
9
|
+
space: number;
|
|
10
|
+
forceCreate?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export declare function estimateNewAccountRentLamports(params: {
|
|
13
|
+
connection: Connection;
|
|
14
|
+
accounts: RentAccountEstimate[];
|
|
15
|
+
}): Promise<number>;
|
|
16
|
+
export declare function estimateExistingAccountLamports(params: {
|
|
17
|
+
connection: Connection;
|
|
18
|
+
accounts: PublicKey[];
|
|
19
|
+
}): Promise<number>;
|
|
20
|
+
export declare function estimateDepositRentLamports(params: {
|
|
21
|
+
connection: Connection;
|
|
22
|
+
depositPda: PublicKey;
|
|
23
|
+
forceCreate?: boolean;
|
|
24
|
+
}): Promise<number>;
|
|
25
|
+
export declare function estimateModifyBalanceRentLamports(params: {
|
|
26
|
+
connection: Connection;
|
|
27
|
+
user: PublicKey;
|
|
28
|
+
tokenMint: PublicKey;
|
|
29
|
+
isNativeSol: boolean;
|
|
30
|
+
}): Promise<number>;
|
|
31
|
+
export declare function estimatePermissionRentLamports(params: {
|
|
32
|
+
connection: Connection;
|
|
33
|
+
permissionPda: PublicKey;
|
|
34
|
+
forceCreate?: boolean;
|
|
35
|
+
}): Promise<number>;
|
|
36
|
+
export declare function estimateDepositDelegationRentLamports(params: {
|
|
37
|
+
connection: Connection;
|
|
38
|
+
user: PublicKey;
|
|
39
|
+
tokenMint: PublicKey;
|
|
40
|
+
depositPda: PublicKey;
|
|
41
|
+
forceCreate?: boolean;
|
|
42
|
+
}): Promise<number>;
|
|
43
|
+
export declare function estimateDepositDelegationRentCreditLamports(params: {
|
|
44
|
+
connection: Connection;
|
|
45
|
+
depositPda: PublicKey;
|
|
46
|
+
}): Promise<number>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Connection, Transaction, type Signer } from "@solana/web3.js";
|
|
2
|
+
import type { Provider } from "@coral-xyz/anchor";
|
|
3
|
+
import type { RpcOptions } from "./types";
|
|
4
|
+
export declare function logFailedTransactionDiagnostics(params: {
|
|
5
|
+
label: string;
|
|
6
|
+
connection: Connection;
|
|
7
|
+
tx: Transaction;
|
|
8
|
+
error: unknown;
|
|
9
|
+
extraContext?: Record<string, unknown>;
|
|
10
|
+
}): Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* Sign, broadcast, and verify a transaction while keeping the
|
|
13
|
+
* signature in hand across confirmation hiccups.
|
|
14
|
+
*
|
|
15
|
+
* The previous implementation delegated to `provider.sendAndConfirm`,
|
|
16
|
+
* which in turn called `connection.confirmTransaction({signature,
|
|
17
|
+
* blockhash, lastValidBlockHeight})`. With Seeker / Seed Vault the
|
|
18
|
+
* user may spend 5–30s between tapping our preview sheet and
|
|
19
|
+
* biometric-confirming on device; by the time Anchor starts its
|
|
20
|
+
* confirmation poll, the RPC node's poll window has often lapsed and
|
|
21
|
+
* `confirmTransaction` throws `TransactionExpiredBlockheightExceeded`
|
|
22
|
+
* — even though the tx is on chain and has moved funds. Anchor
|
|
23
|
+
* re-throws and the signature is lost, so callers surface "Shield
|
|
24
|
+
* failed" on what was actually a success.
|
|
25
|
+
*
|
|
26
|
+
* We handle the send + confirm ourselves:
|
|
27
|
+
* 1. Stamp blockhash + fee payer, sign via the provider's wallet.
|
|
28
|
+
* 2. Broadcast via `sendRawTransaction` — we now own the signature.
|
|
29
|
+
* 3. Poll `getSignatureStatuses` until landed / failed / dropped.
|
|
30
|
+
* This keeps real failures loud while immunizing callers from the
|
|
31
|
+
* "on-chain but our poll timed out" race.
|
|
32
|
+
*/
|
|
33
|
+
export declare function sendAndConfirmWithDiagnostics(params: {
|
|
34
|
+
label: string;
|
|
35
|
+
provider: Provider;
|
|
36
|
+
tx: Transaction;
|
|
37
|
+
signers?: Signer[];
|
|
38
|
+
rpcOptions?: RpcOptions;
|
|
39
|
+
extraContext?: Record<string, unknown>;
|
|
40
|
+
}): Promise<string>;
|