@zebec-network/zebec-vault-sdk 2.0.0 → 3.1.0
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 +219 -219
- package/dist/artifacts/index.d.ts +7 -3
- package/dist/artifacts/index.js +9 -3
- package/dist/artifacts/zebec_instant_card.d.ts +1690 -0
- package/dist/artifacts/zebec_instant_card.js +2 -0
- package/dist/artifacts/zebec_instant_card.json +1444 -0
- package/dist/artifacts/zebec_stream.d.ts +1902 -0
- package/dist/artifacts/zebec_stream.js +2 -0
- package/dist/artifacts/zebec_stream.json +1596 -0
- package/dist/artifacts/zebec_vault.d.ts +1442 -169
- package/dist/artifacts/zebec_vault.json +1178 -891
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +3 -1
- package/dist/pda.d.ts +6 -0
- package/dist/pda.js +40 -3
- package/dist/service.d.ts +152 -8
- package/dist/service.js +396 -35
- package/dist/types.d.ts +1 -1
- package/package.json +12 -11
package/dist/constants.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export type RpcNetwork = "mainnet-beta" | "devnet";
|
|
2
2
|
export declare const ZEBEC_VAULT_PROGRAM_ID: Record<RpcNetwork, string>;
|
|
3
3
|
export declare const TEN_BIGNUM: BigNumber;
|
|
4
|
+
export declare const JUPITER_AGGREGATOR_PROGRAM_ID = "JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4";
|
|
5
|
+
export declare const CARD_LOOKUP_TABLE_ADDRESS = "CgPARkLEbygMJ8C9Z1u6MP57gvdnUERCxdhmR9bTFUSJ";
|
package/dist/constants.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TEN_BIGNUM = exports.ZEBEC_VAULT_PROGRAM_ID = void 0;
|
|
3
|
+
exports.CARD_LOOKUP_TABLE_ADDRESS = exports.JUPITER_AGGREGATOR_PROGRAM_ID = exports.TEN_BIGNUM = exports.ZEBEC_VAULT_PROGRAM_ID = void 0;
|
|
4
4
|
const bignumber_js_1 = require("bignumber.js");
|
|
5
5
|
exports.ZEBEC_VAULT_PROGRAM_ID = {
|
|
6
6
|
"mainnet-beta": "ANqQ8QaAMAyLrY2LVLKALP7pBWRvdTrSF94PBTAvCyim",
|
|
7
7
|
devnet: "ANqQ8QaAMAyLrY2LVLKALP7pBWRvdTrSF94PBTAvCyim",
|
|
8
8
|
};
|
|
9
9
|
exports.TEN_BIGNUM = (0, bignumber_js_1.BigNumber)(10);
|
|
10
|
+
exports.JUPITER_AGGREGATOR_PROGRAM_ID = "JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4";
|
|
11
|
+
exports.CARD_LOOKUP_TABLE_ADDRESS = "CgPARkLEbygMJ8C9Z1u6MP57gvdnUERCxdhmR9bTFUSJ";
|
package/dist/pda.d.ts
CHANGED
|
@@ -2,3 +2,9 @@ import { Address } from "@coral-xyz/anchor";
|
|
|
2
2
|
import { PublicKey } from "@solana/web3.js";
|
|
3
3
|
export declare function deriveVaultSigner(vault: Address, programId: Address): [PublicKey, number];
|
|
4
4
|
export declare function deriveUserVault(user: Address, programId: Address): [PublicKey, number];
|
|
5
|
+
export declare function deriveCardConfigPda(programId: Address): [PublicKey, number];
|
|
6
|
+
export declare function deriveTokenFeeMapPda(programId: Address): [PublicKey, number];
|
|
7
|
+
export declare function deriveCardPurchasePda(buyer: Address, buyerCounter: bigint, programId: Address): [PublicKey, number];
|
|
8
|
+
export declare function deriveUserPurchaseRecordPda(user: Address, programId: Address): [PublicKey, number];
|
|
9
|
+
export declare function deriveStreamConfigPda(programId: Address): [PublicKey, number];
|
|
10
|
+
export declare function deriveStreamVaultPda(metatadata: Address, programId: Address): [PublicKey, number];
|
package/dist/pda.js
CHANGED
|
@@ -2,17 +2,54 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.deriveVaultSigner = deriveVaultSigner;
|
|
4
4
|
exports.deriveUserVault = deriveUserVault;
|
|
5
|
+
exports.deriveCardConfigPda = deriveCardConfigPda;
|
|
6
|
+
exports.deriveTokenFeeMapPda = deriveTokenFeeMapPda;
|
|
7
|
+
exports.deriveCardPurchasePda = deriveCardPurchasePda;
|
|
8
|
+
exports.deriveUserPurchaseRecordPda = deriveUserPurchaseRecordPda;
|
|
9
|
+
exports.deriveStreamConfigPda = deriveStreamConfigPda;
|
|
10
|
+
exports.deriveStreamVaultPda = deriveStreamVaultPda;
|
|
5
11
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
6
12
|
const web3_js_1 = require("@solana/web3.js");
|
|
7
|
-
const
|
|
13
|
+
const VAULT_PROGRAM_V1_SEEDS = {
|
|
8
14
|
USER_VAULT: [122, 101, 98, 101, 99, 95, 117, 115, 101, 114, 95, 118, 97, 117, 108, 116],
|
|
9
15
|
VAULT_SIGNER: [122, 101, 98, 101, 99, 95, 118, 97, 117, 108, 116, 95, 115, 105, 103, 110, 101, 114],
|
|
10
16
|
};
|
|
11
17
|
function deriveVaultSigner(vault, programId) {
|
|
12
|
-
const addressAndBump = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(
|
|
18
|
+
const addressAndBump = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(VAULT_PROGRAM_V1_SEEDS.VAULT_SIGNER), (0, anchor_1.translateAddress)(vault).toBuffer()], (0, anchor_1.translateAddress)(programId));
|
|
13
19
|
return addressAndBump;
|
|
14
20
|
}
|
|
15
21
|
function deriveUserVault(user, programId) {
|
|
16
|
-
const addressAndBump = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(
|
|
22
|
+
const addressAndBump = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(VAULT_PROGRAM_V1_SEEDS.USER_VAULT), (0, anchor_1.translateAddress)(user).toBuffer()], (0, anchor_1.translateAddress)(programId));
|
|
17
23
|
return addressAndBump;
|
|
18
24
|
}
|
|
25
|
+
const CARD_PROGRAM_V2_SEEDS = {
|
|
26
|
+
CARD_CONFIG: anchor_1.utils.bytes.utf8.encode("card_config"),
|
|
27
|
+
TOKEN_FEE_MAP: anchor_1.utils.bytes.utf8.encode("token_fee_map"),
|
|
28
|
+
USER_CARD_PURCHASE: anchor_1.utils.bytes.utf8.encode("user_card_purchase"),
|
|
29
|
+
USER_PURCHASE_RECORD: anchor_1.utils.bytes.utf8.encode("user_purchase_record"),
|
|
30
|
+
};
|
|
31
|
+
function deriveCardConfigPda(programId) {
|
|
32
|
+
return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(CARD_PROGRAM_V2_SEEDS.CARD_CONFIG)], (0, anchor_1.translateAddress)(programId));
|
|
33
|
+
}
|
|
34
|
+
function deriveTokenFeeMapPda(programId) {
|
|
35
|
+
return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(CARD_PROGRAM_V2_SEEDS.TOKEN_FEE_MAP)], (0, anchor_1.translateAddress)(programId));
|
|
36
|
+
}
|
|
37
|
+
function deriveCardPurchasePda(buyer, buyerCounter, programId) {
|
|
38
|
+
return web3_js_1.PublicKey.findProgramAddressSync([
|
|
39
|
+
Buffer.from(CARD_PROGRAM_V2_SEEDS.USER_CARD_PURCHASE),
|
|
40
|
+
(0, anchor_1.translateAddress)(buyer).toBuffer(),
|
|
41
|
+
new anchor_1.BN(buyerCounter.toString()).toArrayLike(Buffer, "le", 8),
|
|
42
|
+
], (0, anchor_1.translateAddress)(programId));
|
|
43
|
+
}
|
|
44
|
+
function deriveUserPurchaseRecordPda(user, programId) {
|
|
45
|
+
return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(CARD_PROGRAM_V2_SEEDS.USER_PURCHASE_RECORD), (0, anchor_1.translateAddress)(user).toBuffer()], (0, anchor_1.translateAddress)(programId));
|
|
46
|
+
}
|
|
47
|
+
const SEEDS = {
|
|
48
|
+
STREAM_CONFIG: anchor_1.utils.bytes.utf8.encode("config"),
|
|
49
|
+
};
|
|
50
|
+
function deriveStreamConfigPda(programId) {
|
|
51
|
+
return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(SEEDS.STREAM_CONFIG)], (0, anchor_1.translateAddress)(programId));
|
|
52
|
+
}
|
|
53
|
+
function deriveStreamVaultPda(metatadata, programId) {
|
|
54
|
+
return web3_js_1.PublicKey.findProgramAddressSync([(0, anchor_1.translateAddress)(metatadata).toBuffer()], (0, anchor_1.translateAddress)(programId));
|
|
55
|
+
}
|
package/dist/service.d.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { Address, BN, Program, Provider } from "@coral-xyz/anchor";
|
|
2
|
-
import { AccountMeta, Keypair, PublicKey, Signer, TransactionInstruction } from "@solana/web3.js";
|
|
3
|
-
import { TransactionPayload } from "@zebec-network/solana-common";
|
|
4
|
-
import {
|
|
2
|
+
import { AccountMeta, Connection, Keypair, PublicKey, Signer, TransactionInstruction } from "@solana/web3.js";
|
|
3
|
+
import { MultiTransactionPayload, TransactionPayload } from "@zebec-network/solana-common";
|
|
4
|
+
import { ZebecCardV2Idl, ZebecStreamIdl, ZebecVaultV1Idl } from "./artifacts";
|
|
5
5
|
import { RpcNetwork } from "./constants";
|
|
6
6
|
import { Numeric, ProposalAction, ProposalInfo, VaultInfo } from "./types";
|
|
7
7
|
export declare class ZebecVaultService {
|
|
8
8
|
readonly provider: Provider;
|
|
9
|
-
readonly
|
|
9
|
+
readonly vaultV1Program: Program<ZebecVaultV1Idl>;
|
|
10
|
+
readonly cardV2Program: Program<ZebecCardV2Idl>;
|
|
11
|
+
readonly streamProgram: Program<ZebecStreamIdl>;
|
|
10
12
|
readonly network: RpcNetwork;
|
|
11
|
-
constructor(provider: Provider,
|
|
12
|
-
static create(provider: Provider, network: RpcNetwork
|
|
13
|
+
constructor(provider: Provider, vaultV1Program: Program<ZebecVaultV1Idl>, cardV2Program: Program<ZebecCardV2Idl>, streamProgram: Program<ZebecStreamIdl>, network: RpcNetwork);
|
|
14
|
+
static create(provider: Provider, network: RpcNetwork): ZebecVaultService;
|
|
13
15
|
getCreateVaultInstruction(payer: PublicKey, owner: PublicKey, signerBump: number): Promise<TransactionInstruction>;
|
|
14
16
|
getDepositSolInstruction(depositor: PublicKey, amount: BN): Promise<TransactionInstruction>;
|
|
15
17
|
getWithdrawSolInstruction(withdrawer: PublicKey, amount: BN): Promise<TransactionInstruction>;
|
|
@@ -20,6 +22,37 @@ export declare class ZebecVaultService {
|
|
|
20
22
|
getDeleteProposalInstruction(proposal: PublicKey): Promise<TransactionInstruction>;
|
|
21
23
|
getExecuteProposalInstruction(caller: PublicKey, proposal: PublicKey, remainingAccounts: AccountMeta[]): Promise<TransactionInstruction>;
|
|
22
24
|
getExecuteProposalDirectInstruction(proposer: PublicKey, actions: ProposalAction[], remainingAccounts: AccountMeta[]): Promise<TransactionInstruction>;
|
|
25
|
+
getSwapAndCreateSilverCardInstruction(cardVault: PublicKey, cardVaultAta: PublicKey, inputMint: PublicKey, inputMintProgram: PublicKey, outputMint: PublicKey, revenueVault: PublicKey, revenueVaultAta: PublicKey, vaultOwner: PublicKey, data: {
|
|
26
|
+
currency: string;
|
|
27
|
+
emailHash: number[];
|
|
28
|
+
index: BN;
|
|
29
|
+
swapData: Buffer;
|
|
30
|
+
}, remainingAccounts: AccountMeta[]): Promise<TransactionInstruction>;
|
|
31
|
+
getSwapAndLoadCarbonCardInstruction(cardVault: PublicKey, cardVaultAta: PublicKey, inputMint: PublicKey, inputMintProgram: PublicKey, outputMint: PublicKey, revenueVault: PublicKey, revenueVaultAta: PublicKey, vaultOwner: PublicKey, data: {
|
|
32
|
+
currency: string;
|
|
33
|
+
emailHash: number[];
|
|
34
|
+
index: BN;
|
|
35
|
+
swapData: Buffer;
|
|
36
|
+
reloadCardId: string;
|
|
37
|
+
}, remainingAccounts: AccountMeta[]): Promise<TransactionInstruction>;
|
|
38
|
+
getCreateStreamFromVaultInstruction(vaultOwner: PublicKey, vault: PublicKey, vaultSigner: PublicKey, vaultSignerAta: PublicKey, receiver: PublicKey, receiverAta: PublicKey, streamToken: PublicKey, streamMetadata: PublicKey, streamConfig: PublicKey, withdrawAccount: PublicKey, streamVault: PublicKey, streamVaultAta: PublicKey, zebecStreamProgram: PublicKey, streamData: {
|
|
39
|
+
amount: BN;
|
|
40
|
+
automaticWithdrawal: boolean;
|
|
41
|
+
cancelableByRecipient: boolean;
|
|
42
|
+
cancelableBySender: boolean;
|
|
43
|
+
canTopup: boolean;
|
|
44
|
+
cliffPercentage: BN;
|
|
45
|
+
duration: BN;
|
|
46
|
+
isPausable: boolean;
|
|
47
|
+
rateUpdatable: boolean;
|
|
48
|
+
startNow: boolean;
|
|
49
|
+
startTime: BN;
|
|
50
|
+
autoWithdrawFrequency: BN;
|
|
51
|
+
streamName: Uint8Array | Buffer;
|
|
52
|
+
transferableByRecipient: boolean;
|
|
53
|
+
transferableBySender: boolean;
|
|
54
|
+
numberOfWithdrawls: BN;
|
|
55
|
+
}): Promise<TransactionInstruction>;
|
|
23
56
|
createVault(params: {
|
|
24
57
|
payer?: Address;
|
|
25
58
|
}): Promise<TransactionPayload>;
|
|
@@ -68,10 +101,121 @@ export declare class ZebecVaultService {
|
|
|
68
101
|
partialSigners?: Signer[];
|
|
69
102
|
addressLookupTables?: Address[];
|
|
70
103
|
}): Promise<TransactionPayload>;
|
|
104
|
+
swapAndCreateSilverCard(params: SwapAndCreateSilverCardParams): Promise<TransactionPayload>;
|
|
105
|
+
swapAndLoadCarbonCard(params: SwapAndLoadCarbonCardParams): Promise<TransactionPayload>;
|
|
106
|
+
createStreamFromVault(params: CreateStreamFromVaultParams): Promise<TransactionPayload>;
|
|
107
|
+
createMultipleStreamFromVault(params: createMultipleStreamFromVaultParams): Promise<MultiTransactionPayload>;
|
|
71
108
|
private _createTransactionPayload;
|
|
109
|
+
private _createMultiTransactionPayload;
|
|
72
110
|
getVaultInfoOfUser(user?: Address): Promise<VaultInfo | null>;
|
|
73
111
|
getAllVaultsInfo(): Promise<VaultInfo[]>;
|
|
74
112
|
getProposalsInfoOfVault(vault: Address): Promise<ProposalInfo[]>;
|
|
75
|
-
get
|
|
76
|
-
get
|
|
113
|
+
get vaultV1ProgramId(): PublicKey;
|
|
114
|
+
get cardV2ProgramId(): PublicKey;
|
|
115
|
+
get streamProgramId(): PublicKey;
|
|
116
|
+
get connection(): Connection;
|
|
77
117
|
}
|
|
118
|
+
export type SwapAndCreateSilverCardParams = {
|
|
119
|
+
quoteInfo: QuoteInfo;
|
|
120
|
+
vaultOwnerAddress: Address;
|
|
121
|
+
nextCardCounter: bigint;
|
|
122
|
+
emailHash: Buffer;
|
|
123
|
+
currency: string;
|
|
124
|
+
wrapAndUnwrapSol?: boolean;
|
|
125
|
+
};
|
|
126
|
+
export type SwapAndLoadCarbonCardParams = {
|
|
127
|
+
quoteInfo: QuoteInfo;
|
|
128
|
+
nextCardCounter: bigint;
|
|
129
|
+
emailHash: Buffer;
|
|
130
|
+
currency: string;
|
|
131
|
+
reloadCardId: string;
|
|
132
|
+
vaultOwnerAddress: Address;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Juptier quote info
|
|
136
|
+
*/
|
|
137
|
+
export type QuoteInfo = {
|
|
138
|
+
inputMint: string;
|
|
139
|
+
inAmount: string;
|
|
140
|
+
outputMint: string;
|
|
141
|
+
outAmount: string;
|
|
142
|
+
otherAmountThreshold: string;
|
|
143
|
+
swapMode: "ExactIn" | "ExactOut";
|
|
144
|
+
slippageBps: number;
|
|
145
|
+
platformFee: {
|
|
146
|
+
amount: string;
|
|
147
|
+
feeBps: number;
|
|
148
|
+
} | null;
|
|
149
|
+
priceImpactPct: string;
|
|
150
|
+
routePlan: RouteInfo[];
|
|
151
|
+
contextSlot: number;
|
|
152
|
+
timeTaken: number;
|
|
153
|
+
swapUsdValue: string;
|
|
154
|
+
simplerRouteUsed: boolean;
|
|
155
|
+
mostReliableAmmsQuoteReport: {
|
|
156
|
+
info: Record<string, string>;
|
|
157
|
+
};
|
|
158
|
+
} | {
|
|
159
|
+
error: string;
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* Jupiter quote routes info
|
|
163
|
+
*/
|
|
164
|
+
export type RouteInfo = {
|
|
165
|
+
swapInfo: {
|
|
166
|
+
ammKey: string;
|
|
167
|
+
label: string;
|
|
168
|
+
inputMint: string;
|
|
169
|
+
outputMint: string;
|
|
170
|
+
inAmount: string;
|
|
171
|
+
outAmount: string;
|
|
172
|
+
feeAmount: string;
|
|
173
|
+
feeMint: string;
|
|
174
|
+
};
|
|
175
|
+
percent: number;
|
|
176
|
+
bps: number;
|
|
177
|
+
};
|
|
178
|
+
export type CreateStreamFromVaultParams = {
|
|
179
|
+
sender: Address;
|
|
180
|
+
receiver: Address;
|
|
181
|
+
streamToken: Address;
|
|
182
|
+
amount: Numeric;
|
|
183
|
+
automaticWithdrawal: boolean;
|
|
184
|
+
cancelableByRecipient: boolean;
|
|
185
|
+
cancelableBySender: boolean;
|
|
186
|
+
cliffPercentage: Numeric;
|
|
187
|
+
duration: number;
|
|
188
|
+
isPausable: boolean;
|
|
189
|
+
startNow: boolean;
|
|
190
|
+
startTime: number;
|
|
191
|
+
autoWithdrawFrequency: number;
|
|
192
|
+
streamName: string;
|
|
193
|
+
transferableByRecipient: boolean;
|
|
194
|
+
transferableBySender: boolean;
|
|
195
|
+
canTopup: boolean;
|
|
196
|
+
rateUpdatable: boolean;
|
|
197
|
+
streamMetadataKeypair?: Keypair;
|
|
198
|
+
};
|
|
199
|
+
export type createMultipleStreamFromVaultParams = {
|
|
200
|
+
sender: Address;
|
|
201
|
+
streamInfo: {
|
|
202
|
+
receiver: Address;
|
|
203
|
+
streamToken: Address;
|
|
204
|
+
amount: Numeric;
|
|
205
|
+
automaticWithdrawal: boolean;
|
|
206
|
+
cancelableByRecipient: boolean;
|
|
207
|
+
cancelableBySender: boolean;
|
|
208
|
+
cliffPercentage: Numeric;
|
|
209
|
+
duration: number;
|
|
210
|
+
isPausable: boolean;
|
|
211
|
+
startNow: boolean;
|
|
212
|
+
startTime: number;
|
|
213
|
+
autoWithdrawFrequency: number;
|
|
214
|
+
streamName: string;
|
|
215
|
+
transferableByRecipient: boolean;
|
|
216
|
+
transferableBySender: boolean;
|
|
217
|
+
canTopup: boolean;
|
|
218
|
+
rateUpdatable: boolean;
|
|
219
|
+
streamMetadataKeypair?: Keypair;
|
|
220
|
+
}[];
|
|
221
|
+
};
|