@debridge-finance/intents-client 1.3.1 → 1.4.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/dist/index.d.mts +33 -18
- package/dist/index.d.ts +33 -18
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PublicKey, Blockhash, AddressLookupTableAccount, TransactionInstruction, Connection, Keypair, VersionedTransaction } from '@solana/web3.js';
|
|
2
1
|
import { IdlAccounts } from '@coral-xyz/anchor';
|
|
2
|
+
import { PublicKey, Blockhash, AddressLookupTableAccount, TransactionInstruction, Connection, Keypair, VersionedTransaction } from '@solana/web3.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Program IDL in camelCase format in order to be used in JS/TS.
|
|
@@ -3244,6 +3244,7 @@ declare const IDL: IntentsProgram;
|
|
|
3244
3244
|
|
|
3245
3245
|
type AddressType = Buffer<ArrayBuffer | ArrayBufferLike>;
|
|
3246
3246
|
type Any = "any";
|
|
3247
|
+
type AnyOr<T> = T | "any";
|
|
3247
3248
|
type GiveToken = {
|
|
3248
3249
|
output: AddressType;
|
|
3249
3250
|
input: AddressType;
|
|
@@ -3258,7 +3259,7 @@ type TakeToken = {
|
|
|
3258
3259
|
output: ({
|
|
3259
3260
|
chainId: number;
|
|
3260
3261
|
token: AddressType;
|
|
3261
|
-
price: bigint
|
|
3262
|
+
price: AnyOr<bigint>;
|
|
3262
3263
|
} | {
|
|
3263
3264
|
chainId: number;
|
|
3264
3265
|
token: Any;
|
|
@@ -3272,7 +3273,7 @@ type InputToken = {
|
|
|
3272
3273
|
constraintBudget: bigint;
|
|
3273
3274
|
};
|
|
3274
3275
|
type ReceiverInfo = {
|
|
3275
|
-
chainIds: number[]
|
|
3276
|
+
chainIds: AnyOr<number[]>;
|
|
3276
3277
|
address: AddressType;
|
|
3277
3278
|
};
|
|
3278
3279
|
interface IntentType {
|
|
@@ -3349,7 +3350,7 @@ interface InitIntentParams {
|
|
|
3349
3350
|
computeBudget?: ComputeBudget;
|
|
3350
3351
|
}
|
|
3351
3352
|
interface CreateAndUpdateIntentParams {
|
|
3352
|
-
|
|
3353
|
+
maker: PublicKey;
|
|
3353
3354
|
payer?: PublicKey;
|
|
3354
3355
|
delegate?: PublicKey;
|
|
3355
3356
|
intent: {
|
|
@@ -3414,22 +3415,23 @@ interface CloseIntentParams {
|
|
|
3414
3415
|
ALTs?: Array<AddressLookupTableAccount>;
|
|
3415
3416
|
computeBudget?: ComputeBudget;
|
|
3416
3417
|
}
|
|
3418
|
+
type DelegateApprovedBudgetsArgs = {
|
|
3419
|
+
set: {
|
|
3420
|
+
tokenMint: PublicKey;
|
|
3421
|
+
approvedAmount: bigint;
|
|
3422
|
+
expiration: bigint;
|
|
3423
|
+
}[];
|
|
3424
|
+
} | {
|
|
3425
|
+
setAny: {};
|
|
3426
|
+
} | {
|
|
3427
|
+
revoke: {};
|
|
3428
|
+
};
|
|
3417
3429
|
interface DelegateApprovedBudgetsParams {
|
|
3418
3430
|
maker: PublicKey;
|
|
3419
3431
|
payer: PublicKey;
|
|
3420
3432
|
delegate: PublicKey;
|
|
3421
3433
|
nonce: bigint;
|
|
3422
|
-
tokens:
|
|
3423
|
-
set: {
|
|
3424
|
-
tokenMint: PublicKey;
|
|
3425
|
-
approvedAmount: bigint;
|
|
3426
|
-
expiration: bigint;
|
|
3427
|
-
}[];
|
|
3428
|
-
} | {
|
|
3429
|
-
setAny: {};
|
|
3430
|
-
} | {
|
|
3431
|
-
revoke: {};
|
|
3432
|
-
};
|
|
3434
|
+
tokens: DelegateApprovedBudgetsArgs;
|
|
3433
3435
|
signature?: Buffer;
|
|
3434
3436
|
}
|
|
3435
3437
|
interface SetMakerCancelUntilTimestampParams {
|
|
@@ -3521,6 +3523,12 @@ interface WithdrawIntentTokenAccountParams extends WithdrawClosedIntentTokenAcco
|
|
|
3521
3523
|
encodedIntentHash: Buffer;
|
|
3522
3524
|
}
|
|
3523
3525
|
|
|
3526
|
+
declare enum IntentProgramSigPrefix {
|
|
3527
|
+
prod = "intents_program",
|
|
3528
|
+
dubai = "intents_program_dubai",
|
|
3529
|
+
hanoi = "intents_program_hanoi",
|
|
3530
|
+
devnet = "intents_program_devnet"
|
|
3531
|
+
}
|
|
3524
3532
|
declare const DEFAULT_RECORD_OFFSET = 33;
|
|
3525
3533
|
declare class IntentsClient {
|
|
3526
3534
|
readonly programId: PublicKey;
|
|
@@ -3536,6 +3544,8 @@ declare class IntentsClient {
|
|
|
3536
3544
|
private getSpace;
|
|
3537
3545
|
getState(connection: Connection): Promise<State | null>;
|
|
3538
3546
|
getIntentStorage(connection: Connection, intentId: Buffer): Promise<IntentStorage | null>;
|
|
3547
|
+
getMakerInfo(connection: Connection, maker: PublicKey): Promise<IdlAccounts<IntentsProgram>["makerInfo"] | null>;
|
|
3548
|
+
getNonceForDelegate(connection: Connection, maker: PublicKey, delegate: PublicKey): Promise<bigint>;
|
|
3539
3549
|
approveProtocolTransfersIxs({ maker, tokens, tokenProgram, }: ApproveProtocolTransfersParams): Promise<TransactionInstruction[]>;
|
|
3540
3550
|
private cancelIntentIxs;
|
|
3541
3551
|
private closeIntentIxs;
|
|
@@ -3563,7 +3573,7 @@ declare class IntentsClient {
|
|
|
3563
3573
|
write: VersionedTransaction[];
|
|
3564
3574
|
record: Keypair;
|
|
3565
3575
|
}>;
|
|
3566
|
-
createAndUpdateIntentTxs({
|
|
3576
|
+
createAndUpdateIntentTxs({ maker, payer, delegate, intent, signature, blockhash, ALTs, computeBudget, }: CreateAndUpdateIntentParams): Promise<VersionedTransaction[]>;
|
|
3567
3577
|
updateRecordTxs({ authority, payer, record, serializedIntent, offset, blockhash, ALTs, computeBudget, }: UpdateRecordTxsParams): Promise<VersionedTransaction[]>;
|
|
3568
3578
|
cancelIntentTxs({ maker, payer, id, encodedIntentHash, tokenMint, tokenProgram, blockhash, ALTs, computeBudget, }: CancelIntentParams): Promise<VersionedTransaction[]>;
|
|
3569
3579
|
closeIntentTxs({ maker, payer, receiver, id, tokenMint, tokenProgram, blockhash, ALTs, computeBudget, }: CloseIntentParams): Promise<VersionedTransaction[]>;
|
|
@@ -3574,7 +3584,9 @@ declare class IntentsClient {
|
|
|
3574
3584
|
static getDelegatesPda(programId: PublicKey, user: PublicKey): PublicKey;
|
|
3575
3585
|
static getEventAuthorityPda(programId: PublicKey): PublicKey;
|
|
3576
3586
|
static getNativePda(programId: PublicKey): PublicKey;
|
|
3577
|
-
static getBufferForIntentSignature(intentId: Buffer, chainId?: number): Buffer;
|
|
3587
|
+
static getBufferForIntentSignature(intentId: Buffer, intentProgramSigPrefix?: IntentProgramSigPrefix, chainId?: number): Buffer;
|
|
3588
|
+
static getDelegateApprovedBudgetsArgs(tokens: DelegateApprovedBudgetsArgs): any;
|
|
3589
|
+
static getBufferForBudgetSignature(delegate: PublicKey, nonce: bigint, tokens: DelegateApprovedBudgetsArgs, intentProgramSigPrefix?: IntentProgramSigPrefix, chainId?: number): Buffer;
|
|
3578
3590
|
}
|
|
3579
3591
|
|
|
3580
3592
|
declare class Intent implements Serializable {
|
|
@@ -3587,8 +3599,11 @@ declare class Intent implements Serializable {
|
|
|
3587
3599
|
private serializeInputTokens;
|
|
3588
3600
|
private serializeGiveTokens;
|
|
3589
3601
|
private serializeTakeTokens;
|
|
3602
|
+
private serializeExternalCallHash;
|
|
3590
3603
|
private serializeOptionalBytes;
|
|
3604
|
+
private serializeDlnMetadata;
|
|
3591
3605
|
private serializeShortArray;
|
|
3606
|
+
private serializeAllowedSenders;
|
|
3592
3607
|
private serializeAddresses;
|
|
3593
3608
|
private serializeOptionalPubkey;
|
|
3594
3609
|
serialize(): Buffer;
|
|
@@ -3599,4 +3614,4 @@ declare class Intent implements Serializable {
|
|
|
3599
3614
|
};
|
|
3600
3615
|
}
|
|
3601
3616
|
|
|
3602
|
-
export { DEFAULT_RECORD_OFFSET, IDL, Intent, IntentsClient };
|
|
3617
|
+
export { DEFAULT_RECORD_OFFSET, IDL, Intent, IntentProgramSigPrefix, IntentsClient };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PublicKey, Blockhash, AddressLookupTableAccount, TransactionInstruction, Connection, Keypair, VersionedTransaction } from '@solana/web3.js';
|
|
2
1
|
import { IdlAccounts } from '@coral-xyz/anchor';
|
|
2
|
+
import { PublicKey, Blockhash, AddressLookupTableAccount, TransactionInstruction, Connection, Keypair, VersionedTransaction } from '@solana/web3.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Program IDL in camelCase format in order to be used in JS/TS.
|
|
@@ -3244,6 +3244,7 @@ declare const IDL: IntentsProgram;
|
|
|
3244
3244
|
|
|
3245
3245
|
type AddressType = Buffer<ArrayBuffer | ArrayBufferLike>;
|
|
3246
3246
|
type Any = "any";
|
|
3247
|
+
type AnyOr<T> = T | "any";
|
|
3247
3248
|
type GiveToken = {
|
|
3248
3249
|
output: AddressType;
|
|
3249
3250
|
input: AddressType;
|
|
@@ -3258,7 +3259,7 @@ type TakeToken = {
|
|
|
3258
3259
|
output: ({
|
|
3259
3260
|
chainId: number;
|
|
3260
3261
|
token: AddressType;
|
|
3261
|
-
price: bigint
|
|
3262
|
+
price: AnyOr<bigint>;
|
|
3262
3263
|
} | {
|
|
3263
3264
|
chainId: number;
|
|
3264
3265
|
token: Any;
|
|
@@ -3272,7 +3273,7 @@ type InputToken = {
|
|
|
3272
3273
|
constraintBudget: bigint;
|
|
3273
3274
|
};
|
|
3274
3275
|
type ReceiverInfo = {
|
|
3275
|
-
chainIds: number[]
|
|
3276
|
+
chainIds: AnyOr<number[]>;
|
|
3276
3277
|
address: AddressType;
|
|
3277
3278
|
};
|
|
3278
3279
|
interface IntentType {
|
|
@@ -3349,7 +3350,7 @@ interface InitIntentParams {
|
|
|
3349
3350
|
computeBudget?: ComputeBudget;
|
|
3350
3351
|
}
|
|
3351
3352
|
interface CreateAndUpdateIntentParams {
|
|
3352
|
-
|
|
3353
|
+
maker: PublicKey;
|
|
3353
3354
|
payer?: PublicKey;
|
|
3354
3355
|
delegate?: PublicKey;
|
|
3355
3356
|
intent: {
|
|
@@ -3414,22 +3415,23 @@ interface CloseIntentParams {
|
|
|
3414
3415
|
ALTs?: Array<AddressLookupTableAccount>;
|
|
3415
3416
|
computeBudget?: ComputeBudget;
|
|
3416
3417
|
}
|
|
3418
|
+
type DelegateApprovedBudgetsArgs = {
|
|
3419
|
+
set: {
|
|
3420
|
+
tokenMint: PublicKey;
|
|
3421
|
+
approvedAmount: bigint;
|
|
3422
|
+
expiration: bigint;
|
|
3423
|
+
}[];
|
|
3424
|
+
} | {
|
|
3425
|
+
setAny: {};
|
|
3426
|
+
} | {
|
|
3427
|
+
revoke: {};
|
|
3428
|
+
};
|
|
3417
3429
|
interface DelegateApprovedBudgetsParams {
|
|
3418
3430
|
maker: PublicKey;
|
|
3419
3431
|
payer: PublicKey;
|
|
3420
3432
|
delegate: PublicKey;
|
|
3421
3433
|
nonce: bigint;
|
|
3422
|
-
tokens:
|
|
3423
|
-
set: {
|
|
3424
|
-
tokenMint: PublicKey;
|
|
3425
|
-
approvedAmount: bigint;
|
|
3426
|
-
expiration: bigint;
|
|
3427
|
-
}[];
|
|
3428
|
-
} | {
|
|
3429
|
-
setAny: {};
|
|
3430
|
-
} | {
|
|
3431
|
-
revoke: {};
|
|
3432
|
-
};
|
|
3434
|
+
tokens: DelegateApprovedBudgetsArgs;
|
|
3433
3435
|
signature?: Buffer;
|
|
3434
3436
|
}
|
|
3435
3437
|
interface SetMakerCancelUntilTimestampParams {
|
|
@@ -3521,6 +3523,12 @@ interface WithdrawIntentTokenAccountParams extends WithdrawClosedIntentTokenAcco
|
|
|
3521
3523
|
encodedIntentHash: Buffer;
|
|
3522
3524
|
}
|
|
3523
3525
|
|
|
3526
|
+
declare enum IntentProgramSigPrefix {
|
|
3527
|
+
prod = "intents_program",
|
|
3528
|
+
dubai = "intents_program_dubai",
|
|
3529
|
+
hanoi = "intents_program_hanoi",
|
|
3530
|
+
devnet = "intents_program_devnet"
|
|
3531
|
+
}
|
|
3524
3532
|
declare const DEFAULT_RECORD_OFFSET = 33;
|
|
3525
3533
|
declare class IntentsClient {
|
|
3526
3534
|
readonly programId: PublicKey;
|
|
@@ -3536,6 +3544,8 @@ declare class IntentsClient {
|
|
|
3536
3544
|
private getSpace;
|
|
3537
3545
|
getState(connection: Connection): Promise<State | null>;
|
|
3538
3546
|
getIntentStorage(connection: Connection, intentId: Buffer): Promise<IntentStorage | null>;
|
|
3547
|
+
getMakerInfo(connection: Connection, maker: PublicKey): Promise<IdlAccounts<IntentsProgram>["makerInfo"] | null>;
|
|
3548
|
+
getNonceForDelegate(connection: Connection, maker: PublicKey, delegate: PublicKey): Promise<bigint>;
|
|
3539
3549
|
approveProtocolTransfersIxs({ maker, tokens, tokenProgram, }: ApproveProtocolTransfersParams): Promise<TransactionInstruction[]>;
|
|
3540
3550
|
private cancelIntentIxs;
|
|
3541
3551
|
private closeIntentIxs;
|
|
@@ -3563,7 +3573,7 @@ declare class IntentsClient {
|
|
|
3563
3573
|
write: VersionedTransaction[];
|
|
3564
3574
|
record: Keypair;
|
|
3565
3575
|
}>;
|
|
3566
|
-
createAndUpdateIntentTxs({
|
|
3576
|
+
createAndUpdateIntentTxs({ maker, payer, delegate, intent, signature, blockhash, ALTs, computeBudget, }: CreateAndUpdateIntentParams): Promise<VersionedTransaction[]>;
|
|
3567
3577
|
updateRecordTxs({ authority, payer, record, serializedIntent, offset, blockhash, ALTs, computeBudget, }: UpdateRecordTxsParams): Promise<VersionedTransaction[]>;
|
|
3568
3578
|
cancelIntentTxs({ maker, payer, id, encodedIntentHash, tokenMint, tokenProgram, blockhash, ALTs, computeBudget, }: CancelIntentParams): Promise<VersionedTransaction[]>;
|
|
3569
3579
|
closeIntentTxs({ maker, payer, receiver, id, tokenMint, tokenProgram, blockhash, ALTs, computeBudget, }: CloseIntentParams): Promise<VersionedTransaction[]>;
|
|
@@ -3574,7 +3584,9 @@ declare class IntentsClient {
|
|
|
3574
3584
|
static getDelegatesPda(programId: PublicKey, user: PublicKey): PublicKey;
|
|
3575
3585
|
static getEventAuthorityPda(programId: PublicKey): PublicKey;
|
|
3576
3586
|
static getNativePda(programId: PublicKey): PublicKey;
|
|
3577
|
-
static getBufferForIntentSignature(intentId: Buffer, chainId?: number): Buffer;
|
|
3587
|
+
static getBufferForIntentSignature(intentId: Buffer, intentProgramSigPrefix?: IntentProgramSigPrefix, chainId?: number): Buffer;
|
|
3588
|
+
static getDelegateApprovedBudgetsArgs(tokens: DelegateApprovedBudgetsArgs): any;
|
|
3589
|
+
static getBufferForBudgetSignature(delegate: PublicKey, nonce: bigint, tokens: DelegateApprovedBudgetsArgs, intentProgramSigPrefix?: IntentProgramSigPrefix, chainId?: number): Buffer;
|
|
3578
3590
|
}
|
|
3579
3591
|
|
|
3580
3592
|
declare class Intent implements Serializable {
|
|
@@ -3587,8 +3599,11 @@ declare class Intent implements Serializable {
|
|
|
3587
3599
|
private serializeInputTokens;
|
|
3588
3600
|
private serializeGiveTokens;
|
|
3589
3601
|
private serializeTakeTokens;
|
|
3602
|
+
private serializeExternalCallHash;
|
|
3590
3603
|
private serializeOptionalBytes;
|
|
3604
|
+
private serializeDlnMetadata;
|
|
3591
3605
|
private serializeShortArray;
|
|
3606
|
+
private serializeAllowedSenders;
|
|
3592
3607
|
private serializeAddresses;
|
|
3593
3608
|
private serializeOptionalPubkey;
|
|
3594
3609
|
serialize(): Buffer;
|
|
@@ -3599,4 +3614,4 @@ declare class Intent implements Serializable {
|
|
|
3599
3614
|
};
|
|
3600
3615
|
}
|
|
3601
3616
|
|
|
3602
|
-
export { DEFAULT_RECORD_OFFSET, IDL, Intent, IntentsClient };
|
|
3617
|
+
export { DEFAULT_RECORD_OFFSET, IDL, Intent, IntentProgramSigPrefix, IntentsClient };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var anchor=require('@coral-xyz/anchor'),solanaUtils=require('@debridge-finance/solana-utils'),web3_js=require('@solana/web3.js'),splToken=require('@solana/spl-token'),splRecord=require('@solana/spl-record'),jsSha3=require('js-sha3');var R={address:"intV2u5xDE8T2ZMFP3W3X6sVqGHBT7zvYtTW3rRLmvE",metadata:{name:"intentsProgram",version:"0.0.0",spec:"0.1.0",description:"deBridge Intents Program"},instructions:[{name:"about",discriminator:[62,111,52,44,118,185,179,229],accounts:[],args:[]},{name:"approveProtocolTransfers",discriminator:[17,3,184,144,112,130,116,98],accounts:[{name:"maker",signer:true},{name:"state",pda:{seeds:[{kind:"const",value:[115,116,97,116,101]}]}},{name:"tokenProgram"}],args:[{name:"amounts",type:{vec:"u64"}}]},{name:"cancelIntent",discriminator:[67,73,238,244,208,89,225,59],accounts:[{name:"initiator",signer:true},{name:"intentStorage",writable:true},{name:"state"}],args:[]},{name:"closeAccount",discriminator:[125,255,149,14,110,34,72,24],accounts:[{name:"programAuthority",signer:true,address:"intV2u5xDE8T2ZMFP3W3X6sVqGHBT7zvYtTW3rRLmvE"},{name:"target",writable:true},{name:"rentReceiver",writable:true}],args:[]},{name:"closeIntent",discriminator:[112,245,154,249,57,126,54,122],accounts:[{name:"initiator",signer:true},{name:"maker",docs:["CHECK"]},{name:"makerInfo",writable:true,pda:{seeds:[{kind:"const",value:[109,97,107,101,114,95,105,110,102,111]},{kind:"account",path:"maker"}]}},{name:"rentPayer",writable:true},{name:"intentStorage",writable:true},{name:"state"},{name:"systemProgram",address:"11111111111111111111111111111111"}],args:[]},{name:"collectFee",discriminator:[60,173,247,103,4,93,130,48],accounts:[{name:"feeCollector",signer:true,relations:["state"]},{name:"state",pda:{seeds:[{kind:"const",value:[115,116,97,116,101]}]}},{name:"feeLedger",writable:true,pda:{seeds:[{kind:"account",path:"state"},{kind:"account",path:"tokenProgram"},{kind:"account",path:"mint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"destination",writable:true},{name:"mint"},{name:"tokenProgram"}],args:[{name:"amount",type:"u64"}]},{name:"executeIntent",discriminator:[53,130,47,154,227,220,122,212],accounts:[{name:"taker",writable:true,signer:true},{name:"state"},{name:"maker",relations:["intentStorage"]},{name:"makerInfo",writable:true,pda:{seeds:[{kind:"const",value:[109,97,107,101,114,95,105,110,102,111]},{kind:"account",path:"maker"}]}},{name:"intentStorage",writable:true},{name:"intentGiveToken",writable:true,pda:{seeds:[{kind:"account",path:"intentStorage"},{kind:"account",path:"tokenProgram"},{kind:"account",path:"tokenMint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"dlnSrc",address:"srch38nzfcgwJnfKE6xWD8vfNJtudazwisdcociAuQt"},{name:"dlnSrcState"},{name:"dlnSrcGiveOrderState",writable:true},{name:"dlnSrcGiveOrderWallet",writable:true},{name:"dlnSrcAuthorizedNativeSender"},{name:"dlnSrcFeeLedgerWallet",writable:true},{name:"tokenMint"},{name:"systemProgram",address:"11111111111111111111111111111111"},{name:"tokenProgram"},{name:"associatedTokenProgram",address:"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{name:"eventAuthority",pda:{seeds:[{kind:"const",value:[95,95,101,118,101,110,116,95,97,117,116,104,111,114,105,116,121]}]}},{name:"program"}],args:[{name:"dlnOrderArgs",type:{defined:{name:"createOrderArgs"}}},{name:"dlnOrderNonce",type:"u64"},{name:"dlnMetadata",type:"bytes"},{name:"tradeId",type:{array:["u8",32]}}]},{name:"executeIntent2",discriminator:[57,145,38,151,5,101,106,72],accounts:[{name:"taker",writable:true,signer:true},{name:"state",pda:{seeds:[{kind:"const",value:[115,116,97,116,101]}]}},{name:"maker",writable:true,relations:["intentStorage"]},{name:"makerInfo",writable:true,pda:{seeds:[{kind:"const",value:[109,97,107,101,114,95,105,110,102,111]},{kind:"account",path:"maker"}]}},{name:"intentStorage",writable:true},{name:"intentTakeToken",writable:true,pda:{seeds:[{kind:"account",path:"intentStorage"},{kind:"account",path:"tokenProgram"},{kind:"account",path:"tokenMint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"feeLedger",writable:true,pda:{seeds:[{kind:"account",path:"state"},{kind:"account",path:"tokenProgram"},{kind:"account",path:"tokenMint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"receiver"},{name:"receiverTakeToken",writable:true},{name:"tokenMint"},{name:"systemProgram",address:"11111111111111111111111111111111"},{name:"tokenProgram"},{name:"associatedTokenProgram",address:"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{name:"eventAuthority",pda:{seeds:[{kind:"const",value:[95,95,101,118,101,110,116,95,97,117,116,104,111,114,105,116,121]}]}},{name:"program"}],args:[{name:"amount",type:"u64"},{name:"tradeId",type:{array:["u8",32]}}]},{name:"initIntent",discriminator:[231,255,81,23,112,148,49,134],accounts:[{name:"maker",signer:true},{name:"rentPayer",writable:true,signer:true},{name:"state"},{name:"intentStorage",writable:true},{name:"systemProgram",address:"11111111111111111111111111111111"},{name:"eventAuthority",pda:{seeds:[{kind:"const",value:[95,95,101,118,101,110,116,95,97,117,116,104,111,114,105,116,121]}]}},{name:"program"}],args:[{name:"space",type:"u32"},{name:"encodedIntentHash",type:{defined:{name:"encodedIntentHash"}}}]},{name:"initIntentByDelegate",discriminator:[85,140,35,112,240,67,16,40],accounts:[{name:"delegate",signer:true},{name:"maker",docs:["CHECK"]},{name:"makerInfo",writable:true,pda:{seeds:[{kind:"const",value:[109,97,107,101,114,95,105,110,102,111]},{kind:"account",path:"maker"}]}},{name:"rentPayer",writable:true,signer:true},{name:"state"},{name:"intentStorage",writable:true},{name:"systemProgram",address:"11111111111111111111111111111111"},{name:"eventAuthority",pda:{seeds:[{kind:"const",value:[95,95,101,118,101,110,116,95,97,117,116,104,111,114,105,116,121]}]}},{name:"program"}],args:[{name:"space",type:"u32"},{name:"encodedIntentHash",type:{defined:{name:"encodedIntentHash"}}}]},{name:"initIntentByDelegateUsingSig",discriminator:[113,25,150,248,204,41,36,34],accounts:[{name:"delegate",docs:["CHECK"]},{name:"maker",docs:["CHECK"]},{name:"makerInfo",pda:{seeds:[{kind:"const",value:[109,97,107,101,114,95,105,110,102,111]},{kind:"account",path:"maker"}]}},{name:"rentPayer",writable:true,signer:true},{name:"state"},{name:"intentStorage",writable:true},{name:"systemProgram",address:"11111111111111111111111111111111"},{name:"eventAuthority",pda:{seeds:[{kind:"const",value:[95,95,101,118,101,110,116,95,97,117,116,104,111,114,105,116,121]}]}},{name:"program"}],args:[{name:"space",type:"u32"},{name:"encodedIntentHash",type:{defined:{name:"encodedIntentHash"}}},{name:"signature",type:{array:["u8",64]}}]},{name:"initIntentUsingSig",discriminator:[163,186,238,179,190,181,19,185],accounts:[{name:"maker",docs:["CHECK"]},{name:"rentPayer",writable:true,signer:true},{name:"state"},{name:"intentStorage",writable:true},{name:"systemProgram",address:"11111111111111111111111111111111"},{name:"eventAuthority",pda:{seeds:[{kind:"const",value:[95,95,101,118,101,110,116,95,97,117,116,104,111,114,105,116,121]}]}},{name:"program"}],args:[{name:"space",type:"u32"},{name:"encodedIntentHash",type:{defined:{name:"encodedIntentHash"}}},{name:"signature",type:{array:["u8",64]}}]},{name:"initState",discriminator:[124,213,73,136,80,37,141,54],accounts:[{name:"protocolAuthority",signer:true},{name:"programAuthority",signer:true,address:"intV2u5xDE8T2ZMFP3W3X6sVqGHBT7zvYtTW3rRLmvE"},{name:"rentPayer",writable:true,signer:true},{name:"state",writable:true,pda:{seeds:[{kind:"const",value:[115,116,97,116,101]}]}},{name:"systemProgram",address:"11111111111111111111111111111111"}],args:[]},{name:"reallocState",discriminator:[67,181,233,214,215,148,245,126],accounts:[{name:"inner",accounts:[{name:"protocolAuthority",signer:true,relations:["state"]},{name:"state",writable:true,pda:{seeds:[{kind:"const",value:[115,116,97,116,101]}]}}]},{name:"rentPayer",writable:true,signer:true},{name:"systemProgram",address:"11111111111111111111111111111111"}],args:[{name:"newSpace",type:"u32"}]},{name:"setCancelUntilTimestamp",discriminator:[206,248,194,176,4,206,30,228],accounts:[{name:"inner",accounts:[{name:"protocolAuthority",signer:true,relations:["state"]},{name:"state",writable:true,pda:{seeds:[{kind:"const",value:[115,116,97,116,101]}]}}]}],args:[{name:"cancelUntilTimestamp",type:"u64"}]},{name:"setDefaultFee",discriminator:[150,137,197,111,176,227,201,110],accounts:[{name:"inner",accounts:[{name:"protocolAuthority",signer:true,relations:["state"]},{name:"state",writable:true,pda:{seeds:[{kind:"const",value:[115,116,97,116,101]}]}}]},{name:"eventAuthority",pda:{seeds:[{kind:"const",value:[95,95,101,118,101,110,116,95,97,117,116,104,111,114,105,116,121]}]}},{name:"program"}],args:[{name:"defaultFeeBps",type:"u32"}]},{name:"setDelegateApprovedBudgets",discriminator:[82,182,181,250,30,186,95,15],accounts:[{name:"maker",signer:true},{name:"delegate"},{name:"rentPayer",writable:true,signer:true},{name:"makerInfo",writable:true,pda:{seeds:[{kind:"const",value:[109,97,107,101,114,95,105,110,102,111]},{kind:"account",path:"maker"}]}},{name:"state"},{name:"systemProgram",address:"11111111111111111111111111111111"}],args:[{name:"nonce",type:"u64"},{name:"approvedTokenBudgets",type:{defined:{name:"setApprovedTokenBudgets"}}}]},{name:"setDelegateApprovedBudgetsUsingSig",discriminator:[26,11,76,149,162,38,128,0],accounts:[{name:"maker"},{name:"delegate"},{name:"rentPayer",writable:true,signer:true},{name:"makerInfo",writable:true,pda:{seeds:[{kind:"const",value:[109,97,107,101,114,95,105,110,102,111]},{kind:"account",path:"maker"}]}},{name:"state"},{name:"systemProgram",address:"11111111111111111111111111111111"}],args:[{name:"nonce",type:"u64"},{name:"encodedApprovedTokenBudgets",type:"bytes"},{name:"signature",type:{array:["u8",64]}}]},{name:"setFeeCollector",discriminator:[143,46,10,113,121,157,245,166],accounts:[{name:"inner",accounts:[{name:"protocolAuthority",signer:true,relations:["state"]},{name:"state",writable:true,pda:{seeds:[{kind:"const",value:[115,116,97,116,101]}]}}]}],args:[{name:"feeCollector",type:"pubkey"}]},{name:"setMakerCancelUntilTimestamp",discriminator:[144,42,186,107,205,215,55,229],accounts:[{name:"maker",signer:true},{name:"rentPayer",writable:true,signer:true},{name:"makerInfo",writable:true,pda:{seeds:[{kind:"const",value:[109,97,107,101,114,95,105,110,102,111]},{kind:"account",path:"maker"}]}},{name:"state"},{name:"systemProgram",address:"11111111111111111111111111111111"}],args:[{name:"cancelUntilTimestamp",type:"u64"}]},{name:"setPause",discriminator:[63,32,154,2,56,103,79,45],accounts:[{name:"inner",accounts:[{name:"protocolAuthority",signer:true,relations:["state"]},{name:"state",writable:true,pda:{seeds:[{kind:"const",value:[115,116,97,116,101]}]}}]}],args:[{name:"pauseFlag",type:"bool"}]},{name:"setProtocolAuthority",discriminator:[96,162,46,152,72,147,175,176],accounts:[{name:"inner",accounts:[{name:"protocolAuthority",signer:true,relations:["state"]},{name:"state",writable:true,pda:{seeds:[{kind:"const",value:[115,116,97,116,101]}]}}]},{name:"newProtocolAuthority",signer:true}],args:[]},{name:"swapBegin",discriminator:[87,236,193,120,215,245,9,37],accounts:[{name:"taker",writable:true,signer:true},{name:"state",pda:{seeds:[{kind:"const",value:[115,116,97,116,101]}]}},{name:"maker",relations:["intentStorage"]},{name:"makerInfo",writable:true,pda:{seeds:[{kind:"const",value:[109,97,107,101,114,95,105,110,102,111]},{kind:"account",path:"maker"}]}},{name:"intentStorage",writable:true},{name:"inputMint"},{name:"outputMint"},{name:"makerInputToken",writable:true,pda:{seeds:[{kind:"account",path:"maker"},{kind:"account",path:"inputTokenProgram"},{kind:"account",path:"inputMint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"takerInputToken",writable:true,pda:{seeds:[{kind:"account",path:"taker"},{kind:"account",path:"inputTokenProgram"},{kind:"account",path:"inputMint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"takerOutputToken",writable:true,pda:{seeds:[{kind:"account",path:"taker"},{kind:"account",path:"outputTokenProgram"},{kind:"account",path:"outputMint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"intentOutputToken",writable:true},{name:"instructions",address:"Sysvar1nstructions1111111111111111111111111"},{name:"systemProgram",address:"11111111111111111111111111111111"},{name:"inputTokenProgram"},{name:"outputTokenProgram"},{name:"associatedTokenProgram",address:"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{name:"eventAuthority",pda:{seeds:[{kind:"const",value:[95,95,101,118,101,110,116,95,97,117,116,104,111,114,105,116,121]}]}},{name:"program"}],args:[{name:"amount",type:"u64"},{name:"target",type:{defined:{name:"targetTokenAccount"}}},{name:"tradeId",type:{array:["u8",32]}}]},{name:"swapEnd",discriminator:[75,178,142,132,50,126,38,31],accounts:[{name:"taker",writable:true,signer:true},{name:"state",pda:{seeds:[{kind:"const",value:[115,116,97,116,101]}]}},{name:"intentStorage",writable:true},{name:"inputMint"},{name:"outputMint"},{name:"takerOutputToken",writable:true,pda:{seeds:[{kind:"account",path:"taker"},{kind:"account",path:"outputTokenProgram"},{kind:"account",path:"outputMint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"intentOutputToken",writable:true,pda:{seeds:[{kind:"account",path:"intentStorage"},{kind:"account",path:"outputTokenProgram"},{kind:"account",path:"outputMint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"instructions",address:"Sysvar1nstructions1111111111111111111111111"},{name:"systemProgram",address:"11111111111111111111111111111111"},{name:"outputTokenProgram"},{name:"associatedTokenProgram",address:"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{name:"eventAuthority",pda:{seeds:[{kind:"const",value:[95,95,101,118,101,110,116,95,97,117,116,104,111,114,105,116,121]}]}},{name:"program"}],args:[{name:"expectedOutputTokenAmount",type:"u64"},{name:"takerSurplusShareBps",type:"u32"}]},{name:"updateIntent",discriminator:[214,203,249,158,90,27,54,17],accounts:[{name:"rentPayer",writable:true,signer:true},{name:"state"},{name:"intentStorage",writable:true},{name:"systemProgram",address:"11111111111111111111111111111111"},{name:"buffer",optional:true},{name:"eventAuthority",pda:{seeds:[{kind:"const",value:[95,95,101,118,101,110,116,95,97,117,116,104,111,114,105,116,121]}]}},{name:"program"}],args:[{name:"dataOrigin",type:{defined:{name:"dataOrigin"}}}]},{name:"withdrawIntentTokenAccount",discriminator:[188,114,123,239,223,164,242,101],accounts:[{name:"state"},{name:"maker",docs:["CHECK"]},{name:"intentStorage"},{name:"intentTokenAccount",writable:true,pda:{seeds:[{kind:"account",path:"intentStorage"},{kind:"account",path:"tokenProgram"},{kind:"account",path:"tokenMint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"makerTokenAccount",writable:true,pda:{seeds:[{kind:"account",path:"maker"},{kind:"account",path:"tokenProgram"},{kind:"account",path:"tokenMint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"rentReceiver",writable:true},{name:"tokenMint"},{name:"tokenProgram"},{name:"associatedTokenProgram",address:"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"}],args:[{name:"encodedIntentHash",type:{option:{defined:{name:"encodedIntentHash"}}}}]}],accounts:[{name:"intentStorage",discriminator:[175,239,93,146,246,119,144,249]},{name:"makerInfo",discriminator:[164,184,52,218,144,52,100,40]},{name:"state",discriminator:[216,146,107,94,104,75,182,177]}],events:[{name:"closedIntent",discriminator:[197,62,20,42,191,176,242,94]},{name:"fulfilled",discriminator:[210,174,131,213,40,182,83,110]},{name:"fulfilledDln",discriminator:[42,231,52,35,155,251,144,108]},{name:"intentBudgetSpent",discriminator:[106,148,20,168,115,89,145,56]},{name:"newIntent",discriminator:[101,118,73,187,15,74,57,97]},{name:"sealedIntent",discriminator:[28,191,234,161,83,32,138,137]},{name:"swapped",discriminator:[217,52,52,83,147,135,96,109]}],errors:[{code:6160,name:"invalidArgument"},{code:6170,name:"invalidAmount"},{code:6172,name:"malformedRemainingAccounts"},{code:16782961,name:"protocolPaused"},{code:16782979,name:"timeParadox"},{code:6234,name:"unknownCaller"},{code:6236,name:"unknownCancelAuthority"},{code:6079,name:"signatureVerificationFailed"},{code:6085,name:"intentIdMiscalculated"},{code:6086,name:"intentFromAnotherChain"},{code:6087,name:"intentSameChainOnly"},{code:6088,name:"intentInconsistentInputTokens"},{code:6089,name:"intentInconsistentGiveTokens"},{code:6096,name:"intentInconsistentTakeTokens"},{code:6097,name:"intentInconsitentReceivers"},{code:6098,name:"intentInconsitentDstAuthorities"},{code:6275,name:"intentStorageAlreadyInitialized"},{code:6276,name:"intentHashMismatch"},{code:6277,name:"intentStorageSealed"},{code:6278,name:"missedBufferAccount"},{code:6288,name:"intentNotReady"},{code:6289,name:"intentCancelled"},{code:6290,name:"intentExpired"},{code:6291,name:"intentInvalidatedByUser"},{code:6292,name:"intentInvalidatedByProtocolAuthority"},{code:6293,name:"expectedClosedIntent"},{code:6294,name:"expectedCancelledIntent"},{code:9664,name:"tokenAccountMissingProtocolDelegate"},{code:9665,name:"unknownInputToken"},{code:9666,name:"inputTokenAmountOutOfRange"},{code:9667,name:"inputTokenAmountExceedsBudget"},{code:9680,name:"takerNotAllowed"},{code:9681,name:"unknownRoute"},{code:9682,name:"priceViolation"},{code:9683,name:"invalidReceiver"},{code:9684,name:"readonlyReceiver"},{code:6101,name:"missedNativeUnwrapFlag"},{code:9793,name:"invalidDlnOrderTakeAmount"},{code:9794,name:"invalidDlnDstReceiver"},{code:9802,name:"invalidDlnDstOrderAuthority"},{code:9803,name:"invalidDlnDstAllowedTaker"},{code:9804,name:"invalidDlnSrcAllowedCancelBeneficiary"},{code:9805,name:"invalidDlnMetadata"},{code:9806,name:"invalidDlnExtcallHash"},{code:9788,name:"cantBeClosed"},{code:9787,name:"invalidTokenAccountRentReceiver"},{code:9839,name:"intentArbitraryDataOverflow"},{code:8832,name:"takerMustBeFixedWhenExtcallAllowed"},{code:8833,name:"ambiguousReceivers"},{code:9600,name:"interactionAccountNotFound"},{code:9601,name:"interactionProgramNotFound"},{code:6239,name:"interactionFixedAccountNotFound"},{code:9536,name:"unknownDelegate"},{code:9537,name:"delegateNonceMismatchNext"},{code:9546,name:"delegateHasNoApproval"},{code:9547,name:"delegateExceedsApprovedBudget"},{code:9550,name:"delegateApprovalExpired"},{code:9551,name:"delegateRevoked"},{code:16767137,name:"crossProgramInvokeRestricted"},{code:16770159,name:"crossProgramInvokeHasIntentsProgramAccount"}],types:[{name:"address",type:{kind:"type",alias:{vec:"u8"}}},{name:"approvedTokenBudget",type:{kind:"struct",fields:[{name:"tokenMint",type:"pubkey"},{name:"approvedAmount",type:"u64"},{name:"expiration",type:"u64"}]}},{name:"closedIntent",type:{kind:"struct",fields:[{name:"status",type:{defined:{name:"closedIntentStatus"}}}]}},{name:"closedIntentStatus",repr:{kind:"rust"},type:{kind:"enum",variants:[{name:"wiped"},{name:"terminated"}]}},{name:"createOrderArgs",docs:["Structure for forming a new order"],type:{kind:"struct",fields:[{name:"giveOriginalAmount",docs:["Input amount for `create order` call, that will be transferred from the user's wallet.","The dln commissions will be deducted from it and the resulting value will be used as [`Order::give.amount`]"],type:"u64"},{name:"take",docs:["Offer to take in destination chain"],type:{defined:{name:"offer"}}},{name:"receiverDst",docs:["Address in dst chain","Address of receiver_dst of tokens in target chain","or","address of external call executor if `external_call` presented"],type:{defined:{name:"address"}}},{name:"extcall",docs:["External call for automatically execution in target chain after execution of order"],type:{option:"bytes"}},{name:"givePatchAuthoritySrc",docs:["Address in source chain","Can call `patch_order_give` method of src program"],type:"pubkey"},{name:"allowedCancelBeneficiarySrc",docs:["Address in source chain","If the field is `Some`, then only this address can receive cancel"],type:{option:"pubkey"}},{name:"orderAuthorityAddressDst",docs:["Address in destination chain","Can `send_order_cancel`, `process_fallback` and `patch_order_take`"],type:{defined:{name:"address"}}},{name:"allowedTakerDst",docs:["Address in destination chain","If the field is `Some`, then only this address can call `fulfill_order` with this","order"],type:{option:{defined:{name:"address"}}}}]}},{name:"currentTokenBudget",type:{kind:"struct",fields:[{name:"tokenMint",type:"pubkey"},{name:"approvedAmount",type:"u64"},{name:"expiration",type:"u64"},{name:"remainingAmount",type:"u64"}]}},{name:"dataOrigin",type:{kind:"enum",variants:[{name:"instruction",fields:["bytes"]},{name:"buffer",fields:[{name:"offset",type:"u32"},{name:"length",type:"u32"}]}]}},{name:"delegateBudgets",type:{kind:"enum",variants:[{name:"any"},{name:"perToken",fields:[{vec:{defined:{name:"currentTokenBudget"}}}]},{name:"revoked"}]}},{name:"delegateInfo",type:{kind:"struct",fields:[{name:"delegate",type:"pubkey"},{name:"nonce",type:"u64"},{name:"budgets",type:{defined:{name:"delegateBudgets"}}}]}},{name:"encodedIntentHash",type:{kind:"struct",fields:[{array:["u8",32]}]}},{name:"fulfilled",type:{kind:"struct",fields:[{name:"intentId",type:{defined:{name:"intentId"}}},{name:"tradeId",type:{array:["u8",32]}},{name:"executionMetadata",type:{option:"bytes"}},{name:"takeToken",type:"pubkey"},{name:"takeTokenAmount",type:"u64"},{name:"takeTokenFeeAmount",type:"u64"}]}},{name:"fulfilledDln",type:{kind:"struct",fields:[{name:"intentId",type:{defined:{name:"intentId"}}},{name:"executionMetadata",type:{option:"bytes"}},{name:"tradeId",type:{array:["u8",32]}},{name:"orderId",type:{defined:{name:"u256"}}},{name:"giveTokenFeeAmount",type:"u64"}]}},{name:"intentBudget",type:{kind:"struct",fields:[{name:"mintIndex",type:"u8"},{name:"remainingAmount",type:"u64"}]}},{name:"intentBudgetSpent",type:{kind:"struct",fields:[{name:"intentId",type:{defined:{name:"intentId"}}},{name:"tradeId",type:{array:["u8",32]}},{name:"executionMetadata",type:{option:"bytes"}},{name:"inputToken",type:"pubkey"},{name:"inputTokenSpentAmount",type:"u64"}]}},{name:"intentBudgets",type:{kind:"struct",fields:[{vec:{defined:{name:"intentBudget"}}}]}},{name:"intentId",type:{kind:"struct",fields:[{array:["u8",32]}]}},{name:"intentStorage",type:{kind:"struct",fields:[{name:"maker",type:"pubkey"},{name:"delegate",type:{option:"pubkey"}},{name:"rentPayer",type:"pubkey"},{name:"arbitraryData",type:{array:["u8",100]}},{name:"encodedIntentHash",type:{defined:{name:"encodedIntentHash"}}},{name:"version",type:"u8"},{name:"storedIntent",type:{defined:{name:"storedIntent"}}},{name:"bump",type:"u8"}]}},{name:"makerInfo",type:{kind:"struct",fields:[{name:"cancelUntilTimestamp",type:"u64"},{name:"delegates",type:{vec:{defined:{name:"delegateInfo"}}}}]}},{name:"newIntent",type:{kind:"struct",fields:[{name:"intentId",type:{defined:{name:"intentId"}}}]}},{name:"offer",type:{kind:"struct",fields:[{name:"chainId",type:{defined:{name:"u256"}}},{name:"tokenAddress",type:{defined:{name:"address"}}},{name:"amount",type:{defined:{name:"u256"}}}]}},{name:"sealedIntent",type:{kind:"struct",fields:[{name:"intentId",type:{defined:{name:"intentId"}}},{name:"encodedIntent",type:"bytes"}]}},{name:"setApprovedTokenBudgets",type:{kind:"enum",variants:[{name:"set",fields:[{vec:{defined:{name:"approvedTokenBudget"}}}]},{name:"setAny"},{name:"revoke"}]}},{name:"state",type:{kind:"struct",fields:[{name:"protocolAuthority",type:"pubkey"},{name:"feeCollector",type:"pubkey"},{name:"defaultFeeBps",type:"u32"},{name:"isPaused",type:"bool"},{name:"cancelUntilTimestamp",type:"u64"},{name:"bump",type:"u8"}]}},{name:"storedIntent",type:{kind:"enum",variants:[{name:"uninitialized"},{name:"ready",fields:[{name:"encodedIntent",type:"bytes"},{name:"budgets",type:{defined:{name:"intentBudgets"}}}]},{name:"cancelled",fields:[{name:"encodedIntent",type:"bytes"},{name:"budgets",type:{defined:{name:"intentBudgets"}}}]}]}},{name:"swapped",type:{kind:"struct",fields:[{name:"intentId",type:{defined:{name:"intentId"}}},{name:"tradeId",type:{array:["u8",32]}},{name:"executionMetadata",type:{option:"bytes"}},{name:"inputToken",type:"pubkey"},{name:"inputTokenAmount",type:"u64"},{name:"outputToken",type:"pubkey"},{name:"outputTokenAmount",type:"u64"},{name:"takerOutputTokenShareAmount",type:"u64"}]}},{name:"targetTokenAccount",type:{kind:"enum",variants:[{name:"taker"},{name:"intent"}]}},{name:"u256",type:{kind:"type",alias:{array:["u8",32]}}}],constants:[{name:"budgetsSigPrefix",type:"bytes",value:"[98, 117, 100, 103, 101, 116, 115]"},{name:"clockDriftToleranceSecs",type:"u64",value:"300"},{name:"defaultFeeBps",type:"u32",value:"8"},{name:"intentIdHashPrefix",docs:["Used **only** as sub-seed for [IntentId][`crate::types::IntentId`]"],type:"bytes",value:"[105, 110, 116, 101, 110, 116, 95, 105, 100]"},{name:"intentProgramSigPrefix",type:"bytes",value:"[105, 110, 116, 101, 110, 116, 115, 95, 112, 114, 111, 103, 114, 97, 109]"},{name:"intentSigPrefix",type:"bytes",value:"[105, 110, 116, 101, 110, 116, 115]"},{name:"intentStorageBaseSeed",type:"bytes",value:"[105, 110, 116, 101, 110, 116, 95, 115, 116, 111, 114, 97, 103, 101]"},{name:"interactionCallAuthority",type:"bytes",value:"[105, 110, 116, 101, 114, 97, 99, 116, 105, 111, 110, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121]"},{name:"makerInfoSeed",type:"bytes",value:"[109, 97, 107, 101, 114, 95, 105, 110, 102, 111]"},{name:"stateSeed",type:"bytes",value:"[115, 116, 97, 116, 101]"},{name:"unwrapNativePseudoMint",type:"pubkey",value:"11111111111111111111111111111111"},{name:"unwrapNativeReceiverSeed",type:"bytes",value:"[117, 110, 119, 114, 97, 112, 95, 110, 97, 116, 105, 118, 101, 95, 114, 101, 99, 101, 105, 118, 101, 114]"}]};function G(c,e){let t;switch(e){case "u256":t=32;break;case "u64":t=8;break}return new anchor.BN(c.toString()).toArray("be",t)}var x=c=>{let e=[];return c?.limit&&e.push(web3_js.ComputeBudgetProgram.setComputeUnitLimit({units:c.limit})),c?.price&&e.push(web3_js.ComputeBudgetProgram.setComputeUnitPrice({microLamports:c.price})),e},k=({instructions:c,payer:e,blockhash:t,ALTs:n})=>new web3_js.VersionedTransaction(web3_js.MessageV0.compile({instructions:c,payerKey:e,recentBlockhash:t,addressLookupTableAccounts:n}));var E=splRecord.RECORD_META_DATA_SIZE,Z=class c{programId;idl;recordProgramId;_provider;_intentsProgram;_state;constructor(e,{programId:t,recordProgramId:n=splRecord.RECORD_PROGRAM_ID}){R.address=t.toString(),this.idl=R,this.programId=t,this.recordProgramId=n,this._provider=new anchor.AnchorProvider(e,{},{}),anchor.setProvider(this._provider),this._intentsProgram=new anchor.Program(R,this._provider),this._state=c.getStatePda(this._intentsProgram.programId);}getSpace(e,t){return 198+(1+e+(4+9*t))}async getState(e){let t=await e.getAccountInfo(this._state);if(!t)return null;let n=this._intentsProgram.coder.accounts.decode("state",t.data);return {...n,lastValidTimestamp:Number(n.lastValidTimestamp.toString())}}async getIntentStorage(e,t){let n=c.getIntentStoragePda(this._intentsProgram.programId,t),a=await e.getAccountInfo(n);if(!a)return null;let r=this._intentsProgram.coder.accounts.decode("intentStorage",a.data);return {...r,intentId:Buffer.from(r.intentId[0])}}async approveProtocolTransfersIxs({maker:e,tokens:t,tokenProgram:n=splToken.TOKEN_PROGRAM_ID}){let{amounts:a,accounts:r}=t.reduce(({amounts:s,accounts:i},{mint:o,amount:d})=>({amounts:s.concat(new anchor.BN(d.toString())),accounts:i.concat({pubkey:splToken.getAssociatedTokenAddressSync(o,e,true,n),isSigner:false,isWritable:true})}),{amounts:[],accounts:[]});return [await this._intentsProgram.methods.approveProtocolTransfers(a).accountsStrict({maker:e,state:this._state,tokenProgram:n}).remainingAccounts(r).instruction()]}async cancelIntentIxs(e,t){return [await this._intentsProgram.methods.cancelIntent().accountsStrict({initiator:e,intentStorage:c.getIntentStoragePda(this._intentsProgram.programId,t),state:this._state}).instruction()]}async closeIntentIxs(e,t,n){return [await this._intentsProgram.methods.closeIntent().accountsStrict({initiator:e,rentPayer:t,intentStorage:c.getIntentStoragePda(this._intentsProgram.programId,n),state:this._state,systemProgram:web3_js.SystemProgram.programId,makerInfo:c.getMakerInfoPda(this._intentsProgram.programId,e),maker:e}).instruction()]}async executeIntentIxs({tradeId:e,intentId:t,taker:n,maker:a,tokenMint:r,dlnOrder:s,dlnMetadata:i,dlnSrc:o=new web3_js.PublicKey(solanaUtils.programs.dlnSrc),tokenProgram:d=splToken.TOKEN_PROGRAM_ID}){let m=solanaUtils.dlnSrcResolver(o).methods,[u]=m.getStateAccount(),[p]=m.getGiveOrderStateAccount(s.id),[l]=m.getGiveOrderWalletAddress(s.id),[f]=m.getAuthorizedNativeSenderAddress(Buffer.from(new anchor.BN(s.dstChainId.toString()).toArray("be",32))),[g]=m.getFeeLedgerWalletAddress(r),y=c.getIntentStoragePda(this._intentsProgram.programId,t),b=splToken.getAssociatedTokenAddressSync(r,y,true,d),A={giveOriginalAmount:new anchor.BN(s.args.giveOriginalAmount.toString()),take:{amount:G(s.args.take.amount,"u256"),chainId:G(s.args.take.chainId,"u256"),tokenAddress:Array.from(s.args.take.tokenAddress)},receiverDst:Array.from(s.args.receiver),extcall:s.args.externalCall?.externalCallData?Buffer.from(s.args.externalCall.externalCallData):null,givePatchAuthoritySrc:s.args.givePatchAuthority,orderAuthorityAddressDst:Array.from(s.args.orderAuthorityDstAddress),allowedCancelBeneficiarySrc:s.args.allowedCancelBeneficiary,allowedTakerDst:s.args.allowedTaker?Array.from(s.args.allowedTaker):null};return [await this._intentsProgram.methods.executeIntent(A,new anchor.BN(s.nonce.toString()),i??Buffer.from([]),Array.from(e)).accountsStrict({taker:n,state:this._state,intentStorage:y,maker:a,makerInfo:c.getMakerInfoPda(this._intentsProgram.programId,a),intentGiveToken:b,dlnSrc:o,dlnSrcState:u,dlnSrcGiveOrderState:p,dlnSrcGiveOrderWallet:l,dlnSrcAuthorizedNativeSender:f,dlnSrcFeeLedgerWallet:g,tokenMint:r,systemProgram:web3_js.SystemProgram.programId,tokenProgram:d,associatedTokenProgram:splToken.ASSOCIATED_TOKEN_PROGRAM_ID,eventAuthority:c.getEventAuthorityPda(this._intentsProgram.programId),program:this._intentsProgram.programId}).instruction()]}async executeSameChainIntentIxs({tradeId:e,intentId:t,taker:n,maker:a,tokenMint:r,receiver:s,amount:i,tokenProgram:o=splToken.TOKEN_PROGRAM_ID,unwrapTakeToken:d}){let m,u=c.getIntentStoragePda(this._intentsProgram.programId,t),p=splToken.getAssociatedTokenAddressSync(r,u,true,o);d&&r.toBase58()===splToken.NATIVE_MINT.toBase58()?m=c.getNativePda(this._intentsProgram.programId):m=splToken.getAssociatedTokenAddressSync(r,s,true,o);let l=splToken.getAssociatedTokenAddressSync(r,this._state,true,o);return [await this._intentsProgram.methods.executeIntent2(new anchor.BN(i.toString()),Array.from(e)).accountsStrict({taker:n,state:this._state,maker:a,receiver:s,makerInfo:c.getMakerInfoPda(this._intentsProgram.programId,a),intentStorage:u,intentTakeToken:p,feeLedger:l,receiverTakeToken:m,tokenMint:r,systemProgram:web3_js.SystemProgram.programId,tokenProgram:o,associatedTokenProgram:splToken.ASSOCIATED_TOKEN_PROGRAM_ID,eventAuthority:c.getEventAuthorityPda(this._intentsProgram.programId),program:this._intentsProgram.programId}).instruction()]}async initIntentIxs(e,t,n=null,a,r,s,i){let o=this.getSpace(s,i);return [await(n?this._intentsProgram.methods.initIntentByDelegate(o,{0:Array.from(r)}):this._intentsProgram.methods.initIntent(o,{0:Array.from(r)})).accountsStrict({maker:e,...n&&{delegate:n,makerInfo:c.getMakerInfoPda(this._intentsProgram.programId,e)},rentPayer:t,state:this._state,intentStorage:c.getIntentStoragePda(this._intentsProgram.programId,a),systemProgram:web3_js.SystemProgram.programId,eventAuthority:c.getEventAuthorityPda(this._intentsProgram.programId),program:this._intentsProgram.programId}).instruction()]}async initIntentUsingSigIxs(e,t,n=null,a,r,s,i,o){let d=this.getSpace(s,i);return [await(n?this._intentsProgram.methods.initIntentByDelegateUsingSig(d,{0:Array.from(r)},Array.from(o)):this._intentsProgram.methods.initIntentUsingSig(d,{0:Array.from(r)},Array.from(o))).accountsStrict({...n&&{delegate:n,makerInfo:c.getMakerInfoPda(this._intentsProgram.programId,e)},maker:e,rentPayer:t,state:this._state,intentStorage:c.getIntentStoragePda(this._intentsProgram.programId,a),systemProgram:web3_js.SystemProgram.programId,eventAuthority:c.getEventAuthorityPda(this._intentsProgram.programId),program:this._intentsProgram.programId}).instruction()]}async setDelegateApprovedBudgetsIxs({maker:e,payer:t,delegate:n,nonce:a,tokens:r,signature:s}){let i;return "set"in r?i={set:{0:r.set.map(({tokenMint:d,approvedAmount:m,expiration:u})=>({tokenMint:d,approvedAmount:new anchor.BN(m.toString()),expiration:new anchor.BN(u.toString())}))}}:"setAny"in r?i={setAny:{}}:i={revoke:{}},[await(s?this._intentsProgram.methods.setDelegateApprovedBudgetsUsingSig(new anchor.BN(a.toString()),i,Array.from(s)):this._intentsProgram.methods.setDelegateApprovedBudgets(new anchor.BN(a.toString()),i)).accountsStrict({maker:e,delegate:n,rentPayer:t,state:this._state,makerInfo:c.getMakerInfoPda(this._intentsProgram.programId,e),systemProgram:web3_js.SystemProgram.programId}).instruction()]}async setMakerCancelUntilTimestampIxs({maker:e,payer:t,timestamp:n}){return [await this._intentsProgram.methods.setMakerCancelUntilTimestamp(new anchor.BN(n.toString())).accountsStrict({maker:e,rentPayer:t,state:this._state,makerInfo:c.getMakerInfoPda(this._intentsProgram.programId,e),systemProgram:web3_js.SystemProgram.programId}).instruction()]}async swapBeginIxs({taker:e,maker:t,intentId:n,tradeId:a,beginAmount:r,target:s,inputMint:i,outputMint:o,inputTokenProgram:d=splToken.TOKEN_PROGRAM_ID,outputTokenProgram:m=splToken.TOKEN_PROGRAM_ID}){let u=c.getIntentStoragePda(this._intentsProgram.programId,n),p=splToken.getAssociatedTokenAddressSync(i,t,true,d),l=splToken.getAssociatedTokenAddressSync(i,e,true,d),f=splToken.getAssociatedTokenAddressSync(o,e,true,m),g=splToken.getAssociatedTokenAddressSync(o,u,true,m);return [await this._intentsProgram.methods.swapBegin(new anchor.BN(r.toString()),s==="intent"?{intent:{}}:{taker:{}},Array.from(a)).accountsStrict({taker:e,maker:t,state:this._state,intentStorage:u,inputMint:i,outputMint:o,makerInputToken:p,takerInputToken:l,takerOutputToken:f,intentOutputToken:g,instructions:web3_js.SYSVAR_INSTRUCTIONS_PUBKEY,systemProgram:web3_js.SystemProgram.programId,inputTokenProgram:d,outputTokenProgram:m,associatedTokenProgram:splToken.ASSOCIATED_TOKEN_PROGRAM_ID,makerInfo:c.getMakerInfoPda(this._intentsProgram.programId,t),eventAuthority:c.getEventAuthorityPda(this._intentsProgram.programId),program:this._intentsProgram.programId}).instruction()]}async swapEndIxs({taker:e,intentId:t,endAmount:n,bps:a,inputMint:r,outputMint:s,outputTokenProgram:i=splToken.TOKEN_PROGRAM_ID}){let o=c.getIntentStoragePda(this._intentsProgram.programId,t),d=splToken.getAssociatedTokenAddressSync(s,e,true,i),m=splToken.getAssociatedTokenAddressSync(s,o,true,i);return [await this._intentsProgram.methods.swapEnd(new anchor.BN(n.toString()),a).accountsStrict({taker:e,state:this._state,intentStorage:o,inputMint:r,outputMint:s,takerOutputToken:d,intentOutputToken:m,instructions:web3_js.SYSVAR_INSTRUCTIONS_PUBKEY,systemProgram:web3_js.SystemProgram.programId,outputTokenProgram:i,associatedTokenProgram:splToken.ASSOCIATED_TOKEN_PROGRAM_ID,eventAuthority:c.getEventAuthorityPda(this._intentsProgram.programId),program:this._intentsProgram.programId}).instruction()]}async updateIntentIxs({payer:e,record:t,id:n,offset:a,length:r,data:s}){let i=c.getIntentStoragePda(this._intentsProgram.programId,n);return [await this._intentsProgram.methods.updateIntent(s?{instruction:[s]}:{buffer:{offset:a,length:r}}).accountsStrict({rentPayer:e,state:this._state,intentStorage:i,systemProgram:web3_js.SystemProgram.programId,buffer:t??null,eventAuthority:c.getEventAuthorityPda(this._intentsProgram.programId),program:this._intentsProgram.programId}).instruction()]}async withdrawIntentTokenAccountIxs({maker:e,receiver:t,id:n,encodedIntentHash:a,tokenMint:r,tokenProgram:s=splToken.TOKEN_PROGRAM_ID}){t||(t=e);let i=c.getIntentStoragePda(this._intentsProgram.programId,n),o=splToken.getAssociatedTokenAddressSync(r,i,true,s),d=splToken.getAssociatedTokenAddressSync(r,e,true,s);return [await this._intentsProgram.methods.withdrawIntentTokenAccount({0:Array.from(a)}).accountsStrict({state:this._state,maker:e,intentStorage:i,intentTokenAccount:o,makerTokenAccount:d,rentReceiver:t,tokenMint:r,tokenProgram:s,associatedTokenProgram:splToken.ASSOCIATED_TOKEN_PROGRAM_ID}).instruction()]}closeRecordIxs({record:e,authority:t,receiver:n}){return n||(n=t),[splRecord.createCloseAccountInstruction(e,t,n,this.recordProgramId)]}writeRecordIxs({authority:e,record:t,buffer:n,offset:a}){return [splRecord.createWriteInstruction(t,e,BigInt(a),n,this.recordProgramId)]}async reallocRecordIxs({authority:e,payer:t,record:n,buffer:a,offset:r}){t||(t=e);let s=await this._provider.connection.getAccountInfo(n);if(!s)throw new Error("Record account not found");let i=s.lamports,o=s.data.length,d=r+a.length,m=[];if(d>o){let p=await this._provider.connection.getMinimumBalanceForRentExemption(d+1)-i,l=web3_js.SystemProgram.transfer({fromPubkey:t,toPubkey:n,lamports:p});m.push(l);let f=splRecord.createReallocateInstruction(n,e,BigInt(d-E),this.recordProgramId);m.push(f);}return m}async initIntentTxs({authority:e,payer:t,delegate:n,intent:a,signature:r,blockhash:s,ALTs:i,computeBudget:o}){t||(t=e);let d,m=web3_js.Keypair.generate(),u=a.data,p=E+u.length,l=await this._provider.connection.getMinimumBalanceForRentExemption(p+1),f=x(o);r?d=await this.initIntentUsingSigIxs(e,t,n??null,a.id,a.hash,u.length,a.inputTokensLength,r):d=await this.initIntentIxs(e,t,n??null,a.id,a.hash,u.length,a.inputTokensLength);let g=web3_js.SystemProgram.createAccount({fromPubkey:t,newAccountPubkey:m.publicKey,lamports:l,space:p,programId:this.recordProgramId}),y=splRecord.createInitializeInstruction(m.publicKey,t,this.recordProgramId),b=k({instructions:[...f,...d,g,y],payer:t,blockhash:s,ALTs:i});return {record:m,txs:[b]}}async writeIntentTxs({authority:e,payer:t,record:n,intent:a,blockhash:r,ALTs:s,computeBudget:i}){t||(t=e);let o=[],d=a.data,m=d.length,u=x(i),p=this.closeRecordIxs({record:n,authority:t,receiver:t}),l=k({instructions:[...u,...await this.updateIntentIxs({payer:t,id:a.id,data:d}),...p],payer:t,blockhash:r,ALTs:s}),f=solanaUtils.txs.getTransactionSize(l);if(f&&f<=solanaUtils.constants.MAX_TX_SIZE)return [l];let g=0,y=[];for(;g<m;){let T,M=[...u],D=1,z=m-g,K=[],W=0;for(;D<=z;){let O=Math.floor((D+z)/2),J=d.subarray(g,g+O);T=this.writeRecordIxs({authority:t,record:n,buffer:J,offset:g});let Y=k({instructions:[...M,...T],payer:t,blockhash:r,ALTs:s}),N=solanaUtils.txs.getTransactionSize(Y);N&&N<=solanaUtils.constants.MAX_TX_SIZE?(K=T,W=O,D=O+1):z=O-1;}M.push(...K),y=M;let X=k({instructions:M,payer:t,blockhash:r,ALTs:s});o.push(X),g+=W;}let A=[...await this.updateIntentIxs({record:n,payer:t,id:a.id,offset:E,length:m}),...p],_=[...y,...A],C=k({instructions:_,payer:t,blockhash:r,ALTs:s}),w=solanaUtils.txs.getTransactionSize(C);if(w&&w<=solanaUtils.constants.MAX_TX_SIZE)o[o.length-1]=C;else {let T=k({instructions:A,payer:t,blockhash:r,ALTs:s});o.push(T);}return o}async createIntentTxs({authority:e,payer:t,delegate:n,intent:a,signature:r,blockhash:s,ALTs:i,computeBudget:o}){let{record:d,txs:m}=await this.initIntentTxs({authority:e,payer:t,delegate:n,intent:a,signature:r,blockhash:s,ALTs:i,computeBudget:o}),u=await this.writeIntentTxs({authority:e,payer:t,record:d.publicKey,intent:a,blockhash:s,ALTs:i,computeBudget:o});return {init:m,write:u,record:d}}async createAndUpdateIntentTxs({authority:e,payer:t,delegate:n,intent:a,signature:r,blockhash:s,ALTs:i,computeBudget:o}){t||(t=e);let d,m,u=x(o);r?d=await this.initIntentUsingSigIxs(e,t,n,a.id,a.hash,a.data?a.data.length:a.length,a.inputTokensLength,r):d=await this.initIntentIxs(e,t,n,a.id,a.hash,a.data?a.data.length:a.length,a.inputTokensLength),a.data?m=await this.updateIntentIxs({payer:t,id:a.id,data:a.data}):m=await this.updateIntentIxs({payer:t,record:a.record,id:a.id,offset:E+a.offset,length:a.length});let p=k({instructions:[...u,...d,...m],payer:t,blockhash:s,ALTs:i}),l=solanaUtils.txs.getTransactionSize(p);if(l&&l>solanaUtils.constants.MAX_TX_SIZE)throw new Error(`Tx size is ${l}, should be less than ${solanaUtils.constants.MAX_TX_SIZE}`);return [p]}async updateRecordTxs({authority:e,payer:t,record:n,serializedIntent:a,offset:r=E,blockhash:s,ALTs:i,computeBudget:o}){if(t||(t=e),r<E)throw new Error(`Offset can't be less than ${E}`);let d=[],m=a.length,u=await this.reallocRecordIxs({authority:e,payer:t,record:n,buffer:a,offset:r}),p=x(o),l=0;for(;l<m;){let f,g=[...p,...l===0?u:[]],y=1,b=m-l,A=[],_=0;for(;y<=b;){let w=Math.floor((y+b)/2),T=a.subarray(l,l+w);f=this.writeRecordIxs({authority:t,record:n,buffer:T,offset:l});let M=k({instructions:[...g,...f],payer:t,blockhash:s,ALTs:i}),D=solanaUtils.txs.getTransactionSize(M);D&&D<=solanaUtils.constants.MAX_TX_SIZE?(A=f,_=w,y=w+1):b=w-1;}g.push(...A);let C=k({instructions:g,payer:t,blockhash:s,ALTs:i});d.push(C),l+=_;}return d}async cancelIntentTxs({maker:e,payer:t,id:n,encodedIntentHash:a,tokenMint:r,tokenProgram:s=splToken.TOKEN_PROGRAM_ID,blockhash:i,ALTs:o,computeBudget:d}){t||(t=e);let m=x(d),u=await this.cancelIntentIxs(e,n);if(m.push(...u),r){let l=await this.withdrawIntentTokenAccountIxs({maker:e,receiver:t,id:n,encodedIntentHash:a,tokenMint:r,tokenProgram:s});m.push(...l);}return [k({instructions:m,payer:t,blockhash:i,ALTs:o})]}async closeIntentTxs({maker:e,payer:t,receiver:n,id:a,tokenMint:r,tokenProgram:s=splToken.TOKEN_PROGRAM_ID,blockhash:i,ALTs:o,computeBudget:d}){t||(t=e);let m=x(d),u=await this.closeIntentIxs(e,n??e,a);return m.push(...u),[k({instructions:m,payer:t,blockhash:i,ALTs:o})]}async swapTxs({taker:e,maker:t,intentId:n,tradeId:a,inputMint:r,outputMint:s,beginAmount:i,endAmount:o,bps:d,target:m,inputTokenProgram:u=splToken.TOKEN_PROGRAM_ID,outputTokenProgram:p=splToken.TOKEN_PROGRAM_ID,instructions:l=[],lastInstructions:f=[],computeBudget:g,payer:y,blockhash:b,ALTs:A}){y||(y=e);let _=x(g),C=await this.swapBeginIxs({taker:e,maker:t,intentId:n,tradeId:a,inputMint:r,outputMint:s,beginAmount:i,target:m,inputTokenProgram:u,outputTokenProgram:p}),w=await this.swapEndIxs({taker:e,intentId:n,endAmount:o,bps:d,inputMint:r,outputMint:s,outputTokenProgram:p});return [k({instructions:[..._,...C,...l,...w,...f],payer:y,blockhash:b,ALTs:A})]}static getStatePda(e){let[t]=web3_js.PublicKey.findProgramAddressSync([Buffer.from("state")],e);return t}static getIntentStoragePda(e,t){let[n]=web3_js.PublicKey.findProgramAddressSync([Buffer.from("intent_storage"),t],e);return n}static getMakerInfoPda(e,t){let[n]=web3_js.PublicKey.findProgramAddressSync([Buffer.from("maker_info"),t.toBuffer()],e);return n}static getDelegatesPda(e,t){let[n]=web3_js.PublicKey.findProgramAddressSync([Buffer.from("user_delegates"),t.toBuffer()],e);return n}static getEventAuthorityPda(e){let[t]=web3_js.PublicKey.findProgramAddressSync([Buffer.from("__event_authority")],e);return t}static getNativePda(e){let[t]=web3_js.PublicKey.findProgramAddressSync([Buffer.from("unwrap_native_receiver")],e);return t}static getBufferForIntentSignature(e,t=solanaUtils.constants.SOLANA_CHAIN_ID){let n=Buffer.from([105,110,116,101,110,116,115,95,112,114,111,103,114,97,109]),a=Buffer.alloc(4);a.writeUInt32LE(t,0);let r=Buffer.from([105,110,116,101,110,116,115]);return Buffer.concat([n,a,r,e])}};var H=class{addresses;lookupMap=new Map;constructor(e){this.addresses=e.map(t=>Buffer.from(t));}lookupIndex(e){let t=e.toString("hex"),n=this.lookupMap.get(t);if(n===void 0)throw new Error(`Address ${t} not found in AddressesList`);return n}serialize(){let e=new Map;for(let i of this.addresses){let o=e.get(i.length);o===void 0?e.set(i.length,[i]):o.push(i);}let t=Array.from(e.keys()).sort(),n=Buffer.alloc(t.reduce((i,o)=>i+e.get(o).length*o,0)+t.length*2+1);n[0]=t.length;let a=1,r=1+t.length*2,s=0;for(let i of t){let o=e.get(i).sort((m,u)=>m.compare(u));for(let m of o)this.lookupMap.set(m.toString("hex"),s),s+=1;n[a]=i,a+=1,n[a]=o.length,a+=1;let d=Buffer.concat(o);n.set(d,r),r+=d.length;}return n}};var q=class{data;addressesList;serializedList;constructor(e){this.data=e,this.addressesList=this.buildAddressesListFromIntent(e),this.serializedList=this.addressesList.serialize();}buildAddressesListFromIntent(e){let t=new Set,n=o=>t.add(o.toString("hex")),a=o=>{if(o)for(let{address:d}of o)n(d);},r=o=>{if(o)for(let d of o)d.input!=="any"&&n(d.input),n(d.output);},s=o=>{if(o){for(let d of o)if(n(d.input),d.output!=="any")for(let m of d.output)m.token&&m.token!=="any"&&n(m.token);}};for(let o of e.inputTokens)n(o.token);r(e.giveTokens),s(e.takeTokens),a(e.receiverDetails),a(e.dstAuthorityAddress);let i=Array.from(t).map(o=>Buffer.from(o,"hex"));return new H(i)}serializeReceiversInfo(e){if(!e||e.length===0)return Buffer.from([0]);let t=e.map(({chainIds:n,address:a})=>{let r;if(n==="any")r=Buffer.alloc(2),r.writeUInt8(this.addressesList.lookupIndex(a),0),r.writeUInt8(1,1);else {r=Buffer.alloc(3+n.length*4),r.writeUInt8(this.addressesList.lookupIndex(a),0),r.writeUInt8(0,1),r.writeUInt8(n.length,2);for(let[s,i]of n.entries())r.writeUInt32LE(i,3+s*4);}return r});return Buffer.concat([Buffer.from([t.length]),...t])}serializeInputTokens(){let e=this.data.inputTokens.map(t=>{let n=Buffer.alloc(25);return n[0]=this.addressesList.lookupIndex(t.token),n.writeBigUInt64LE(t.minPartialAmount,1),n.writeBigUInt64LE(t.maxPartialAmount,9),n.writeBigUInt64LE(t.constraintBudget,17),n});return Buffer.concat([Buffer.from([e.length]),...e])}serializeGiveTokens(e){if(!e||e.length===0)return Buffer.from([0]);let t=e.map(n=>{let a;if(n.input==="any")a=Buffer.alloc(2),a.writeUInt8(this.addressesList.lookupIndex(n.output),0),a.writeUInt8(1,1);else {a=Buffer.alloc(35),a.writeUInt8(this.addressesList.lookupIndex(n.output),0),a.writeUInt8(0,1),a.writeUInt8(this.addressesList.lookupIndex(n.input),2),a.writeBigInt64LE(n.price,3);let r=n.price.toString(16).padStart(64,"0");Buffer.from(r,"hex").copy(a,3);}return a});return Buffer.concat([Buffer.from([e.length]),...t])}serializeTakeTokens(e){let t=0,n=e.map(a=>{let r;return a.output==="any"?(t=1,r=Buffer.alloc(2),r.writeUInt8(this.addressesList.lookupIndex(a.input),0),r.writeUInt8(1,1)):(t+=a.output.length,r=Buffer.concat(a.output.map(s=>{if(s.token==="any"){let i=Buffer.alloc(6);return i.writeUInt8(0,0),i.writeUInt8(s.chainId,1),i.writeUInt8(1,5),Buffer.concat([Buffer.from([this.addressesList.lookupIndex(a.input)]),i])}else {let i;if(s.price==="any")i=Buffer.alloc(8),i.writeUInt8(0,0),i.writeUInt32LE(s.chainId,1),i.writeUInt8(0,5),i.writeUInt8(this.addressesList.lookupIndex(s.token),6),i.writeUInt8(1,7);else {i=Buffer.alloc(40),i.writeUInt8(0,0),i.writeUInt32LE(s.chainId,1),i.writeUInt8(0,5),i.writeUInt8(this.addressesList.lookupIndex(s.token),6),i.writeUInt8(0,7);let o=s.price.toString(16).padStart(64,"0");Buffer.from(o,"hex").copy(i,8);}return Buffer.concat([Buffer.from([this.addressesList.lookupIndex(a.input)]),i])}}))),r});return Buffer.concat([Buffer.from([t]),...n])}serializeOptionalBytes(e){return e?Buffer.concat([Buffer.from([1]),e]):Buffer.from([0])}serializeShortArray(e){if(!e)return Buffer.from([0]);let t=Buffer.alloc(2);return t.writeInt16LE(e.length,0),Buffer.concat([Buffer.from([1]),t,e])}serializeAddresses(e){return !e||e.length===0?Buffer.from([0]):Buffer.concat([Buffer.from([e.length]),...e])}serializeOptionalPubkey(e){return e?Buffer.concat([Buffer.from([1]),e.toBuffer()]):Buffer.from([0])}serialize(){let e=[],t=Buffer.alloc(4);t.writeUInt32LE(this.data.chainId,0),e.push(t),this.data.authority?e.push(Buffer.from([1]),this.data.authority.toBuffer()):e.push(Buffer.from([0]));let n=Buffer.alloc(16);return n.writeBigUInt64LE(BigInt(this.data.timestamp),0),n.writeBigUInt64LE(BigInt(this.data.expirationTimestamp),8),e.push(n),e.push(this.serializedList),e.push(this.serializeInputTokens()),e.push(this.serializeGiveTokens(this.data.giveTokens)),e.push(this.serializeTakeTokens(this.data.takeTokens)),e.push(this.serializeReceiversInfo(this.data.receiverDetails)),this.data.allowedSenders==="any"?e.push(Buffer.from([1])):e.push(Buffer.from([0]),this.serializeAddresses(this.data.allowedSenders)),e.push(this.serializeOptionalPubkey(this.data.preInteractions)),e.push(this.serializeOptionalPubkey(this.data.postInteractions)),e.push(this.serializeShortArray(this.data.validationRules)),e.push(this.serializeOptionalBytes(this.data.executionMetadataHash)),e.push(this.serializeAddresses(this.data.srcAllowedCancelBeneficiary)),e.push(this.serializeReceiversInfo(this.data.dstAuthorityAddress)),this.data.externalCallHash==="any"?e.push(Buffer.from([1]),Buffer.from([1])):this.data.externalCallHash?e.push(Buffer.from([1]),Buffer.from([0]),this.serializeOptionalBytes(this.data.externalCallHash)):e.push(Buffer.from([0])),this.data.dlnMetadata==="any"?e.push(Buffer.from([1]),Buffer.from([1])):this.data.dlnMetadata?e.push(Buffer.from([1]),Buffer.from([0]),this.serializeShortArray(this.data.dlnMetadata)):e.push(Buffer.from([0])),Buffer.concat(e)}static getId(e,t,n){let a=jsSha3.keccak256(e),r=Buffer.from(a,"hex"),[s]=web3_js.PublicKey.findProgramAddressSync([Buffer.from("intent_id"),t.toBuffer(),r],n);return {hex:`0x${s.toBuffer().toString("hex")}`,buffer:s.toBuffer(),rawHash:r}}};exports.DEFAULT_RECORD_OFFSET=E;exports.IDL=R;exports.Intent=q;exports.IntentsClient=Z;//# sourceMappingURL=index.js.map
|
|
1
|
+
'use strict';var anchor=require('@coral-xyz/anchor'),solanaUtils=require('@debridge-finance/solana-utils'),web3_js=require('@solana/web3.js'),splToken=require('@solana/spl-token'),splRecord=require('@solana/spl-record'),jsSha3=require('js-sha3');var R={address:"intV2u5xDE8T2ZMFP3W3X6sVqGHBT7zvYtTW3rRLmvE",metadata:{name:"intentsProgram",version:"0.0.0",spec:"0.1.0",description:"deBridge Intents Program"},instructions:[{name:"about",discriminator:[62,111,52,44,118,185,179,229],accounts:[],args:[]},{name:"approveProtocolTransfers",discriminator:[17,3,184,144,112,130,116,98],accounts:[{name:"maker",signer:true},{name:"state",pda:{seeds:[{kind:"const",value:[115,116,97,116,101]}]}},{name:"tokenProgram"}],args:[{name:"amounts",type:{vec:"u64"}}]},{name:"cancelIntent",discriminator:[67,73,238,244,208,89,225,59],accounts:[{name:"initiator",signer:true},{name:"intentStorage",writable:true},{name:"state"}],args:[]},{name:"closeAccount",discriminator:[125,255,149,14,110,34,72,24],accounts:[{name:"programAuthority",signer:true,address:"intV2u5xDE8T2ZMFP3W3X6sVqGHBT7zvYtTW3rRLmvE"},{name:"target",writable:true},{name:"rentReceiver",writable:true}],args:[]},{name:"closeIntent",discriminator:[112,245,154,249,57,126,54,122],accounts:[{name:"initiator",signer:true},{name:"maker",docs:["CHECK"]},{name:"makerInfo",writable:true,pda:{seeds:[{kind:"const",value:[109,97,107,101,114,95,105,110,102,111]},{kind:"account",path:"maker"}]}},{name:"rentPayer",writable:true},{name:"intentStorage",writable:true},{name:"state"},{name:"systemProgram",address:"11111111111111111111111111111111"}],args:[]},{name:"collectFee",discriminator:[60,173,247,103,4,93,130,48],accounts:[{name:"feeCollector",signer:true,relations:["state"]},{name:"state",pda:{seeds:[{kind:"const",value:[115,116,97,116,101]}]}},{name:"feeLedger",writable:true,pda:{seeds:[{kind:"account",path:"state"},{kind:"account",path:"tokenProgram"},{kind:"account",path:"mint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"destination",writable:true},{name:"mint"},{name:"tokenProgram"}],args:[{name:"amount",type:"u64"}]},{name:"executeIntent",discriminator:[53,130,47,154,227,220,122,212],accounts:[{name:"taker",writable:true,signer:true},{name:"state"},{name:"maker",relations:["intentStorage"]},{name:"makerInfo",writable:true,pda:{seeds:[{kind:"const",value:[109,97,107,101,114,95,105,110,102,111]},{kind:"account",path:"maker"}]}},{name:"intentStorage",writable:true},{name:"intentGiveToken",writable:true,pda:{seeds:[{kind:"account",path:"intentStorage"},{kind:"account",path:"tokenProgram"},{kind:"account",path:"tokenMint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"dlnSrc",address:"srch38nzfcgwJnfKE6xWD8vfNJtudazwisdcociAuQt"},{name:"dlnSrcState"},{name:"dlnSrcGiveOrderState",writable:true},{name:"dlnSrcGiveOrderWallet",writable:true},{name:"dlnSrcAuthorizedNativeSender"},{name:"dlnSrcFeeLedgerWallet",writable:true},{name:"tokenMint"},{name:"systemProgram",address:"11111111111111111111111111111111"},{name:"tokenProgram"},{name:"associatedTokenProgram",address:"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{name:"eventAuthority",pda:{seeds:[{kind:"const",value:[95,95,101,118,101,110,116,95,97,117,116,104,111,114,105,116,121]}]}},{name:"program"}],args:[{name:"dlnOrderArgs",type:{defined:{name:"createOrderArgs"}}},{name:"dlnOrderNonce",type:"u64"},{name:"dlnMetadata",type:"bytes"},{name:"tradeId",type:{array:["u8",32]}}]},{name:"executeIntent2",discriminator:[57,145,38,151,5,101,106,72],accounts:[{name:"taker",writable:true,signer:true},{name:"state",pda:{seeds:[{kind:"const",value:[115,116,97,116,101]}]}},{name:"maker",writable:true,relations:["intentStorage"]},{name:"makerInfo",writable:true,pda:{seeds:[{kind:"const",value:[109,97,107,101,114,95,105,110,102,111]},{kind:"account",path:"maker"}]}},{name:"intentStorage",writable:true},{name:"intentTakeToken",writable:true,pda:{seeds:[{kind:"account",path:"intentStorage"},{kind:"account",path:"tokenProgram"},{kind:"account",path:"tokenMint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"feeLedger",writable:true,pda:{seeds:[{kind:"account",path:"state"},{kind:"account",path:"tokenProgram"},{kind:"account",path:"tokenMint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"receiver"},{name:"receiverTakeToken",writable:true},{name:"tokenMint"},{name:"systemProgram",address:"11111111111111111111111111111111"},{name:"tokenProgram"},{name:"associatedTokenProgram",address:"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{name:"eventAuthority",pda:{seeds:[{kind:"const",value:[95,95,101,118,101,110,116,95,97,117,116,104,111,114,105,116,121]}]}},{name:"program"}],args:[{name:"amount",type:"u64"},{name:"tradeId",type:{array:["u8",32]}}]},{name:"initIntent",discriminator:[231,255,81,23,112,148,49,134],accounts:[{name:"maker",signer:true},{name:"rentPayer",writable:true,signer:true},{name:"state"},{name:"intentStorage",writable:true},{name:"systemProgram",address:"11111111111111111111111111111111"},{name:"eventAuthority",pda:{seeds:[{kind:"const",value:[95,95,101,118,101,110,116,95,97,117,116,104,111,114,105,116,121]}]}},{name:"program"}],args:[{name:"space",type:"u32"},{name:"encodedIntentHash",type:{defined:{name:"encodedIntentHash"}}}]},{name:"initIntentByDelegate",discriminator:[85,140,35,112,240,67,16,40],accounts:[{name:"delegate",signer:true},{name:"maker",docs:["CHECK"]},{name:"makerInfo",writable:true,pda:{seeds:[{kind:"const",value:[109,97,107,101,114,95,105,110,102,111]},{kind:"account",path:"maker"}]}},{name:"rentPayer",writable:true,signer:true},{name:"state"},{name:"intentStorage",writable:true},{name:"systemProgram",address:"11111111111111111111111111111111"},{name:"eventAuthority",pda:{seeds:[{kind:"const",value:[95,95,101,118,101,110,116,95,97,117,116,104,111,114,105,116,121]}]}},{name:"program"}],args:[{name:"space",type:"u32"},{name:"encodedIntentHash",type:{defined:{name:"encodedIntentHash"}}}]},{name:"initIntentByDelegateUsingSig",discriminator:[113,25,150,248,204,41,36,34],accounts:[{name:"delegate",docs:["CHECK"]},{name:"maker",docs:["CHECK"]},{name:"makerInfo",pda:{seeds:[{kind:"const",value:[109,97,107,101,114,95,105,110,102,111]},{kind:"account",path:"maker"}]}},{name:"rentPayer",writable:true,signer:true},{name:"state"},{name:"intentStorage",writable:true},{name:"systemProgram",address:"11111111111111111111111111111111"},{name:"eventAuthority",pda:{seeds:[{kind:"const",value:[95,95,101,118,101,110,116,95,97,117,116,104,111,114,105,116,121]}]}},{name:"program"}],args:[{name:"space",type:"u32"},{name:"encodedIntentHash",type:{defined:{name:"encodedIntentHash"}}},{name:"signature",type:{array:["u8",64]}}]},{name:"initIntentUsingSig",discriminator:[163,186,238,179,190,181,19,185],accounts:[{name:"maker",docs:["CHECK"]},{name:"rentPayer",writable:true,signer:true},{name:"state"},{name:"intentStorage",writable:true},{name:"systemProgram",address:"11111111111111111111111111111111"},{name:"eventAuthority",pda:{seeds:[{kind:"const",value:[95,95,101,118,101,110,116,95,97,117,116,104,111,114,105,116,121]}]}},{name:"program"}],args:[{name:"space",type:"u32"},{name:"encodedIntentHash",type:{defined:{name:"encodedIntentHash"}}},{name:"signature",type:{array:["u8",64]}}]},{name:"initState",discriminator:[124,213,73,136,80,37,141,54],accounts:[{name:"protocolAuthority",signer:true},{name:"programAuthority",signer:true,address:"intV2u5xDE8T2ZMFP3W3X6sVqGHBT7zvYtTW3rRLmvE"},{name:"rentPayer",writable:true,signer:true},{name:"state",writable:true,pda:{seeds:[{kind:"const",value:[115,116,97,116,101]}]}},{name:"systemProgram",address:"11111111111111111111111111111111"}],args:[]},{name:"reallocState",discriminator:[67,181,233,214,215,148,245,126],accounts:[{name:"inner",accounts:[{name:"protocolAuthority",signer:true,relations:["state"]},{name:"state",writable:true,pda:{seeds:[{kind:"const",value:[115,116,97,116,101]}]}}]},{name:"rentPayer",writable:true,signer:true},{name:"systemProgram",address:"11111111111111111111111111111111"}],args:[{name:"newSpace",type:"u32"}]},{name:"setCancelUntilTimestamp",discriminator:[206,248,194,176,4,206,30,228],accounts:[{name:"inner",accounts:[{name:"protocolAuthority",signer:true,relations:["state"]},{name:"state",writable:true,pda:{seeds:[{kind:"const",value:[115,116,97,116,101]}]}}]}],args:[{name:"cancelUntilTimestamp",type:"u64"}]},{name:"setDefaultFee",discriminator:[150,137,197,111,176,227,201,110],accounts:[{name:"inner",accounts:[{name:"protocolAuthority",signer:true,relations:["state"]},{name:"state",writable:true,pda:{seeds:[{kind:"const",value:[115,116,97,116,101]}]}}]},{name:"eventAuthority",pda:{seeds:[{kind:"const",value:[95,95,101,118,101,110,116,95,97,117,116,104,111,114,105,116,121]}]}},{name:"program"}],args:[{name:"defaultFeeBps",type:"u32"}]},{name:"setDelegateApprovedBudgets",discriminator:[82,182,181,250,30,186,95,15],accounts:[{name:"maker",signer:true},{name:"delegate"},{name:"rentPayer",writable:true,signer:true},{name:"makerInfo",writable:true,pda:{seeds:[{kind:"const",value:[109,97,107,101,114,95,105,110,102,111]},{kind:"account",path:"maker"}]}},{name:"state"},{name:"systemProgram",address:"11111111111111111111111111111111"}],args:[{name:"nonce",type:"u64"},{name:"approvedTokenBudgets",type:{defined:{name:"setApprovedTokenBudgets"}}}]},{name:"setDelegateApprovedBudgetsUsingSig",discriminator:[26,11,76,149,162,38,128,0],accounts:[{name:"maker"},{name:"delegate"},{name:"rentPayer",writable:true,signer:true},{name:"makerInfo",writable:true,pda:{seeds:[{kind:"const",value:[109,97,107,101,114,95,105,110,102,111]},{kind:"account",path:"maker"}]}},{name:"state"},{name:"systemProgram",address:"11111111111111111111111111111111"}],args:[{name:"nonce",type:"u64"},{name:"encodedApprovedTokenBudgets",type:"bytes"},{name:"signature",type:{array:["u8",64]}}]},{name:"setFeeCollector",discriminator:[143,46,10,113,121,157,245,166],accounts:[{name:"inner",accounts:[{name:"protocolAuthority",signer:true,relations:["state"]},{name:"state",writable:true,pda:{seeds:[{kind:"const",value:[115,116,97,116,101]}]}}]}],args:[{name:"feeCollector",type:"pubkey"}]},{name:"setMakerCancelUntilTimestamp",discriminator:[144,42,186,107,205,215,55,229],accounts:[{name:"maker",signer:true},{name:"rentPayer",writable:true,signer:true},{name:"makerInfo",writable:true,pda:{seeds:[{kind:"const",value:[109,97,107,101,114,95,105,110,102,111]},{kind:"account",path:"maker"}]}},{name:"state"},{name:"systemProgram",address:"11111111111111111111111111111111"}],args:[{name:"cancelUntilTimestamp",type:"u64"}]},{name:"setPause",discriminator:[63,32,154,2,56,103,79,45],accounts:[{name:"inner",accounts:[{name:"protocolAuthority",signer:true,relations:["state"]},{name:"state",writable:true,pda:{seeds:[{kind:"const",value:[115,116,97,116,101]}]}}]}],args:[{name:"pauseFlag",type:"bool"}]},{name:"setProtocolAuthority",discriminator:[96,162,46,152,72,147,175,176],accounts:[{name:"inner",accounts:[{name:"protocolAuthority",signer:true,relations:["state"]},{name:"state",writable:true,pda:{seeds:[{kind:"const",value:[115,116,97,116,101]}]}}]},{name:"newProtocolAuthority",signer:true}],args:[]},{name:"swapBegin",discriminator:[87,236,193,120,215,245,9,37],accounts:[{name:"taker",writable:true,signer:true},{name:"state",pda:{seeds:[{kind:"const",value:[115,116,97,116,101]}]}},{name:"maker",relations:["intentStorage"]},{name:"makerInfo",writable:true,pda:{seeds:[{kind:"const",value:[109,97,107,101,114,95,105,110,102,111]},{kind:"account",path:"maker"}]}},{name:"intentStorage",writable:true},{name:"inputMint"},{name:"outputMint"},{name:"makerInputToken",writable:true,pda:{seeds:[{kind:"account",path:"maker"},{kind:"account",path:"inputTokenProgram"},{kind:"account",path:"inputMint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"takerInputToken",writable:true,pda:{seeds:[{kind:"account",path:"taker"},{kind:"account",path:"inputTokenProgram"},{kind:"account",path:"inputMint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"takerOutputToken",writable:true,pda:{seeds:[{kind:"account",path:"taker"},{kind:"account",path:"outputTokenProgram"},{kind:"account",path:"outputMint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"intentOutputToken",writable:true},{name:"instructions",address:"Sysvar1nstructions1111111111111111111111111"},{name:"systemProgram",address:"11111111111111111111111111111111"},{name:"inputTokenProgram"},{name:"outputTokenProgram"},{name:"associatedTokenProgram",address:"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{name:"eventAuthority",pda:{seeds:[{kind:"const",value:[95,95,101,118,101,110,116,95,97,117,116,104,111,114,105,116,121]}]}},{name:"program"}],args:[{name:"amount",type:"u64"},{name:"target",type:{defined:{name:"targetTokenAccount"}}},{name:"tradeId",type:{array:["u8",32]}}]},{name:"swapEnd",discriminator:[75,178,142,132,50,126,38,31],accounts:[{name:"taker",writable:true,signer:true},{name:"state",pda:{seeds:[{kind:"const",value:[115,116,97,116,101]}]}},{name:"intentStorage",writable:true},{name:"inputMint"},{name:"outputMint"},{name:"takerOutputToken",writable:true,pda:{seeds:[{kind:"account",path:"taker"},{kind:"account",path:"outputTokenProgram"},{kind:"account",path:"outputMint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"intentOutputToken",writable:true,pda:{seeds:[{kind:"account",path:"intentStorage"},{kind:"account",path:"outputTokenProgram"},{kind:"account",path:"outputMint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"instructions",address:"Sysvar1nstructions1111111111111111111111111"},{name:"systemProgram",address:"11111111111111111111111111111111"},{name:"outputTokenProgram"},{name:"associatedTokenProgram",address:"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{name:"eventAuthority",pda:{seeds:[{kind:"const",value:[95,95,101,118,101,110,116,95,97,117,116,104,111,114,105,116,121]}]}},{name:"program"}],args:[{name:"expectedOutputTokenAmount",type:"u64"},{name:"takerSurplusShareBps",type:"u32"}]},{name:"updateIntent",discriminator:[214,203,249,158,90,27,54,17],accounts:[{name:"rentPayer",writable:true,signer:true},{name:"state"},{name:"intentStorage",writable:true},{name:"systemProgram",address:"11111111111111111111111111111111"},{name:"buffer",optional:true},{name:"eventAuthority",pda:{seeds:[{kind:"const",value:[95,95,101,118,101,110,116,95,97,117,116,104,111,114,105,116,121]}]}},{name:"program"}],args:[{name:"dataOrigin",type:{defined:{name:"dataOrigin"}}}]},{name:"withdrawIntentTokenAccount",discriminator:[188,114,123,239,223,164,242,101],accounts:[{name:"state"},{name:"maker",docs:["CHECK"]},{name:"intentStorage"},{name:"intentTokenAccount",writable:true,pda:{seeds:[{kind:"account",path:"intentStorage"},{kind:"account",path:"tokenProgram"},{kind:"account",path:"tokenMint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"makerTokenAccount",writable:true,pda:{seeds:[{kind:"account",path:"maker"},{kind:"account",path:"tokenProgram"},{kind:"account",path:"tokenMint"}],program:{kind:"const",value:[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{name:"rentReceiver",writable:true},{name:"tokenMint"},{name:"tokenProgram"},{name:"associatedTokenProgram",address:"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"}],args:[{name:"encodedIntentHash",type:{option:{defined:{name:"encodedIntentHash"}}}}]}],accounts:[{name:"intentStorage",discriminator:[175,239,93,146,246,119,144,249]},{name:"makerInfo",discriminator:[164,184,52,218,144,52,100,40]},{name:"state",discriminator:[216,146,107,94,104,75,182,177]}],events:[{name:"closedIntent",discriminator:[197,62,20,42,191,176,242,94]},{name:"fulfilled",discriminator:[210,174,131,213,40,182,83,110]},{name:"fulfilledDln",discriminator:[42,231,52,35,155,251,144,108]},{name:"intentBudgetSpent",discriminator:[106,148,20,168,115,89,145,56]},{name:"newIntent",discriminator:[101,118,73,187,15,74,57,97]},{name:"sealedIntent",discriminator:[28,191,234,161,83,32,138,137]},{name:"swapped",discriminator:[217,52,52,83,147,135,96,109]}],errors:[{code:6160,name:"invalidArgument"},{code:6170,name:"invalidAmount"},{code:6172,name:"malformedRemainingAccounts"},{code:16782961,name:"protocolPaused"},{code:16782979,name:"timeParadox"},{code:6234,name:"unknownCaller"},{code:6236,name:"unknownCancelAuthority"},{code:6079,name:"signatureVerificationFailed"},{code:6085,name:"intentIdMiscalculated"},{code:6086,name:"intentFromAnotherChain"},{code:6087,name:"intentSameChainOnly"},{code:6088,name:"intentInconsistentInputTokens"},{code:6089,name:"intentInconsistentGiveTokens"},{code:6096,name:"intentInconsistentTakeTokens"},{code:6097,name:"intentInconsitentReceivers"},{code:6098,name:"intentInconsitentDstAuthorities"},{code:6275,name:"intentStorageAlreadyInitialized"},{code:6276,name:"intentHashMismatch"},{code:6277,name:"intentStorageSealed"},{code:6278,name:"missedBufferAccount"},{code:6288,name:"intentNotReady"},{code:6289,name:"intentCancelled"},{code:6290,name:"intentExpired"},{code:6291,name:"intentInvalidatedByUser"},{code:6292,name:"intentInvalidatedByProtocolAuthority"},{code:6293,name:"expectedClosedIntent"},{code:6294,name:"expectedCancelledIntent"},{code:9664,name:"tokenAccountMissingProtocolDelegate"},{code:9665,name:"unknownInputToken"},{code:9666,name:"inputTokenAmountOutOfRange"},{code:9667,name:"inputTokenAmountExceedsBudget"},{code:9680,name:"takerNotAllowed"},{code:9681,name:"unknownRoute"},{code:9682,name:"priceViolation"},{code:9683,name:"invalidReceiver"},{code:9684,name:"readonlyReceiver"},{code:6101,name:"missedNativeUnwrapFlag"},{code:9793,name:"invalidDlnOrderTakeAmount"},{code:9794,name:"invalidDlnDstReceiver"},{code:9802,name:"invalidDlnDstOrderAuthority"},{code:9803,name:"invalidDlnDstAllowedTaker"},{code:9804,name:"invalidDlnSrcAllowedCancelBeneficiary"},{code:9805,name:"invalidDlnMetadata"},{code:9806,name:"invalidDlnExtcallHash"},{code:9788,name:"cantBeClosed"},{code:9787,name:"invalidTokenAccountRentReceiver"},{code:9839,name:"intentArbitraryDataOverflow"},{code:8832,name:"takerMustBeFixedWhenExtcallAllowed"},{code:8833,name:"ambiguousReceivers"},{code:9600,name:"interactionAccountNotFound"},{code:9601,name:"interactionProgramNotFound"},{code:6239,name:"interactionFixedAccountNotFound"},{code:9536,name:"unknownDelegate"},{code:9537,name:"delegateNonceMismatchNext"},{code:9546,name:"delegateHasNoApproval"},{code:9547,name:"delegateExceedsApprovedBudget"},{code:9550,name:"delegateApprovalExpired"},{code:9551,name:"delegateRevoked"},{code:16767137,name:"crossProgramInvokeRestricted"},{code:16770159,name:"crossProgramInvokeHasIntentsProgramAccount"}],types:[{name:"address",type:{kind:"type",alias:{vec:"u8"}}},{name:"approvedTokenBudget",type:{kind:"struct",fields:[{name:"tokenMint",type:"pubkey"},{name:"approvedAmount",type:"u64"},{name:"expiration",type:"u64"}]}},{name:"closedIntent",type:{kind:"struct",fields:[{name:"status",type:{defined:{name:"closedIntentStatus"}}}]}},{name:"closedIntentStatus",repr:{kind:"rust"},type:{kind:"enum",variants:[{name:"wiped"},{name:"terminated"}]}},{name:"createOrderArgs",docs:["Structure for forming a new order"],type:{kind:"struct",fields:[{name:"giveOriginalAmount",docs:["Input amount for `create order` call, that will be transferred from the user's wallet.","The dln commissions will be deducted from it and the resulting value will be used as [`Order::give.amount`]"],type:"u64"},{name:"take",docs:["Offer to take in destination chain"],type:{defined:{name:"offer"}}},{name:"receiverDst",docs:["Address in dst chain","Address of receiver_dst of tokens in target chain","or","address of external call executor if `external_call` presented"],type:{defined:{name:"address"}}},{name:"extcall",docs:["External call for automatically execution in target chain after execution of order"],type:{option:"bytes"}},{name:"givePatchAuthoritySrc",docs:["Address in source chain","Can call `patch_order_give` method of src program"],type:"pubkey"},{name:"allowedCancelBeneficiarySrc",docs:["Address in source chain","If the field is `Some`, then only this address can receive cancel"],type:{option:"pubkey"}},{name:"orderAuthorityAddressDst",docs:["Address in destination chain","Can `send_order_cancel`, `process_fallback` and `patch_order_take`"],type:{defined:{name:"address"}}},{name:"allowedTakerDst",docs:["Address in destination chain","If the field is `Some`, then only this address can call `fulfill_order` with this","order"],type:{option:{defined:{name:"address"}}}}]}},{name:"currentTokenBudget",type:{kind:"struct",fields:[{name:"tokenMint",type:"pubkey"},{name:"approvedAmount",type:"u64"},{name:"expiration",type:"u64"},{name:"remainingAmount",type:"u64"}]}},{name:"dataOrigin",type:{kind:"enum",variants:[{name:"instruction",fields:["bytes"]},{name:"buffer",fields:[{name:"offset",type:"u32"},{name:"length",type:"u32"}]}]}},{name:"delegateBudgets",type:{kind:"enum",variants:[{name:"any"},{name:"perToken",fields:[{vec:{defined:{name:"currentTokenBudget"}}}]},{name:"revoked"}]}},{name:"delegateInfo",type:{kind:"struct",fields:[{name:"delegate",type:"pubkey"},{name:"nonce",type:"u64"},{name:"budgets",type:{defined:{name:"delegateBudgets"}}}]}},{name:"encodedIntentHash",type:{kind:"struct",fields:[{array:["u8",32]}]}},{name:"fulfilled",type:{kind:"struct",fields:[{name:"intentId",type:{defined:{name:"intentId"}}},{name:"tradeId",type:{array:["u8",32]}},{name:"executionMetadata",type:{option:"bytes"}},{name:"takeToken",type:"pubkey"},{name:"takeTokenAmount",type:"u64"},{name:"takeTokenFeeAmount",type:"u64"}]}},{name:"fulfilledDln",type:{kind:"struct",fields:[{name:"intentId",type:{defined:{name:"intentId"}}},{name:"executionMetadata",type:{option:"bytes"}},{name:"tradeId",type:{array:["u8",32]}},{name:"orderId",type:{defined:{name:"u256"}}},{name:"giveTokenFeeAmount",type:"u64"}]}},{name:"intentBudget",type:{kind:"struct",fields:[{name:"mintIndex",type:"u8"},{name:"remainingAmount",type:"u64"}]}},{name:"intentBudgetSpent",type:{kind:"struct",fields:[{name:"intentId",type:{defined:{name:"intentId"}}},{name:"tradeId",type:{array:["u8",32]}},{name:"executionMetadata",type:{option:"bytes"}},{name:"inputToken",type:"pubkey"},{name:"inputTokenSpentAmount",type:"u64"}]}},{name:"intentBudgets",type:{kind:"struct",fields:[{vec:{defined:{name:"intentBudget"}}}]}},{name:"intentId",type:{kind:"struct",fields:[{array:["u8",32]}]}},{name:"intentStorage",type:{kind:"struct",fields:[{name:"maker",type:"pubkey"},{name:"delegate",type:{option:"pubkey"}},{name:"rentPayer",type:"pubkey"},{name:"arbitraryData",type:{array:["u8",100]}},{name:"encodedIntentHash",type:{defined:{name:"encodedIntentHash"}}},{name:"version",type:"u8"},{name:"storedIntent",type:{defined:{name:"storedIntent"}}},{name:"bump",type:"u8"}]}},{name:"makerInfo",type:{kind:"struct",fields:[{name:"cancelUntilTimestamp",type:"u64"},{name:"delegates",type:{vec:{defined:{name:"delegateInfo"}}}}]}},{name:"newIntent",type:{kind:"struct",fields:[{name:"intentId",type:{defined:{name:"intentId"}}}]}},{name:"offer",type:{kind:"struct",fields:[{name:"chainId",type:{defined:{name:"u256"}}},{name:"tokenAddress",type:{defined:{name:"address"}}},{name:"amount",type:{defined:{name:"u256"}}}]}},{name:"sealedIntent",type:{kind:"struct",fields:[{name:"intentId",type:{defined:{name:"intentId"}}},{name:"encodedIntent",type:"bytes"}]}},{name:"setApprovedTokenBudgets",type:{kind:"enum",variants:[{name:"set",fields:[{vec:{defined:{name:"approvedTokenBudget"}}}]},{name:"setAny"},{name:"revoke"}]}},{name:"state",type:{kind:"struct",fields:[{name:"protocolAuthority",type:"pubkey"},{name:"feeCollector",type:"pubkey"},{name:"defaultFeeBps",type:"u32"},{name:"isPaused",type:"bool"},{name:"cancelUntilTimestamp",type:"u64"},{name:"bump",type:"u8"}]}},{name:"storedIntent",type:{kind:"enum",variants:[{name:"uninitialized"},{name:"ready",fields:[{name:"encodedIntent",type:"bytes"},{name:"budgets",type:{defined:{name:"intentBudgets"}}}]},{name:"cancelled",fields:[{name:"encodedIntent",type:"bytes"},{name:"budgets",type:{defined:{name:"intentBudgets"}}}]}]}},{name:"swapped",type:{kind:"struct",fields:[{name:"intentId",type:{defined:{name:"intentId"}}},{name:"tradeId",type:{array:["u8",32]}},{name:"executionMetadata",type:{option:"bytes"}},{name:"inputToken",type:"pubkey"},{name:"inputTokenAmount",type:"u64"},{name:"outputToken",type:"pubkey"},{name:"outputTokenAmount",type:"u64"},{name:"takerOutputTokenShareAmount",type:"u64"}]}},{name:"targetTokenAccount",type:{kind:"enum",variants:[{name:"taker"},{name:"intent"}]}},{name:"u256",type:{kind:"type",alias:{array:["u8",32]}}}],constants:[{name:"budgetsSigPrefix",type:"bytes",value:"[98, 117, 100, 103, 101, 116, 115]"},{name:"clockDriftToleranceSecs",type:"u64",value:"300"},{name:"defaultFeeBps",type:"u32",value:"8"},{name:"intentIdHashPrefix",docs:["Used **only** as sub-seed for [IntentId][`crate::types::IntentId`]"],type:"bytes",value:"[105, 110, 116, 101, 110, 116, 95, 105, 100]"},{name:"intentProgramSigPrefix",type:"bytes",value:"[105, 110, 116, 101, 110, 116, 115, 95, 112, 114, 111, 103, 114, 97, 109]"},{name:"intentSigPrefix",type:"bytes",value:"[105, 110, 116, 101, 110, 116, 115]"},{name:"intentStorageBaseSeed",type:"bytes",value:"[105, 110, 116, 101, 110, 116, 95, 115, 116, 111, 114, 97, 103, 101]"},{name:"interactionCallAuthority",type:"bytes",value:"[105, 110, 116, 101, 114, 97, 99, 116, 105, 111, 110, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121]"},{name:"makerInfoSeed",type:"bytes",value:"[109, 97, 107, 101, 114, 95, 105, 110, 102, 111]"},{name:"stateSeed",type:"bytes",value:"[115, 116, 97, 116, 101]"},{name:"unwrapNativePseudoMint",type:"pubkey",value:"11111111111111111111111111111111"},{name:"unwrapNativeReceiverSeed",type:"bytes",value:"[117, 110, 119, 114, 97, 112, 95, 110, 97, 116, 105, 118, 101, 95, 114, 101, 99, 101, 105, 118, 101, 114]"}]};function N(m,e){let t;switch(e){case "u256":t=32;break;case "u64":t=8;break}return new anchor.BN(m.toString()).toArray("be",t)}var B=m=>{let e=[];return m?.limit&&e.push(web3_js.ComputeBudgetProgram.setComputeUnitLimit({units:m.limit})),m?.price&&e.push(web3_js.ComputeBudgetProgram.setComputeUnitPrice({microLamports:m.price})),e},k=({instructions:m,payer:e,blockhash:t,ALTs:a})=>new web3_js.VersionedTransaction(web3_js.MessageV0.compile({instructions:m,payerKey:e,recentBlockhash:t,addressLookupTableAccounts:a}));var he=(n=>(n.prod="intents_program",n.dubai="intents_program_dubai",n.hanoi="intents_program_hanoi",n.devnet="intents_program_devnet",n))(he||{}),C=splRecord.RECORD_META_DATA_SIZE,Y=class m{programId;idl;recordProgramId;_provider;_intentsProgram;_state;constructor(e,{programId:t,recordProgramId:a=splRecord.RECORD_PROGRAM_ID}){R.address=t.toString(),this.idl=R,this.programId=t,this.recordProgramId=a,this._provider=new anchor.AnchorProvider(e,{},{}),anchor.setProvider(this._provider),this._intentsProgram=new anchor.Program(R,this._provider),this._state=m.getStatePda(this._intentsProgram.programId);}getSpace(e,t){return 198+(1+e+(4+9*t))}async getState(e){let t=await e.getAccountInfo(this._state);if(!t)return null;let a=this._intentsProgram.coder.accounts.decode("state",t.data);return {...a,lastValidTimestamp:Number(a.lastValidTimestamp.toString())}}async getIntentStorage(e,t){let a=m.getIntentStoragePda(this._intentsProgram.programId,t),n=await e.getAccountInfo(a);if(!n)return null;let s=this._intentsProgram.coder.accounts.decode("intentStorage",n.data);return {...s,intentId:Buffer.from(s.intentId[0])}}async getMakerInfo(e,t){let a=m.getMakerInfoPda(this._intentsProgram.programId,t),n=await e.getAccountInfo(a);return n?this._intentsProgram.coder.accounts.decode("makerInfo",n.data):null}async getNonceForDelegate(e,t,a){let n=await this.getMakerInfo(e,t);if(!n)return 0n;for(let s of n.delegates)if(s.delegate.toBase58()===a.toBase58())return BigInt(s.nonce.toString());return 0n}async approveProtocolTransfersIxs({maker:e,tokens:t,tokenProgram:a=splToken.TOKEN_PROGRAM_ID}){let{amounts:n,accounts:s}=t.reduce(({amounts:i,accounts:o},{mint:r,amount:d})=>({amounts:i.concat(new anchor.BN(d.toString())),accounts:o.concat({pubkey:splToken.getAssociatedTokenAddressSync(r,e,true,a),isSigner:false,isWritable:true})}),{amounts:[],accounts:[]});return [await this._intentsProgram.methods.approveProtocolTransfers(n).accountsStrict({maker:e,state:this._state,tokenProgram:a}).remainingAccounts(s).instruction()]}async cancelIntentIxs(e,t){return [await this._intentsProgram.methods.cancelIntent().accountsStrict({initiator:e,intentStorage:m.getIntentStoragePda(this._intentsProgram.programId,t),state:this._state}).instruction()]}async closeIntentIxs(e,t,a){return [await this._intentsProgram.methods.closeIntent().accountsStrict({initiator:e,rentPayer:t,intentStorage:m.getIntentStoragePda(this._intentsProgram.programId,a),state:this._state,systemProgram:web3_js.SystemProgram.programId,makerInfo:m.getMakerInfoPda(this._intentsProgram.programId,e),maker:e}).instruction()]}async executeIntentIxs({tradeId:e,intentId:t,taker:a,maker:n,tokenMint:s,dlnOrder:i,dlnMetadata:o,dlnSrc:r=new web3_js.PublicKey(solanaUtils.programs.dlnSrc),tokenProgram:d=splToken.TOKEN_PROGRAM_ID}){let c=solanaUtils.dlnSrcResolver(r).methods,[u]=c.getStateAccount(),[p]=c.getGiveOrderStateAccount(i.id),[l]=c.getGiveOrderWalletAddress(i.id),[f]=c.getAuthorizedNativeSenderAddress(Buffer.from(new anchor.BN(i.dstChainId.toString()).toArray("be",32))),[g]=c.getFeeLedgerWalletAddress(s),y=m.getIntentStoragePda(this._intentsProgram.programId,t),v=splToken.getAssociatedTokenAddressSync(s,y,true,d),b={giveOriginalAmount:new anchor.BN(i.args.giveOriginalAmount.toString()),take:{amount:N(i.args.take.amount,"u256"),chainId:N(i.args.take.chainId,"u256"),tokenAddress:Array.from(i.args.take.tokenAddress)},receiverDst:Array.from(i.args.receiver),extcall:i.args.externalCall?.externalCallData?Buffer.from(i.args.externalCall.externalCallData):null,givePatchAuthoritySrc:i.args.givePatchAuthority,orderAuthorityAddressDst:Array.from(i.args.orderAuthorityDstAddress),allowedCancelBeneficiarySrc:i.args.allowedCancelBeneficiary,allowedTakerDst:i.args.allowedTaker?Array.from(i.args.allowedTaker):null};return [await this._intentsProgram.methods.executeIntent(b,new anchor.BN(i.nonce.toString()),o??Buffer.from([]),Array.from(e)).accountsStrict({taker:a,state:this._state,intentStorage:y,maker:n,makerInfo:m.getMakerInfoPda(this._intentsProgram.programId,n),intentGiveToken:v,dlnSrc:r,dlnSrcState:u,dlnSrcGiveOrderState:p,dlnSrcGiveOrderWallet:l,dlnSrcAuthorizedNativeSender:f,dlnSrcFeeLedgerWallet:g,tokenMint:s,systemProgram:web3_js.SystemProgram.programId,tokenProgram:d,associatedTokenProgram:splToken.ASSOCIATED_TOKEN_PROGRAM_ID,eventAuthority:m.getEventAuthorityPda(this._intentsProgram.programId),program:this._intentsProgram.programId}).instruction()]}async executeSameChainIntentIxs({tradeId:e,intentId:t,taker:a,maker:n,tokenMint:s,receiver:i,amount:o,tokenProgram:r=splToken.TOKEN_PROGRAM_ID,unwrapTakeToken:d}){let c=false,u,p=m.getIntentStoragePda(this._intentsProgram.programId,t),l=splToken.getAssociatedTokenAddressSync(s,p,true,r);d&&s.toBase58()===splToken.NATIVE_MINT.toBase58()?(u=m.getNativePda(this._intentsProgram.programId),c=true):u=splToken.getAssociatedTokenAddressSync(s,i,true,r);let f=splToken.getAssociatedTokenAddressSync(s,this._state,true,r),g=await this._intentsProgram.methods.executeIntent2(new anchor.BN(o.toString()),Array.from(e)).accountsStrict({taker:a,state:this._state,maker:n,receiver:i,makerInfo:m.getMakerInfoPda(this._intentsProgram.programId,n),intentStorage:p,intentTakeToken:l,feeLedger:f,receiverTakeToken:u,tokenMint:s,systemProgram:web3_js.SystemProgram.programId,tokenProgram:r,associatedTokenProgram:splToken.ASSOCIATED_TOKEN_PROGRAM_ID,eventAuthority:m.getEventAuthorityPda(this._intentsProgram.programId),program:this._intentsProgram.programId}).instruction();if(c){let y=g.keys.findIndex(v=>v.pubkey==i);g.keys[y].isWritable=true;}return [g]}async initIntentIxs(e,t,a=null,n,s,i,o){let r=this.getSpace(i,o);return [await(a?this._intentsProgram.methods.initIntentByDelegate(r,{0:Array.from(s)}):this._intentsProgram.methods.initIntent(r,{0:Array.from(s)})).accountsStrict({maker:e,...a&&{delegate:a,makerInfo:m.getMakerInfoPda(this._intentsProgram.programId,e)},rentPayer:t,state:this._state,intentStorage:m.getIntentStoragePda(this._intentsProgram.programId,n),systemProgram:web3_js.SystemProgram.programId,eventAuthority:m.getEventAuthorityPda(this._intentsProgram.programId),program:this._intentsProgram.programId}).instruction()]}async initIntentUsingSigIxs(e,t,a=null,n,s,i,o,r){let d=this.getSpace(i,o);return [await(a?this._intentsProgram.methods.initIntentByDelegateUsingSig(d,{0:Array.from(s)},Array.from(r)):this._intentsProgram.methods.initIntentUsingSig(d,{0:Array.from(s)},Array.from(r))).accountsStrict({...a&&{delegate:a,makerInfo:m.getMakerInfoPda(this._intentsProgram.programId,e)},maker:e,rentPayer:t,state:this._state,intentStorage:m.getIntentStoragePda(this._intentsProgram.programId,n),systemProgram:web3_js.SystemProgram.programId,eventAuthority:m.getEventAuthorityPda(this._intentsProgram.programId),program:this._intentsProgram.programId}).instruction()]}async setDelegateApprovedBudgetsIxs({maker:e,payer:t,delegate:a,nonce:n,tokens:s,signature:i}){let o=m.getDelegateApprovedBudgetsArgs(s),r=this._intentsProgram.coder.types.encode("setApprovedTokenBudgets",o);return [await(i?this._intentsProgram.methods.setDelegateApprovedBudgetsUsingSig(new anchor.BN(n.toString()),r,Array.from(i)):this._intentsProgram.methods.setDelegateApprovedBudgets(new anchor.BN(n.toString()),o)).accountsStrict({maker:e,delegate:a,rentPayer:t,state:this._state,makerInfo:m.getMakerInfoPda(this._intentsProgram.programId,e),systemProgram:web3_js.SystemProgram.programId}).instruction()]}async setMakerCancelUntilTimestampIxs({maker:e,payer:t,timestamp:a}){return [await this._intentsProgram.methods.setMakerCancelUntilTimestamp(new anchor.BN(a.toString())).accountsStrict({maker:e,rentPayer:t,state:this._state,makerInfo:m.getMakerInfoPda(this._intentsProgram.programId,e),systemProgram:web3_js.SystemProgram.programId}).instruction()]}async swapBeginIxs({taker:e,maker:t,intentId:a,tradeId:n,beginAmount:s,target:i,inputMint:o,outputMint:r,inputTokenProgram:d=splToken.TOKEN_PROGRAM_ID,outputTokenProgram:c=splToken.TOKEN_PROGRAM_ID}){let u=m.getIntentStoragePda(this._intentsProgram.programId,a),p=splToken.getAssociatedTokenAddressSync(o,t,true,d),l=splToken.getAssociatedTokenAddressSync(o,e,true,d),f=splToken.getAssociatedTokenAddressSync(r,e,true,c),g=splToken.getAssociatedTokenAddressSync(r,u,true,c);return [await this._intentsProgram.methods.swapBegin(new anchor.BN(s.toString()),i==="intent"?{intent:{}}:{taker:{}},Array.from(n)).accountsStrict({taker:e,maker:t,state:this._state,intentStorage:u,inputMint:o,outputMint:r,makerInputToken:p,takerInputToken:l,takerOutputToken:f,intentOutputToken:g,instructions:web3_js.SYSVAR_INSTRUCTIONS_PUBKEY,systemProgram:web3_js.SystemProgram.programId,inputTokenProgram:d,outputTokenProgram:c,associatedTokenProgram:splToken.ASSOCIATED_TOKEN_PROGRAM_ID,makerInfo:m.getMakerInfoPda(this._intentsProgram.programId,t),eventAuthority:m.getEventAuthorityPda(this._intentsProgram.programId),program:this._intentsProgram.programId}).instruction()]}async swapEndIxs({taker:e,intentId:t,endAmount:a,bps:n,inputMint:s,outputMint:i,outputTokenProgram:o=splToken.TOKEN_PROGRAM_ID}){let r=m.getIntentStoragePda(this._intentsProgram.programId,t),d=splToken.getAssociatedTokenAddressSync(i,e,true,o),c=splToken.getAssociatedTokenAddressSync(i,r,true,o);return [await this._intentsProgram.methods.swapEnd(new anchor.BN(a.toString()),n).accountsStrict({taker:e,state:this._state,intentStorage:r,inputMint:s,outputMint:i,takerOutputToken:d,intentOutputToken:c,instructions:web3_js.SYSVAR_INSTRUCTIONS_PUBKEY,systemProgram:web3_js.SystemProgram.programId,outputTokenProgram:o,associatedTokenProgram:splToken.ASSOCIATED_TOKEN_PROGRAM_ID,eventAuthority:m.getEventAuthorityPda(this._intentsProgram.programId),program:this._intentsProgram.programId}).instruction()]}async updateIntentIxs({payer:e,record:t,id:a,offset:n,length:s,data:i}){let o=m.getIntentStoragePda(this._intentsProgram.programId,a);return [await this._intentsProgram.methods.updateIntent(i?{instruction:[i]}:{buffer:{offset:n,length:s}}).accountsStrict({rentPayer:e,state:this._state,intentStorage:o,systemProgram:web3_js.SystemProgram.programId,buffer:t??null,eventAuthority:m.getEventAuthorityPda(this._intentsProgram.programId),program:this._intentsProgram.programId}).instruction()]}async withdrawIntentTokenAccountIxs({maker:e,receiver:t,id:a,encodedIntentHash:n,tokenMint:s,tokenProgram:i=splToken.TOKEN_PROGRAM_ID}){t||(t=e);let o=m.getIntentStoragePda(this._intentsProgram.programId,a),r=splToken.getAssociatedTokenAddressSync(s,o,true,i),d=splToken.getAssociatedTokenAddressSync(s,e,true,i);return [await this._intentsProgram.methods.withdrawIntentTokenAccount({0:Array.from(n)}).accountsStrict({state:this._state,maker:e,intentStorage:o,intentTokenAccount:r,makerTokenAccount:d,rentReceiver:t,tokenMint:s,tokenProgram:i,associatedTokenProgram:splToken.ASSOCIATED_TOKEN_PROGRAM_ID}).instruction()]}closeRecordIxs({record:e,authority:t,receiver:a}){return a||(a=t),[splRecord.createCloseAccountInstruction(e,t,a,this.recordProgramId)]}writeRecordIxs({authority:e,record:t,buffer:a,offset:n}){return [splRecord.createWriteInstruction(t,e,BigInt(n),a,this.recordProgramId)]}async reallocRecordIxs({authority:e,payer:t,record:a,buffer:n,offset:s}){t||(t=e);let i=await this._provider.connection.getAccountInfo(a);if(!i)throw new Error("Record account not found");let o=i.lamports,r=i.data.length,d=s+n.length,c=[];if(d>r){let p=await this._provider.connection.getMinimumBalanceForRentExemption(d+1)-o,l=web3_js.SystemProgram.transfer({fromPubkey:t,toPubkey:a,lamports:p});c.push(l);let f=splRecord.createReallocateInstruction(a,e,BigInt(d-C),this.recordProgramId);c.push(f);}return c}async initIntentTxs({authority:e,payer:t,delegate:a,intent:n,signature:s,blockhash:i,ALTs:o,computeBudget:r}){t||(t=e);let d,c=web3_js.Keypair.generate(),u=n.data,p=C+u.length,l=await this._provider.connection.getMinimumBalanceForRentExemption(p+1),f=B(r);s?d=await this.initIntentUsingSigIxs(e,t,a??null,n.id,n.hash,u.length,n.inputTokensLength,s):d=await this.initIntentIxs(e,t,a??null,n.id,n.hash,u.length,n.inputTokensLength);let g=web3_js.SystemProgram.createAccount({fromPubkey:t,newAccountPubkey:c.publicKey,lamports:l,space:p,programId:this.recordProgramId}),y=splRecord.createInitializeInstruction(c.publicKey,t,this.recordProgramId),v=k({instructions:[...f,...d,g,y],payer:t,blockhash:i,ALTs:o});return {record:c,txs:[v]}}async writeIntentTxs({authority:e,payer:t,record:a,intent:n,blockhash:s,ALTs:i,computeBudget:o}){t||(t=e);let r=[],d=n.data,c=d.length,u=B(o),p=this.closeRecordIxs({record:a,authority:t,receiver:t}),l=k({instructions:[...u,...await this.updateIntentIxs({payer:t,id:n.id,data:d}),...p],payer:t,blockhash:s,ALTs:i}),f=solanaUtils.txs.getTransactionSize(l);if(f&&f<=solanaUtils.constants.MAX_TX_SIZE)return [l];let g=0,y=[];for(;g<c;){let S,U=[...u],L=1,G=c-g,V=[],Z=0;for(;L<=G;){let H=Math.floor((L+G)/2),j=d.subarray(g,g+H);S=this.writeRecordIxs({authority:t,record:a,buffer:j,offset:g});let ee=k({instructions:[...U,...S],payer:t,blockhash:s,ALTs:i}),q=solanaUtils.txs.getTransactionSize(ee);q&&q<=solanaUtils.constants.MAX_TX_SIZE?(V=S,Z=H,L=H+1):G=H-1;}U.push(...V),y=U;let Q=k({instructions:U,payer:t,blockhash:s,ALTs:i});r.push(Q),g+=Z;}let b=[...await this.updateIntentIxs({record:a,payer:t,id:n.id,offset:C,length:c}),...p],D=[...y,...b],M=k({instructions:D,payer:t,blockhash:s,ALTs:i}),w=solanaUtils.txs.getTransactionSize(M);if(w&&w<=solanaUtils.constants.MAX_TX_SIZE)r[r.length-1]=M;else {let S=k({instructions:b,payer:t,blockhash:s,ALTs:i});r.push(S);}return r}async createIntentTxs({authority:e,payer:t,delegate:a,intent:n,signature:s,blockhash:i,ALTs:o,computeBudget:r}){let{record:d,txs:c}=await this.initIntentTxs({authority:e,payer:t,delegate:a,intent:n,signature:s,blockhash:i,ALTs:o,computeBudget:r}),u=await this.writeIntentTxs({authority:e,payer:t,record:d.publicKey,intent:n,blockhash:i,ALTs:o,computeBudget:r});return {init:c,write:u,record:d}}async createAndUpdateIntentTxs({maker:e,payer:t,delegate:a,intent:n,signature:s,blockhash:i,ALTs:o,computeBudget:r}){t||(t=e);let d,c,u=B(r);s?d=await this.initIntentUsingSigIxs(e,t,a,n.id,n.hash,n.data?n.data.length:n.length,n.inputTokensLength,s):d=await this.initIntentIxs(e,t,a,n.id,n.hash,n.data?n.data.length:n.length,n.inputTokensLength),n.data?c=await this.updateIntentIxs({payer:t,id:n.id,data:n.data}):c=await this.updateIntentIxs({payer:t,record:n.record,id:n.id,offset:C+n.offset,length:n.length});let p=k({instructions:[...u,...d,...c],payer:t,blockhash:i,ALTs:o}),l=solanaUtils.txs.getTransactionSize(p);if(l&&l>solanaUtils.constants.MAX_TX_SIZE)throw new Error(`Tx size is ${l}, should be less than ${solanaUtils.constants.MAX_TX_SIZE}`);return [p]}async updateRecordTxs({authority:e,payer:t,record:a,serializedIntent:n,offset:s=C,blockhash:i,ALTs:o,computeBudget:r}){if(t||(t=e),s<C)throw new Error(`Offset can't be less than ${C}`);let d=[],c=n.length,u=await this.reallocRecordIxs({authority:e,payer:t,record:a,buffer:n,offset:s}),p=B(r),l=0;for(;l<c;){let f,g=[...p,...l===0?u:[]],y=1,v=c-l,b=[],D=0;for(;y<=v;){let w=Math.floor((y+v)/2),S=n.subarray(l,l+w);f=this.writeRecordIxs({authority:t,record:a,buffer:S,offset:l});let U=k({instructions:[...g,...f],payer:t,blockhash:i,ALTs:o}),L=solanaUtils.txs.getTransactionSize(U);L&&L<=solanaUtils.constants.MAX_TX_SIZE?(b=f,D=w,y=w+1):v=w-1;}g.push(...b);let M=k({instructions:g,payer:t,blockhash:i,ALTs:o});d.push(M),l+=D;}return d}async cancelIntentTxs({maker:e,payer:t,id:a,encodedIntentHash:n,tokenMint:s,tokenProgram:i=splToken.TOKEN_PROGRAM_ID,blockhash:o,ALTs:r,computeBudget:d}){t||(t=e);let c=B(d),u=await this.cancelIntentIxs(e,a);if(c.push(...u),s){let l=await this.withdrawIntentTokenAccountIxs({maker:e,receiver:t,id:a,encodedIntentHash:n,tokenMint:s,tokenProgram:i});c.push(...l);}return [k({instructions:c,payer:t,blockhash:o,ALTs:r})]}async closeIntentTxs({maker:e,payer:t,receiver:a,id:n,tokenMint:s,tokenProgram:i=splToken.TOKEN_PROGRAM_ID,blockhash:o,ALTs:r,computeBudget:d}){t||(t=e);let c=B(d),u=await this.closeIntentIxs(e,a??e,n);return c.push(...u),[k({instructions:c,payer:t,blockhash:o,ALTs:r})]}async swapTxs({taker:e,maker:t,intentId:a,tradeId:n,inputMint:s,outputMint:i,beginAmount:o,endAmount:r,bps:d,target:c,inputTokenProgram:u=splToken.TOKEN_PROGRAM_ID,outputTokenProgram:p=splToken.TOKEN_PROGRAM_ID,instructions:l=[],lastInstructions:f=[],computeBudget:g,payer:y,blockhash:v,ALTs:b}){y||(y=e);let D=B(g),M=await this.swapBeginIxs({taker:e,maker:t,intentId:a,tradeId:n,inputMint:s,outputMint:i,beginAmount:o,target:c,inputTokenProgram:u,outputTokenProgram:p}),w=await this.swapEndIxs({taker:e,intentId:a,endAmount:r,bps:d,inputMint:s,outputMint:i,outputTokenProgram:p});return [k({instructions:[...D,...M,...l,...w,...f],payer:y,blockhash:v,ALTs:b})]}static getStatePda(e){let[t]=web3_js.PublicKey.findProgramAddressSync([Buffer.from("state")],e);return t}static getIntentStoragePda(e,t){let[a]=web3_js.PublicKey.findProgramAddressSync([Buffer.from("intent_storage"),t],e);return a}static getMakerInfoPda(e,t){let[a]=web3_js.PublicKey.findProgramAddressSync([Buffer.from("maker_info"),t.toBuffer()],e);return a}static getDelegatesPda(e,t){let[a]=web3_js.PublicKey.findProgramAddressSync([Buffer.from("user_delegates"),t.toBuffer()],e);return a}static getEventAuthorityPda(e){let[t]=web3_js.PublicKey.findProgramAddressSync([Buffer.from("__event_authority")],e);return t}static getNativePda(e){let[t]=web3_js.PublicKey.findProgramAddressSync([Buffer.from("unwrap_native_receiver")],e);return t}static getBufferForIntentSignature(e,t="intents_program",a=solanaUtils.constants.SOLANA_CHAIN_ID){let n=Buffer.alloc(4);n.writeUInt32LE(a,0);let s=Buffer.from([105,110,116,101,110,116,115]);return Buffer.concat([Buffer.from(t),n,s,e])}static getDelegateApprovedBudgetsArgs(e){let t;return "set"in e?t={set:{0:e.set.map(({tokenMint:a,approvedAmount:n,expiration:s})=>({tokenMint:a,approvedAmount:new anchor.BN(n.toString()),expiration:new anchor.BN(s.toString())}))}}:"setAny"in e?t={setAny:{}}:t={revoke:{}},t}static getBufferForBudgetSignature(e,t,a,n="intents_program",s=solanaUtils.constants.SOLANA_CHAIN_ID){let i=m.getDelegateApprovedBudgetsArgs(a),r=new anchor.BorshCoder(R).types.encode("setApprovedTokenBudgets",i),d=Buffer.alloc(4);d.writeUInt32LE(s,0);let c=Buffer.from([98,117,100,103,101,116,115]);return Buffer.concat([Buffer.from(n),d,c,e.toBuffer(),Buffer.from(new anchor.BN(t.toString()).toArray("le",8)),r])}};var K=class{addresses;lookupMap=new Map;constructor(e){this.addresses=e.map(t=>Buffer.from(t));}lookupIndex(e){let t=e.toString("hex"),a=this.lookupMap.get(t);if(a===void 0)throw new Error(`Address ${t} not found in AddressesList`);return a}serialize(){let e=new Map;for(let o of this.addresses){let r=e.get(o.length);r===void 0?e.set(o.length,[o]):r.push(o);}let t=Array.from(e.keys()).sort(),a=Buffer.alloc(t.reduce((o,r)=>o+e.get(r).length*r,0)+t.length*2+1);a[0]=t.length;let n=1,s=1+t.length*2,i=0;for(let o of t){let r=e.get(o).sort((c,u)=>c.compare(u));for(let c of r)this.lookupMap.set(c.toString("hex"),i),i+=1;a[n]=o,n+=1,a[n]=r.length,n+=1;let d=Buffer.concat(r);a.set(d,s),s+=d.length;}return a}};var W=Buffer.from([1]),F=Buffer.from([0]),T=Buffer.from([0]),x=Buffer.from([1]),$=class{data;addressesList;serializedList;constructor(e){this.data=e,this.addressesList=this.buildAddressesListFromIntent(e),this.serializedList=this.addressesList.serialize();}buildAddressesListFromIntent(e){let t=new Set,a=r=>t.add(r.toString("hex")),n=r=>{if(r)for(let{address:d}of r)a(d);},s=r=>{if(r)for(let d of r)d.input!=="any"&&a(d.input),a(d.output);},i=r=>{if(r){for(let d of r)if(a(d.input),d.output!=="any")for(let c of d.output)c.token&&c.token!=="any"&&a(c.token);}};for(let r of e.inputTokens)a(r.token);s(e.giveTokens),i(e.takeTokens),n(e.receiverDetails),n(e.dstAuthorityAddress);let o=Array.from(t).map(r=>Buffer.from(r,"hex"));return new K(o)}serializeReceiversInfo(e){if(!e||e.length===0)return T;let t=e.map(({chainIds:n,address:s})=>{let i;if(n==="any")i=Buffer.alloc(2),i.writeUInt8(this.addressesList.lookupIndex(s),0),i.writeUInt8(1,1);else {i=Buffer.alloc(3+n.length*4),i.writeUInt8(this.addressesList.lookupIndex(s),0),i.writeUInt8(0,1),i.writeUInt8(n.length,2);for(let[o,r]of n.entries())i.writeUInt32LE(r,3+o*4);}return i}),a=Buffer.alloc(1);return a.writeUInt8(t.length,0),Buffer.concat([a,...t])}serializeInputTokens(){let e=this.data.inputTokens.map(a=>{let n=Buffer.alloc(25);return n[0]=this.addressesList.lookupIndex(a.token),n.writeBigUInt64LE(a.minPartialAmount,1),n.writeBigUInt64LE(a.maxPartialAmount,9),n.writeBigUInt64LE(a.constraintBudget,17),n}),t=Buffer.alloc(1);return t.writeUInt8(e.length,0),Buffer.concat([t,...e])}serializeGiveTokens(e){if(!e||e.length===0)return T;let t=e.map(n=>{let s;if(n.input==="any")s=Buffer.alloc(2),s.writeUInt8(this.addressesList.lookupIndex(n.output),0),s.writeUInt8(1,1);else {s=Buffer.alloc(35),s.writeUInt8(this.addressesList.lookupIndex(n.output),0),s.writeUInt8(0,1),s.writeUInt8(this.addressesList.lookupIndex(n.input),2),s.writeBigInt64LE(n.price,3);let i=n.price.toString(16).padStart(64,"0");Buffer.from(i,"hex").copy(s,3);}return s}),a=Buffer.alloc(1);return a.writeUInt8(e.length,0),Buffer.concat([a,...t])}serializeTakeTokens(e){let t=0,a=e.map(s=>{let i;return s.output==="any"?(t=1,i=Buffer.alloc(2),i.writeUInt8(this.addressesList.lookupIndex(s.input),0),i.writeUInt8(1,1)):(t+=s.output.length,i=Buffer.concat(s.output.map(o=>{if(o.token==="any"){let r=Buffer.alloc(6);return r.writeUInt8(0,0),r.writeUInt8(o.chainId,1),r.writeUInt8(1,5),Buffer.concat([Buffer.from([this.addressesList.lookupIndex(s.input)]),r])}else {let r;if(o.price==="any")r=Buffer.alloc(8),r.writeUInt8(0,0),r.writeUInt32LE(o.chainId,1),r.writeUInt8(0,5),r.writeUInt8(this.addressesList.lookupIndex(o.token),6),r.writeUInt8(1,7);else {r=Buffer.alloc(40),r.writeUInt8(0,0),r.writeUInt32LE(o.chainId,1),r.writeUInt8(0,5),r.writeUInt8(this.addressesList.lookupIndex(o.token),6),r.writeUInt8(0,7);let d=o.price.toString(16).padStart(64,"0");Buffer.from(d,"hex").copy(r,8);}return Buffer.concat([Buffer.from([this.addressesList.lookupIndex(s.input)]),r])}}))),i}),n=Buffer.alloc(1);return n.writeUInt8(t,0),Buffer.concat([n,...a])}serializeExternalCallHash(e){return e?e==="any"?Buffer.concat([x,W]):Buffer.concat([x,F,x,e]):T}serializeOptionalBytes(e){return e?Buffer.concat([x,e]):T}serializeDlnMetadata(e){if(!e)return T;if(e==="any")return Buffer.concat([x,W]);{let t=Buffer.alloc(2);return t.writeInt16LE(e.length,0),Buffer.concat([x,F,t,e])}}serializeShortArray(e){if(!e)return T;let t=Buffer.alloc(2);return t.writeInt16LE(e.length,0),Buffer.concat([x,t,e])}serializeAllowedSenders(e){if(this.data.allowedSenders==="any")return W;let t=Buffer.alloc(1);return t.writeUInt8(e.length,0),Buffer.concat([F,t,...e])}serializeAddresses(e){if(!e||e.length===0)return T;let t=Buffer.alloc(1);return t.writeUInt8(e.length,0),Buffer.concat([t,...e])}serializeOptionalPubkey(e){return e?Buffer.concat([x,e.toBuffer()]):T}serialize(){let e=[],t=Buffer.alloc(4);t.writeUInt32LE(this.data.chainId,0),e.push(t),this.data.authority?e.push(x,this.data.authority.toBuffer()):e.push(T);let a=Buffer.alloc(16);return a.writeBigUInt64LE(BigInt(this.data.timestamp),0),a.writeBigUInt64LE(BigInt(this.data.expirationTimestamp),8),e.push(a),e.push(this.serializedList),e.push(this.serializeInputTokens()),e.push(this.serializeGiveTokens(this.data.giveTokens)),e.push(this.serializeTakeTokens(this.data.takeTokens)),e.push(this.serializeReceiversInfo(this.data.receiverDetails)),e.push(this.serializeAllowedSenders(this.data.allowedSenders)),e.push(this.serializeOptionalPubkey(this.data.preInteractions)),e.push(this.serializeOptionalPubkey(this.data.postInteractions)),e.push(this.serializeShortArray(this.data.validationRules)),e.push(this.serializeOptionalBytes(this.data.executionMetadataHash)),e.push(this.serializeAddresses(this.data.srcAllowedCancelBeneficiary)),e.push(this.serializeReceiversInfo(this.data.dstAuthorityAddress)),e.push(this.serializeExternalCallHash(this.data.externalCallHash)),e.push(this.serializeDlnMetadata(this.data.dlnMetadata)),Buffer.concat(e)}static getId(e,t,a){let n=jsSha3.keccak256(e),s=Buffer.from(n,"hex"),[i]=web3_js.PublicKey.findProgramAddressSync([Buffer.from("intent_id"),t.toBuffer(),s],a);return {hex:`0x${i.toBuffer().toString("hex")}`,buffer:i.toBuffer(),rawHash:s}}};exports.DEFAULT_RECORD_OFFSET=C;exports.IDL=R;exports.Intent=$;exports.IntentProgramSigPrefix=he;exports.IntentsClient=Y;//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|