@kodiak-finance/orderly-default-solana-adapter 2.8.18-rc.1 → 2.8.19-rc.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.js CHANGED
@@ -1,2 +1,3630 @@
1
- "use strict";var Ca=Object.create;var U=Object.defineProperty,La=Object.defineProperties,Ha=Object.getOwnPropertyDescriptor,Na=Object.getOwnPropertyDescriptors,Wa=Object.getOwnPropertyNames,Ne=Object.getOwnPropertySymbols,Ua=Object.getPrototypeOf,We=Object.prototype.hasOwnProperty,Va=Object.prototype.propertyIsEnumerable;var ce=(a,n,e)=>n in a?U(a,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[n]=e,g=(a,n)=>{for(var e in n||(n={}))We.call(n,e)&&ce(a,e,n[e]);if(Ne)for(var e of Ne(n))Va.call(n,e)&&ce(a,e,n[e]);return a},h=(a,n)=>La(a,Na(n));var Ga=(a,n)=>{for(var e in n)U(a,e,{get:n[e],enumerable:!0})},Ue=(a,n,e,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of Wa(n))!We.call(a,r)&&r!==e&&U(a,r,{get:()=>n[r],enumerable:!(s=Ha(n,r))||s.enumerable});return a};var Fa=(a,n,e)=>(e=a!=null?Ca(Ua(a)):{},Ue(n||!a||!a.__esModule?U(e,"default",{value:a,enumerable:!0}):e,a)),za=a=>Ue(U({},"__esModule",{value:!0}),a);var N=(a,n,e)=>(ce(a,typeof n!="symbol"?n+"":n,e),e);var f=(a,n,e)=>new Promise((s,r)=>{var t=u=>{try{d(e.next(u))}catch(i){r(i)}},o=u=>{try{d(e.throw(u))}catch(i){r(i)}},d=u=>u.done?s(u.value):Promise.resolve(u.value).then(t,o);d((e=e.apply(a,n)).next())});var qa={};Ga(qa,{DefaultSolanaWalletAdapter:()=>$,version:()=>Ve});module.exports=za(qa);typeof window!="undefined"&&(window.__ORDERLY_VERSION__=window.__ORDERLY_VERSION__||{},window.__ORDERLY_VERSION__["@kodiak-finance/orderly-default-solana-adapter"]="2.7.4");var Ve="2.7.4";var wa=Fa(require("@noble/ed25519")),Ia=require("@solana/spl-token"),Ea=require("@solana/wallet-adapter-base"),p=require("@solana/web3.js"),xa=require("bs58"),Da=require("ethereum-cryptography/utils"),ee=require("@kodiak-finance/orderly-core"),ae=require("@kodiak-finance/orderly-types");var K=require("@coral-xyz/anchor"),y=require("@solana/web3.js"),Ke=require("bs58"),D=require("ethereum-cryptography/keccak"),b=require("ethereum-cryptography/utils"),S=require("ethers"),fa=require("@kodiak-finance/orderly-core"),J=require("@kodiak-finance/orderly-types");var V=require("@layerzerolabs/lz-v2-utilities"),A=require("@solana/web3.js"),w=new A.PublicKey("76y77prsiCMvXMjuoZ5VRrhG5qYBrUMYTE5WgHqgjEn6"),M=new A.PublicKey("7a4WjyR8VZ7yZz5XJAKm39BUGn5iT9CKcv2pmG9tdXVH"),G=new A.PublicKey("6doghB248px58JSSwG4qejQ46kFMW4AMj7vzJnWZHNZn"),B=new A.PublicKey("8ahPGPjEbpgGaZx2NV1iG5Shj7TDwvsjkEDcGWjt94TP"),Ge=M,Fe=M,F=new A.PublicKey("HtEYV4xB4wvsj5fgTkcfuChYpvGYzgzwvNhgDZQNh7wW"),ze="VaultAuthority",Ye="Broker",qe="Token",Qe="SolVault",pe=(0,V.addressToBytes32)("0x9Dc724b24146BeDD2dA28b8C4B74126169B8f312"),je=(0,V.addressToBytes32)("0x45b6C6266A7A2170617d8A27A50C642fd68b91c4"),Ze=(0,V.addressToBytes32)("0x5Bf771A65d057e778C5f0Ed52A0003316f94322D"),Xe=(0,V.addressToBytes32)("0xCecAe061aa078e13b5e70D5F9eCee90a3F2B6AeA"),Je=40200,$e=30213,Z=new A.PublicKey("BWp8HaYYhiNHekt3zgQhqoCrRftneGxxfgKmCZ6svHN"),ea=new A.PublicKey("BswrQQoPKAFojTuJutZcBMtigAgTghEH4M8ofn3EG2X2"),aa=new A.PublicKey("BbGKfxuPwDmu58BjPpd7PMG69TqnZjSpKaLDMgf9E9Dr"),na=new A.PublicKey("8iq7xCQt3bLdRRn4A46d5GuaXYinBoiAhbe2sUmZVzwg"),fe=new A.PublicKey("EYJq9eU4GMRUriUJBgGoZ8YLQBXcWaciXuSsEXE7ieQS"),ye=new A.PublicKey("5zBjLor7vEraAt4zp2H82sy9MSqFoDnNa1Lx6EYKTYRZ"),ge=new A.PublicKey("9shwxWDUNhtwkHocsUAmrNAQfBH2DHh4njdAEdHZZkF2"),X=new A.PublicKey("ErBmAD61mGFKvrFNaTJuxoPwqrS8GgtwtqJTJVjFWx9Q");var Se={version:"0.1.0",name:"solana_vault",instructions:[{name:"setVault",accounts:[{name:"admin",isMut:!0,isSigner:!0},{name:"vaultAuthority",isMut:!0,isSigner:!1},{name:"oappConfig",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[{name:"params",type:{defined:"SetVaultParams"}}]},{name:"deposit",accounts:[{name:"user",isMut:!0,isSigner:!0},{name:"userTokenAccount",isMut:!0,isSigner:!1},{name:"vaultAuthority",isMut:!0,isSigner:!1},{name:"vaultTokenAccount",isMut:!0,isSigner:!1},{name:"depositToken",isMut:!1,isSigner:!1},{name:"peer",isMut:!1,isSigner:!1},{name:"enforcedOptions",isMut:!1,isSigner:!1},{name:"oappConfig",isMut:!1,isSigner:!1},{name:"allowedBroker",isMut:!1,isSigner:!1},{name:"allowedToken",isMut:!1,isSigner:!1},{name:"tokenProgram",isMut:!1,isSigner:!1},{name:"associatedTokenProgram",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[{name:"depositParams",type:{defined:"DepositParams"}},{name:"oappParams",type:{defined:"OAppSendParams"}}],returns:{defined:"MessagingReceipt"}},{name:"depositSol",accounts:[{name:"user",isMut:!0,isSigner:!0},{name:"vaultAuthority",isMut:!0,isSigner:!1},{name:"solVault",isMut:!0,isSigner:!1,docs:["CHECKED: sol_vault is used for SOL deposit"]},{name:"peer",isMut:!1,isSigner:!1},{name:"enforcedOptions",isMut:!1,isSigner:!1},{name:"oappConfig",isMut:!1,isSigner:!1},{name:"allowedBroker",isMut:!1,isSigner:!1},{name:"allowedToken",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[{name:"depositParams",type:{defined:"DepositParams"}},{name:"oappParams",type:{defined:"OAppSendParams"}}],returns:{defined:"MessagingReceipt"}},{name:"initOapp",accounts:[{name:"payer",isMut:!0,isSigner:!0},{name:"oappConfig",isMut:!0,isSigner:!1},{name:"lzReceiveTypes",isMut:!0,isSigner:!1},{name:"accountList",isMut:!0,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[{name:"params",type:{defined:"InitOAppParams"}}]},{name:"setAccountList",accounts:[{name:"admin",isMut:!0,isSigner:!0},{name:"oappConfig",isMut:!1,isSigner:!1},{name:"lzReceiveTypes",isMut:!0,isSigner:!1},{name:"accountsList",isMut:!0,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[{name:"params",type:{defined:"SetAccountListParams"}}]},{name:"setManagerRole",accounts:[{name:"owner",isMut:!0,isSigner:!0},{name:"vaultAuthority",isMut:!0,isSigner:!1},{name:"managerRole",isMut:!0,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[{name:"params",type:{defined:"SetManagerRoleParams"}}]},{name:"setBroker",accounts:[{name:"brokerManager",isMut:!0,isSigner:!0},{name:"allowedBroker",isMut:!0,isSigner:!1},{name:"managerRole",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[{name:"params",type:{defined:"SetBrokerParams"}}]},{name:"setWithdrawBroker",accounts:[{name:"brokerManager",isMut:!0,isSigner:!0},{name:"withdrawBroker",isMut:!0,isSigner:!1},{name:"managerRole",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[{name:"params",type:{defined:"SetWithdrawBrokerParams"}}]},{name:"setToken",accounts:[{name:"tokenManager",isMut:!0,isSigner:!0},{name:"allowedToken",isMut:!0,isSigner:!1},{name:"managerRole",isMut:!1,isSigner:!1},{name:"mintAccount",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[{name:"params",type:{defined:"SetTokenParams"}}]},{name:"setWithdrawToken",accounts:[{name:"tokenManager",isMut:!0,isSigner:!0},{name:"withdrawToken",isMut:!0,isSigner:!1},{name:"managerRole",isMut:!1,isSigner:!1},{name:"mintAccount",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[{name:"params",type:{defined:"SetWithdrawTokenParams"}}]},{name:"setOrderDelivery",accounts:[{name:"owner",isMut:!0,isSigner:!0},{name:"vaultAuthority",isMut:!0,isSigner:!1}],args:[{name:"params",type:{defined:"SetOrderDeliveryParams"}}]},{name:"oappQuote",accounts:[{name:"oappConfig",isMut:!1,isSigner:!1},{name:"peer",isMut:!1,isSigner:!1},{name:"enforcedOptions",isMut:!1,isSigner:!1},{name:"vaultAuthority",isMut:!1,isSigner:!1}],args:[{name:"params",type:{defined:"DepositParams"}}],returns:{defined:"MessagingFee"}},{name:"lzReceive",accounts:[{name:"payer",isMut:!0,isSigner:!0},{name:"peer",isMut:!1,isSigner:!1},{name:"oappConfig",isMut:!1,isSigner:!1},{name:"withdrawBrokerPda",isMut:!1,isSigner:!1},{name:"withdrawTokenPda",isMut:!1,isSigner:!1,docs:["CHECK"]},{name:"tokenMint",isMut:!1,isSigner:!1,docs:["CHECK"]},{name:"receiver",isMut:!0,isSigner:!1,docs:["CHECK"]},{name:"receiverTokenAccount",isMut:!0,isSigner:!1,docs:["UNCHECKED"]},{name:"vaultAuthority",isMut:!0,isSigner:!1},{name:"vaultTokenAccount",isMut:!0,isSigner:!1},{name:"tokenProgram",isMut:!1,isSigner:!1,docs:["CHECKED: sol_vault is used for SOL withdrawal"]},{name:"associatedTokenProgram",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1},{name:"eventAuthority",isMut:!1,isSigner:!1},{name:"program",isMut:!1,isSigner:!1}],args:[{name:"params",type:{defined:"OAppLzReceiveParams"}}]},{name:"lzReceiveTypes",accounts:[{name:"oappConfig",isMut:!1,isSigner:!1},{name:"accountList",isMut:!1,isSigner:!1}],args:[{name:"params",type:{defined:"OAppLzReceiveParams"}}],returns:{vec:{defined:"oapp::endpoint_cpi::LzAccount"}}},{name:"setRateLimit",accounts:[{name:"admin",isMut:!1,isSigner:!0},{name:"peer",isMut:!0,isSigner:!1},{name:"oappConfig",isMut:!1,isSigner:!1}],args:[{name:"params",type:{defined:"SetRateLimitParams"}}]},{name:"setDelegate",accounts:[{name:"admin",isMut:!1,isSigner:!0},{name:"oappConfig",isMut:!1,isSigner:!1}],args:[{name:"params",type:{defined:"SetDelegateParams"}}]},{name:"transferAdmin",accounts:[{name:"admin",isMut:!1,isSigner:!0},{name:"oappConfig",isMut:!0,isSigner:!1}],args:[{name:"params",type:{defined:"TransferAdminParams"}}]},{name:"setPeer",accounts:[{name:"admin",isMut:!0,isSigner:!0},{name:"peer",isMut:!0,isSigner:!1},{name:"oappConfig",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[{name:"params",type:{defined:"SetPeerParams"}}]},{name:"setEnforcedOptions",accounts:[{name:"admin",isMut:!0,isSigner:!0},{name:"enforcedOptions",isMut:!0,isSigner:!1},{name:"oappConfig",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[{name:"params",type:{defined:"SetEnforcedOptionsParams"}}]}],accounts:[{name:"enforcedOptions",type:{kind:"struct",fields:[{name:"send",type:"bytes"},{name:"sendAndCall",type:"bytes"},{name:"bump",type:"u8"}]}},{name:"oAppConfig",type:{kind:"struct",fields:[{name:"endpointProgram",type:"publicKey"},{name:"bump",type:"u8"},{name:"admin",type:"publicKey"}]}},{name:"oAppLzReceiveTypesAccounts",type:{kind:"struct",fields:[{name:"oappConfig",type:"publicKey"},{name:"accountList",type:"publicKey"}]}},{name:"accountList",type:{kind:"struct",fields:[{name:"bump",type:"u8"},{name:"woofiProPda",type:"publicKey"},{name:"withdrawUsdcPda",type:"publicKey"},{name:"usdcMint",type:"publicKey"},{name:"withdrawUsdtPda",type:"publicKey"},{name:"usdtMint",type:"publicKey"},{name:"withdrawWsolPda",type:"publicKey"},{name:"wsolMint",type:"publicKey"}]}},{name:"peer",type:{kind:"struct",fields:[{name:"address",type:{array:["u8",32]}},{name:"rateLimiter",type:{option:{defined:"RateLimiter"}}},{name:"bump",type:"u8"}]}},{name:"allowedBroker",type:{kind:"struct",fields:[{name:"brokerHash",type:{array:["u8",32]}},{name:"allowed",type:"bool"},{name:"bump",type:"u8"}]}},{name:"allowedToken",type:{kind:"struct",fields:[{name:"mintAccount",type:"publicKey"},{name:"tokenHash",type:{array:["u8",32]}},{name:"tokenDecimals",type:"u8"},{name:"allowed",type:"bool"},{name:"bump",type:"u8"}]}},{name:"managerRole",type:{kind:"struct",fields:[{name:"roleHash",type:{array:["u8",32]}},{name:"allowed",type:"bool"},{name:"bump",type:"u8"}]}},{name:"vaultAuthority",type:{kind:"struct",fields:[{name:"bump",docs:["Bump seed for the vault authority PDA"],type:"u8"},{name:"owner",type:"publicKey"},{name:"depositNonce",type:"u64"},{name:"orderDelivery",type:"bool"},{name:"inboundNonce",type:"u64"},{name:"dstEid",type:"u32"},{name:"solChainId",type:"u128"}]}},{name:"withdrawBroker",type:{kind:"struct",fields:[{name:"brokerHash",type:{array:["u8",32]}},{name:"brokerIndex",type:"u16"},{name:"allowed",type:"bool"},{name:"bump",type:"u8"}]}},{name:"withdrawToken",type:{kind:"struct",fields:[{name:"mintAccount",type:"publicKey"},{name:"tokenHash",type:{array:["u8",32]}},{name:"tokenDecimals",type:"u8"},{name:"tokenIndex",type:"u8"},{name:"allowed",type:"bool"},{name:"bump",type:"u8"}]}}],types:[{name:"VaultDepositParams",type:{kind:"struct",fields:[{name:"accountId",type:{array:["u8",32]}},{name:"brokerHash",type:{array:["u8",32]}},{name:"userAddress",type:{array:["u8",32]}},{name:"tokenHash",type:{array:["u8",32]}},{name:"srcChainId",type:"u128"},{name:"tokenAmount",type:"u128"},{name:"srcChainDepositNonce",type:"u64"}]}},{name:"LzMessage",type:{kind:"struct",fields:[{name:"msgType",type:"u8"},{name:"payload",type:"bytes"}]}},{name:"AccountWithdrawSol",type:{kind:"struct",fields:[{name:"sender",type:{array:["u8",32]}},{name:"receiver",type:{array:["u8",32]}},{name:"brokerIndex",type:"u16"},{name:"tokenIndex",type:"u8"},{name:"tokenAmount",type:"u64"},{name:"fee",type:"u64"},{name:"chainId",type:"u64"},{name:"withdrawNonce",type:"u64"}]}},{name:"VaultWithdrawParams",type:{kind:"struct",fields:[{name:"accountId",type:{array:["u8",32]}},{name:"sender",type:{array:["u8",32]}},{name:"receiver",type:{array:["u8",32]}},{name:"brokerHash",type:{array:["u8",32]}},{name:"tokenHash",type:{array:["u8",32]}},{name:"tokenAmount",type:"u64"},{name:"fee",type:"u128"},{name:"chainId",type:"u128"},{name:"withdrawNonce",type:"u64"}]}},{name:"InitOAppParams",type:{kind:"struct",fields:[{name:"admin",type:"publicKey"},{name:"accountList",type:"publicKey"},{name:"endpointProgram",type:{option:"publicKey"}}]}},{name:"OAppLzReceiveParams",type:{kind:"struct",fields:[{name:"srcEid",type:"u32"},{name:"sender",type:{array:["u8",32]}},{name:"nonce",type:"u64"},{name:"guid",type:{array:["u8",32]}},{name:"message",type:"bytes"},{name:"extraData",type:"bytes"}]}},{name:"MessagingFee",type:{kind:"struct",fields:[{name:"nativeFee",type:"u64"},{name:"lzTokenFee",type:"u64"}]}},{name:"SetAccountListParams",type:{kind:"struct",fields:[{name:"woofiProPda",type:"publicKey"},{name:"withdrawUsdcPda",type:"publicKey"},{name:"usdcMint",type:"publicKey"},{name:"withdrawUsdtPda",type:"publicKey"},{name:"usdtMint",type:"publicKey"},{name:"withdrawWsolPda",type:"publicKey"},{name:"wsolMint",type:"publicKey"}]}},{name:"SetDelegateParams",type:{kind:"struct",fields:[{name:"delegate",type:"publicKey"}]}},{name:"SetEnforcedOptionsParams",type:{kind:"struct",fields:[{name:"dstEid",type:"u32"},{name:"send",type:"bytes"},{name:"sendAndCall",type:"bytes"}]}},{name:"SetPeerParams",type:{kind:"struct",fields:[{name:"dstEid",type:"u32"},{name:"peer",type:{array:["u8",32]}}]}},{name:"SetRateLimitParams",type:{kind:"struct",fields:[{name:"dstEid",type:"u32"},{name:"refillPerSecond",type:{option:"u64"}},{name:"capacity",type:{option:"u64"}},{name:"enabled",type:"bool"}]}},{name:"TransferAdminParams",type:{kind:"struct",fields:[{name:"admin",type:"publicKey"}]}},{name:"DepositParams",type:{kind:"struct",fields:[{name:"accountId",type:{array:["u8",32]}},{name:"brokerHash",type:{array:["u8",32]}},{name:"tokenHash",type:{array:["u8",32]}},{name:"userAddress",type:{array:["u8",32]}},{name:"tokenAmount",type:"u64"}]}},{name:"OAppSendParams",type:{kind:"struct",fields:[{name:"nativeFee",type:"u64"},{name:"lzTokenFee",type:"u64"}]}},{name:"SetBrokerParams",type:{kind:"struct",fields:[{name:"brokerManagerRole",type:{array:["u8",32]}},{name:"brokerHash",type:{array:["u8",32]}},{name:"allowed",type:"bool"}]}},{name:"SetManagerRoleParams",type:{kind:"struct",fields:[{name:"roleHash",type:{array:["u8",32]}},{name:"managerAddress",type:"publicKey"},{name:"allowed",type:"bool"}]}},{name:"SetOrderDeliveryParams",type:{kind:"struct",fields:[{name:"orderDelivery",type:"bool"},{name:"nonce",type:"u64"}]}},{name:"SetTokenParams",type:{kind:"struct",fields:[{name:"tokenManagerRole",type:{array:["u8",32]}},{name:"mintAccount",type:"publicKey"},{name:"tokenHash",type:{array:["u8",32]}},{name:"allowed",type:"bool"}]}},{name:"SetVaultParams",type:{kind:"struct",fields:[{name:"owner",type:"publicKey"},{name:"depositNonce",type:"u64"},{name:"orderDelivery",type:"bool"},{name:"inboundNonce",type:"u64"},{name:"dstEid",type:"u32"},{name:"solChainId",type:"u128"}]}},{name:"SetWithdrawBrokerParams",type:{kind:"struct",fields:[{name:"brokerManagerRole",type:{array:["u8",32]}},{name:"brokerHash",type:{array:["u8",32]}},{name:"brokerIndex",type:"u16"},{name:"allowed",type:"bool"}]}},{name:"SetWithdrawTokenParams",type:{kind:"struct",fields:[{name:"tokenManagerRole",type:{array:["u8",32]}},{name:"tokenHash",type:{array:["u8",32]}},{name:"tokenIndex",type:"u8"},{name:"allowed",type:"bool"}]}},{name:"RateLimiter",type:{kind:"struct",fields:[{name:"capacity",type:"u64"},{name:"tokens",type:"u64"},{name:"refillPerSecond",type:"u64"},{name:"lastRefillTime",type:"u64"}]}},{name:"OAppError",type:{kind:"enum",variants:[{name:"Unauthorized"},{name:"InvalidSender"},{name:"InvalidReceiver"},{name:"InvalidOptions"},{name:"InvalidEndpointProgram"},{name:"RateLimitExceeded"},{name:"WithdrawFailed"},{name:"InvalidInboundNonce"},{name:"InvalidReceiverTokenAccount"},{name:"InvalidAdminTokenAccount"},{name:"InvalidMessageType"},{name:"InvalidTokenIndex"}]}},{name:"MsgType",type:{kind:"enum",variants:[{name:"Deposit"},{name:"Withdraw"},{name:"RebalanceBurn"},{name:"RebalanceMint"}]}}],events:[{name:"SetAllowedBroker",fields:[{name:"brokerHash",type:{array:["u8",32]},index:!1}]},{name:"ResetAllowedBroker",fields:[{name:"brokerHash",type:{array:["u8",32]},index:!1}]},{name:"SetAllowedToken",fields:[{name:"tokenHash",type:{array:["u8",32]},index:!1},{name:"mintAccount",type:"publicKey",index:!1}]},{name:"ResetAllowedToken",fields:[{name:"tokenHash",type:{array:["u8",32]},index:!1},{name:"mintAccount",type:"publicKey",index:!1}]},{name:"SetWithdrawTokenIndex",fields:[{name:"tokenIndex",type:"u8",index:!1},{name:"tokenHash",type:{array:["u8",32]},index:!1},{name:"mintAccount",type:"publicKey",index:!1}]},{name:"ResetWithdrawTokenIndex",fields:[{name:"tokenIndex",type:"u8",index:!1},{name:"tokenHash",type:{array:["u8",32]},index:!1},{name:"mintAccount",type:"publicKey",index:!1}]},{name:"SetWithdrawBrokerEvent",fields:[{name:"brokerHash",type:{array:["u8",32]},index:!1},{name:"brokerIndex",type:"u16",index:!1}]},{name:"ResetWithdrawBrokerEvent",fields:[{name:"brokerHash",type:{array:["u8",32]},index:!1},{name:"brokerIndex",type:"u16",index:!1}]},{name:"SetManager",fields:[{name:"roleHash",type:{array:["u8",32]},index:!1},{name:"managerAddress",type:"publicKey",index:!1},{name:"allowed",type:"bool",index:!1}]},{name:"Deposited",fields:[{name:"user",type:"publicKey",index:!1},{name:"amount",type:"u64",index:!1}]},{name:"Withdrawn",fields:[{name:"user",type:"publicKey",index:!1},{name:"amount",type:"u64",index:!1}]},{name:"CreatedATA",fields:[{name:"accountId",type:{array:["u8",32]},index:!1},{name:"receiver",type:{array:["u8",32]},index:!1},{name:"receiverTokenAccount",type:{array:["u8",32]},index:!1},{name:"withdrawNonce",type:"u64",index:!1}]},{name:"VaultDeposited",fields:[{name:"accountId",type:{array:["u8",32]},index:!1},{name:"brokerHash",type:{array:["u8",32]},index:!1},{name:"userAddress",type:{array:["u8",32]},index:!1},{name:"tokenHash",type:{array:["u8",32]},index:!1},{name:"srcChainId",type:"u128",index:!1},{name:"tokenAmount",type:"u64",index:!1},{name:"srcChainDepositNonce",type:"u64",index:!1}]},{name:"VaultWithdrawn",fields:[{name:"accountId",type:{array:["u8",32]},index:!1},{name:"sender",type:{array:["u8",32]},index:!1},{name:"receiver",type:{array:["u8",32]},index:!1},{name:"brokerHash",type:{array:["u8",32]},index:!1},{name:"tokenHash",type:{array:["u8",32]},index:!1},{name:"tokenAmount",type:"u64",index:!1},{name:"fee",type:"u128",index:!1},{name:"chainId",type:"u128",index:!1},{name:"withdrawNonce",type:"u64",index:!1}]},{name:"FrozenWithdrawn",fields:[{name:"accountId",type:{array:["u8",32]},index:!1},{name:"sender",type:{array:["u8",32]},index:!1},{name:"receiver",type:{array:["u8",32]},index:!1},{name:"brokerHash",type:{array:["u8",32]},index:!1},{name:"tokenHash",type:{array:["u8",32]},index:!1},{name:"tokenAmount",type:"u64",index:!1},{name:"fee",type:"u128",index:!1},{name:"chainId",type:"u128",index:!1},{name:"withdrawNonce",type:"u64",index:!1}]},{name:"OAppSent",fields:[{name:"guid",type:{array:["u8",32]},index:!1},{name:"dstEid",type:"u32",index:!1}]},{name:"OAppReceived",fields:[{name:"guid",type:{array:["u8",32]},index:!1},{name:"srcEid",type:"u32",index:!1}]}],errors:[{code:6e3,name:"InsufficientFunds",msg:"Deposited funds are insufficient for withdrawal"},{code:6001,name:"UserInfoBelongsToAnotherUser",msg:"User info pda belongs to another user"},{code:6002,name:"BrokerNotAllowed",msg:"Broker is not allowed"},{code:6003,name:"TokenNotAllowed",msg:"Token is not allowed"},{code:6004,name:"InvalidAccountId",msg:"AccountId is invalid"},{code:6005,name:"InvalidVaultOwner",msg:"Vault owner is not the same as the payer"},{code:6006,name:"ManagerRoleNotAllowed",msg:"Manager role is not allowed"}]};var m=require("@layerzerolabs/lz-solana-sdk-v2"),ta=require("@solana/spl-token"),c=require("@solana/web3.js");var z=(a,n)=>(0,ta.getAssociatedTokenAddressSync)(a,n,!0);function be(a){return c.PublicKey.findProgramAddressSync([Buffer.from(ze,"utf8")],a)[0]}function sa(a){return c.PublicKey.findProgramAddressSync([Buffer.from(Qe,"utf8")],a)[0]}function ra(a,n){let e=Array.from(Buffer.from(n.slice(2),"hex"));return c.PublicKey.findProgramAddressSync([Buffer.from(Ye,"utf8"),Buffer.from(e)],a)[0]}function ia(a,n){let e=Array.from(Buffer.from(n.slice(2),"hex"));return c.PublicKey.findProgramAddressSync([Buffer.from(qe,"utf8"),Buffer.from(e)],a)[0]}function ke(a){return c.PublicKey.findProgramAddressSync([Buffer.from(m.OAPP_SEED,"utf8")],a)[0]}function Ae(a,n,e){let s=Buffer.alloc(4);return s.writeUInt32BE(e),c.PublicKey.findProgramAddressSync([Buffer.from(m.PEER_SEED,"utf8"),n.toBuffer(),s],a)[0]}function Pe(a,n,e){let s=Buffer.alloc(4);return s.writeUInt32BE(e),c.PublicKey.findProgramAddressSync([Buffer.from(m.ENFORCED_OPTIONS_SEED,"utf8"),n.toBuffer(),s],a)[0]}function oa(){return c.PublicKey.findProgramAddressSync([Buffer.from(m.MESSAGE_LIB_SEED,"utf8")],M)[0]}function he(a,n){let e=Buffer.alloc(4);return e.writeUInt32BE(n),c.PublicKey.findProgramAddressSync([Buffer.from(m.SEND_LIBRARY_CONFIG_SEED,"utf8"),a.toBuffer(),e],w)[0]}function Me(a){let n=Buffer.alloc(4);return n.writeUInt32BE(a),c.PublicKey.findProgramAddressSync([Buffer.from(m.SEND_LIBRARY_CONFIG_SEED,"utf8"),n],w)[0]}function ua(a){return c.PublicKey.findProgramAddressSync([Buffer.from(m.MESSAGE_LIB_SEED,"utf8"),a.toBuffer()],w)[0]}function we(){return c.PublicKey.findProgramAddressSync([Buffer.from(m.ENDPOINT_SEED,"utf8")],w)[0]}function Ya(a){let n=pe;return a.toBase58()===fe.toBase58()&&(n=pe),a.toBase58()===ye.toBase58()&&(n=je),a.toBase58()===ge.toBase58()&&(n=Ze),a.toBase58()===X.toBase58()&&(n=Xe),n}function Ie(a,n,e){let s=Buffer.alloc(4),r=Ya(a);return s.writeUInt32BE(e),c.PublicKey.findProgramAddressSync([Buffer.from(m.NONCE_SEED,"utf8"),n.toBuffer(),s,r],w)[0]}function ma(){return c.PublicKey.findProgramAddressSync([Buffer.from(m.EVENT_SEED,"utf8")],w)[0]}function da(){return c.PublicKey.findProgramAddressSync([Buffer.from(m.ULN_SEED,"utf8")],M)[0]}function Ee(a,n){let e=Buffer.alloc(4);return e.writeUInt32BE(n),c.PublicKey.findProgramAddressSync([Buffer.from(m.SEND_CONFIG_SEED,"utf8"),e,a.toBuffer()],M)[0]}function xe(a){let n=Buffer.alloc(4);return n.writeUInt32BE(a),c.PublicKey.findProgramAddressSync([Buffer.from(m.SEND_CONFIG_SEED,"utf8"),n],Ge)[0]}function la(){return c.PublicKey.findProgramAddressSync([Buffer.from(m.EVENT_SEED,"utf8")],M)[0]}function De(){return c.PublicKey.findProgramAddressSync([Buffer.from(m.EXECUTOR_CONFIG_SEED,"utf8")],G)[0]}function Te(){return c.PublicKey.findProgramAddressSync([Buffer.from(m.PRICE_FEED_SEED,"utf8")],B)[0]}function ve(){return c.PublicKey.findProgramAddressSync([Buffer.from(m.DVN_CONFIG_SEED,"utf8")],F)[0]}function Re(a){return a.toBase58()===X.toBase58()?$e:Je}function _e(a){return a.toBase58()===fe.toBase58()?(console.log("DEV_LOOKUP_TABLE_ADDRESS: ",Z.toBase58()),Z):a.toBase58()===ye.toBase58()?ea:a.toBase58()===ge.toBase58()?aa:a.toBase58()===X.toBase58()?na:Z}function ca(a){return c.PublicKey.findProgramAddressSync([Buffer.from(m.MESSAGE_LIB_SEED,"utf8")],a||M)[0]}function pa(a,n){return c.PublicKey.findProgramAddressSync([Buffer.from(m.MESSAGE_LIB_SEED,"utf8"),a.toBytes()],n||w)[0]}function Be(a,n){return f(this,null,function*(){return(yield a.getAddressLookupTable(n)).value})}function ya(a){let{publicKey:n,brokerId:e,expiration:s=365,timestamp:r=Date.now(),scope:t,tag:o,chainId:d,subAccountId:u}=a,i=g(g({brokerId:e,chainType:"SOL",orderlyKey:n,scope:t||J.DEFAUL_ORDERLY_KEY_SCOPE,chainId:d,timestamp:r,expiration:r+1e3*60*60*24*s},typeof o!="undefined"?{tag:o}:{}),typeof u!="undefined"?{subAccountId:u}:{}),l=(0,S.solidityPackedKeccak256)(["string"],[i.brokerId]),I=(0,S.solidityPackedKeccak256)(["string"],[i.orderlyKey]),x=(0,S.solidityPackedKeccak256)(["string"],[i.scope]),P=S.AbiCoder.defaultAbiCoder(),T=(0,D.keccak256)((0,b.hexToBytes)(P.encode(["bytes32","bytes32","bytes32","uint256","uint256","uint256"],[l,I,x,i.chainId,i.timestamp,i.expiration]))),E=(0,b.bytesToHex)(T),_=new TextEncoder().encode(E);return[i,_]}function ga(a){let{chainId:n,registrationNonce:e,brokerId:s,timestamp:r}=a,t={brokerId:s,chainId:n,timestamp:r,registrationNonce:e},o=(0,S.solidityPackedKeccak256)(["string"],[t.brokerId]),d=S.AbiCoder.defaultAbiCoder(),u=(0,D.keccak256)((0,b.hexToBytes)(d.encode(["bytes32","uint256","uint256","uint256"],[o,t.chainId,t.timestamp,t.registrationNonce]))),i=(0,b.bytesToHex)(u),l=new TextEncoder().encode(i);return[t,l]}function Sa(a){let{chainId:n,receiver:e,token:s,amount:r,nonce:t}=a,o={chainId:n,receiver:e,token:s,amount:r,transferNonce:t,chainType:"SOL"},d=(0,S.solidityPackedKeccak256)(["string"],[o.token]),u=S.AbiCoder.defaultAbiCoder(),i=(0,D.keccak256)((0,b.hexToBytes)(u.encode(["bytes32","bytes32","uint256","uint64","uint256"],[o.receiver,d,o.amount,o.transferNonce,n]))),l=(0,b.bytesToHex)(i),I=new TextEncoder().encode(l);return[o,I]}function ba(a){return f(this,null,function*(){let{payloadType:n,nonce:e,receiver:s,amount:r,vaultId:t,token:o,dexBrokerId:d,chainId:u}=a,i={payloadType:n,nonce:e,receiver:s,amount:r,vaultId:t,token:o,dexBrokerId:d,chainId:u},l;l=(0,Ke.decode)(s),new Uint8Array(32).set(l);let P=(0,b.hexToBytes)(t),T=(0,D.keccak256)(new TextEncoder().encode(o)),E=(0,D.keccak256)(new TextEncoder().encode(d)),_=S.AbiCoder.defaultAbiCoder(),O=(0,D.keccak256)((0,b.hexToBytes)(_.encode(["uint8","uint256","bytes32","uint256","bytes32","bytes32","bytes32","uint256"],[n,e,l,r,P,T,E,u]))),C=(0,b.bytesToHex)(O),k=new TextEncoder().encode(C);return[i,k]})}function ka(a){let{chainId:n,receiver:e,token:s,amount:r,nonce:t,brokerId:o}=a,d=Date.now(),u={brokerId:o,chainId:n,receiver:e,token:s,amount:r,withdrawNonce:t,timestamp:d,chainType:"SOL"},i=(0,S.solidityPackedKeccak256)(["string"],[u.brokerId]),l=(0,S.solidityPackedKeccak256)(["string"],[u.token]),I=(0,D.keccak256)(Buffer.from("Orderly Network")),x=S.AbiCoder.defaultAbiCoder(),P=(0,D.keccak256)((0,b.hexToBytes)(x.encode(["bytes32","bytes32","uint256","bytes32","uint256","uint64","uint64","bytes32"],[i,l,n,(0,Ke.decode)(u.receiver),u.amount,u.withdrawNonce,d,I]))),T=(0,b.bytesToHex)(P),E=new TextEncoder().encode(T);return[u,E]}function Aa(a){let{settlePnlNonce:n,brokerId:e,chainId:s,timestamp:r}=a,t={brokerId:e,chainId:s,timestamp:r,chainType:"SOL",settleNonce:n},o=(0,S.solidityPackedKeccak256)(["string"],[e]),d=S.AbiCoder.defaultAbiCoder(),u=(0,D.keccak256)((0,b.hexToBytes)(d.encode(["bytes32","uint256","uint64","uint64"],[o,t.chainId,t.settleNonce,t.timestamp]))),i=(0,b.bytesToHex)(u),l=new TextEncoder().encode(i);return[t,l]}function Oe(r){return f(this,arguments,function*({vaultAddress:a,userAddress:n,connection:e,depositData:s}){console.log("-- vaultAddress",a);let t=new y.PublicKey(a),o=Re(t),d=new K.Program(Se,t,{connection:e}),u=new y.PublicKey(n),i=ke(t),l=Ae(t,i,o),I=Pe(t,i,o),x=he(i,o),P=Me(o),T=we(),E=Ie(t,i,o),_=Ee(i,o),O=xe(o),C=De(),k=Te(),v=ve(),W=ca(M),Y=pa(W),ne=be(t),te=Pa(n,s),se=yield d.methods.oappQuote(te).accounts({oappConfig:i,peer:l,enforcedOptions:I,vaultAuthority:ne}).remainingAccounts([{pubkey:w,isWritable:!1,isSigner:!1},{pubkey:M,isWritable:!1,isSigner:!1},{pubkey:x,isWritable:!1,isSigner:!1},{pubkey:P,isWritable:!1,isSigner:!1},{pubkey:Y,isWritable:!1,isSigner:!1},{pubkey:T,isWritable:!1,isSigner:!1},{pubkey:E,isWritable:!1,isSigner:!1},{pubkey:W,isWritable:!1,isSigner:!1},{pubkey:_,isWritable:!1,isSigner:!1},{pubkey:O,isWritable:!1,isSigner:!1},{pubkey:G,isWritable:!1,isSigner:!1},{pubkey:C,isWritable:!1,isSigner:!1},{pubkey:B,isWritable:!1,isSigner:!1},{pubkey:k,isWritable:!1,isSigner:!1},{pubkey:F,isWritable:!1,isSigner:!1},{pubkey:v,isWritable:!1,isSigner:!1},{pubkey:B,isWritable:!1,isSigner:!1},{pubkey:k,isWritable:!1,isSigner:!1}]).instruction(),re=yield e.getLatestBlockhash(),ie=_e(t),q=yield Be(e,ie);if(!q)throw console.log("-- lookup table account error"),new Error("-- lookup table account error");let oe=new y.TransactionMessage({payerKey:u,recentBlockhash:re.blockhash,instructions:[se]}).compileToV0Message([q]),ue=new y.VersionedTransaction(oe),R=yield e.simulateTransaction(ue);if(console.log("-- feeRes",R),R.value.err){let H=typeof R.value.err=="object"?JSON.stringify(R.value.err):R.value.err;throw H.toString().includes("AccountNotFound")?new Error("Error: Account gas is insufficient."):new Error(`Error: ${H}`)}let Q=`Program return: ${d.programId} `,j=R.value.logs.find(H=>H.startsWith(Q));if(!j)throw new Error("Error: get deposit fee error");let me=j.slice(Q.length),L=Buffer.from(me,"base64");return console.log(L.readBigUInt64LE(0),L.readBigUInt64LE(1)),L.readBigUInt64LE(0)})}var Pa=(a,n)=>{let e=n.brokerHash,s=Array.from(Buffer.from(e.slice(2),"hex")),r=n.tokenHash,t=Array.from(Buffer.from(r.slice(2),"hex")),o=n.accountId,d=Array.from(Buffer.from(o.slice(2),"hex")),u=new y.PublicKey(a);return{accountId:d,brokerHash:s,tokenHash:t,userAddress:Array.from(u.toBuffer()),tokenAmount:new K.BN(n.tokenAmount)}};function ha(t){return f(this,arguments,function*({vaultAddress:a,userAddress:n,connection:e,sendTransaction:s,depositData:r}){let o=r.brokerHash,d=r.tokenHash,u=fa.utils.parseTokenHash("SOL"),i=d.toLowerCase()===u.toLowerCase();console.log("-- vault address",a);let l=new y.PublicKey(a),I=new K.Program(Se,l,{connection:e}),x=new y.PublicKey(r.tokenAddress),P=new y.PublicKey(n),T=z(x,P),E=be(l),_=z(x,E),O=ra(l,o),C=ia(l,d),k=ke(l);console.log("-- oappconfig pda",k.toBase58());let v=Re(l),W=Ae(l,k,v),Y=Pe(l,k,v),ne=oa(),te=he(k,v),se=Me(v),re=ua(ne),ie=we(),q=Ie(l,k,v),oe=ma(),ue=da(),R=Ee(k,v),Q=xe(v),j=la(),me=De(),L=Te(),H=ve(),de=Pa(n,r),Ce=()=>[{isSigner:!1,isWritable:!1,pubkey:w},{isSigner:!1,isWritable:!1,pubkey:k},{isSigner:!1,isWritable:!1,pubkey:M},{isSigner:!1,isWritable:!1,pubkey:te},{isSigner:!1,isWritable:!1,pubkey:se},{isSigner:!1,isWritable:!1,pubkey:re},{isSigner:!1,isWritable:!1,pubkey:ie},{isSigner:!1,isWritable:!0,pubkey:q},{isSigner:!1,isWritable:!1,pubkey:oe},{isSigner:!1,isWritable:!1,pubkey:w},{isSigner:!1,isWritable:!1,pubkey:ue},{isSigner:!1,isWritable:!1,pubkey:R},{isSigner:!1,isWritable:!1,pubkey:Q},{isSigner:!0,isWritable:!1,pubkey:P},{isSigner:!1,isWritable:!1,pubkey:Fe},{isSigner:!1,isWritable:!1,pubkey:y.SystemProgram.programId},{isSigner:!1,isWritable:!1,pubkey:j},{isSigner:!1,isWritable:!1,pubkey:M},{isSigner:!1,isWritable:!1,pubkey:G},{isSigner:!1,isWritable:!0,pubkey:me},{isSigner:!1,isWritable:!1,pubkey:B},{isSigner:!1,isWritable:!1,pubkey:L},{isSigner:!1,isWritable:!1,pubkey:F},{isSigner:!1,isWritable:!0,pubkey:H},{isSigner:!1,isWritable:!1,pubkey:B},{isSigner:!1,isWritable:!1,pubkey:L}],Ta=yield Oe({vaultAddress:a,userAddress:n,connection:e,depositData:r}),le={nativeFee:new K.BN(Ta.toString()),lzTokenFee:new K.BN(0)};console.log("--- value params",{vaultDepositParams:de,sendParam:le});let va=i?yield I.methods.depositSol(de,le).accounts({solVault:sa(l),vaultAuthority:E,user:P,peer:W,enforcedOptions:Y,oappConfig:k,allowedBroker:O,allowedToken:C}).remainingAccounts(Ce()).instruction():yield I.methods.deposit(de,le).accounts({userTokenAccount:T,vaultAuthority:E,vaultTokenAccount:_,depositToken:x,user:P,peer:W,enforcedOptions:Y,oappConfig:k,allowedBroker:O,allowedToken:C}).remainingAccounts(Ce()).instruction(),Ra=_e(l),Le=yield Be(e,Ra);if(!Le){console.log("-- lookup table account error");return}let _a=y.ComputeBudgetProgram.setComputeUnitLimit({units:4e5}),Ba=yield e.getLatestBlockhash(),Ka=new y.TransactionMessage({payerKey:P,recentBlockhash:Ba.blockhash,instructions:[va,_a]}).compileToV0Message([Le]),Oa=new y.VersionedTransaction(Ka),He=yield s(Oa,e);return console.log("res",He),He})}function Ma(a){let n=window.localStorage.getItem(J.LedgerWalletKey);if(!n)return!1;let e=JSON.parse(n!=null?n:"[]");return console.log("-- addressArr",e),!!e.includes(a)}var $=class extends ee.BaseWalletAdapter{constructor(){super();N(this,"chainNamespace",ae.ChainNamespace.solana);N(this,"_address");N(this,"_chainId");N(this,"_provider");N(this,"_connection")}get address(){return this._address}get chainId(){return this._chainId}set chainId(e){this._chainId=e}get connection(){if(this._connection)return this._connection;if(this._provider.rpcUrl)return this._connection=new p.Connection(this._provider.rpcUrl,{commitment:"confirmed"}),this._connection;if(this._provider.network===Ea.WalletAdapterNetwork.Devnet)return this._connection=new p.Connection((0,p.clusterApiUrl)(this._provider.network),{commitment:"confirmed"}),this._connection;let e=ee.SimpleDI.get("account"),s="/v1/solana-rpc-proxy";return this._connection=new p.Connection(`${e.apiBaseUrl}${s}`,{commitment:"confirmed",fetchMiddleware:(r,t,o)=>f(this,null,function*(){let d={url:s,method:t==null?void 0:t.method,data:JSON.parse(t==null?void 0:t.body)},u=yield this.signMessageByOrderlyKey(d);for(let i of Object.keys(u))(t==null?void 0:t.headers)[i]=u[i];return o(r,t)})}),this._connection}setConfig(e){this._address=e.address,this._chainId=e.chain.id,e.provider&&(this._provider=e.provider)}lifecycleName(e,s){console.log("lifecycle",e,s)}active(e){this.setConfig(e),this.lifecycleName("active",e)}deactivate(){this.lifecycleName("deactivate",{})}update(e){this.lifecycleName("update",e),this.setConfig(e)}generateSecretKey(){let e,s;do e=wa.utils.randomPrivateKey(),s=(0,xa.encode)(e);while(s.length!==44);return s}uint8ArrayToHexString(e){return Array.from(e).map(s=>s.toString(16).padStart(2,"0")).join("")}signMessage(e){return f(this,null,function*(){if(Ma(this._address)){let t=new p.Transaction;t.add(new p.TransactionInstruction({keys:[],programId:new p.PublicKey("ComputeBudget111111111111111111111111111111"),data:new Uint8Array([3,0,0,0,0,0,0,0,0])})),t.add(new p.TransactionInstruction({keys:[],programId:new p.PublicKey("ComputeBudget111111111111111111111111111111"),data:new Uint8Array([2,0,0,0,0])})),t.add(new p.TransactionInstruction({keys:[],programId:new p.PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),data:e}));let o=new p.PublicKey(this.address);t.feePayer=o;let d=new Uint8Array(32).fill(0);t.recentBlockhash=new p.PublicKey(d).toString();let i=(yield this._provider.signTransaction(t)).signatures[0].signature;if(i)return this.uint8ArrayToHexString(i);throw console.log("-- sign message error",i),new Error("Unsupported signature")}let r=yield this._provider.signMessage(e);return"0x"+(0,Da.bytesToHex)(r)})}generateRegisterAccountMessage(e){return f(this,null,function*(){let[s,r]=ga(h(g({},e),{chainId:this.chainId})),t=yield this.signMessage(r);return{message:h(g({},s),{chainType:"SOL"}),signatured:t}})}generateWithdrawMessage(e){return f(this,null,function*(){let[s,r]=ka(h(g({},e),{chainId:this.chainId})),t=yield this.signMessage(r);return{message:h(g({},s),{chainType:"SOL"}),domain:{name:"",version:"",chainId:this.chainId,verifyingContract:e.verifyContract},signatured:t}})}generateInternalTransferMessage(e){return f(this,null,function*(){let[s,r]=Sa(h(g({},e),{chainId:this.chainId})),t=yield this.signMessage(r);return{message:h(g({},s),{chainType:"SOL"}),domain:{name:"",version:"",chainId:this.chainId,verifyingContract:e.verifyContract},signatured:t}})}generateAddOrderlyKeyMessage(e){return f(this,null,function*(){let[s,r]=ya(h(g({},e),{chainId:this.chainId})),t=yield this.signMessage(r);return{message:h(g({},s),{chainType:"SOL"}),signatured:t}})}generateSettleMessage(e){return f(this,null,function*(){let[s,r]=Aa(h(g({},e),{chainId:this.chainId})),t=yield this.signMessage(r);return{message:h(g({},s),{chainType:"SOL"}),domain:{name:"",version:"",chainId:this.chainId,verifyingContract:e.verifyContract},signatured:t}})}generateDexRequestMessage(e){return f(this,null,function*(){let[s,r]=yield ba(h(g({},e),{chainId:this.chainId})),t=yield this.signMessage(r);return{message:h(g({},e),{chainType:"SOL"}),signatured:t,domain:e.domain}})}getBalance(){return f(this,null,function*(){let e=new p.PublicKey(this.address),s=yield this.connection.getBalance(e);return BigInt(s)})}call(e,s,r,t){return f(this,null,function*(){if(s==="balanceOf"){let o=new p.PublicKey(e),d=new p.PublicKey(this._address),u=z(o,d),i=this.connection;return(yield(0,Ia.getAccount)(i,u,"confirmed")).amount}return s==="allowance"?ae.MaxUint256:BigInt(0)})}sendTransaction(e,s,r,t){return f(this,null,function*(){if(console.log("-- solanan sendTransaction",{contractAddress:e,method:s,payload:r,options:t}),s==="deposit")return ha({vaultAddress:e,userAddress:this._address,connection:this.connection,depositData:r.data[0],sendTransaction:this._provider.sendTransaction})})}callOnChain(e,s,r,t,o){return f(this,null,function*(){return console.log("-- params ",{chain:e,address:s,method:r,params:t}),r==="getDepositFee"?Oe({vaultAddress:s,userAddress:this._address,connection:this.connection,depositData:t[1]}):0})}pollTransactionReceiptWithBackoff(e,s,r,t){return f(this,null,function*(){return Promise.resolve({status:1})})}};0&&(module.exports={DefaultSolanaWalletAdapter,version});
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __defProps = Object.defineProperties;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
+ var __getProtoOf = Object.getPrototypeOf;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
+ var __spreadValues = (a, b) => {
14
+ for (var prop in b || (b = {}))
15
+ if (__hasOwnProp.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ if (__getOwnPropSymbols)
18
+ for (var prop of __getOwnPropSymbols(b)) {
19
+ if (__propIsEnum.call(b, prop))
20
+ __defNormalProp(a, prop, b[prop]);
21
+ }
22
+ return a;
23
+ };
24
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
+ var __export = (target, all) => {
26
+ for (var name in all)
27
+ __defProp(target, name, { get: all[name], enumerable: true });
28
+ };
29
+ var __copyProps = (to, from, except, desc) => {
30
+ if (from && typeof from === "object" || typeof from === "function") {
31
+ for (let key of __getOwnPropNames(from))
32
+ if (!__hasOwnProp.call(to, key) && key !== except)
33
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
34
+ }
35
+ return to;
36
+ };
37
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
38
+ // If the importer is in node compatibility mode or this is not an ESM
39
+ // file that has been converted to a CommonJS file using a Babel-
40
+ // compatible transform (i.e. "__esModule" has not been set), then set
41
+ // "default" to the CommonJS "module.exports" for node compatibility.
42
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
43
+ mod
44
+ ));
45
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
46
+ var __publicField = (obj, key, value) => {
47
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
48
+ return value;
49
+ };
50
+ var __async = (__this, __arguments, generator) => {
51
+ return new Promise((resolve, reject) => {
52
+ var fulfilled = (value) => {
53
+ try {
54
+ step(generator.next(value));
55
+ } catch (e) {
56
+ reject(e);
57
+ }
58
+ };
59
+ var rejected = (value) => {
60
+ try {
61
+ step(generator.throw(value));
62
+ } catch (e) {
63
+ reject(e);
64
+ }
65
+ };
66
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
67
+ step((generator = generator.apply(__this, __arguments)).next());
68
+ });
69
+ };
70
+
71
+ // src/index.ts
72
+ var src_exports = {};
73
+ __export(src_exports, {
74
+ DefaultSolanaWalletAdapter: () => DefaultSolanaWalletAdapter,
75
+ version: () => version_default
76
+ });
77
+ module.exports = __toCommonJS(src_exports);
78
+
79
+ // src/version.ts
80
+ if (typeof window !== "undefined") {
81
+ window.__ORDERLY_VERSION__ = window.__ORDERLY_VERSION__ || {};
82
+ window.__ORDERLY_VERSION__["@kodiak-finance/orderly-default-solana-adapter"] = "2.7.4";
83
+ }
84
+ var version_default = "2.7.4";
85
+
86
+ // src/walletAdapter.ts
87
+ var ed = __toESM(require("@noble/ed25519"));
88
+ var import_spl_token2 = require("@solana/spl-token");
89
+ var import_wallet_adapter_base = require("@solana/wallet-adapter-base");
90
+ var import_web34 = require("@solana/web3.js");
91
+ var import_bs582 = require("bs58");
92
+ var import_utils2 = require("ethereum-cryptography/utils");
93
+ var import_orderly_core2 = require("@kodiak-finance/orderly-core");
94
+ var import_orderly_types2 = require("@kodiak-finance/orderly-types");
95
+
96
+ // src/helper.ts
97
+ var import_anchor = require("@coral-xyz/anchor");
98
+ var import_web33 = require("@solana/web3.js");
99
+ var import_bs58 = require("bs58");
100
+ var import_keccak = require("ethereum-cryptography/keccak");
101
+ var import_utils = require("ethereum-cryptography/utils");
102
+ var import_ethers = require("ethers");
103
+ var import_orderly_core = require("@kodiak-finance/orderly-core");
104
+ var import_orderly_types = require("@kodiak-finance/orderly-types");
105
+
106
+ // src/constant.ts
107
+ var import_lz_v2_utilities = require("@layerzerolabs/lz-v2-utilities");
108
+ var import_web3 = require("@solana/web3.js");
109
+ var ENDPOINT_PROGRAM_ID = new import_web3.PublicKey(
110
+ "76y77prsiCMvXMjuoZ5VRrhG5qYBrUMYTE5WgHqgjEn6"
111
+ );
112
+ var SEND_LIB_PROGRAM_ID = new import_web3.PublicKey(
113
+ "7a4WjyR8VZ7yZz5XJAKm39BUGn5iT9CKcv2pmG9tdXVH"
114
+ );
115
+ var EXECUTOR_PROGRAM_ID = new import_web3.PublicKey(
116
+ "6doghB248px58JSSwG4qejQ46kFMW4AMj7vzJnWZHNZn"
117
+ );
118
+ var PRICE_FEED_PROGRAM_ID = new import_web3.PublicKey(
119
+ "8ahPGPjEbpgGaZx2NV1iG5Shj7TDwvsjkEDcGWjt94TP"
120
+ );
121
+ var RECEIVE_LIB_PROGRAM_ID = SEND_LIB_PROGRAM_ID;
122
+ var TREASURY_PROGRAM_ID = SEND_LIB_PROGRAM_ID;
123
+ var DVN_PROGRAM_ID = new import_web3.PublicKey(
124
+ "HtEYV4xB4wvsj5fgTkcfuChYpvGYzgzwvNhgDZQNh7wW"
125
+ );
126
+ var VAULT_AUTHORITY_SEED = "VaultAuthority";
127
+ var BROKER_SEED = "Broker";
128
+ var TOKEN_SEED = "Token";
129
+ var SOL_VAULT_SEED = "SolVault";
130
+ var DEV_PEER_ADDRESS = (0, import_lz_v2_utilities.addressToBytes32)(
131
+ "0x9Dc724b24146BeDD2dA28b8C4B74126169B8f312"
132
+ );
133
+ var QA_PEER_ADDRESS = (0, import_lz_v2_utilities.addressToBytes32)(
134
+ "0x45b6C6266A7A2170617d8A27A50C642fd68b91c4"
135
+ );
136
+ var STAGING_PEER_ADDRESS = (0, import_lz_v2_utilities.addressToBytes32)(
137
+ "0x5Bf771A65d057e778C5f0Ed52A0003316f94322D"
138
+ );
139
+ var MAINNET_PEER_ADDRESS = (0, import_lz_v2_utilities.addressToBytes32)(
140
+ "0xCecAe061aa078e13b5e70D5F9eCee90a3F2B6AeA"
141
+ );
142
+ var DEV_DST_EID = 40200;
143
+ var MAIN_DST_EID = 30213;
144
+ var DEV_LOOKUP_TABLE_ADDRESS = new import_web3.PublicKey(
145
+ "BWp8HaYYhiNHekt3zgQhqoCrRftneGxxfgKmCZ6svHN"
146
+ );
147
+ var QA_LOOKUP_TABLE_ADDRESS = new import_web3.PublicKey(
148
+ "BswrQQoPKAFojTuJutZcBMtigAgTghEH4M8ofn3EG2X2"
149
+ );
150
+ var STAGING_LOOKUP_TABLE_ADDRESS = new import_web3.PublicKey(
151
+ "BbGKfxuPwDmu58BjPpd7PMG69TqnZjSpKaLDMgf9E9Dr"
152
+ );
153
+ var MAINNET_LOOKUP_TABLE_ADDRESS = new import_web3.PublicKey(
154
+ "8iq7xCQt3bLdRRn4A46d5GuaXYinBoiAhbe2sUmZVzwg"
155
+ );
156
+ var DEV_OAPP_PROGRAM_ID = new import_web3.PublicKey(
157
+ "EYJq9eU4GMRUriUJBgGoZ8YLQBXcWaciXuSsEXE7ieQS"
158
+ );
159
+ var QA_OAPP_PROGRAM_ID = new import_web3.PublicKey(
160
+ "5zBjLor7vEraAt4zp2H82sy9MSqFoDnNa1Lx6EYKTYRZ"
161
+ );
162
+ var STAGING_OAPP_PROGRAM_ID = new import_web3.PublicKey(
163
+ "9shwxWDUNhtwkHocsUAmrNAQfBH2DHh4njdAEdHZZkF2"
164
+ );
165
+ var MAINNET_OAPP_PROGRAM_ID = new import_web3.PublicKey(
166
+ "ErBmAD61mGFKvrFNaTJuxoPwqrS8GgtwtqJTJVjFWx9Q"
167
+ );
168
+
169
+ // src/idl/solana_vault.ts
170
+ var IDL = {
171
+ version: "0.1.0",
172
+ name: "solana_vault",
173
+ instructions: [
174
+ {
175
+ name: "setVault",
176
+ accounts: [
177
+ {
178
+ name: "admin",
179
+ isMut: true,
180
+ isSigner: true
181
+ },
182
+ {
183
+ name: "vaultAuthority",
184
+ isMut: true,
185
+ isSigner: false
186
+ },
187
+ {
188
+ name: "oappConfig",
189
+ isMut: false,
190
+ isSigner: false
191
+ },
192
+ {
193
+ name: "systemProgram",
194
+ isMut: false,
195
+ isSigner: false
196
+ }
197
+ ],
198
+ args: [
199
+ {
200
+ name: "params",
201
+ type: {
202
+ defined: "SetVaultParams"
203
+ }
204
+ }
205
+ ]
206
+ },
207
+ {
208
+ name: "deposit",
209
+ accounts: [
210
+ {
211
+ name: "user",
212
+ isMut: true,
213
+ isSigner: true
214
+ },
215
+ {
216
+ name: "userTokenAccount",
217
+ isMut: true,
218
+ isSigner: false
219
+ },
220
+ {
221
+ name: "vaultAuthority",
222
+ isMut: true,
223
+ isSigner: false
224
+ },
225
+ {
226
+ name: "vaultTokenAccount",
227
+ isMut: true,
228
+ isSigner: false
229
+ },
230
+ {
231
+ name: "depositToken",
232
+ isMut: false,
233
+ isSigner: false
234
+ },
235
+ {
236
+ name: "peer",
237
+ isMut: false,
238
+ isSigner: false
239
+ },
240
+ {
241
+ name: "enforcedOptions",
242
+ isMut: false,
243
+ isSigner: false
244
+ },
245
+ {
246
+ name: "oappConfig",
247
+ isMut: false,
248
+ isSigner: false
249
+ },
250
+ {
251
+ name: "allowedBroker",
252
+ isMut: false,
253
+ isSigner: false
254
+ },
255
+ {
256
+ name: "allowedToken",
257
+ isMut: false,
258
+ isSigner: false
259
+ },
260
+ {
261
+ name: "tokenProgram",
262
+ isMut: false,
263
+ isSigner: false
264
+ },
265
+ {
266
+ name: "associatedTokenProgram",
267
+ isMut: false,
268
+ isSigner: false
269
+ },
270
+ {
271
+ name: "systemProgram",
272
+ isMut: false,
273
+ isSigner: false
274
+ }
275
+ ],
276
+ args: [
277
+ {
278
+ name: "depositParams",
279
+ type: {
280
+ defined: "DepositParams"
281
+ }
282
+ },
283
+ {
284
+ name: "oappParams",
285
+ type: {
286
+ defined: "OAppSendParams"
287
+ }
288
+ }
289
+ ],
290
+ returns: {
291
+ defined: "MessagingReceipt"
292
+ }
293
+ },
294
+ {
295
+ name: "depositSol",
296
+ accounts: [
297
+ {
298
+ name: "user",
299
+ isMut: true,
300
+ isSigner: true
301
+ },
302
+ {
303
+ name: "vaultAuthority",
304
+ isMut: true,
305
+ isSigner: false
306
+ },
307
+ {
308
+ name: "solVault",
309
+ isMut: true,
310
+ isSigner: false,
311
+ docs: ["CHECKED: sol_vault is used for SOL deposit"]
312
+ },
313
+ {
314
+ name: "peer",
315
+ isMut: false,
316
+ isSigner: false
317
+ },
318
+ {
319
+ name: "enforcedOptions",
320
+ isMut: false,
321
+ isSigner: false
322
+ },
323
+ {
324
+ name: "oappConfig",
325
+ isMut: false,
326
+ isSigner: false
327
+ },
328
+ {
329
+ name: "allowedBroker",
330
+ isMut: false,
331
+ isSigner: false
332
+ },
333
+ {
334
+ name: "allowedToken",
335
+ isMut: false,
336
+ isSigner: false
337
+ },
338
+ {
339
+ name: "systemProgram",
340
+ isMut: false,
341
+ isSigner: false
342
+ }
343
+ ],
344
+ args: [
345
+ {
346
+ name: "depositParams",
347
+ type: {
348
+ defined: "DepositParams"
349
+ }
350
+ },
351
+ {
352
+ name: "oappParams",
353
+ type: {
354
+ defined: "OAppSendParams"
355
+ }
356
+ }
357
+ ],
358
+ returns: {
359
+ defined: "MessagingReceipt"
360
+ }
361
+ },
362
+ {
363
+ name: "initOapp",
364
+ accounts: [
365
+ {
366
+ name: "payer",
367
+ isMut: true,
368
+ isSigner: true
369
+ },
370
+ {
371
+ name: "oappConfig",
372
+ isMut: true,
373
+ isSigner: false
374
+ },
375
+ {
376
+ name: "lzReceiveTypes",
377
+ isMut: true,
378
+ isSigner: false
379
+ },
380
+ {
381
+ name: "accountList",
382
+ isMut: true,
383
+ isSigner: false
384
+ },
385
+ {
386
+ name: "systemProgram",
387
+ isMut: false,
388
+ isSigner: false
389
+ }
390
+ ],
391
+ args: [
392
+ {
393
+ name: "params",
394
+ type: {
395
+ defined: "InitOAppParams"
396
+ }
397
+ }
398
+ ]
399
+ },
400
+ {
401
+ name: "setAccountList",
402
+ accounts: [
403
+ {
404
+ name: "admin",
405
+ isMut: true,
406
+ isSigner: true
407
+ },
408
+ {
409
+ name: "oappConfig",
410
+ isMut: false,
411
+ isSigner: false
412
+ },
413
+ {
414
+ name: "lzReceiveTypes",
415
+ isMut: true,
416
+ isSigner: false
417
+ },
418
+ {
419
+ name: "accountsList",
420
+ isMut: true,
421
+ isSigner: false
422
+ },
423
+ {
424
+ name: "systemProgram",
425
+ isMut: false,
426
+ isSigner: false
427
+ }
428
+ ],
429
+ args: [
430
+ {
431
+ name: "params",
432
+ type: {
433
+ defined: "SetAccountListParams"
434
+ }
435
+ }
436
+ ]
437
+ },
438
+ {
439
+ name: "setManagerRole",
440
+ accounts: [
441
+ {
442
+ name: "owner",
443
+ isMut: true,
444
+ isSigner: true
445
+ },
446
+ {
447
+ name: "vaultAuthority",
448
+ isMut: true,
449
+ isSigner: false
450
+ },
451
+ {
452
+ name: "managerRole",
453
+ isMut: true,
454
+ isSigner: false
455
+ },
456
+ {
457
+ name: "systemProgram",
458
+ isMut: false,
459
+ isSigner: false
460
+ }
461
+ ],
462
+ args: [
463
+ {
464
+ name: "params",
465
+ type: {
466
+ defined: "SetManagerRoleParams"
467
+ }
468
+ }
469
+ ]
470
+ },
471
+ {
472
+ name: "setBroker",
473
+ accounts: [
474
+ {
475
+ name: "brokerManager",
476
+ isMut: true,
477
+ isSigner: true
478
+ },
479
+ {
480
+ name: "allowedBroker",
481
+ isMut: true,
482
+ isSigner: false
483
+ },
484
+ {
485
+ name: "managerRole",
486
+ isMut: false,
487
+ isSigner: false
488
+ },
489
+ {
490
+ name: "systemProgram",
491
+ isMut: false,
492
+ isSigner: false
493
+ }
494
+ ],
495
+ args: [
496
+ {
497
+ name: "params",
498
+ type: {
499
+ defined: "SetBrokerParams"
500
+ }
501
+ }
502
+ ]
503
+ },
504
+ {
505
+ name: "setWithdrawBroker",
506
+ accounts: [
507
+ {
508
+ name: "brokerManager",
509
+ isMut: true,
510
+ isSigner: true
511
+ },
512
+ {
513
+ name: "withdrawBroker",
514
+ isMut: true,
515
+ isSigner: false
516
+ },
517
+ {
518
+ name: "managerRole",
519
+ isMut: false,
520
+ isSigner: false
521
+ },
522
+ {
523
+ name: "systemProgram",
524
+ isMut: false,
525
+ isSigner: false
526
+ }
527
+ ],
528
+ args: [
529
+ {
530
+ name: "params",
531
+ type: {
532
+ defined: "SetWithdrawBrokerParams"
533
+ }
534
+ }
535
+ ]
536
+ },
537
+ {
538
+ name: "setToken",
539
+ accounts: [
540
+ {
541
+ name: "tokenManager",
542
+ isMut: true,
543
+ isSigner: true
544
+ },
545
+ {
546
+ name: "allowedToken",
547
+ isMut: true,
548
+ isSigner: false
549
+ },
550
+ {
551
+ name: "managerRole",
552
+ isMut: false,
553
+ isSigner: false
554
+ },
555
+ {
556
+ name: "mintAccount",
557
+ isMut: false,
558
+ isSigner: false
559
+ },
560
+ {
561
+ name: "systemProgram",
562
+ isMut: false,
563
+ isSigner: false
564
+ }
565
+ ],
566
+ args: [
567
+ {
568
+ name: "params",
569
+ type: {
570
+ defined: "SetTokenParams"
571
+ }
572
+ }
573
+ ]
574
+ },
575
+ {
576
+ name: "setWithdrawToken",
577
+ accounts: [
578
+ {
579
+ name: "tokenManager",
580
+ isMut: true,
581
+ isSigner: true
582
+ },
583
+ {
584
+ name: "withdrawToken",
585
+ isMut: true,
586
+ isSigner: false
587
+ },
588
+ {
589
+ name: "managerRole",
590
+ isMut: false,
591
+ isSigner: false
592
+ },
593
+ {
594
+ name: "mintAccount",
595
+ isMut: false,
596
+ isSigner: false
597
+ },
598
+ {
599
+ name: "systemProgram",
600
+ isMut: false,
601
+ isSigner: false
602
+ }
603
+ ],
604
+ args: [
605
+ {
606
+ name: "params",
607
+ type: {
608
+ defined: "SetWithdrawTokenParams"
609
+ }
610
+ }
611
+ ]
612
+ },
613
+ {
614
+ name: "setOrderDelivery",
615
+ accounts: [
616
+ {
617
+ name: "owner",
618
+ isMut: true,
619
+ isSigner: true
620
+ },
621
+ {
622
+ name: "vaultAuthority",
623
+ isMut: true,
624
+ isSigner: false
625
+ }
626
+ ],
627
+ args: [
628
+ {
629
+ name: "params",
630
+ type: {
631
+ defined: "SetOrderDeliveryParams"
632
+ }
633
+ }
634
+ ]
635
+ },
636
+ {
637
+ name: "oappQuote",
638
+ accounts: [
639
+ {
640
+ name: "oappConfig",
641
+ isMut: false,
642
+ isSigner: false
643
+ },
644
+ {
645
+ name: "peer",
646
+ isMut: false,
647
+ isSigner: false
648
+ },
649
+ {
650
+ name: "enforcedOptions",
651
+ isMut: false,
652
+ isSigner: false
653
+ },
654
+ {
655
+ name: "vaultAuthority",
656
+ isMut: false,
657
+ isSigner: false
658
+ }
659
+ ],
660
+ args: [
661
+ {
662
+ name: "params",
663
+ type: {
664
+ defined: "DepositParams"
665
+ }
666
+ }
667
+ ],
668
+ returns: {
669
+ defined: "MessagingFee"
670
+ }
671
+ },
672
+ {
673
+ name: "lzReceive",
674
+ accounts: [
675
+ {
676
+ name: "payer",
677
+ isMut: true,
678
+ isSigner: true
679
+ },
680
+ {
681
+ name: "peer",
682
+ isMut: false,
683
+ isSigner: false
684
+ },
685
+ {
686
+ name: "oappConfig",
687
+ isMut: false,
688
+ isSigner: false
689
+ },
690
+ {
691
+ name: "withdrawBrokerPda",
692
+ isMut: false,
693
+ isSigner: false
694
+ },
695
+ {
696
+ name: "withdrawTokenPda",
697
+ isMut: false,
698
+ isSigner: false,
699
+ docs: ["CHECK"]
700
+ },
701
+ {
702
+ name: "tokenMint",
703
+ isMut: false,
704
+ isSigner: false,
705
+ docs: ["CHECK"]
706
+ },
707
+ {
708
+ name: "receiver",
709
+ isMut: true,
710
+ isSigner: false,
711
+ docs: ["CHECK"]
712
+ },
713
+ {
714
+ name: "receiverTokenAccount",
715
+ isMut: true,
716
+ isSigner: false,
717
+ docs: ["UNCHECKED"]
718
+ },
719
+ {
720
+ name: "vaultAuthority",
721
+ isMut: true,
722
+ isSigner: false
723
+ },
724
+ {
725
+ name: "vaultTokenAccount",
726
+ isMut: true,
727
+ isSigner: false
728
+ },
729
+ {
730
+ name: "tokenProgram",
731
+ isMut: false,
732
+ isSigner: false,
733
+ docs: ["CHECKED: sol_vault is used for SOL withdrawal"]
734
+ },
735
+ {
736
+ name: "associatedTokenProgram",
737
+ isMut: false,
738
+ isSigner: false
739
+ },
740
+ {
741
+ name: "systemProgram",
742
+ isMut: false,
743
+ isSigner: false
744
+ },
745
+ {
746
+ name: "eventAuthority",
747
+ isMut: false,
748
+ isSigner: false
749
+ },
750
+ {
751
+ name: "program",
752
+ isMut: false,
753
+ isSigner: false
754
+ }
755
+ ],
756
+ args: [
757
+ {
758
+ name: "params",
759
+ type: {
760
+ defined: "OAppLzReceiveParams"
761
+ }
762
+ }
763
+ ]
764
+ },
765
+ {
766
+ name: "lzReceiveTypes",
767
+ accounts: [
768
+ {
769
+ name: "oappConfig",
770
+ isMut: false,
771
+ isSigner: false
772
+ },
773
+ {
774
+ name: "accountList",
775
+ isMut: false,
776
+ isSigner: false
777
+ }
778
+ ],
779
+ args: [
780
+ {
781
+ name: "params",
782
+ type: {
783
+ defined: "OAppLzReceiveParams"
784
+ }
785
+ }
786
+ ],
787
+ returns: {
788
+ vec: {
789
+ defined: "oapp::endpoint_cpi::LzAccount"
790
+ }
791
+ }
792
+ },
793
+ {
794
+ name: "setRateLimit",
795
+ accounts: [
796
+ {
797
+ name: "admin",
798
+ isMut: false,
799
+ isSigner: true
800
+ },
801
+ {
802
+ name: "peer",
803
+ isMut: true,
804
+ isSigner: false
805
+ },
806
+ {
807
+ name: "oappConfig",
808
+ isMut: false,
809
+ isSigner: false
810
+ }
811
+ ],
812
+ args: [
813
+ {
814
+ name: "params",
815
+ type: {
816
+ defined: "SetRateLimitParams"
817
+ }
818
+ }
819
+ ]
820
+ },
821
+ {
822
+ name: "setDelegate",
823
+ accounts: [
824
+ {
825
+ name: "admin",
826
+ isMut: false,
827
+ isSigner: true
828
+ },
829
+ {
830
+ name: "oappConfig",
831
+ isMut: false,
832
+ isSigner: false
833
+ }
834
+ ],
835
+ args: [
836
+ {
837
+ name: "params",
838
+ type: {
839
+ defined: "SetDelegateParams"
840
+ }
841
+ }
842
+ ]
843
+ },
844
+ {
845
+ name: "transferAdmin",
846
+ accounts: [
847
+ {
848
+ name: "admin",
849
+ isMut: false,
850
+ isSigner: true
851
+ },
852
+ {
853
+ name: "oappConfig",
854
+ isMut: true,
855
+ isSigner: false
856
+ }
857
+ ],
858
+ args: [
859
+ {
860
+ name: "params",
861
+ type: {
862
+ defined: "TransferAdminParams"
863
+ }
864
+ }
865
+ ]
866
+ },
867
+ {
868
+ name: "setPeer",
869
+ accounts: [
870
+ {
871
+ name: "admin",
872
+ isMut: true,
873
+ isSigner: true
874
+ },
875
+ {
876
+ name: "peer",
877
+ isMut: true,
878
+ isSigner: false
879
+ },
880
+ {
881
+ name: "oappConfig",
882
+ isMut: false,
883
+ isSigner: false
884
+ },
885
+ {
886
+ name: "systemProgram",
887
+ isMut: false,
888
+ isSigner: false
889
+ }
890
+ ],
891
+ args: [
892
+ {
893
+ name: "params",
894
+ type: {
895
+ defined: "SetPeerParams"
896
+ }
897
+ }
898
+ ]
899
+ },
900
+ {
901
+ name: "setEnforcedOptions",
902
+ accounts: [
903
+ {
904
+ name: "admin",
905
+ isMut: true,
906
+ isSigner: true
907
+ },
908
+ {
909
+ name: "enforcedOptions",
910
+ isMut: true,
911
+ isSigner: false
912
+ },
913
+ {
914
+ name: "oappConfig",
915
+ isMut: false,
916
+ isSigner: false
917
+ },
918
+ {
919
+ name: "systemProgram",
920
+ isMut: false,
921
+ isSigner: false
922
+ }
923
+ ],
924
+ args: [
925
+ {
926
+ name: "params",
927
+ type: {
928
+ defined: "SetEnforcedOptionsParams"
929
+ }
930
+ }
931
+ ]
932
+ }
933
+ ],
934
+ accounts: [
935
+ {
936
+ name: "enforcedOptions",
937
+ type: {
938
+ kind: "struct",
939
+ fields: [
940
+ {
941
+ name: "send",
942
+ type: "bytes"
943
+ },
944
+ {
945
+ name: "sendAndCall",
946
+ type: "bytes"
947
+ },
948
+ {
949
+ name: "bump",
950
+ type: "u8"
951
+ }
952
+ ]
953
+ }
954
+ },
955
+ {
956
+ name: "oAppConfig",
957
+ type: {
958
+ kind: "struct",
959
+ fields: [
960
+ {
961
+ name: "endpointProgram",
962
+ type: "publicKey"
963
+ },
964
+ {
965
+ name: "bump",
966
+ type: "u8"
967
+ },
968
+ {
969
+ name: "admin",
970
+ type: "publicKey"
971
+ }
972
+ ]
973
+ }
974
+ },
975
+ {
976
+ name: "oAppLzReceiveTypesAccounts",
977
+ type: {
978
+ kind: "struct",
979
+ fields: [
980
+ {
981
+ name: "oappConfig",
982
+ type: "publicKey"
983
+ },
984
+ {
985
+ name: "accountList",
986
+ type: "publicKey"
987
+ }
988
+ ]
989
+ }
990
+ },
991
+ {
992
+ name: "accountList",
993
+ type: {
994
+ kind: "struct",
995
+ fields: [
996
+ {
997
+ name: "bump",
998
+ type: "u8"
999
+ },
1000
+ {
1001
+ name: "woofiProPda",
1002
+ type: "publicKey"
1003
+ },
1004
+ {
1005
+ name: "withdrawUsdcPda",
1006
+ type: "publicKey"
1007
+ },
1008
+ {
1009
+ name: "usdcMint",
1010
+ type: "publicKey"
1011
+ },
1012
+ {
1013
+ name: "withdrawUsdtPda",
1014
+ type: "publicKey"
1015
+ },
1016
+ {
1017
+ name: "usdtMint",
1018
+ type: "publicKey"
1019
+ },
1020
+ {
1021
+ name: "withdrawWsolPda",
1022
+ type: "publicKey"
1023
+ },
1024
+ {
1025
+ name: "wsolMint",
1026
+ type: "publicKey"
1027
+ }
1028
+ ]
1029
+ }
1030
+ },
1031
+ {
1032
+ name: "peer",
1033
+ type: {
1034
+ kind: "struct",
1035
+ fields: [
1036
+ {
1037
+ name: "address",
1038
+ type: {
1039
+ array: ["u8", 32]
1040
+ }
1041
+ },
1042
+ {
1043
+ name: "rateLimiter",
1044
+ type: {
1045
+ option: {
1046
+ defined: "RateLimiter"
1047
+ }
1048
+ }
1049
+ },
1050
+ {
1051
+ name: "bump",
1052
+ type: "u8"
1053
+ }
1054
+ ]
1055
+ }
1056
+ },
1057
+ {
1058
+ name: "allowedBroker",
1059
+ type: {
1060
+ kind: "struct",
1061
+ fields: [
1062
+ {
1063
+ name: "brokerHash",
1064
+ type: {
1065
+ array: ["u8", 32]
1066
+ }
1067
+ },
1068
+ {
1069
+ name: "allowed",
1070
+ type: "bool"
1071
+ },
1072
+ {
1073
+ name: "bump",
1074
+ type: "u8"
1075
+ }
1076
+ ]
1077
+ }
1078
+ },
1079
+ {
1080
+ name: "allowedToken",
1081
+ type: {
1082
+ kind: "struct",
1083
+ fields: [
1084
+ {
1085
+ name: "mintAccount",
1086
+ type: "publicKey"
1087
+ },
1088
+ {
1089
+ name: "tokenHash",
1090
+ type: {
1091
+ array: ["u8", 32]
1092
+ }
1093
+ },
1094
+ {
1095
+ name: "tokenDecimals",
1096
+ type: "u8"
1097
+ },
1098
+ {
1099
+ name: "allowed",
1100
+ type: "bool"
1101
+ },
1102
+ {
1103
+ name: "bump",
1104
+ type: "u8"
1105
+ }
1106
+ ]
1107
+ }
1108
+ },
1109
+ {
1110
+ name: "managerRole",
1111
+ type: {
1112
+ kind: "struct",
1113
+ fields: [
1114
+ {
1115
+ name: "roleHash",
1116
+ type: {
1117
+ array: ["u8", 32]
1118
+ }
1119
+ },
1120
+ {
1121
+ name: "allowed",
1122
+ type: "bool"
1123
+ },
1124
+ {
1125
+ name: "bump",
1126
+ type: "u8"
1127
+ }
1128
+ ]
1129
+ }
1130
+ },
1131
+ {
1132
+ name: "vaultAuthority",
1133
+ type: {
1134
+ kind: "struct",
1135
+ fields: [
1136
+ {
1137
+ name: "bump",
1138
+ docs: ["Bump seed for the vault authority PDA"],
1139
+ type: "u8"
1140
+ },
1141
+ {
1142
+ name: "owner",
1143
+ type: "publicKey"
1144
+ },
1145
+ {
1146
+ name: "depositNonce",
1147
+ type: "u64"
1148
+ },
1149
+ {
1150
+ name: "orderDelivery",
1151
+ type: "bool"
1152
+ },
1153
+ {
1154
+ name: "inboundNonce",
1155
+ type: "u64"
1156
+ },
1157
+ {
1158
+ name: "dstEid",
1159
+ type: "u32"
1160
+ },
1161
+ {
1162
+ name: "solChainId",
1163
+ type: "u128"
1164
+ }
1165
+ ]
1166
+ }
1167
+ },
1168
+ {
1169
+ name: "withdrawBroker",
1170
+ type: {
1171
+ kind: "struct",
1172
+ fields: [
1173
+ {
1174
+ name: "brokerHash",
1175
+ type: {
1176
+ array: ["u8", 32]
1177
+ }
1178
+ },
1179
+ {
1180
+ name: "brokerIndex",
1181
+ type: "u16"
1182
+ },
1183
+ {
1184
+ name: "allowed",
1185
+ type: "bool"
1186
+ },
1187
+ {
1188
+ name: "bump",
1189
+ type: "u8"
1190
+ }
1191
+ ]
1192
+ }
1193
+ },
1194
+ {
1195
+ name: "withdrawToken",
1196
+ type: {
1197
+ kind: "struct",
1198
+ fields: [
1199
+ {
1200
+ name: "mintAccount",
1201
+ type: "publicKey"
1202
+ },
1203
+ {
1204
+ name: "tokenHash",
1205
+ type: {
1206
+ array: ["u8", 32]
1207
+ }
1208
+ },
1209
+ {
1210
+ name: "tokenDecimals",
1211
+ type: "u8"
1212
+ },
1213
+ {
1214
+ name: "tokenIndex",
1215
+ type: "u8"
1216
+ },
1217
+ {
1218
+ name: "allowed",
1219
+ type: "bool"
1220
+ },
1221
+ {
1222
+ name: "bump",
1223
+ type: "u8"
1224
+ }
1225
+ ]
1226
+ }
1227
+ }
1228
+ ],
1229
+ types: [
1230
+ {
1231
+ name: "VaultDepositParams",
1232
+ type: {
1233
+ kind: "struct",
1234
+ fields: [
1235
+ {
1236
+ name: "accountId",
1237
+ type: {
1238
+ array: ["u8", 32]
1239
+ }
1240
+ },
1241
+ {
1242
+ name: "brokerHash",
1243
+ type: {
1244
+ array: ["u8", 32]
1245
+ }
1246
+ },
1247
+ {
1248
+ name: "userAddress",
1249
+ type: {
1250
+ array: ["u8", 32]
1251
+ }
1252
+ },
1253
+ {
1254
+ name: "tokenHash",
1255
+ type: {
1256
+ array: ["u8", 32]
1257
+ }
1258
+ },
1259
+ {
1260
+ name: "srcChainId",
1261
+ type: "u128"
1262
+ },
1263
+ {
1264
+ name: "tokenAmount",
1265
+ type: "u128"
1266
+ },
1267
+ {
1268
+ name: "srcChainDepositNonce",
1269
+ type: "u64"
1270
+ }
1271
+ ]
1272
+ }
1273
+ },
1274
+ {
1275
+ name: "LzMessage",
1276
+ type: {
1277
+ kind: "struct",
1278
+ fields: [
1279
+ {
1280
+ name: "msgType",
1281
+ type: "u8"
1282
+ },
1283
+ {
1284
+ name: "payload",
1285
+ type: "bytes"
1286
+ }
1287
+ ]
1288
+ }
1289
+ },
1290
+ {
1291
+ name: "AccountWithdrawSol",
1292
+ type: {
1293
+ kind: "struct",
1294
+ fields: [
1295
+ {
1296
+ name: "sender",
1297
+ type: {
1298
+ array: ["u8", 32]
1299
+ }
1300
+ },
1301
+ {
1302
+ name: "receiver",
1303
+ type: {
1304
+ array: ["u8", 32]
1305
+ }
1306
+ },
1307
+ {
1308
+ name: "brokerIndex",
1309
+ type: "u16"
1310
+ },
1311
+ {
1312
+ name: "tokenIndex",
1313
+ type: "u8"
1314
+ },
1315
+ {
1316
+ name: "tokenAmount",
1317
+ type: "u64"
1318
+ },
1319
+ {
1320
+ name: "fee",
1321
+ type: "u64"
1322
+ },
1323
+ {
1324
+ name: "chainId",
1325
+ type: "u64"
1326
+ },
1327
+ {
1328
+ name: "withdrawNonce",
1329
+ type: "u64"
1330
+ }
1331
+ ]
1332
+ }
1333
+ },
1334
+ {
1335
+ name: "VaultWithdrawParams",
1336
+ type: {
1337
+ kind: "struct",
1338
+ fields: [
1339
+ {
1340
+ name: "accountId",
1341
+ type: {
1342
+ array: ["u8", 32]
1343
+ }
1344
+ },
1345
+ {
1346
+ name: "sender",
1347
+ type: {
1348
+ array: ["u8", 32]
1349
+ }
1350
+ },
1351
+ {
1352
+ name: "receiver",
1353
+ type: {
1354
+ array: ["u8", 32]
1355
+ }
1356
+ },
1357
+ {
1358
+ name: "brokerHash",
1359
+ type: {
1360
+ array: ["u8", 32]
1361
+ }
1362
+ },
1363
+ {
1364
+ name: "tokenHash",
1365
+ type: {
1366
+ array: ["u8", 32]
1367
+ }
1368
+ },
1369
+ {
1370
+ name: "tokenAmount",
1371
+ type: "u64"
1372
+ },
1373
+ {
1374
+ name: "fee",
1375
+ type: "u128"
1376
+ },
1377
+ {
1378
+ name: "chainId",
1379
+ type: "u128"
1380
+ },
1381
+ {
1382
+ name: "withdrawNonce",
1383
+ type: "u64"
1384
+ }
1385
+ ]
1386
+ }
1387
+ },
1388
+ {
1389
+ name: "InitOAppParams",
1390
+ type: {
1391
+ kind: "struct",
1392
+ fields: [
1393
+ {
1394
+ name: "admin",
1395
+ type: "publicKey"
1396
+ },
1397
+ {
1398
+ name: "accountList",
1399
+ type: "publicKey"
1400
+ },
1401
+ {
1402
+ name: "endpointProgram",
1403
+ type: {
1404
+ option: "publicKey"
1405
+ }
1406
+ }
1407
+ ]
1408
+ }
1409
+ },
1410
+ {
1411
+ name: "OAppLzReceiveParams",
1412
+ type: {
1413
+ kind: "struct",
1414
+ fields: [
1415
+ {
1416
+ name: "srcEid",
1417
+ type: "u32"
1418
+ },
1419
+ {
1420
+ name: "sender",
1421
+ type: {
1422
+ array: ["u8", 32]
1423
+ }
1424
+ },
1425
+ {
1426
+ name: "nonce",
1427
+ type: "u64"
1428
+ },
1429
+ {
1430
+ name: "guid",
1431
+ type: {
1432
+ array: ["u8", 32]
1433
+ }
1434
+ },
1435
+ {
1436
+ name: "message",
1437
+ type: "bytes"
1438
+ },
1439
+ {
1440
+ name: "extraData",
1441
+ type: "bytes"
1442
+ }
1443
+ ]
1444
+ }
1445
+ },
1446
+ {
1447
+ name: "MessagingFee",
1448
+ type: {
1449
+ kind: "struct",
1450
+ fields: [
1451
+ {
1452
+ name: "nativeFee",
1453
+ type: "u64"
1454
+ },
1455
+ {
1456
+ name: "lzTokenFee",
1457
+ type: "u64"
1458
+ }
1459
+ ]
1460
+ }
1461
+ },
1462
+ {
1463
+ name: "SetAccountListParams",
1464
+ type: {
1465
+ kind: "struct",
1466
+ fields: [
1467
+ {
1468
+ name: "woofiProPda",
1469
+ type: "publicKey"
1470
+ },
1471
+ {
1472
+ name: "withdrawUsdcPda",
1473
+ type: "publicKey"
1474
+ },
1475
+ {
1476
+ name: "usdcMint",
1477
+ type: "publicKey"
1478
+ },
1479
+ {
1480
+ name: "withdrawUsdtPda",
1481
+ type: "publicKey"
1482
+ },
1483
+ {
1484
+ name: "usdtMint",
1485
+ type: "publicKey"
1486
+ },
1487
+ {
1488
+ name: "withdrawWsolPda",
1489
+ type: "publicKey"
1490
+ },
1491
+ {
1492
+ name: "wsolMint",
1493
+ type: "publicKey"
1494
+ }
1495
+ ]
1496
+ }
1497
+ },
1498
+ {
1499
+ name: "SetDelegateParams",
1500
+ type: {
1501
+ kind: "struct",
1502
+ fields: [
1503
+ {
1504
+ name: "delegate",
1505
+ type: "publicKey"
1506
+ }
1507
+ ]
1508
+ }
1509
+ },
1510
+ {
1511
+ name: "SetEnforcedOptionsParams",
1512
+ type: {
1513
+ kind: "struct",
1514
+ fields: [
1515
+ {
1516
+ name: "dstEid",
1517
+ type: "u32"
1518
+ },
1519
+ {
1520
+ name: "send",
1521
+ type: "bytes"
1522
+ },
1523
+ {
1524
+ name: "sendAndCall",
1525
+ type: "bytes"
1526
+ }
1527
+ ]
1528
+ }
1529
+ },
1530
+ {
1531
+ name: "SetPeerParams",
1532
+ type: {
1533
+ kind: "struct",
1534
+ fields: [
1535
+ {
1536
+ name: "dstEid",
1537
+ type: "u32"
1538
+ },
1539
+ {
1540
+ name: "peer",
1541
+ type: {
1542
+ array: ["u8", 32]
1543
+ }
1544
+ }
1545
+ ]
1546
+ }
1547
+ },
1548
+ {
1549
+ name: "SetRateLimitParams",
1550
+ type: {
1551
+ kind: "struct",
1552
+ fields: [
1553
+ {
1554
+ name: "dstEid",
1555
+ type: "u32"
1556
+ },
1557
+ {
1558
+ name: "refillPerSecond",
1559
+ type: {
1560
+ option: "u64"
1561
+ }
1562
+ },
1563
+ {
1564
+ name: "capacity",
1565
+ type: {
1566
+ option: "u64"
1567
+ }
1568
+ },
1569
+ {
1570
+ name: "enabled",
1571
+ type: "bool"
1572
+ }
1573
+ ]
1574
+ }
1575
+ },
1576
+ {
1577
+ name: "TransferAdminParams",
1578
+ type: {
1579
+ kind: "struct",
1580
+ fields: [
1581
+ {
1582
+ name: "admin",
1583
+ type: "publicKey"
1584
+ }
1585
+ ]
1586
+ }
1587
+ },
1588
+ {
1589
+ name: "DepositParams",
1590
+ type: {
1591
+ kind: "struct",
1592
+ fields: [
1593
+ {
1594
+ name: "accountId",
1595
+ type: {
1596
+ array: ["u8", 32]
1597
+ }
1598
+ },
1599
+ {
1600
+ name: "brokerHash",
1601
+ type: {
1602
+ array: ["u8", 32]
1603
+ }
1604
+ },
1605
+ {
1606
+ name: "tokenHash",
1607
+ type: {
1608
+ array: ["u8", 32]
1609
+ }
1610
+ },
1611
+ {
1612
+ name: "userAddress",
1613
+ type: {
1614
+ array: ["u8", 32]
1615
+ }
1616
+ },
1617
+ {
1618
+ name: "tokenAmount",
1619
+ type: "u64"
1620
+ }
1621
+ ]
1622
+ }
1623
+ },
1624
+ {
1625
+ name: "OAppSendParams",
1626
+ type: {
1627
+ kind: "struct",
1628
+ fields: [
1629
+ {
1630
+ name: "nativeFee",
1631
+ type: "u64"
1632
+ },
1633
+ {
1634
+ name: "lzTokenFee",
1635
+ type: "u64"
1636
+ }
1637
+ ]
1638
+ }
1639
+ },
1640
+ {
1641
+ name: "SetBrokerParams",
1642
+ type: {
1643
+ kind: "struct",
1644
+ fields: [
1645
+ {
1646
+ name: "brokerManagerRole",
1647
+ type: {
1648
+ array: ["u8", 32]
1649
+ }
1650
+ },
1651
+ {
1652
+ name: "brokerHash",
1653
+ type: {
1654
+ array: ["u8", 32]
1655
+ }
1656
+ },
1657
+ {
1658
+ name: "allowed",
1659
+ type: "bool"
1660
+ }
1661
+ ]
1662
+ }
1663
+ },
1664
+ {
1665
+ name: "SetManagerRoleParams",
1666
+ type: {
1667
+ kind: "struct",
1668
+ fields: [
1669
+ {
1670
+ name: "roleHash",
1671
+ type: {
1672
+ array: ["u8", 32]
1673
+ }
1674
+ },
1675
+ {
1676
+ name: "managerAddress",
1677
+ type: "publicKey"
1678
+ },
1679
+ {
1680
+ name: "allowed",
1681
+ type: "bool"
1682
+ }
1683
+ ]
1684
+ }
1685
+ },
1686
+ {
1687
+ name: "SetOrderDeliveryParams",
1688
+ type: {
1689
+ kind: "struct",
1690
+ fields: [
1691
+ {
1692
+ name: "orderDelivery",
1693
+ type: "bool"
1694
+ },
1695
+ {
1696
+ name: "nonce",
1697
+ type: "u64"
1698
+ }
1699
+ ]
1700
+ }
1701
+ },
1702
+ {
1703
+ name: "SetTokenParams",
1704
+ type: {
1705
+ kind: "struct",
1706
+ fields: [
1707
+ {
1708
+ name: "tokenManagerRole",
1709
+ type: {
1710
+ array: ["u8", 32]
1711
+ }
1712
+ },
1713
+ {
1714
+ name: "mintAccount",
1715
+ type: "publicKey"
1716
+ },
1717
+ {
1718
+ name: "tokenHash",
1719
+ type: {
1720
+ array: ["u8", 32]
1721
+ }
1722
+ },
1723
+ {
1724
+ name: "allowed",
1725
+ type: "bool"
1726
+ }
1727
+ ]
1728
+ }
1729
+ },
1730
+ {
1731
+ name: "SetVaultParams",
1732
+ type: {
1733
+ kind: "struct",
1734
+ fields: [
1735
+ {
1736
+ name: "owner",
1737
+ type: "publicKey"
1738
+ },
1739
+ {
1740
+ name: "depositNonce",
1741
+ type: "u64"
1742
+ },
1743
+ {
1744
+ name: "orderDelivery",
1745
+ type: "bool"
1746
+ },
1747
+ {
1748
+ name: "inboundNonce",
1749
+ type: "u64"
1750
+ },
1751
+ {
1752
+ name: "dstEid",
1753
+ type: "u32"
1754
+ },
1755
+ {
1756
+ name: "solChainId",
1757
+ type: "u128"
1758
+ }
1759
+ ]
1760
+ }
1761
+ },
1762
+ {
1763
+ name: "SetWithdrawBrokerParams",
1764
+ type: {
1765
+ kind: "struct",
1766
+ fields: [
1767
+ {
1768
+ name: "brokerManagerRole",
1769
+ type: {
1770
+ array: ["u8", 32]
1771
+ }
1772
+ },
1773
+ {
1774
+ name: "brokerHash",
1775
+ type: {
1776
+ array: ["u8", 32]
1777
+ }
1778
+ },
1779
+ {
1780
+ name: "brokerIndex",
1781
+ type: "u16"
1782
+ },
1783
+ {
1784
+ name: "allowed",
1785
+ type: "bool"
1786
+ }
1787
+ ]
1788
+ }
1789
+ },
1790
+ {
1791
+ name: "SetWithdrawTokenParams",
1792
+ type: {
1793
+ kind: "struct",
1794
+ fields: [
1795
+ {
1796
+ name: "tokenManagerRole",
1797
+ type: {
1798
+ array: ["u8", 32]
1799
+ }
1800
+ },
1801
+ {
1802
+ name: "tokenHash",
1803
+ type: {
1804
+ array: ["u8", 32]
1805
+ }
1806
+ },
1807
+ {
1808
+ name: "tokenIndex",
1809
+ type: "u8"
1810
+ },
1811
+ {
1812
+ name: "allowed",
1813
+ type: "bool"
1814
+ }
1815
+ ]
1816
+ }
1817
+ },
1818
+ {
1819
+ name: "RateLimiter",
1820
+ type: {
1821
+ kind: "struct",
1822
+ fields: [
1823
+ {
1824
+ name: "capacity",
1825
+ type: "u64"
1826
+ },
1827
+ {
1828
+ name: "tokens",
1829
+ type: "u64"
1830
+ },
1831
+ {
1832
+ name: "refillPerSecond",
1833
+ type: "u64"
1834
+ },
1835
+ {
1836
+ name: "lastRefillTime",
1837
+ type: "u64"
1838
+ }
1839
+ ]
1840
+ }
1841
+ },
1842
+ {
1843
+ name: "OAppError",
1844
+ type: {
1845
+ kind: "enum",
1846
+ variants: [
1847
+ {
1848
+ name: "Unauthorized"
1849
+ },
1850
+ {
1851
+ name: "InvalidSender"
1852
+ },
1853
+ {
1854
+ name: "InvalidReceiver"
1855
+ },
1856
+ {
1857
+ name: "InvalidOptions"
1858
+ },
1859
+ {
1860
+ name: "InvalidEndpointProgram"
1861
+ },
1862
+ {
1863
+ name: "RateLimitExceeded"
1864
+ },
1865
+ {
1866
+ name: "WithdrawFailed"
1867
+ },
1868
+ {
1869
+ name: "InvalidInboundNonce"
1870
+ },
1871
+ {
1872
+ name: "InvalidReceiverTokenAccount"
1873
+ },
1874
+ {
1875
+ name: "InvalidAdminTokenAccount"
1876
+ },
1877
+ {
1878
+ name: "InvalidMessageType"
1879
+ },
1880
+ {
1881
+ name: "InvalidTokenIndex"
1882
+ }
1883
+ ]
1884
+ }
1885
+ },
1886
+ {
1887
+ name: "MsgType",
1888
+ type: {
1889
+ kind: "enum",
1890
+ variants: [
1891
+ {
1892
+ name: "Deposit"
1893
+ },
1894
+ {
1895
+ name: "Withdraw"
1896
+ },
1897
+ {
1898
+ name: "RebalanceBurn"
1899
+ },
1900
+ {
1901
+ name: "RebalanceMint"
1902
+ }
1903
+ ]
1904
+ }
1905
+ }
1906
+ ],
1907
+ events: [
1908
+ {
1909
+ name: "SetAllowedBroker",
1910
+ fields: [
1911
+ {
1912
+ name: "brokerHash",
1913
+ type: {
1914
+ array: ["u8", 32]
1915
+ },
1916
+ index: false
1917
+ }
1918
+ ]
1919
+ },
1920
+ {
1921
+ name: "ResetAllowedBroker",
1922
+ fields: [
1923
+ {
1924
+ name: "brokerHash",
1925
+ type: {
1926
+ array: ["u8", 32]
1927
+ },
1928
+ index: false
1929
+ }
1930
+ ]
1931
+ },
1932
+ {
1933
+ name: "SetAllowedToken",
1934
+ fields: [
1935
+ {
1936
+ name: "tokenHash",
1937
+ type: {
1938
+ array: ["u8", 32]
1939
+ },
1940
+ index: false
1941
+ },
1942
+ {
1943
+ name: "mintAccount",
1944
+ type: "publicKey",
1945
+ index: false
1946
+ }
1947
+ ]
1948
+ },
1949
+ {
1950
+ name: "ResetAllowedToken",
1951
+ fields: [
1952
+ {
1953
+ name: "tokenHash",
1954
+ type: {
1955
+ array: ["u8", 32]
1956
+ },
1957
+ index: false
1958
+ },
1959
+ {
1960
+ name: "mintAccount",
1961
+ type: "publicKey",
1962
+ index: false
1963
+ }
1964
+ ]
1965
+ },
1966
+ {
1967
+ name: "SetWithdrawTokenIndex",
1968
+ fields: [
1969
+ {
1970
+ name: "tokenIndex",
1971
+ type: "u8",
1972
+ index: false
1973
+ },
1974
+ {
1975
+ name: "tokenHash",
1976
+ type: {
1977
+ array: ["u8", 32]
1978
+ },
1979
+ index: false
1980
+ },
1981
+ {
1982
+ name: "mintAccount",
1983
+ type: "publicKey",
1984
+ index: false
1985
+ }
1986
+ ]
1987
+ },
1988
+ {
1989
+ name: "ResetWithdrawTokenIndex",
1990
+ fields: [
1991
+ {
1992
+ name: "tokenIndex",
1993
+ type: "u8",
1994
+ index: false
1995
+ },
1996
+ {
1997
+ name: "tokenHash",
1998
+ type: {
1999
+ array: ["u8", 32]
2000
+ },
2001
+ index: false
2002
+ },
2003
+ {
2004
+ name: "mintAccount",
2005
+ type: "publicKey",
2006
+ index: false
2007
+ }
2008
+ ]
2009
+ },
2010
+ {
2011
+ name: "SetWithdrawBrokerEvent",
2012
+ fields: [
2013
+ {
2014
+ name: "brokerHash",
2015
+ type: {
2016
+ array: ["u8", 32]
2017
+ },
2018
+ index: false
2019
+ },
2020
+ {
2021
+ name: "brokerIndex",
2022
+ type: "u16",
2023
+ index: false
2024
+ }
2025
+ ]
2026
+ },
2027
+ {
2028
+ name: "ResetWithdrawBrokerEvent",
2029
+ fields: [
2030
+ {
2031
+ name: "brokerHash",
2032
+ type: {
2033
+ array: ["u8", 32]
2034
+ },
2035
+ index: false
2036
+ },
2037
+ {
2038
+ name: "brokerIndex",
2039
+ type: "u16",
2040
+ index: false
2041
+ }
2042
+ ]
2043
+ },
2044
+ {
2045
+ name: "SetManager",
2046
+ fields: [
2047
+ {
2048
+ name: "roleHash",
2049
+ type: {
2050
+ array: ["u8", 32]
2051
+ },
2052
+ index: false
2053
+ },
2054
+ {
2055
+ name: "managerAddress",
2056
+ type: "publicKey",
2057
+ index: false
2058
+ },
2059
+ {
2060
+ name: "allowed",
2061
+ type: "bool",
2062
+ index: false
2063
+ }
2064
+ ]
2065
+ },
2066
+ {
2067
+ name: "Deposited",
2068
+ fields: [
2069
+ {
2070
+ name: "user",
2071
+ type: "publicKey",
2072
+ index: false
2073
+ },
2074
+ {
2075
+ name: "amount",
2076
+ type: "u64",
2077
+ index: false
2078
+ }
2079
+ ]
2080
+ },
2081
+ {
2082
+ name: "Withdrawn",
2083
+ fields: [
2084
+ {
2085
+ name: "user",
2086
+ type: "publicKey",
2087
+ index: false
2088
+ },
2089
+ {
2090
+ name: "amount",
2091
+ type: "u64",
2092
+ index: false
2093
+ }
2094
+ ]
2095
+ },
2096
+ {
2097
+ name: "CreatedATA",
2098
+ fields: [
2099
+ {
2100
+ name: "accountId",
2101
+ type: {
2102
+ array: ["u8", 32]
2103
+ },
2104
+ index: false
2105
+ },
2106
+ {
2107
+ name: "receiver",
2108
+ type: {
2109
+ array: ["u8", 32]
2110
+ },
2111
+ index: false
2112
+ },
2113
+ {
2114
+ name: "receiverTokenAccount",
2115
+ type: {
2116
+ array: ["u8", 32]
2117
+ },
2118
+ index: false
2119
+ },
2120
+ {
2121
+ name: "withdrawNonce",
2122
+ type: "u64",
2123
+ index: false
2124
+ }
2125
+ ]
2126
+ },
2127
+ {
2128
+ name: "VaultDeposited",
2129
+ fields: [
2130
+ {
2131
+ name: "accountId",
2132
+ type: {
2133
+ array: ["u8", 32]
2134
+ },
2135
+ index: false
2136
+ },
2137
+ {
2138
+ name: "brokerHash",
2139
+ type: {
2140
+ array: ["u8", 32]
2141
+ },
2142
+ index: false
2143
+ },
2144
+ {
2145
+ name: "userAddress",
2146
+ type: {
2147
+ array: ["u8", 32]
2148
+ },
2149
+ index: false
2150
+ },
2151
+ {
2152
+ name: "tokenHash",
2153
+ type: {
2154
+ array: ["u8", 32]
2155
+ },
2156
+ index: false
2157
+ },
2158
+ {
2159
+ name: "srcChainId",
2160
+ type: "u128",
2161
+ index: false
2162
+ },
2163
+ {
2164
+ name: "tokenAmount",
2165
+ type: "u64",
2166
+ index: false
2167
+ },
2168
+ {
2169
+ name: "srcChainDepositNonce",
2170
+ type: "u64",
2171
+ index: false
2172
+ }
2173
+ ]
2174
+ },
2175
+ {
2176
+ name: "VaultWithdrawn",
2177
+ fields: [
2178
+ {
2179
+ name: "accountId",
2180
+ type: {
2181
+ array: ["u8", 32]
2182
+ },
2183
+ index: false
2184
+ },
2185
+ {
2186
+ name: "sender",
2187
+ type: {
2188
+ array: ["u8", 32]
2189
+ },
2190
+ index: false
2191
+ },
2192
+ {
2193
+ name: "receiver",
2194
+ type: {
2195
+ array: ["u8", 32]
2196
+ },
2197
+ index: false
2198
+ },
2199
+ {
2200
+ name: "brokerHash",
2201
+ type: {
2202
+ array: ["u8", 32]
2203
+ },
2204
+ index: false
2205
+ },
2206
+ {
2207
+ name: "tokenHash",
2208
+ type: {
2209
+ array: ["u8", 32]
2210
+ },
2211
+ index: false
2212
+ },
2213
+ {
2214
+ name: "tokenAmount",
2215
+ type: "u64",
2216
+ index: false
2217
+ },
2218
+ {
2219
+ name: "fee",
2220
+ type: "u128",
2221
+ index: false
2222
+ },
2223
+ {
2224
+ name: "chainId",
2225
+ type: "u128",
2226
+ index: false
2227
+ },
2228
+ {
2229
+ name: "withdrawNonce",
2230
+ type: "u64",
2231
+ index: false
2232
+ }
2233
+ ]
2234
+ },
2235
+ {
2236
+ name: "FrozenWithdrawn",
2237
+ fields: [
2238
+ {
2239
+ name: "accountId",
2240
+ type: {
2241
+ array: ["u8", 32]
2242
+ },
2243
+ index: false
2244
+ },
2245
+ {
2246
+ name: "sender",
2247
+ type: {
2248
+ array: ["u8", 32]
2249
+ },
2250
+ index: false
2251
+ },
2252
+ {
2253
+ name: "receiver",
2254
+ type: {
2255
+ array: ["u8", 32]
2256
+ },
2257
+ index: false
2258
+ },
2259
+ {
2260
+ name: "brokerHash",
2261
+ type: {
2262
+ array: ["u8", 32]
2263
+ },
2264
+ index: false
2265
+ },
2266
+ {
2267
+ name: "tokenHash",
2268
+ type: {
2269
+ array: ["u8", 32]
2270
+ },
2271
+ index: false
2272
+ },
2273
+ {
2274
+ name: "tokenAmount",
2275
+ type: "u64",
2276
+ index: false
2277
+ },
2278
+ {
2279
+ name: "fee",
2280
+ type: "u128",
2281
+ index: false
2282
+ },
2283
+ {
2284
+ name: "chainId",
2285
+ type: "u128",
2286
+ index: false
2287
+ },
2288
+ {
2289
+ name: "withdrawNonce",
2290
+ type: "u64",
2291
+ index: false
2292
+ }
2293
+ ]
2294
+ },
2295
+ {
2296
+ name: "OAppSent",
2297
+ fields: [
2298
+ {
2299
+ name: "guid",
2300
+ type: {
2301
+ array: ["u8", 32]
2302
+ },
2303
+ index: false
2304
+ },
2305
+ {
2306
+ name: "dstEid",
2307
+ type: "u32",
2308
+ index: false
2309
+ }
2310
+ ]
2311
+ },
2312
+ {
2313
+ name: "OAppReceived",
2314
+ fields: [
2315
+ {
2316
+ name: "guid",
2317
+ type: {
2318
+ array: ["u8", 32]
2319
+ },
2320
+ index: false
2321
+ },
2322
+ {
2323
+ name: "srcEid",
2324
+ type: "u32",
2325
+ index: false
2326
+ }
2327
+ ]
2328
+ }
2329
+ ],
2330
+ errors: [
2331
+ {
2332
+ code: 6e3,
2333
+ name: "InsufficientFunds",
2334
+ msg: "Deposited funds are insufficient for withdrawal"
2335
+ },
2336
+ {
2337
+ code: 6001,
2338
+ name: "UserInfoBelongsToAnotherUser",
2339
+ msg: "User info pda belongs to another user"
2340
+ },
2341
+ {
2342
+ code: 6002,
2343
+ name: "BrokerNotAllowed",
2344
+ msg: "Broker is not allowed"
2345
+ },
2346
+ {
2347
+ code: 6003,
2348
+ name: "TokenNotAllowed",
2349
+ msg: "Token is not allowed"
2350
+ },
2351
+ {
2352
+ code: 6004,
2353
+ name: "InvalidAccountId",
2354
+ msg: "AccountId is invalid"
2355
+ },
2356
+ {
2357
+ code: 6005,
2358
+ name: "InvalidVaultOwner",
2359
+ msg: "Vault owner is not the same as the payer"
2360
+ },
2361
+ {
2362
+ code: 6006,
2363
+ name: "ManagerRoleNotAllowed",
2364
+ msg: "Manager role is not allowed"
2365
+ }
2366
+ ]
2367
+ };
2368
+
2369
+ // src/solana.util.ts
2370
+ var import_lz_solana_sdk_v2 = require("@layerzerolabs/lz-solana-sdk-v2");
2371
+ var import_spl_token = require("@solana/spl-token");
2372
+ var import_web32 = require("@solana/web3.js");
2373
+ var getTokenAccounts = (token, owner) => {
2374
+ const tokenAccount = (0, import_spl_token.getAssociatedTokenAddressSync)(token, owner, true);
2375
+ return tokenAccount;
2376
+ };
2377
+ function getVaultAuthorityPda(VAULT_PROGRAM_ID) {
2378
+ return import_web32.PublicKey.findProgramAddressSync(
2379
+ [Buffer.from(VAULT_AUTHORITY_SEED, "utf8")],
2380
+ VAULT_PROGRAM_ID
2381
+ )[0];
2382
+ }
2383
+ function getSolVaultPda(VAULT_PROGRAM_ID) {
2384
+ return import_web32.PublicKey.findProgramAddressSync(
2385
+ [Buffer.from(SOL_VAULT_SEED, "utf8")],
2386
+ VAULT_PROGRAM_ID
2387
+ )[0];
2388
+ }
2389
+ function getBrokerPDA(programId, brokerHash) {
2390
+ const hash = Array.from(Buffer.from(brokerHash.slice(2), "hex"));
2391
+ return import_web32.PublicKey.findProgramAddressSync(
2392
+ [Buffer.from(BROKER_SEED, "utf8"), Buffer.from(hash)],
2393
+ programId
2394
+ )[0];
2395
+ }
2396
+ function getTokenPDA(programId, tokenHash) {
2397
+ const hash = Array.from(Buffer.from(tokenHash.slice(2), "hex"));
2398
+ return import_web32.PublicKey.findProgramAddressSync(
2399
+ [Buffer.from(TOKEN_SEED, "utf8"), Buffer.from(hash)],
2400
+ programId
2401
+ )[0];
2402
+ }
2403
+ function getOAppConfigPda(programId) {
2404
+ return import_web32.PublicKey.findProgramAddressSync(
2405
+ [Buffer.from(import_lz_solana_sdk_v2.OAPP_SEED, "utf8")],
2406
+ programId
2407
+ )[0];
2408
+ }
2409
+ function getPeerPda(OAPP_PROGRAM_ID, oappConfigPda, dstEid) {
2410
+ const bufferDstEid = Buffer.alloc(4);
2411
+ bufferDstEid.writeUInt32BE(dstEid);
2412
+ return import_web32.PublicKey.findProgramAddressSync(
2413
+ [Buffer.from(import_lz_solana_sdk_v2.PEER_SEED, "utf8"), oappConfigPda.toBuffer(), bufferDstEid],
2414
+ OAPP_PROGRAM_ID
2415
+ )[0];
2416
+ }
2417
+ function getEndorcedOptionsPda(OAPP_PROGRAM_ID, oappConfigPda, dstEid) {
2418
+ const bufferDstEid = Buffer.alloc(4);
2419
+ bufferDstEid.writeUInt32BE(dstEid);
2420
+ return import_web32.PublicKey.findProgramAddressSync(
2421
+ [
2422
+ Buffer.from(import_lz_solana_sdk_v2.ENFORCED_OPTIONS_SEED, "utf8"),
2423
+ oappConfigPda.toBuffer(),
2424
+ bufferDstEid
2425
+ ],
2426
+ OAPP_PROGRAM_ID
2427
+ )[0];
2428
+ }
2429
+ function getSendLibPda() {
2430
+ return import_web32.PublicKey.findProgramAddressSync(
2431
+ [Buffer.from(import_lz_solana_sdk_v2.MESSAGE_LIB_SEED, "utf8")],
2432
+ SEND_LIB_PROGRAM_ID
2433
+ )[0];
2434
+ }
2435
+ function getSendLibConfigPda(oappConfigPda, dstEid) {
2436
+ const bufferDstEid = Buffer.alloc(4);
2437
+ bufferDstEid.writeUInt32BE(dstEid);
2438
+ return import_web32.PublicKey.findProgramAddressSync(
2439
+ [
2440
+ Buffer.from(import_lz_solana_sdk_v2.SEND_LIBRARY_CONFIG_SEED, "utf8"),
2441
+ oappConfigPda.toBuffer(),
2442
+ bufferDstEid
2443
+ ],
2444
+ ENDPOINT_PROGRAM_ID
2445
+ )[0];
2446
+ }
2447
+ function getDefaultSendLibConfigPda(dstEid) {
2448
+ const bufferDstEid = Buffer.alloc(4);
2449
+ bufferDstEid.writeUInt32BE(dstEid);
2450
+ return import_web32.PublicKey.findProgramAddressSync(
2451
+ [Buffer.from(import_lz_solana_sdk_v2.SEND_LIBRARY_CONFIG_SEED, "utf8"), bufferDstEid],
2452
+ ENDPOINT_PROGRAM_ID
2453
+ )[0];
2454
+ }
2455
+ function getSendLibInfoPda(sendLibPda) {
2456
+ return import_web32.PublicKey.findProgramAddressSync(
2457
+ [Buffer.from(import_lz_solana_sdk_v2.MESSAGE_LIB_SEED, "utf8"), sendLibPda.toBuffer()],
2458
+ ENDPOINT_PROGRAM_ID
2459
+ )[0];
2460
+ }
2461
+ function getEndpointSettingPda() {
2462
+ return import_web32.PublicKey.findProgramAddressSync(
2463
+ [Buffer.from(import_lz_solana_sdk_v2.ENDPOINT_SEED, "utf8")],
2464
+ ENDPOINT_PROGRAM_ID
2465
+ )[0];
2466
+ }
2467
+ function getPeerAddress(OAPP_PROGRAM_ID) {
2468
+ let peer_address = DEV_PEER_ADDRESS;
2469
+ if (OAPP_PROGRAM_ID.toBase58() === DEV_OAPP_PROGRAM_ID.toBase58()) {
2470
+ peer_address = DEV_PEER_ADDRESS;
2471
+ }
2472
+ if (OAPP_PROGRAM_ID.toBase58() === QA_OAPP_PROGRAM_ID.toBase58()) {
2473
+ peer_address = QA_PEER_ADDRESS;
2474
+ }
2475
+ if (OAPP_PROGRAM_ID.toBase58() === STAGING_OAPP_PROGRAM_ID.toBase58()) {
2476
+ peer_address = STAGING_PEER_ADDRESS;
2477
+ }
2478
+ if (OAPP_PROGRAM_ID.toBase58() === MAINNET_OAPP_PROGRAM_ID.toBase58()) {
2479
+ peer_address = MAINNET_PEER_ADDRESS;
2480
+ }
2481
+ return peer_address;
2482
+ }
2483
+ function getNoncePda(OAPP_PROGRAM_ID, oappConfigPda, dstEid) {
2484
+ const bufferDstEid = Buffer.alloc(4);
2485
+ const peer_address = getPeerAddress(OAPP_PROGRAM_ID);
2486
+ bufferDstEid.writeUInt32BE(dstEid);
2487
+ return import_web32.PublicKey.findProgramAddressSync(
2488
+ [
2489
+ Buffer.from(import_lz_solana_sdk_v2.NONCE_SEED, "utf8"),
2490
+ oappConfigPda.toBuffer(),
2491
+ bufferDstEid,
2492
+ peer_address
2493
+ ],
2494
+ ENDPOINT_PROGRAM_ID
2495
+ )[0];
2496
+ }
2497
+ function getEventAuthorityPda() {
2498
+ return import_web32.PublicKey.findProgramAddressSync(
2499
+ [Buffer.from(import_lz_solana_sdk_v2.EVENT_SEED, "utf8")],
2500
+ ENDPOINT_PROGRAM_ID
2501
+ )[0];
2502
+ }
2503
+ function getUlnSettingPda() {
2504
+ return import_web32.PublicKey.findProgramAddressSync(
2505
+ [Buffer.from(import_lz_solana_sdk_v2.ULN_SEED, "utf8")],
2506
+ SEND_LIB_PROGRAM_ID
2507
+ )[0];
2508
+ }
2509
+ function getSendConfigPda(oappConfigPda, dstEid) {
2510
+ const bufferDstEid = Buffer.alloc(4);
2511
+ bufferDstEid.writeUInt32BE(dstEid);
2512
+ return import_web32.PublicKey.findProgramAddressSync(
2513
+ [
2514
+ Buffer.from(import_lz_solana_sdk_v2.SEND_CONFIG_SEED, "utf8"),
2515
+ bufferDstEid,
2516
+ oappConfigPda.toBuffer()
2517
+ ],
2518
+ SEND_LIB_PROGRAM_ID
2519
+ )[0];
2520
+ }
2521
+ function getDefaultSendConfigPda(dstEid) {
2522
+ const bufferDstEid = Buffer.alloc(4);
2523
+ bufferDstEid.writeUInt32BE(dstEid);
2524
+ return import_web32.PublicKey.findProgramAddressSync(
2525
+ [Buffer.from(import_lz_solana_sdk_v2.SEND_CONFIG_SEED, "utf8"), bufferDstEid],
2526
+ RECEIVE_LIB_PROGRAM_ID
2527
+ )[0];
2528
+ }
2529
+ function getUlnEventAuthorityPda() {
2530
+ return import_web32.PublicKey.findProgramAddressSync(
2531
+ [Buffer.from(import_lz_solana_sdk_v2.EVENT_SEED, "utf8")],
2532
+ SEND_LIB_PROGRAM_ID
2533
+ )[0];
2534
+ }
2535
+ function getExecutorConfigPda() {
2536
+ return import_web32.PublicKey.findProgramAddressSync(
2537
+ [Buffer.from(import_lz_solana_sdk_v2.EXECUTOR_CONFIG_SEED, "utf8")],
2538
+ EXECUTOR_PROGRAM_ID
2539
+ )[0];
2540
+ }
2541
+ function getPriceFeedPda() {
2542
+ return import_web32.PublicKey.findProgramAddressSync(
2543
+ [Buffer.from(import_lz_solana_sdk_v2.PRICE_FEED_SEED, "utf8")],
2544
+ PRICE_FEED_PROGRAM_ID
2545
+ )[0];
2546
+ }
2547
+ function getDvnConfigPda() {
2548
+ return import_web32.PublicKey.findProgramAddressSync(
2549
+ [Buffer.from(import_lz_solana_sdk_v2.DVN_CONFIG_SEED, "utf8")],
2550
+ DVN_PROGRAM_ID
2551
+ )[0];
2552
+ }
2553
+ function getDstEID(OAPP_PROGRAM_ID) {
2554
+ if (OAPP_PROGRAM_ID.toBase58() === MAINNET_OAPP_PROGRAM_ID.toBase58()) {
2555
+ return MAIN_DST_EID;
2556
+ }
2557
+ return DEV_DST_EID;
2558
+ }
2559
+ function getLookupTableAddress(OAPP_PROGRAM_ID) {
2560
+ if (OAPP_PROGRAM_ID.toBase58() === DEV_OAPP_PROGRAM_ID.toBase58()) {
2561
+ console.log(
2562
+ "DEV_LOOKUP_TABLE_ADDRESS: ",
2563
+ DEV_LOOKUP_TABLE_ADDRESS.toBase58()
2564
+ );
2565
+ return DEV_LOOKUP_TABLE_ADDRESS;
2566
+ }
2567
+ if (OAPP_PROGRAM_ID.toBase58() === QA_OAPP_PROGRAM_ID.toBase58()) {
2568
+ return QA_LOOKUP_TABLE_ADDRESS;
2569
+ }
2570
+ if (OAPP_PROGRAM_ID.toBase58() === STAGING_OAPP_PROGRAM_ID.toBase58()) {
2571
+ return STAGING_LOOKUP_TABLE_ADDRESS;
2572
+ }
2573
+ if (OAPP_PROGRAM_ID.toBase58() === MAINNET_OAPP_PROGRAM_ID.toBase58()) {
2574
+ return MAINNET_LOOKUP_TABLE_ADDRESS;
2575
+ }
2576
+ return DEV_LOOKUP_TABLE_ADDRESS;
2577
+ }
2578
+ function getMessageLibPda(programId) {
2579
+ return import_web32.PublicKey.findProgramAddressSync(
2580
+ [Buffer.from(import_lz_solana_sdk_v2.MESSAGE_LIB_SEED, "utf8")],
2581
+ programId ? programId : SEND_LIB_PROGRAM_ID
2582
+ )[0];
2583
+ }
2584
+ function getMessageLibInfoPda(msgLibPda, programId) {
2585
+ return import_web32.PublicKey.findProgramAddressSync(
2586
+ [Buffer.from(import_lz_solana_sdk_v2.MESSAGE_LIB_SEED, "utf8"), msgLibPda.toBytes()],
2587
+ programId ? programId : ENDPOINT_PROGRAM_ID
2588
+ )[0];
2589
+ }
2590
+ function getLookupTableAccount(connection, lookupTableAddress) {
2591
+ return __async(this, null, function* () {
2592
+ const lookupTableAccount = (yield connection.getAddressLookupTable(lookupTableAddress)).value;
2593
+ return lookupTableAccount;
2594
+ });
2595
+ }
2596
+
2597
+ // src/helper.ts
2598
+ function addOrderlyKeyMessage(inputs) {
2599
+ const {
2600
+ publicKey,
2601
+ brokerId,
2602
+ expiration = 365,
2603
+ timestamp = Date.now(),
2604
+ scope,
2605
+ tag,
2606
+ chainId,
2607
+ subAccountId
2608
+ } = inputs;
2609
+ const message = __spreadValues(__spreadValues({
2610
+ brokerId,
2611
+ chainType: "SOL",
2612
+ orderlyKey: publicKey,
2613
+ scope: scope || import_orderly_types.DEFAUL_ORDERLY_KEY_SCOPE,
2614
+ chainId,
2615
+ timestamp,
2616
+ expiration: timestamp + 1e3 * 60 * 60 * 24 * expiration
2617
+ }, typeof tag !== "undefined" ? { tag } : {}), typeof subAccountId !== "undefined" ? { subAccountId } : {});
2618
+ const brokerIdHash = (0, import_ethers.solidityPackedKeccak256)(["string"], [message.brokerId]);
2619
+ const orderlyKeyHash = (0, import_ethers.solidityPackedKeccak256)(
2620
+ ["string"],
2621
+ [message.orderlyKey]
2622
+ );
2623
+ const scopeHash = (0, import_ethers.solidityPackedKeccak256)(["string"], [message.scope]);
2624
+ const abicoder = import_ethers.AbiCoder.defaultAbiCoder();
2625
+ const msgToSign = (0, import_keccak.keccak256)(
2626
+ (0, import_utils.hexToBytes)(
2627
+ abicoder.encode(
2628
+ ["bytes32", "bytes32", "bytes32", "uint256", "uint256", "uint256"],
2629
+ [
2630
+ brokerIdHash,
2631
+ orderlyKeyHash,
2632
+ scopeHash,
2633
+ message.chainId,
2634
+ message.timestamp,
2635
+ message.expiration
2636
+ ]
2637
+ )
2638
+ )
2639
+ );
2640
+ const msgToSignHex = (0, import_utils.bytesToHex)(msgToSign);
2641
+ const msgToSignTextEncoded = new TextEncoder().encode(
2642
+ msgToSignHex
2643
+ );
2644
+ return [message, msgToSignTextEncoded];
2645
+ }
2646
+ function registerAccountMessage(inputs) {
2647
+ const { chainId, registrationNonce, brokerId, timestamp } = inputs;
2648
+ const message = {
2649
+ brokerId,
2650
+ chainId,
2651
+ timestamp,
2652
+ registrationNonce
2653
+ };
2654
+ const brokerIdHash = (0, import_ethers.solidityPackedKeccak256)(["string"], [message.brokerId]);
2655
+ const abicoder = import_ethers.AbiCoder.defaultAbiCoder();
2656
+ const msgToSign = (0, import_keccak.keccak256)(
2657
+ (0, import_utils.hexToBytes)(
2658
+ abicoder.encode(
2659
+ ["bytes32", "uint256", "uint256", "uint256"],
2660
+ [
2661
+ brokerIdHash,
2662
+ message.chainId,
2663
+ message.timestamp,
2664
+ message.registrationNonce
2665
+ ]
2666
+ )
2667
+ )
2668
+ );
2669
+ const msgToSignHex = (0, import_utils.bytesToHex)(msgToSign);
2670
+ const msgToSignTextEncoded = new TextEncoder().encode(
2671
+ msgToSignHex
2672
+ );
2673
+ return [message, msgToSignTextEncoded];
2674
+ }
2675
+ function internalTransferMessage(inputs) {
2676
+ const { chainId, receiver, token, amount, nonce } = inputs;
2677
+ const message = {
2678
+ chainId,
2679
+ receiver,
2680
+ token,
2681
+ amount,
2682
+ transferNonce: nonce,
2683
+ chainType: "SOL"
2684
+ };
2685
+ const tokenSymbolHash = (0, import_ethers.solidityPackedKeccak256)(["string"], [message.token]);
2686
+ const abicoder = import_ethers.AbiCoder.defaultAbiCoder();
2687
+ const msgToSign = (0, import_keccak.keccak256)(
2688
+ (0, import_utils.hexToBytes)(
2689
+ abicoder.encode(
2690
+ ["bytes32", "bytes32", "uint256", "uint64", "uint256"],
2691
+ [
2692
+ message.receiver,
2693
+ tokenSymbolHash,
2694
+ message.amount,
2695
+ message.transferNonce,
2696
+ chainId
2697
+ ]
2698
+ )
2699
+ )
2700
+ );
2701
+ const msgToSignHex = (0, import_utils.bytesToHex)(msgToSign);
2702
+ const msgToSignTextEncoded = new TextEncoder().encode(
2703
+ msgToSignHex
2704
+ );
2705
+ return [message, msgToSignTextEncoded];
2706
+ }
2707
+ function dexRequestMessage(inputs) {
2708
+ return __async(this, null, function* () {
2709
+ const {
2710
+ payloadType,
2711
+ nonce,
2712
+ receiver,
2713
+ amount,
2714
+ vaultId,
2715
+ token,
2716
+ dexBrokerId,
2717
+ chainId
2718
+ } = inputs;
2719
+ const message = {
2720
+ payloadType,
2721
+ nonce,
2722
+ receiver,
2723
+ amount,
2724
+ vaultId,
2725
+ token,
2726
+ dexBrokerId,
2727
+ chainId
2728
+ };
2729
+ let receiverBytes;
2730
+ receiverBytes = (0, import_bs58.decode)(receiver);
2731
+ const receiverBytes32 = new Uint8Array(32);
2732
+ receiverBytes32.set(receiverBytes);
2733
+ const vaultIdHex = vaultId;
2734
+ const vaultIdBytes = (0, import_utils.hexToBytes)(vaultIdHex);
2735
+ const tokenHash = (0, import_keccak.keccak256)(new TextEncoder().encode(token));
2736
+ const dexBrokerIdHash = (0, import_keccak.keccak256)(new TextEncoder().encode(dexBrokerId));
2737
+ const abicoder = import_ethers.AbiCoder.defaultAbiCoder();
2738
+ const msgToSign = (0, import_keccak.keccak256)(
2739
+ (0, import_utils.hexToBytes)(
2740
+ abicoder.encode(
2741
+ [
2742
+ "uint8",
2743
+ // payloadType
2744
+ "uint256",
2745
+ // nonce
2746
+ "bytes32",
2747
+ // receiver (Base58 decoded)
2748
+ "uint256",
2749
+ // amount
2750
+ "bytes32",
2751
+ // vaultId
2752
+ "bytes32",
2753
+ // token hash
2754
+ "bytes32",
2755
+ // dexBrokerId hash
2756
+ "uint256"
2757
+ // chainId
2758
+ ],
2759
+ [
2760
+ payloadType,
2761
+ nonce,
2762
+ receiverBytes,
2763
+ amount,
2764
+ vaultIdBytes,
2765
+ tokenHash,
2766
+ dexBrokerIdHash,
2767
+ chainId
2768
+ ]
2769
+ )
2770
+ )
2771
+ );
2772
+ const msgToSignHex = (0, import_utils.bytesToHex)(msgToSign);
2773
+ const msgToSignTextEncoded = new TextEncoder().encode(
2774
+ msgToSignHex
2775
+ );
2776
+ return [message, msgToSignTextEncoded];
2777
+ });
2778
+ }
2779
+ function withdrawMessage(inputs) {
2780
+ const { chainId, receiver, token, amount, nonce, brokerId } = inputs;
2781
+ const timestamp = Date.now();
2782
+ const message = {
2783
+ brokerId,
2784
+ chainId,
2785
+ receiver,
2786
+ token,
2787
+ amount,
2788
+ withdrawNonce: nonce,
2789
+ timestamp,
2790
+ chainType: "SOL"
2791
+ };
2792
+ const brokerIdHash = (0, import_ethers.solidityPackedKeccak256)(["string"], [message.brokerId]);
2793
+ const tokenSymbolHash = (0, import_ethers.solidityPackedKeccak256)(["string"], [message.token]);
2794
+ const salt = (0, import_keccak.keccak256)(Buffer.from("Orderly Network"));
2795
+ const abicoder = import_ethers.AbiCoder.defaultAbiCoder();
2796
+ const msgToSign = (0, import_keccak.keccak256)(
2797
+ (0, import_utils.hexToBytes)(
2798
+ abicoder.encode(
2799
+ [
2800
+ "bytes32",
2801
+ "bytes32",
2802
+ "uint256",
2803
+ "bytes32",
2804
+ "uint256",
2805
+ "uint64",
2806
+ "uint64",
2807
+ "bytes32"
2808
+ ],
2809
+ [
2810
+ brokerIdHash,
2811
+ tokenSymbolHash,
2812
+ chainId,
2813
+ (0, import_bs58.decode)(message.receiver),
2814
+ message.amount,
2815
+ message.withdrawNonce,
2816
+ timestamp,
2817
+ salt
2818
+ ]
2819
+ )
2820
+ )
2821
+ );
2822
+ const msgToSignHex = (0, import_utils.bytesToHex)(msgToSign);
2823
+ const msgToSignTextEncoded = new TextEncoder().encode(
2824
+ msgToSignHex
2825
+ );
2826
+ return [message, msgToSignTextEncoded];
2827
+ }
2828
+ function settleMessage(inputs) {
2829
+ const { settlePnlNonce, brokerId, chainId, timestamp } = inputs;
2830
+ const message = {
2831
+ brokerId,
2832
+ chainId,
2833
+ timestamp,
2834
+ chainType: "SOL",
2835
+ settleNonce: settlePnlNonce
2836
+ };
2837
+ const brokerIdHash = (0, import_ethers.solidityPackedKeccak256)(["string"], [brokerId]);
2838
+ const abicoder = import_ethers.AbiCoder.defaultAbiCoder();
2839
+ const msgToSign = (0, import_keccak.keccak256)(
2840
+ (0, import_utils.hexToBytes)(
2841
+ abicoder.encode(
2842
+ ["bytes32", "uint256", "uint64", "uint64"],
2843
+ [brokerIdHash, message.chainId, message.settleNonce, message.timestamp]
2844
+ )
2845
+ )
2846
+ );
2847
+ const msgToSignHex = (0, import_utils.bytesToHex)(msgToSign);
2848
+ const msgToSignTextEncoded = new TextEncoder().encode(
2849
+ msgToSignHex
2850
+ );
2851
+ return [message, msgToSignTextEncoded];
2852
+ }
2853
+ function getDepositQuoteFee(_0) {
2854
+ return __async(this, arguments, function* ({
2855
+ vaultAddress,
2856
+ userAddress,
2857
+ connection,
2858
+ depositData
2859
+ }) {
2860
+ console.log("-- vaultAddress", vaultAddress);
2861
+ const appProgramId = new import_web33.PublicKey(vaultAddress);
2862
+ const DST_EID = getDstEID(appProgramId);
2863
+ const program = new import_anchor.Program(IDL, appProgramId, {
2864
+ connection
2865
+ });
2866
+ const userPublicKey = new import_web33.PublicKey(userAddress);
2867
+ const oappConfigPDA = getOAppConfigPda(appProgramId);
2868
+ const peerPDA = getPeerPda(appProgramId, oappConfigPDA, DST_EID);
2869
+ const endorcedPDA = getEndorcedOptionsPda(
2870
+ appProgramId,
2871
+ oappConfigPDA,
2872
+ DST_EID
2873
+ );
2874
+ const sendLibConfigPDA = getSendLibConfigPda(oappConfigPDA, DST_EID);
2875
+ const defaultSendLibPDA = getDefaultSendLibConfigPda(DST_EID);
2876
+ const endpointSettingPDA = getEndpointSettingPda();
2877
+ const noncePDA = getNoncePda(appProgramId, oappConfigPDA, DST_EID);
2878
+ const sendConfigPDA = getSendConfigPda(oappConfigPDA, DST_EID);
2879
+ const defaultSendConfigPDA = getDefaultSendConfigPda(DST_EID);
2880
+ const executorConfigPDA = getExecutorConfigPda();
2881
+ const priceFeedPDA = getPriceFeedPda();
2882
+ const dvnConfigPDA = getDvnConfigPda();
2883
+ const messageLibPDA = getMessageLibPda(SEND_LIB_PROGRAM_ID);
2884
+ const messageLibInfoPDA = getMessageLibInfoPda(messageLibPDA);
2885
+ const vaultAuthorityPDA = getVaultAuthorityPda(appProgramId);
2886
+ const depositParams = getDepositParams(userAddress, depositData);
2887
+ const quoteFee = yield program.methods.oappQuote(depositParams).accounts({
2888
+ oappConfig: oappConfigPDA,
2889
+ peer: peerPDA,
2890
+ enforcedOptions: endorcedPDA,
2891
+ vaultAuthority: vaultAuthorityPDA
2892
+ }).remainingAccounts([
2893
+ // ENDPOINT solana/programs/programs/uln/src/instructions/endpoint/send.rs
2894
+ {
2895
+ pubkey: ENDPOINT_PROGRAM_ID,
2896
+ isWritable: false,
2897
+ isSigner: false
2898
+ },
2899
+ {
2900
+ pubkey: SEND_LIB_PROGRAM_ID,
2901
+ isWritable: false,
2902
+ isSigner: false
2903
+ },
2904
+ {
2905
+ pubkey: sendLibConfigPDA,
2906
+ // send_library_config
2907
+ isWritable: false,
2908
+ isSigner: false
2909
+ },
2910
+ {
2911
+ pubkey: defaultSendLibPDA,
2912
+ // default_send_library_config
2913
+ isWritable: false,
2914
+ isSigner: false
2915
+ },
2916
+ {
2917
+ pubkey: messageLibInfoPDA,
2918
+ // send_library_info
2919
+ isWritable: false,
2920
+ isSigner: false
2921
+ },
2922
+ {
2923
+ pubkey: endpointSettingPDA,
2924
+ // endpoint settings
2925
+ isWritable: false,
2926
+ isSigner: false
2927
+ },
2928
+ {
2929
+ pubkey: noncePDA,
2930
+ // nonce
2931
+ isWritable: false,
2932
+ isSigner: false
2933
+ },
2934
+ {
2935
+ pubkey: messageLibPDA,
2936
+ isWritable: false,
2937
+ isSigner: false
2938
+ },
2939
+ {
2940
+ pubkey: sendConfigPDA,
2941
+ isWritable: false,
2942
+ isSigner: false
2943
+ },
2944
+ {
2945
+ pubkey: defaultSendConfigPDA,
2946
+ isWritable: false,
2947
+ isSigner: false
2948
+ },
2949
+ {
2950
+ pubkey: EXECUTOR_PROGRAM_ID,
2951
+ isWritable: false,
2952
+ isSigner: false
2953
+ },
2954
+ {
2955
+ pubkey: executorConfigPDA,
2956
+ isWritable: false,
2957
+ isSigner: false
2958
+ },
2959
+ {
2960
+ pubkey: PRICE_FEED_PROGRAM_ID,
2961
+ isWritable: false,
2962
+ isSigner: false
2963
+ },
2964
+ {
2965
+ pubkey: priceFeedPDA,
2966
+ isWritable: false,
2967
+ isSigner: false
2968
+ },
2969
+ {
2970
+ pubkey: DVN_PROGRAM_ID,
2971
+ isWritable: false,
2972
+ isSigner: false
2973
+ },
2974
+ {
2975
+ pubkey: dvnConfigPDA,
2976
+ isWritable: false,
2977
+ isSigner: false
2978
+ },
2979
+ {
2980
+ pubkey: PRICE_FEED_PROGRAM_ID,
2981
+ isWritable: false,
2982
+ isSigner: false
2983
+ },
2984
+ {
2985
+ pubkey: priceFeedPDA,
2986
+ isWritable: false,
2987
+ isSigner: false
2988
+ }
2989
+ ]).instruction();
2990
+ const lastBlockHash = yield connection.getLatestBlockhash();
2991
+ const lookupTableAddress = getLookupTableAddress(appProgramId);
2992
+ const lookupTableAccount = yield getLookupTableAccount(
2993
+ connection,
2994
+ lookupTableAddress
2995
+ );
2996
+ if (!lookupTableAccount) {
2997
+ console.log("-- lookup table account error");
2998
+ throw new Error("-- lookup table account error");
2999
+ }
3000
+ const feeMsg = new import_web33.TransactionMessage({
3001
+ payerKey: userPublicKey,
3002
+ recentBlockhash: lastBlockHash.blockhash,
3003
+ instructions: [quoteFee]
3004
+ }).compileToV0Message([lookupTableAccount]);
3005
+ const feeTx = new import_web33.VersionedTransaction(feeMsg);
3006
+ const feeRes = yield connection.simulateTransaction(feeTx);
3007
+ console.log("-- feeRes", feeRes);
3008
+ if (feeRes.value.err) {
3009
+ const errorInfo = typeof feeRes.value.err === "object" ? JSON.stringify(feeRes.value.err) : feeRes.value.err;
3010
+ if (errorInfo.toString().includes("AccountNotFound")) {
3011
+ throw new Error("Error: Account gas is insufficient.");
3012
+ }
3013
+ throw new Error(`Error: ${errorInfo}`);
3014
+ }
3015
+ const returnPrefix = `Program return: ${program.programId} `;
3016
+ const returnLogEntry = feeRes.value.logs.find(
3017
+ (log) => log.startsWith(returnPrefix)
3018
+ );
3019
+ if (!returnLogEntry) {
3020
+ throw new Error("Error: get deposit fee error");
3021
+ }
3022
+ const encodedReturnData = returnLogEntry.slice(returnPrefix.length);
3023
+ const decodedBuffer = Buffer.from(encodedReturnData, "base64");
3024
+ console.log(
3025
+ decodedBuffer.readBigUInt64LE(0),
3026
+ decodedBuffer.readBigUInt64LE(1)
3027
+ );
3028
+ return decodedBuffer.readBigUInt64LE(0);
3029
+ });
3030
+ }
3031
+ var getDepositParams = (userAddress, depositData) => {
3032
+ const brokerHash = depositData.brokerHash;
3033
+ const codedBrokerHash = Array.from(Buffer.from(brokerHash.slice(2), "hex"));
3034
+ const tokenHash = depositData.tokenHash;
3035
+ const codedTokenHash = Array.from(Buffer.from(tokenHash.slice(2), "hex"));
3036
+ const solAccountId = depositData.accountId;
3037
+ const codedAccountId = Array.from(Buffer.from(solAccountId.slice(2), "hex"));
3038
+ const userPublicKey = new import_web33.PublicKey(userAddress);
3039
+ return {
3040
+ accountId: codedAccountId,
3041
+ brokerHash: codedBrokerHash,
3042
+ tokenHash: codedTokenHash,
3043
+ userAddress: Array.from(userPublicKey.toBuffer()),
3044
+ tokenAmount: new import_anchor.BN(depositData.tokenAmount)
3045
+ };
3046
+ };
3047
+ function deposit(_0) {
3048
+ return __async(this, arguments, function* ({
3049
+ vaultAddress,
3050
+ userAddress,
3051
+ connection,
3052
+ sendTransaction,
3053
+ depositData
3054
+ }) {
3055
+ const brokerHash = depositData.brokerHash;
3056
+ const tokenHash = depositData.tokenHash;
3057
+ const SOL_HASH = import_orderly_core.utils.parseTokenHash("SOL");
3058
+ const isSolDeposit = tokenHash.toLowerCase() === SOL_HASH.toLowerCase();
3059
+ console.log("-- vault address", vaultAddress);
3060
+ const appProgramId = new import_web33.PublicKey(vaultAddress);
3061
+ const program = new import_anchor.Program(IDL, appProgramId, {
3062
+ connection
3063
+ });
3064
+ const token = new import_web33.PublicKey(depositData.tokenAddress);
3065
+ const userPublicKey = new import_web33.PublicKey(userAddress);
3066
+ const userTokenAccount = getTokenAccounts(token, userPublicKey);
3067
+ const vaultAuthorityPda = getVaultAuthorityPda(appProgramId);
3068
+ const vaultTokenAccount = getTokenAccounts(token, vaultAuthorityPda);
3069
+ const allowedBrokerPDA = getBrokerPDA(appProgramId, brokerHash);
3070
+ const allowedTokenPDA = getTokenPDA(appProgramId, tokenHash);
3071
+ const oappConfigPDA = getOAppConfigPda(appProgramId);
3072
+ console.log("-- oappconfig pda", oappConfigPDA.toBase58());
3073
+ const DST_EID = getDstEID(appProgramId);
3074
+ const peerPDA = getPeerPda(appProgramId, oappConfigPDA, DST_EID);
3075
+ const endorcedPDA = getEndorcedOptionsPda(
3076
+ appProgramId,
3077
+ oappConfigPDA,
3078
+ DST_EID
3079
+ );
3080
+ const sendLibPDA = getSendLibPda();
3081
+ const sendLibConfigPDA = getSendLibConfigPda(oappConfigPDA, DST_EID);
3082
+ const defaultSendLibPDA = getDefaultSendLibConfigPda(DST_EID);
3083
+ const sendLibInfoPDA = getSendLibInfoPda(sendLibPDA);
3084
+ const endpointSettingPDA = getEndpointSettingPda();
3085
+ const noncePDA = getNoncePda(appProgramId, oappConfigPDA, DST_EID);
3086
+ const eventAuthorityPDA = getEventAuthorityPda();
3087
+ const ulnSettingPDA = getUlnSettingPda();
3088
+ const sendConfigPDA = getSendConfigPda(oappConfigPDA, DST_EID);
3089
+ const defaultSendConfigPDA = getDefaultSendConfigPda(DST_EID);
3090
+ const ulnEventAuthorityPDA = getUlnEventAuthorityPda();
3091
+ const executorConfigPDA = getExecutorConfigPda();
3092
+ const priceFeedPDA = getPriceFeedPda();
3093
+ const dvnConfigPDA = getDvnConfigPda();
3094
+ const vaultDepositParams = getDepositParams(userAddress, depositData);
3095
+ const buildSendRemainingAccounts = () => [
3096
+ // ENDPOINT solana/programs/programs/uln/src/instructions/endpoint/send.rs
3097
+ {
3098
+ isSigner: false,
3099
+ isWritable: false,
3100
+ pubkey: ENDPOINT_PROGRAM_ID
3101
+ },
3102
+ {
3103
+ isSigner: false,
3104
+ isWritable: false,
3105
+ // 0
3106
+ pubkey: oappConfigPDA
3107
+ },
3108
+ {
3109
+ isSigner: false,
3110
+ isWritable: false,
3111
+ pubkey: SEND_LIB_PROGRAM_ID
3112
+ },
3113
+ {
3114
+ isSigner: false,
3115
+ isWritable: false,
3116
+ // 7
3117
+ pubkey: sendLibConfigPDA
3118
+ },
3119
+ {
3120
+ isSigner: false,
3121
+ isWritable: false,
3122
+ // 9
3123
+ pubkey: defaultSendLibPDA
3124
+ },
3125
+ {
3126
+ isSigner: false,
3127
+ isWritable: false,
3128
+ // 8
3129
+ pubkey: sendLibInfoPDA
3130
+ },
3131
+ {
3132
+ isSigner: false,
3133
+ isWritable: false,
3134
+ // 14
3135
+ pubkey: endpointSettingPDA
3136
+ },
3137
+ {
3138
+ isSigner: false,
3139
+ isWritable: true,
3140
+ // 15
3141
+ pubkey: noncePDA
3142
+ },
3143
+ {
3144
+ isSigner: false,
3145
+ isWritable: false,
3146
+ // 3
3147
+ pubkey: eventAuthorityPDA
3148
+ },
3149
+ // ULN solana/programs/programs/uln/src/instructions/endpoint/send.rs
3150
+ {
3151
+ isSigner: false,
3152
+ isWritable: false,
3153
+ pubkey: ENDPOINT_PROGRAM_ID
3154
+ },
3155
+ {
3156
+ isSigner: false,
3157
+ isWritable: false,
3158
+ // 13
3159
+ pubkey: ulnSettingPDA
3160
+ },
3161
+ {
3162
+ isSigner: false,
3163
+ isWritable: false,
3164
+ // 10
3165
+ pubkey: sendConfigPDA
3166
+ },
3167
+ {
3168
+ isSigner: false,
3169
+ isWritable: false,
3170
+ // 11
3171
+ pubkey: defaultSendConfigPDA
3172
+ },
3173
+ {
3174
+ isSigner: true,
3175
+ isWritable: false,
3176
+ pubkey: userPublicKey
3177
+ },
3178
+ {
3179
+ isSigner: false,
3180
+ isWritable: false,
3181
+ pubkey: TREASURY_PROGRAM_ID
3182
+ },
3183
+ {
3184
+ isSigner: false,
3185
+ isWritable: false,
3186
+ pubkey: import_web33.SystemProgram.programId
3187
+ },
3188
+ {
3189
+ isSigner: false,
3190
+ isWritable: false,
3191
+ // 12
3192
+ pubkey: ulnEventAuthorityPDA
3193
+ },
3194
+ {
3195
+ isSigner: false,
3196
+ isWritable: false,
3197
+ pubkey: SEND_LIB_PROGRAM_ID
3198
+ },
3199
+ {
3200
+ isSigner: false,
3201
+ isWritable: false,
3202
+ pubkey: EXECUTOR_PROGRAM_ID
3203
+ },
3204
+ {
3205
+ isSigner: false,
3206
+ isWritable: true,
3207
+ // 16
3208
+ pubkey: executorConfigPDA
3209
+ },
3210
+ {
3211
+ isSigner: false,
3212
+ isWritable: false,
3213
+ pubkey: PRICE_FEED_PROGRAM_ID
3214
+ },
3215
+ {
3216
+ isSigner: false,
3217
+ isWritable: false,
3218
+ // 17
3219
+ pubkey: priceFeedPDA
3220
+ },
3221
+ {
3222
+ isSigner: false,
3223
+ isWritable: false,
3224
+ pubkey: DVN_PROGRAM_ID
3225
+ },
3226
+ {
3227
+ isSigner: false,
3228
+ isWritable: true,
3229
+ // 18
3230
+ pubkey: dvnConfigPDA
3231
+ },
3232
+ {
3233
+ isSigner: false,
3234
+ isWritable: false,
3235
+ pubkey: PRICE_FEED_PROGRAM_ID
3236
+ },
3237
+ {
3238
+ isSigner: false,
3239
+ isWritable: false,
3240
+ // 17
3241
+ pubkey: priceFeedPDA
3242
+ }
3243
+ ];
3244
+ const fee = yield getDepositQuoteFee({
3245
+ vaultAddress,
3246
+ userAddress,
3247
+ connection,
3248
+ depositData
3249
+ });
3250
+ const sendParam = {
3251
+ nativeFee: new import_anchor.BN(fee.toString()),
3252
+ lzTokenFee: new import_anchor.BN(0)
3253
+ };
3254
+ console.log("--- value params", {
3255
+ vaultDepositParams,
3256
+ sendParam
3257
+ });
3258
+ const ixDepositEntry = isSolDeposit ? yield program.methods.depositSol(vaultDepositParams, sendParam).accounts({
3259
+ solVault: getSolVaultPda(appProgramId),
3260
+ vaultAuthority: vaultAuthorityPda,
3261
+ user: userPublicKey,
3262
+ peer: peerPDA,
3263
+ enforcedOptions: endorcedPDA,
3264
+ oappConfig: oappConfigPDA,
3265
+ allowedBroker: allowedBrokerPDA,
3266
+ allowedToken: allowedTokenPDA
3267
+ }).remainingAccounts(buildSendRemainingAccounts()).instruction() : yield program.methods.deposit(vaultDepositParams, sendParam).accounts({
3268
+ userTokenAccount,
3269
+ vaultAuthority: vaultAuthorityPda,
3270
+ vaultTokenAccount,
3271
+ depositToken: token,
3272
+ user: userPublicKey,
3273
+ peer: peerPDA,
3274
+ enforcedOptions: endorcedPDA,
3275
+ oappConfig: oappConfigPDA,
3276
+ allowedBroker: allowedBrokerPDA,
3277
+ allowedToken: allowedTokenPDA
3278
+ }).remainingAccounts(buildSendRemainingAccounts()).instruction();
3279
+ const lookupTableAddress = getLookupTableAddress(appProgramId);
3280
+ const lookupTableAccount = yield getLookupTableAccount(
3281
+ connection,
3282
+ lookupTableAddress
3283
+ );
3284
+ if (!lookupTableAccount) {
3285
+ console.log("-- lookup table account error");
3286
+ return;
3287
+ }
3288
+ const ixAddComputeBudget = import_web33.ComputeBudgetProgram.setComputeUnitLimit({
3289
+ units: 4e5
3290
+ });
3291
+ const lastBlockHash = yield connection.getLatestBlockhash();
3292
+ const msg = new import_web33.TransactionMessage({
3293
+ payerKey: userPublicKey,
3294
+ recentBlockhash: lastBlockHash.blockhash,
3295
+ instructions: [ixDepositEntry, ixAddComputeBudget]
3296
+ }).compileToV0Message([lookupTableAccount]);
3297
+ const tx = new import_web33.VersionedTransaction(msg);
3298
+ const res = yield sendTransaction(tx, connection);
3299
+ console.log("res", res);
3300
+ return res;
3301
+ });
3302
+ }
3303
+ function checkIsLedgerWallet(userAddress) {
3304
+ const info = window.localStorage.getItem(import_orderly_types.LedgerWalletKey);
3305
+ if (!info) {
3306
+ return false;
3307
+ }
3308
+ const addressArr = JSON.parse(info != null ? info : "[]");
3309
+ console.log("-- addressArr", addressArr);
3310
+ if (addressArr.includes(userAddress)) {
3311
+ return true;
3312
+ }
3313
+ return false;
3314
+ }
3315
+
3316
+ // src/walletAdapter.ts
3317
+ var DefaultSolanaWalletAdapter = class extends import_orderly_core2.BaseWalletAdapter {
3318
+ constructor() {
3319
+ super();
3320
+ __publicField(this, "chainNamespace", import_orderly_types2.ChainNamespace.solana);
3321
+ __publicField(this, "_address");
3322
+ __publicField(this, "_chainId");
3323
+ __publicField(this, "_provider");
3324
+ __publicField(this, "_connection");
3325
+ }
3326
+ get address() {
3327
+ return this._address;
3328
+ }
3329
+ get chainId() {
3330
+ return this._chainId;
3331
+ }
3332
+ set chainId(chainId) {
3333
+ this._chainId = chainId;
3334
+ }
3335
+ get connection() {
3336
+ if (this._connection) {
3337
+ return this._connection;
3338
+ }
3339
+ if (this._provider.rpcUrl) {
3340
+ this._connection = new import_web34.Connection(this._provider.rpcUrl, {
3341
+ commitment: "confirmed"
3342
+ });
3343
+ return this._connection;
3344
+ }
3345
+ if (this._provider.network === import_wallet_adapter_base.WalletAdapterNetwork.Devnet) {
3346
+ this._connection = new import_web34.Connection((0, import_web34.clusterApiUrl)(this._provider.network), {
3347
+ commitment: "confirmed"
3348
+ });
3349
+ return this._connection;
3350
+ }
3351
+ const account = import_orderly_core2.SimpleDI.get("account");
3352
+ const url = "/v1/solana-rpc-proxy";
3353
+ this._connection = new import_web34.Connection(`${account.apiBaseUrl}${url}`, {
3354
+ commitment: "confirmed",
3355
+ fetchMiddleware: (info, init, fetch) => __async(this, null, function* () {
3356
+ const payload = {
3357
+ url,
3358
+ method: init == null ? void 0 : init.method,
3359
+ data: JSON.parse(init == null ? void 0 : init.body)
3360
+ };
3361
+ const signature = yield this.signMessageByOrderlyKey(payload);
3362
+ for (const key of Object.keys(signature)) {
3363
+ (init == null ? void 0 : init.headers)[key] = signature[key];
3364
+ }
3365
+ return fetch(info, init);
3366
+ })
3367
+ });
3368
+ return this._connection;
3369
+ }
3370
+ setConfig(config) {
3371
+ this._address = config.address;
3372
+ this._chainId = config.chain.id;
3373
+ if (config.provider) {
3374
+ this._provider = config.provider;
3375
+ }
3376
+ }
3377
+ lifecycleName(name, data) {
3378
+ console.log("lifecycle", name, data);
3379
+ }
3380
+ active(config) {
3381
+ this.setConfig(config);
3382
+ this.lifecycleName("active", config);
3383
+ }
3384
+ deactivate() {
3385
+ this.lifecycleName("deactivate", {});
3386
+ }
3387
+ update(config) {
3388
+ this.lifecycleName("update", config);
3389
+ this.setConfig(config);
3390
+ }
3391
+ generateSecretKey() {
3392
+ let privKey, secretKey;
3393
+ do {
3394
+ privKey = ed.utils.randomPrivateKey();
3395
+ secretKey = (0, import_bs582.encode)(privKey);
3396
+ } while (secretKey.length !== 44);
3397
+ return secretKey;
3398
+ }
3399
+ uint8ArrayToHexString(uint8Array) {
3400
+ return Array.from(uint8Array).map((byte) => byte.toString(16).padStart(2, "0")).join("");
3401
+ }
3402
+ signMessage(message) {
3403
+ return __async(this, null, function* () {
3404
+ const isLedger = checkIsLedgerWallet(this._address);
3405
+ if (isLedger) {
3406
+ const transaction = new import_web34.Transaction();
3407
+ transaction.add(
3408
+ new import_web34.TransactionInstruction({
3409
+ keys: [],
3410
+ programId: new import_web34.PublicKey(
3411
+ "ComputeBudget111111111111111111111111111111"
3412
+ ),
3413
+ data: new Uint8Array([3, 0, 0, 0, 0, 0, 0, 0, 0])
3414
+ })
3415
+ );
3416
+ transaction.add(
3417
+ new import_web34.TransactionInstruction({
3418
+ keys: [],
3419
+ programId: new import_web34.PublicKey(
3420
+ "ComputeBudget111111111111111111111111111111"
3421
+ ),
3422
+ data: new Uint8Array([2, 0, 0, 0, 0])
3423
+ })
3424
+ );
3425
+ transaction.add(
3426
+ new import_web34.TransactionInstruction({
3427
+ keys: [],
3428
+ programId: new import_web34.PublicKey(
3429
+ "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"
3430
+ ),
3431
+ data: message
3432
+ })
3433
+ );
3434
+ const userPublicKey = new import_web34.PublicKey(this.address);
3435
+ transaction.feePayer = userPublicKey;
3436
+ const zeroHash = new Uint8Array(32).fill(0);
3437
+ transaction.recentBlockhash = new import_web34.PublicKey(zeroHash).toString();
3438
+ const signedTransaction = yield this._provider.signTransaction(transaction);
3439
+ const signature = signedTransaction.signatures[0].signature;
3440
+ if (signature) {
3441
+ return this.uint8ArrayToHexString(signature);
3442
+ } else {
3443
+ console.log("-- sign message error", signature);
3444
+ throw new Error("Unsupported signature");
3445
+ }
3446
+ }
3447
+ const signRes = yield this._provider.signMessage(message);
3448
+ return "0x" + (0, import_utils2.bytesToHex)(signRes);
3449
+ });
3450
+ }
3451
+ generateRegisterAccountMessage(inputs) {
3452
+ return __async(this, null, function* () {
3453
+ const [message, toSignatureMessage] = registerAccountMessage(__spreadProps(__spreadValues({}, inputs), {
3454
+ chainId: this.chainId
3455
+ }));
3456
+ const signature = yield this.signMessage(toSignatureMessage);
3457
+ return {
3458
+ message: __spreadProps(__spreadValues({}, message), {
3459
+ chainType: "SOL"
3460
+ }),
3461
+ signatured: signature
3462
+ };
3463
+ });
3464
+ }
3465
+ generateWithdrawMessage(inputs) {
3466
+ return __async(this, null, function* () {
3467
+ const [message, toSignatureMessage] = withdrawMessage(__spreadProps(__spreadValues({}, inputs), {
3468
+ chainId: this.chainId
3469
+ }));
3470
+ const signature = yield this.signMessage(toSignatureMessage);
3471
+ return {
3472
+ message: __spreadProps(__spreadValues({}, message), {
3473
+ chainType: "SOL"
3474
+ }),
3475
+ domain: {
3476
+ name: "",
3477
+ version: "",
3478
+ chainId: this.chainId,
3479
+ verifyingContract: inputs.verifyContract
3480
+ },
3481
+ signatured: signature
3482
+ };
3483
+ });
3484
+ }
3485
+ generateInternalTransferMessage(inputs) {
3486
+ return __async(this, null, function* () {
3487
+ const [message, toSignatureMessage] = internalTransferMessage(__spreadProps(__spreadValues({}, inputs), {
3488
+ chainId: this.chainId
3489
+ }));
3490
+ const signature = yield this.signMessage(toSignatureMessage);
3491
+ return {
3492
+ message: __spreadProps(__spreadValues({}, message), {
3493
+ chainType: "SOL"
3494
+ }),
3495
+ domain: {
3496
+ name: "",
3497
+ version: "",
3498
+ chainId: this.chainId,
3499
+ verifyingContract: inputs.verifyContract
3500
+ },
3501
+ signatured: signature
3502
+ };
3503
+ });
3504
+ }
3505
+ generateAddOrderlyKeyMessage(inputs) {
3506
+ return __async(this, null, function* () {
3507
+ const [message, toSignatureMessage] = addOrderlyKeyMessage(__spreadProps(__spreadValues({}, inputs), {
3508
+ chainId: this.chainId
3509
+ }));
3510
+ const signature = yield this.signMessage(toSignatureMessage);
3511
+ return {
3512
+ message: __spreadProps(__spreadValues({}, message), {
3513
+ chainType: "SOL"
3514
+ }),
3515
+ signatured: signature
3516
+ };
3517
+ });
3518
+ }
3519
+ generateSettleMessage(inputs) {
3520
+ return __async(this, null, function* () {
3521
+ const [message, toSignatureMessage] = settleMessage(__spreadProps(__spreadValues({}, inputs), {
3522
+ chainId: this.chainId
3523
+ }));
3524
+ const signature = yield this.signMessage(toSignatureMessage);
3525
+ return {
3526
+ message: __spreadProps(__spreadValues({}, message), {
3527
+ chainType: "SOL"
3528
+ }),
3529
+ domain: {
3530
+ name: "",
3531
+ version: "",
3532
+ chainId: this.chainId,
3533
+ verifyingContract: inputs.verifyContract
3534
+ },
3535
+ signatured: signature
3536
+ };
3537
+ });
3538
+ }
3539
+ generateDexRequestMessage(inputs) {
3540
+ return __async(this, null, function* () {
3541
+ const [message, toSignatureMessage] = yield dexRequestMessage(__spreadProps(__spreadValues({}, inputs), {
3542
+ chainId: this.chainId
3543
+ }));
3544
+ const signature = yield this.signMessage(toSignatureMessage);
3545
+ return {
3546
+ message: __spreadProps(__spreadValues({}, inputs), {
3547
+ chainType: "SOL"
3548
+ }),
3549
+ signatured: signature,
3550
+ domain: inputs.domain
3551
+ };
3552
+ });
3553
+ }
3554
+ getBalance() {
3555
+ return __async(this, null, function* () {
3556
+ const publicKey = new import_web34.PublicKey(this.address);
3557
+ const lamports = yield this.connection.getBalance(publicKey);
3558
+ return BigInt(lamports);
3559
+ });
3560
+ }
3561
+ call(address, method, params, options) {
3562
+ return __async(this, null, function* () {
3563
+ if (method === "balanceOf") {
3564
+ const tokenPublicKey = new import_web34.PublicKey(address);
3565
+ const userPublicKey = new import_web34.PublicKey(this._address);
3566
+ const userTokenAccount = getTokenAccounts(tokenPublicKey, userPublicKey);
3567
+ const connection = this.connection;
3568
+ const tokenAmount = yield (0, import_spl_token2.getAccount)(
3569
+ connection,
3570
+ userTokenAccount,
3571
+ "confirmed"
3572
+ );
3573
+ return tokenAmount.amount;
3574
+ }
3575
+ if (method === "allowance") {
3576
+ return import_orderly_types2.MaxUint256;
3577
+ }
3578
+ return BigInt(0);
3579
+ });
3580
+ }
3581
+ sendTransaction(contractAddress, method, payload, options) {
3582
+ return __async(this, null, function* () {
3583
+ console.log("-- solanan sendTransaction", {
3584
+ contractAddress,
3585
+ method,
3586
+ payload,
3587
+ options
3588
+ });
3589
+ if (method === "deposit") {
3590
+ return deposit({
3591
+ vaultAddress: contractAddress,
3592
+ userAddress: this._address,
3593
+ connection: this.connection,
3594
+ depositData: payload.data[0],
3595
+ sendTransaction: this._provider.sendTransaction
3596
+ });
3597
+ }
3598
+ });
3599
+ }
3600
+ callOnChain(chain, address, method, params, options) {
3601
+ return __async(this, null, function* () {
3602
+ console.log("-- params ", {
3603
+ chain,
3604
+ address,
3605
+ method,
3606
+ params
3607
+ });
3608
+ if (method === "getDepositFee") {
3609
+ return getDepositQuoteFee({
3610
+ vaultAddress: address,
3611
+ userAddress: this._address,
3612
+ connection: this.connection,
3613
+ depositData: params[1]
3614
+ });
3615
+ }
3616
+ return 0;
3617
+ });
3618
+ }
3619
+ pollTransactionReceiptWithBackoff(txHash, baseInterval, maxInterval, maxRetries) {
3620
+ return __async(this, null, function* () {
3621
+ return Promise.resolve({ status: 1 });
3622
+ });
3623
+ }
3624
+ };
3625
+ // Annotate the CommonJS export names for ESM import in node:
3626
+ 0 && (module.exports = {
3627
+ DefaultSolanaWalletAdapter,
3628
+ version
3629
+ });
2
3630
  //# sourceMappingURL=index.js.map