@allbridge/bridge-core-sdk 3.27.0-alpha.20 → 3.27.0-alpha.21

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.
@@ -6,7 +6,7 @@ export declare class JupiterService {
6
6
  apiKeyHeader?: string;
7
7
  maxAccounts?: number;
8
8
  constructor(solanaRpcUrl: string, jupiterParams: JupiterParams);
9
- getJupiterSwapTx(userAddress: string, stableTokenAddress: string, amount: string, exactOut: boolean): Promise<{
9
+ getJupiterSwapTx(userAddress: string, stableTokenAddress: string, amount: string, exactOut: boolean, payer?: string): Promise<{
10
10
  tx: VersionedTransaction;
11
11
  amountIn?: string;
12
12
  }>;
@@ -40,7 +40,7 @@ class JupiterService {
40
40
  this.apiKeyHeader = jupiterParams.jupiterApiKeyHeader;
41
41
  this.maxAccounts = jupiterParams.jupiterMaxAccounts;
42
42
  }
43
- async getJupiterSwapTx(userAddress, stableTokenAddress, amount, exactOut) {
43
+ async getJupiterSwapTx(userAddress, stableTokenAddress, amount, exactOut, payer) {
44
44
  let quoteResponse;
45
45
  try {
46
46
  const swapMode = exactOut ? "ExactOut" : "ExactIn";
@@ -71,6 +71,7 @@ class JupiterService {
71
71
  quoteResponse: quoteResponse.data,
72
72
  userPublicKey: userAddress,
73
73
  wrapAndUnwrapSol: true,
74
+ payer: payer,
74
75
  }, {
75
76
  headers: this.apiKeyHeader ? { "x-api-key": this.apiKeyHeader } : undefined,
76
77
  });
@@ -1 +1 @@
1
- {"version":3,"file":"jupiter.js","sourceRoot":"","sources":["../../../../../src/services/bridge/sol/jupiter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAgD;AAChD,6CAAuF;AACvF,+CAA0C;AAC1C,oDAA6D;AAC7D,oDAAiF;AAGjF,MAAa,cAAc;IACzB,UAAU,CAAa;IACvB,UAAU,CAAS;IACnB,YAAY,CAAU;IACtB,WAAW,CAAU;IAErB,YAAY,YAAoB,EAAE,aAA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C,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC5F,MAAM,SAAS,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;gBACtC,IAAI,CAAC,SAAS,EAAE,CAAC;oBACf,MAAM,IAAI,qBAAQ,CAAC,wBAAwB,CAAC,CAAC;gBAC/C,CAAC;gBACD,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACzC,CAAC;YACD,OAAO,WAAW,CAAC;QACrB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAI,CAAC,YAAY,KAAK,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;gBACpC,MAAM,IAAI,yBAAY,CAAC,0EAA0E,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;YAChH,CAAC;YACD,MAAM,IAAI,yBAAY,CAAC,uEAAuE,CAAC,CAAC;QAClG,CAAC;IACH,CAAC;CACF;AAjHD,wCAiHC","sourcesContent":["import { NATIVE_MINT } from \"@solana/spl-token\";\nimport { Connection, TransactionMessage, VersionedTransaction } from \"@solana/web3.js\";\nimport axios, { AxiosError } from \"axios\";\nimport { JupiterError, SdkError } from \"../../../exceptions\";\nimport { fetchAddressLookupTableAccountsFromTx } from \"../../../utils/sol/utils\";\nimport { JupiterParams } from \"./index\";\n\nexport class JupiterService {\n connection: Connection;\n jupiterUrl: string;\n apiKeyHeader?: string;\n maxAccounts?: number;\n\n constructor(solanaRpcUrl: string, jupiterParams: JupiterParams) {\n this.connection = new Connection(solanaRpcUrl);\n this.jupiterUrl = jupiterParams.jupiterUrl.replace(/\\/$/, \"\"); // trim last \"/\" if exist\n this.apiKeyHeader = jupiterParams.jupiterApiKeyHeader;\n this.maxAccounts = jupiterParams.jupiterMaxAccounts;\n }\n\n async getJupiterSwapTx(\n userAddress: string,\n stableTokenAddress: string,\n amount: string,\n exactOut: boolean\n ): Promise<{ tx: VersionedTransaction; amountIn?: string }> {\n let quoteResponse: any;\n try {\n const swapMode = exactOut ? \"ExactOut\" : \"ExactIn\";\n let url = `${this.jupiterUrl}/quote?inputMint=${stableTokenAddress}&outputMint=${NATIVE_MINT.toString()}&amount=${amount}&swapMode=${swapMode}&slippageBps=100&onlyDirectRoutes=true`;\n\n if (this.maxAccounts) {\n url += `&maxAccounts=${this.maxAccounts}`;\n }\n quoteResponse = await axios.get(url, {\n headers: this.apiKeyHeader ? { \"x-api-key\": this.apiKeyHeader } : undefined,\n });\n } catch (err) {\n if (err instanceof AxiosError && err.response && err.response.data && err.response.data.error) {\n throw new JupiterError(err.response.data.error);\n }\n throw new JupiterError(\"Cannot get route\");\n }\n\n let inAmount;\n if (exactOut && quoteResponse?.data?.inAmount) {\n inAmount = quoteResponse.data.inAmount;\n } else if (exactOut) {\n throw new JupiterError(\"Cannot get inAmount\");\n }\n\n let transactionResponse: any;\n try {\n transactionResponse = await axios.post(\n `${this.jupiterUrl}/swap`,\n {\n quoteResponse: quoteResponse.data,\n userPublicKey: userAddress,\n wrapAndUnwrapSol: true,\n },\n {\n headers: this.apiKeyHeader ? { \"x-api-key\": this.apiKeyHeader } : undefined,\n }\n );\n } catch (err) {\n if (err instanceof AxiosError && err.response && err.response.data && err.response.data.error) {\n throw new JupiterError(err.response.data.error);\n }\n throw new JupiterError(\"Cannot get swap transaction\");\n }\n\n let swapTransaction;\n if (transactionResponse?.data?.swapTransaction) {\n swapTransaction = transactionResponse.data.swapTransaction;\n } else {\n throw new JupiterError(\"Cannot get swap transaction\");\n }\n\n const swapTransactionBuf = Buffer.from(swapTransaction, \"base64\");\n const tx = VersionedTransaction.deserialize(swapTransactionBuf);\n\n return exactOut ? { tx, amountIn: inAmount } : { tx };\n }\n\n async amendJupiterWithSdkTx(\n transaction: VersionedTransaction,\n sdkTx: VersionedTransaction\n ): Promise<VersionedTransaction> {\n try {\n const addressLookupTableAccounts = await fetchAddressLookupTableAccountsFromTx(transaction, this.connection);\n const sdkAddressLookupTableAccounts = await fetchAddressLookupTableAccountsFromTx(sdkTx, this.connection);\n\n const message = TransactionMessage.decompile(transaction.message, {\n addressLookupTableAccounts: addressLookupTableAccounts,\n });\n const sdkMessage = TransactionMessage.decompile(sdkTx.message, {\n addressLookupTableAccounts: sdkAddressLookupTableAccounts,\n });\n sdkMessage.instructions.shift();\n message.instructions.push(...sdkMessage.instructions);\n\n addressLookupTableAccounts.push(...sdkAddressLookupTableAccounts);\n\n transaction.message = message.compileToV0Message(addressLookupTableAccounts);\n\n if (sdkTx.message.header.numRequiredSignatures === 2 && transaction.signatures.length === 1) {\n const signature = sdkTx.signatures[0];\n if (!signature) {\n throw new SdkError(\"Signature is undefined\");\n }\n transaction.signatures.push(signature);\n }\n return transaction;\n } catch (e) {\n if (e instanceof Error && e.message) {\n throw new JupiterError(`Some error occurred during creation final swap and bridge transaction. ${e.message}`);\n }\n throw new JupiterError(\"Some error occurred during creation final swap and bridge transaction\");\n }\n }\n}\n"]}
1
+ {"version":3,"file":"jupiter.js","sourceRoot":"","sources":["../../../../../src/services/bridge/sol/jupiter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAgD;AAChD,6CAAuF;AACvF,+CAA0C;AAC1C,oDAA6D;AAC7D,oDAAiF;AAGjF,MAAa,cAAc;IACzB,UAAU,CAAa;IACvB,UAAU,CAAS;IACnB,YAAY,CAAU;IACtB,WAAW,CAAU;IAErB,YAAY,YAAoB,EAAE,aAA4B;QAC5D,IAAI,CAAC,UAAU,GAAG,IAAI,oBAAU,CAAC,YAAY,CAAC,CAAC;QAC/C,IAAI,CAAC,UAAU,GAAG,aAAa,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,yBAAyB;QACxF,IAAI,CAAC,YAAY,GAAG,aAAa,CAAC,mBAAmB,CAAC;QACtD,IAAI,CAAC,WAAW,GAAG,aAAa,CAAC,kBAAkB,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,gBAAgB,CACpB,WAAmB,EACnB,kBAA0B,EAC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EAAE,CAAC;YACX,IAAI,CAAC,YAAY,KAAK,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;gBACpC,MAAM,IAAI,yBAAY,CAAC,0EAA0E,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;YAChH,CAAC;YACD,MAAM,IAAI,yBAAY,CAAC,uEAAuE,CAAC,CAAC;QAClG,CAAC;IACH,CAAC;CACF;AAnHD,wCAmHC","sourcesContent":["import { NATIVE_MINT } from \"@solana/spl-token\";\nimport { Connection, TransactionMessage, VersionedTransaction } from \"@solana/web3.js\";\nimport axios, { AxiosError } from \"axios\";\nimport { JupiterError, SdkError } from \"../../../exceptions\";\nimport { fetchAddressLookupTableAccountsFromTx } from \"../../../utils/sol/utils\";\nimport { JupiterParams } from \"./index\";\n\nexport class JupiterService {\n connection: Connection;\n jupiterUrl: string;\n apiKeyHeader?: string;\n maxAccounts?: number;\n\n constructor(solanaRpcUrl: string, jupiterParams: JupiterParams) {\n this.connection = new Connection(solanaRpcUrl);\n this.jupiterUrl = jupiterParams.jupiterUrl.replace(/\\/$/, \"\"); // trim last \"/\" if exist\n this.apiKeyHeader = jupiterParams.jupiterApiKeyHeader;\n this.maxAccounts = jupiterParams.jupiterMaxAccounts;\n }\n\n async getJupiterSwapTx(\n userAddress: string,\n stableTokenAddress: string,\n amount: string,\n exactOut: boolean,\n payer?: string\n ): Promise<{ tx: VersionedTransaction; amountIn?: string }> {\n let quoteResponse: any;\n try {\n const swapMode = exactOut ? \"ExactOut\" : \"ExactIn\";\n let url = `${this.jupiterUrl}/quote?inputMint=${stableTokenAddress}&outputMint=${NATIVE_MINT.toString()}&amount=${amount}&swapMode=${swapMode}&slippageBps=100&onlyDirectRoutes=true`;\n\n if (this.maxAccounts) {\n url += `&maxAccounts=${this.maxAccounts}`;\n }\n quoteResponse = await axios.get(url, {\n headers: this.apiKeyHeader ? { \"x-api-key\": this.apiKeyHeader } : undefined,\n });\n } catch (err) {\n if (err instanceof AxiosError && err.response && err.response.data && err.response.data.error) {\n throw new JupiterError(err.response.data.error);\n }\n throw new JupiterError(\"Cannot get route\");\n }\n\n let inAmount;\n if (exactOut && quoteResponse?.data?.inAmount) {\n inAmount = quoteResponse.data.inAmount;\n } else if (exactOut) {\n throw new JupiterError(\"Cannot get inAmount\");\n }\n\n let transactionResponse: any;\n try {\n transactionResponse = await axios.post(\n `${this.jupiterUrl}/swap`,\n {\n quoteResponse: quoteResponse.data,\n userPublicKey: userAddress,\n wrapAndUnwrapSol: true,\n payer: payer,\n },\n {\n headers: this.apiKeyHeader ? { \"x-api-key\": this.apiKeyHeader } : undefined,\n }\n );\n } catch (err) {\n if (err instanceof AxiosError && err.response && err.response.data && err.response.data.error) {\n throw new JupiterError(err.response.data.error);\n }\n throw new JupiterError(\"Cannot get swap transaction\");\n }\n\n let swapTransaction;\n if (transactionResponse?.data?.swapTransaction) {\n swapTransaction = transactionResponse.data.swapTransaction;\n } else {\n throw new JupiterError(\"Cannot get swap transaction\");\n }\n\n const swapTransactionBuf = Buffer.from(swapTransaction, \"base64\");\n const tx = VersionedTransaction.deserialize(swapTransactionBuf);\n\n return exactOut ? { tx, amountIn: inAmount } : { tx };\n }\n\n async amendJupiterWithSdkTx(\n transaction: VersionedTransaction,\n sdkTx: VersionedTransaction\n ): Promise<VersionedTransaction> {\n try {\n const addressLookupTableAccounts = await fetchAddressLookupTableAccountsFromTx(transaction, this.connection);\n const sdkAddressLookupTableAccounts = await fetchAddressLookupTableAccountsFromTx(sdkTx, this.connection);\n\n const message = TransactionMessage.decompile(transaction.message, {\n addressLookupTableAccounts: addressLookupTableAccounts,\n });\n const sdkMessage = TransactionMessage.decompile(sdkTx.message, {\n addressLookupTableAccounts: sdkAddressLookupTableAccounts,\n });\n sdkMessage.instructions.shift();\n message.instructions.push(...sdkMessage.instructions);\n\n addressLookupTableAccounts.push(...sdkAddressLookupTableAccounts);\n\n transaction.message = message.compileToV0Message(addressLookupTableAccounts);\n\n if (sdkTx.message.header.numRequiredSignatures === 2 && transaction.signatures.length === 1) {\n const signature = sdkTx.signatures[0];\n if (!signature) {\n throw new SdkError(\"Signature is undefined\");\n }\n transaction.signatures.push(signature);\n }\n return transaction;\n } catch (e) {\n if (e instanceof Error && e.message) {\n throw new JupiterError(`Some error occurred during creation final swap and bridge transaction. ${e.message}`);\n }\n throw new JupiterError(\"Some error occurred during creation final swap and bridge transaction\");\n }\n }\n}\n"]}
@@ -57,33 +57,36 @@ class SolanaPoolService extends pool_1.ChainPoolService {
57
57
  }
58
58
  async buildRawTransactionDeposit(params) {
59
59
  const { bridge, accounts, preInstructions } = await this.prepareDataForTransaction(params);
60
+ const feePayer = (0, sol_1.getFeePayer)(new web3_js_1.PublicKey(params.accountAddress), params.txFeeParams);
60
61
  const tx = await bridge.methods
61
62
  .deposit(new anchor_1.BN(params.amount))
62
63
  .accounts(accounts)
63
64
  .preInstructions(preInstructions)
64
65
  .transaction();
65
66
  tx.recentBlockhash = (await this.buildAnchorProvider(params.accountAddress).connection.getLatestBlockhash()).blockhash;
66
- tx.feePayer = new web3_js_1.PublicKey(params.accountAddress);
67
+ tx.feePayer = feePayer;
67
68
  await (0, compute_budget_1.addUnitLimitAndUnitPriceToTx)(tx, params.txFeeParams, this.solanaRpcUrl);
68
69
  return tx;
69
70
  }
70
71
  async buildRawTransactionWithdraw(params) {
71
72
  const { bridge, accounts, preInstructions } = await this.prepareDataForTransaction(params);
73
+ const feePayer = (0, sol_1.getFeePayer)(new web3_js_1.PublicKey(params.accountAddress), params.txFeeParams);
72
74
  const tx = await bridge.methods
73
75
  .withdraw(new anchor_1.BN(params.amount))
74
76
  .accounts(accounts)
75
77
  .preInstructions(preInstructions)
76
78
  .transaction();
77
79
  tx.recentBlockhash = (await this.buildAnchorProvider(params.accountAddress).connection.getLatestBlockhash()).blockhash;
78
- tx.feePayer = new web3_js_1.PublicKey(params.accountAddress);
80
+ tx.feePayer = feePayer;
79
81
  await (0, compute_budget_1.addUnitLimitAndUnitPriceToTx)(tx, params.txFeeParams, this.solanaRpcUrl);
80
82
  return tx;
81
83
  }
82
84
  async buildRawTransactionClaimRewards(params) {
83
85
  const { bridge, accounts, preInstructions } = await this.prepareDataForTransaction(params);
86
+ const feePayer = (0, sol_1.getFeePayer)(new web3_js_1.PublicKey(params.accountAddress), params.txFeeParams);
84
87
  const tx = await bridge.methods.claimRewards().accounts(accounts).preInstructions(preInstructions).transaction();
85
88
  tx.recentBlockhash = (await this.buildAnchorProvider(params.accountAddress).connection.getLatestBlockhash()).blockhash;
86
- tx.feePayer = new web3_js_1.PublicKey(params.accountAddress);
89
+ tx.feePayer = feePayer;
87
90
  await (0, compute_budget_1.addUnitLimitAndUnitPriceToTx)(tx, params.txFeeParams, this.solanaRpcUrl);
88
91
  return tx;
89
92
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/services/liquidity-pool/sol/index.ts"],"names":[],"mappings":";;;AAAA,kDAAyF;AACzF,6CAAgF;AAChF,6DAAwD;AAGxD,4DAAwE;AAExE,0DAAuF;AACvF,yCAAsD;AACtD,uDAMkC;AAClC,mEAA8E;AAC9E,sCAA+G;AAC/G,yCAAkD;AAkBlD,MAAa,iBAAkB,SAAQ,uBAAgB;IAK5C;IACA;IALT,SAAS,GAAqB,uBAAS,CAAC,MAAM,CAAC;IACvC,CAAC,GAAG,EAAE,CAAC;IAEf,YACS,YAAoB,EACpB,GAAwB;QAE/B,KAAK,EAAE,CAAC;QAHD,iBAAY,GAAZ,YAAY,CAAQ;QACpB,QAAG,GAAH,GAAG,CAAqB;IAGjC,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,cAAsB,EAAE,KAA4B;QAC3E,MAAM,QAAQ,GAAG,IAAI,CAAC,mBAAmB,CAAC,cAAc,CAAC,CAAC;QAC1D,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;QAC7D,MAAM,WAAW,GAAG,IAAI,mBAAS,CAAC,KAAK,C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AM,MAAM,CAAC,OAAO;iBAC7D,kBAAkB,EAAE;iBACpB,QAAQ,CAAC;gBACR,IAAI,EAAE,gBAAgB;gBACtB,IAAI;gBACJ,WAAW,EAAE,kBAAkB;aAChC,CAAC;iBACD,WAAW,EAAE,CAAC;YACjB,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACpC,CAAC;QAED,MAAM,QAAQ,GAAe;YAC3B,IAAI,EAAE,gBAAgB;YACtB,IAAI;YACJ,MAAM,EAAE,aAAa;YACrB,IAAI,EAAE,WAAW;YACjB,eAAe,EAAE,eAAe;YAChC,WAAW,EAAE,kBAAkB;YAC/B,SAAS;YACT,WAAW,EAAE,kBAAkB;SAChC,CAAC;QAEF,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC;IACvC,CAAC;CACF;AA/LD,8CA+LC","sourcesContent":["import { AnchorProvider, BN, Program, Provider, Spl, web3 } from \"@project-serum/anchor\";\nimport { Connection, PublicKey, TransactionInstruction } from \"@solana/web3.js\";\nimport { ChainType } from \"../../../chains/chain.enums\";\nimport { AllbridgeCoreClient } from \"../../../client/core-api/core-client-base\";\nimport { PoolInfo, TokenWithChainDetails } from \"../../../tokens-info\";\nimport { calculatePoolInfoImbalance } from \"../../../utils/calculation\";\nimport { RawTransaction } from \"../../models\";\nimport { Bridge as BridgeType, IDL as bridgeIdl } from \"../../models/sol/types/bridge\";\nimport { getTokenAccountData } from \"../../utils/sol\";\nimport {\n getAssociatedAccount,\n getAuthorityAccount,\n getBridgeTokenAccount,\n getConfigAccount,\n getUserDepositAccount,\n} from \"../../utils/sol/accounts\";\nimport { addUnitLimitAndUnitPriceToTx } from \"../../utils/sol/compute-budget\";\nimport { LiquidityPoolsParams, LiquidityPoolsParamsWithAmount, UserBalance, UserBalanceInfo } from \"../models\";\nimport { ChainPoolService } from \"../models/pool\";\n\ninterface LPAccounts {\n mint: PublicKey;\n user: PublicKey;\n config: PublicKey;\n pool: PublicKey;\n bridgeAuthority: PublicKey;\n userDeposit: PublicKey;\n userToken: PublicKey;\n bridgeToken: PublicKey;\n}\n\ninterface LPTransactionData {\n accounts: LPAccounts;\n preInstructions: TransactionInstruction[];\n}\n\nexport class SolanaPoolService extends ChainPoolService {\n chainType: ChainType.SOLANA = ChainType.SOLANA;\n private P = 48;\n\n constructor(\n public solanaRpcUrl: string,\n public api: AllbridgeCoreClient\n ) {\n super();\n }\n\n async getUserBalanceInfo(accountAddress: string, token: TokenWithChainDetails): Promise<UserBalanceInfo> {\n const provider = this.buildAnchorProvider(accountAddress);\n const bridge = this.getBridge(token.bridgeAddress, provider);\n const poolAccount = new PublicKey(token.poolAddress);\n const poolAccountInfo = await bridge.account.pool.fetch(poolAccount);\n try {\n const userDepositAccount = await getUserDepositAccount(\n new PublicKey(accountAddress),\n poolAccountInfo.mint,\n bridge.programId\n );\n const { lpAmount, rewardDebt } = await bridge.account.userDeposit.fetch(userDepositAccount);\n return new UserBalance({\n lpAmount: lpAmount.toString(),\n rewardDebt: rewardDebt.toString(),\n });\n } catch (ignoreError) {\n return new UserBalance({ lpAmount: \"0\", rewardDebt: \"0\" });\n }\n }\n\n async getPoolInfoFromChain(token: TokenWithChainDetails): Promise<PoolInfo> {\n const provider = this.buildAnchorProvider(token.bridgeAddress);\n const pool = await this.getBridge(token.bridgeAddress, provider).account.pool.fetch(token.poolAddress);\n const vUsdBalance = pool.vUsdBalance.toString();\n const tokenBalance = pool.tokenBalance.toString();\n const imbalance = calculatePoolInfoImbalance({ tokenBalance, vUsdBalance });\n return {\n dValue: pool.d.toString(),\n aValue: pool.a.toString(),\n totalLpAmount: pool.totalLpAmount.toString(),\n vUsdBalance,\n tokenBalance,\n accRewardPerShareP: pool.accRewardPerShareP.toString(),\n p: this.P,\n imbalance,\n };\n }\n\n async buildRawTransactionDeposit(params: LiquidityPoolsParamsWithAmount): Promise<RawTransaction> {\n const { bridge, accounts, preInstructions } = await this.prepareDataForTransaction(params);\n\n const tx = await bridge.methods\n .deposit(new BN(params.amount))\n .accounts(accounts)\n .preInstructions(preInstructions)\n .transaction();\n tx.recentBlockhash = (\n await this.buildAnchorProvider(params.accountAddress).connection.getLatestBlockhash()\n ).blockhash;\n tx.feePayer = new PublicKey(params.accountAddress);\n await addUnitLimitAndUnitPriceToTx(tx, params.txFeeParams, this.solanaRpcUrl);\n return tx;\n }\n\n async buildRawTransactionWithdraw(params: LiquidityPoolsParamsWithAmount): Promise<RawTransaction> {\n const { bridge, accounts, preInstructions } = await this.prepareDataForTransaction(params);\n\n const tx = await bridge.methods\n .withdraw(new BN(params.amount))\n .accounts(accounts)\n .preInstructions(preInstructions)\n .transaction();\n tx.recentBlockhash = (\n await this.buildAnchorProvider(params.accountAddress).connection.getLatestBlockhash()\n ).blockhash;\n tx.feePayer = new PublicKey(params.accountAddress);\n await addUnitLimitAndUnitPriceToTx(tx, params.txFeeParams, this.solanaRpcUrl);\n return tx;\n }\n\n async buildRawTransactionClaimRewards(params: LiquidityPoolsParams): Promise<RawTransaction> {\n const { bridge, accounts, preInstructions } = await this.prepareDataForTransaction(params);\n\n const tx = await bridge.methods.claimRewards().accounts(accounts).preInstructions(preInstructions).transaction();\n tx.recentBlockhash = (\n await this.buildAnchorProvider(params.accountAddress).connection.getLatestBlockhash()\n ).blockhash;\n tx.feePayer = new PublicKey(params.accountAddress);\n await addUnitLimitAndUnitPriceToTx(tx, params.txFeeParams, this.solanaRpcUrl);\n return tx;\n }\n\n private async prepareDataForTransaction(params: LiquidityPoolsParams) {\n const provider = this.buildAnchorProvider(params.accountAddress);\n const bridge = this.getBridge(params.token.bridgeAddress, provider);\n\n const { accounts, preInstructions } = await this._getLPTransactionData(\n bridge,\n params.token.poolAddress,\n params.accountAddress,\n provider\n );\n return { bridge, accounts, preInstructions };\n }\n\n private getBridge(bridgeAddress: string, provider: Provider): Program<BridgeType> {\n return new Program<BridgeType>(bridgeIdl, bridgeAddress, provider);\n }\n\n private buildAnchorProvider(accountAddress: string): Provider {\n const connection = new Connection(this.solanaRpcUrl, \"confirmed\");\n\n const publicKey = new PublicKey(accountAddress);\n\n return new AnchorProvider(\n connection,\n // @ts-expect-error enough wallet for fetch actions\n { publicKey: publicKey },\n {\n preflightCommitment: \"confirmed\",\n commitment: \"confirmed\",\n }\n );\n }\n\n private async _getLPTransactionData(\n bridge: Program<BridgeType>,\n poolAddress: string,\n account: string,\n provider: Provider\n ): Promise<LPTransactionData> {\n const user = new PublicKey(account);\n const configAccount = await getConfigAccount(bridge.programId);\n const bridgeAuthority = await getAuthorityAccount(bridge.programId);\n const poolAccount = new PublicKey(poolAddress);\n const poolAccountInfo = await bridge.account.pool.fetch(poolAccount);\n const tokenMintAccount = poolAccountInfo.mint;\n const userToken = await getAssociatedAccount(user, tokenMintAccount);\n const bridgeTokenAccount = await getBridgeTokenAccount(tokenMintAccount, bridge.programId);\n const userDepositAccount = await getUserDepositAccount(user, tokenMintAccount, bridge.programId);\n\n const preInstructions: TransactionInstruction[] = [\n web3.ComputeBudgetProgram.setComputeUnitLimit({\n units: 1000000,\n }),\n ];\n\n try {\n await getTokenAccountData(userToken, provider);\n } catch (ignoreError) {\n const associatedProgram = Spl.associatedToken(provider);\n const createUserTokenInstruction: TransactionInstruction = await associatedProgram.methods\n .create()\n .accounts({\n mint: tokenMintAccount,\n owner: user,\n associatedAccount: userToken,\n })\n .instruction();\n preInstructions.push(createUserTokenInstruction);\n }\n\n try {\n await bridge.account.userDeposit.fetch(userDepositAccount);\n } catch (ignoreError) {\n const instruction: TransactionInstruction = await bridge.methods\n .initDepositAccount()\n .accounts({\n mint: tokenMintAccount,\n user,\n userDeposit: userDepositAccount,\n })\n .instruction();\n preInstructions.push(instruction);\n }\n\n const accounts: LPAccounts = {\n mint: tokenMintAccount,\n user,\n config: configAccount,\n pool: poolAccount,\n bridgeAuthority: bridgeAuthority,\n userDeposit: userDepositAccount,\n userToken,\n bridgeToken: bridgeTokenAccount,\n };\n\n return { accounts, preInstructions };\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources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AQ,GAAe;YAC3B,IAAI,EAAE,gBAAgB;YACtB,IAAI;YACJ,MAAM,EAAE,aAAa;YACrB,IAAI,EAAE,WAAW;YACjB,eAAe,EAAE,eAAe;YAChC,WAAW,EAAE,kBAAkB;YAC/B,SAAS;YACT,WAAW,EAAE,kBAAkB;SAChC,CAAC;QAEF,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC;IACvC,CAAC;CACF;AArMD,8CAqMC","sourcesContent":["import { AnchorProvider, BN, Program, Provider, Spl, web3 } from \"@project-serum/anchor\";\nimport { Connection, PublicKey, TransactionInstruction } from \"@solana/web3.js\";\nimport { ChainType } from \"../../../chains/chain.enums\";\nimport { AllbridgeCoreClient } from \"../../../client/core-api/core-client-base\";\nimport { PoolInfo, TokenWithChainDetails } from \"../../../tokens-info\";\nimport { calculatePoolInfoImbalance } from \"../../../utils/calculation\";\nimport { RawTransaction } from \"../../models\";\nimport { Bridge as BridgeType, IDL as bridgeIdl } from \"../../models/sol/types/bridge\";\nimport { getFeePayer, getTokenAccountData } from \"../../utils/sol\";\nimport {\n getAssociatedAccount,\n getAuthorityAccount,\n getBridgeTokenAccount,\n getConfigAccount,\n getUserDepositAccount,\n} from \"../../utils/sol/accounts\";\nimport { addUnitLimitAndUnitPriceToTx } from \"../../utils/sol/compute-budget\";\nimport { LiquidityPoolsParams, LiquidityPoolsParamsWithAmount, UserBalance, UserBalanceInfo } from \"../models\";\nimport { ChainPoolService } from \"../models/pool\";\n\ninterface LPAccounts {\n mint: PublicKey;\n user: PublicKey;\n config: PublicKey;\n pool: PublicKey;\n bridgeAuthority: PublicKey;\n userDeposit: PublicKey;\n userToken: PublicKey;\n bridgeToken: PublicKey;\n}\n\ninterface LPTransactionData {\n accounts: LPAccounts;\n preInstructions: TransactionInstruction[];\n}\n\nexport class SolanaPoolService extends ChainPoolService {\n chainType: ChainType.SOLANA = ChainType.SOLANA;\n private P = 48;\n\n constructor(\n public solanaRpcUrl: string,\n public api: AllbridgeCoreClient\n ) {\n super();\n }\n\n async getUserBalanceInfo(accountAddress: string, token: TokenWithChainDetails): Promise<UserBalanceInfo> {\n const provider = this.buildAnchorProvider(accountAddress);\n const bridge = this.getBridge(token.bridgeAddress, provider);\n const poolAccount = new PublicKey(token.poolAddress);\n const poolAccountInfo = await bridge.account.pool.fetch(poolAccount);\n try {\n const userDepositAccount = await getUserDepositAccount(\n new PublicKey(accountAddress),\n poolAccountInfo.mint,\n bridge.programId\n );\n const { lpAmount, rewardDebt } = await bridge.account.userDeposit.fetch(userDepositAccount);\n return new UserBalance({\n lpAmount: lpAmount.toString(),\n rewardDebt: rewardDebt.toString(),\n });\n } catch (ignoreError) {\n return new UserBalance({ lpAmount: \"0\", rewardDebt: \"0\" });\n }\n }\n\n async getPoolInfoFromChain(token: TokenWithChainDetails): Promise<PoolInfo> {\n const provider = this.buildAnchorProvider(token.bridgeAddress);\n const pool = await this.getBridge(token.bridgeAddress, provider).account.pool.fetch(token.poolAddress);\n const vUsdBalance = pool.vUsdBalance.toString();\n const tokenBalance = pool.tokenBalance.toString();\n const imbalance = calculatePoolInfoImbalance({ tokenBalance, vUsdBalance });\n return {\n dValue: pool.d.toString(),\n aValue: pool.a.toString(),\n totalLpAmount: pool.totalLpAmount.toString(),\n vUsdBalance,\n tokenBalance,\n accRewardPerShareP: pool.accRewardPerShareP.toString(),\n p: this.P,\n imbalance,\n };\n }\n\n async buildRawTransactionDeposit(params: LiquidityPoolsParamsWithAmount): Promise<RawTransaction> {\n const { bridge, accounts, preInstructions } = await this.prepareDataForTransaction(params);\n\n const feePayer = getFeePayer(new PublicKey(params.accountAddress), params.txFeeParams);\n\n const tx = await bridge.methods\n .deposit(new BN(params.amount))\n .accounts(accounts)\n .preInstructions(preInstructions)\n .transaction();\n tx.recentBlockhash = (\n await this.buildAnchorProvider(params.accountAddress).connection.getLatestBlockhash()\n ).blockhash;\n tx.feePayer = feePayer;\n await addUnitLimitAndUnitPriceToTx(tx, params.txFeeParams, this.solanaRpcUrl);\n return tx;\n }\n\n async buildRawTransactionWithdraw(params: LiquidityPoolsParamsWithAmount): Promise<RawTransaction> {\n const { bridge, accounts, preInstructions } = await this.prepareDataForTransaction(params);\n\n const feePayer = getFeePayer(new PublicKey(params.accountAddress), params.txFeeParams);\n\n const tx = await bridge.methods\n .withdraw(new BN(params.amount))\n .accounts(accounts)\n .preInstructions(preInstructions)\n .transaction();\n tx.recentBlockhash = (\n await this.buildAnchorProvider(params.accountAddress).connection.getLatestBlockhash()\n ).blockhash;\n tx.feePayer = feePayer;\n await addUnitLimitAndUnitPriceToTx(tx, params.txFeeParams, this.solanaRpcUrl);\n return tx;\n }\n\n async buildRawTransactionClaimRewards(params: LiquidityPoolsParams): Promise<RawTransaction> {\n const { bridge, accounts, preInstructions } = await this.prepareDataForTransaction(params);\n\n const feePayer = getFeePayer(new PublicKey(params.accountAddress), params.txFeeParams);\n\n const tx = await bridge.methods.claimRewards().accounts(accounts).preInstructions(preInstructions).transaction();\n tx.recentBlockhash = (\n await this.buildAnchorProvider(params.accountAddress).connection.getLatestBlockhash()\n ).blockhash;\n tx.feePayer = feePayer;\n await addUnitLimitAndUnitPriceToTx(tx, params.txFeeParams, this.solanaRpcUrl);\n return tx;\n }\n\n private async prepareDataForTransaction(params: LiquidityPoolsParams) {\n const provider = this.buildAnchorProvider(params.accountAddress);\n const bridge = this.getBridge(params.token.bridgeAddress, provider);\n\n const { accounts, preInstructions } = await this._getLPTransactionData(\n bridge,\n params.token.poolAddress,\n params.accountAddress,\n provider\n );\n return { bridge, accounts, preInstructions };\n }\n\n private getBridge(bridgeAddress: string, provider: Provider): Program<BridgeType> {\n return new Program<BridgeType>(bridgeIdl, bridgeAddress, provider);\n }\n\n private buildAnchorProvider(accountAddress: string): Provider {\n const connection = new Connection(this.solanaRpcUrl, \"confirmed\");\n\n const publicKey = new PublicKey(accountAddress);\n\n return new AnchorProvider(\n connection,\n // @ts-expect-error enough wallet for fetch actions\n { publicKey: publicKey },\n {\n preflightCommitment: \"confirmed\",\n commitment: \"confirmed\",\n }\n );\n }\n\n private async _getLPTransactionData(\n bridge: Program<BridgeType>,\n poolAddress: string,\n account: string,\n provider: Provider\n ): Promise<LPTransactionData> {\n const user = new PublicKey(account);\n const configAccount = await getConfigAccount(bridge.programId);\n const bridgeAuthority = await getAuthorityAccount(bridge.programId);\n const poolAccount = new PublicKey(poolAddress);\n const poolAccountInfo = await bridge.account.pool.fetch(poolAccount);\n const tokenMintAccount = poolAccountInfo.mint;\n const userToken = await getAssociatedAccount(user, tokenMintAccount);\n const bridgeTokenAccount = await getBridgeTokenAccount(tokenMintAccount, bridge.programId);\n const userDepositAccount = await getUserDepositAccount(user, tokenMintAccount, bridge.programId);\n\n const preInstructions: TransactionInstruction[] = [\n web3.ComputeBudgetProgram.setComputeUnitLimit({\n units: 1000000,\n }),\n ];\n\n try {\n await getTokenAccountData(userToken, provider);\n } catch (ignoreError) {\n const associatedProgram = Spl.associatedToken(provider);\n const createUserTokenInstruction: TransactionInstruction = await associatedProgram.methods\n .create()\n .accounts({\n mint: tokenMintAccount,\n owner: user,\n associatedAccount: userToken,\n })\n .instruction();\n preInstructions.push(createUserTokenInstruction);\n }\n\n try {\n await bridge.account.userDeposit.fetch(userDepositAccount);\n } catch (ignoreError) {\n const instruction: TransactionInstruction = await bridge.methods\n .initDepositAccount()\n .accounts({\n mint: tokenMintAccount,\n user,\n userDeposit: userDepositAccount,\n })\n .instruction();\n preInstructions.push(instruction);\n }\n\n const accounts: LPAccounts = {\n mint: tokenMintAccount,\n user,\n config: configAccount,\n pool: poolAccount,\n bridgeAuthority: bridgeAuthority,\n userDeposit: userDepositAccount,\n userToken,\n bridgeToken: bridgeTokenAccount,\n };\n\n return { accounts, preInstructions };\n }\n}\n"]}
@@ -3,11 +3,23 @@ import { Algodv2 } from "algosdk";
3
3
  import { TronWeb, Types } from "tronweb";
4
4
  import { SolanaTxFee } from "./sol";
5
5
  export { SolanaTxFee, PricePerUnitInMicroLamports, ExtraFeeInLamports, SolanaAutoTxFee } from "./sol";
6
+ export interface SolanaTxFeeParams {
7
+ /**
8
+ * Transaction fee configuration.
9
+ * If omitted, automatic fee calculation is used.
10
+ */
11
+ fee?: SolanaTxFee;
12
+ /**
13
+ * Custom fee payer account.
14
+ * Defaults to transaction signer.
15
+ */
16
+ feePayer?: string;
17
+ }
6
18
  /**
7
- * Blockchain fee added to tx
19
+ * Blockchain fee params for tx
8
20
  */
9
21
  export interface TxFeeParams {
10
- solana?: SolanaTxFee;
22
+ solana?: SolanaTxFee | SolanaTxFeeParams;
11
23
  }
12
24
  /**
13
25
  * The `EssentialWeb3` interface provides the minimum set of Web3 functionalities
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/services/models/index.ts"],"names":[],"mappings":";;;AAMA,6BAAsG;AAA/B,sGAAA,eAAe,OAAA","sourcesContent":["/* eslint-disable @typescript-eslint/no-duplicate-type-constituents */\nimport { Transaction as SolanaWeb3Transaction, VersionedTransaction } from \"@solana/web3.js\";\nimport { Algodv2 } from \"algosdk\";\nimport { TronWeb, Types } from \"tronweb\";\nimport { SolanaTxFee } from \"./sol\";\n\nexport { SolanaTxFee, PricePerUnitInMicroLamports, ExtraFeeInLamports, SolanaAutoTxFee } from \"./sol\";\n\n/**\n * Blockchain fee added to tx\n */\nexport interface TxFeeParams {\n solana?: SolanaTxFee;\n}\n\n/**\n * The `EssentialWeb3` interface provides the minimum set of Web3 functionalities\n * required by the SDK. It allows any web3-like provider to be used, as long as it\n * matches the signature of these essential methods and properties. This prevents\n * tight coupling to a specific version of the `web3` library.\n */\nexport interface EssentialWeb3 {\n eth: {\n getBalance: (address: string) => Promise<any>;\n estimateGas: (tx: any) => Promise<any>;\n sendTransaction: (tx: any) => Promise<any>;\n Contract: new (abi: any, address?: string) => any;\n BatchRequest: new () => any;\n };\n}\n\n/**\n * The provider is type that combines connection implementations for different chains.<br/>\n * TIP: None provider in the Solana blockchain case.\n */\nexport type Provider = EssentialWeb3 | TronWeb | Algodv2;\n\n/**\n * The `EssentialWeb3Transaction` interface provides the minimum set of Web3 Transaction\n * returned by the SDK. It allows any web3-like provider to be used, as long as it\n * matches the signature of these essential interface. This prevents\n * tight coupling to a specific version of the `web3` library.\n */\nexport interface EssentialWeb3Transaction {\n from?: string;\n to?: string;\n value?: string;\n data?: string;\n}\n\nexport type RawTransaction =\n | RawTronTransaction\n | RawEvmTransaction\n | RawSorobanTransaction\n | RawAlgTransaction\n | RawStxTransaction\n | RawSuiTransaction\n | RawBridgeSolanaTransaction\n | RawPoolSolanaTransaction;\nexport type RawEvmTransaction = EssentialWeb3Transaction;\nexport type RawTronTransaction = Types.Transaction;\nexport type RawSorobanTransaction = string;\nexport type RawPoolSolanaTransaction = SolanaWeb3Transaction;\nexport type RawBridgeSolanaTransaction = VersionedTransaction;\nexport type RawSuiTransaction = string;\nexport type RawAlgTransaction = string[];\nexport type RawStxTransaction = string;\n\nexport interface SmartContractMethodParameter {\n type: string;\n value: string | number | Buffer;\n}\n\nexport interface TransactionResponse {\n txId: string;\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/services/models/index.ts"],"names":[],"mappings":";;;AAMA,6BAAsG;AAA/B,sGAAA,eAAe,OAAA","sourcesContent":["/* eslint-disable @typescript-eslint/no-duplicate-type-constituents */\nimport { Transaction as SolanaWeb3Transaction, VersionedTransaction } from \"@solana/web3.js\";\nimport { Algodv2 } from \"algosdk\";\nimport { TronWeb, Types } from \"tronweb\";\nimport { SolanaTxFee } from \"./sol\";\n\nexport { SolanaTxFee, PricePerUnitInMicroLamports, ExtraFeeInLamports, SolanaAutoTxFee } from \"./sol\";\n\nexport interface SolanaTxFeeParams {\n /**\n * Transaction fee configuration.\n * If omitted, automatic fee calculation is used.\n */\n fee?: SolanaTxFee;\n\n /**\n * Custom fee payer account.\n * Defaults to transaction signer.\n */\n feePayer?: string; // Solana public key (base58)\n}\n\n/**\n * Blockchain fee params for tx\n */\nexport interface TxFeeParams {\n solana?: SolanaTxFee | SolanaTxFeeParams;\n}\n\n/**\n * The `EssentialWeb3` interface provides the minimum set of Web3 functionalities\n * required by the SDK. It allows any web3-like provider to be used, as long as it\n * matches the signature of these essential methods and properties. This prevents\n * tight coupling to a specific version of the `web3` library.\n */\nexport interface EssentialWeb3 {\n eth: {\n getBalance: (address: string) => Promise<any>;\n estimateGas: (tx: any) => Promise<any>;\n sendTransaction: (tx: any) => Promise<any>;\n Contract: new (abi: any, address?: string) => any;\n BatchRequest: new () => any;\n };\n}\n\n/**\n * The provider is type that combines connection implementations for different chains.<br/>\n * TIP: None provider in the Solana blockchain case.\n */\nexport type Provider = EssentialWeb3 | TronWeb | Algodv2;\n\n/**\n * The `EssentialWeb3Transaction` interface provides the minimum set of Web3 Transaction\n * returned by the SDK. It allows any web3-like provider to be used, as long as it\n * matches the signature of these essential interface. This prevents\n * tight coupling to a specific version of the `web3` library.\n */\nexport interface EssentialWeb3Transaction {\n from?: string;\n to?: string;\n value?: string;\n data?: string;\n}\n\nexport type RawTransaction =\n | RawTronTransaction\n | RawEvmTransaction\n | RawSorobanTransaction\n | RawAlgTransaction\n | RawStxTransaction\n | RawSuiTransaction\n | RawBridgeSolanaTransaction\n | RawPoolSolanaTransaction;\nexport type RawEvmTransaction = EssentialWeb3Transaction;\nexport type RawTronTransaction = Types.Transaction;\nexport type RawSorobanTransaction = string;\nexport type RawPoolSolanaTransaction = SolanaWeb3Transaction;\nexport type RawBridgeSolanaTransaction = VersionedTransaction;\nexport type RawSuiTransaction = string;\nexport type RawAlgTransaction = string[];\nexport type RawStxTransaction = string;\n\nexport interface SmartContractMethodParameter {\n type: string;\n value: string | number | Buffer;\n}\n\nexport interface TransactionResponse {\n txId: string;\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  import { Transaction, VersionedTransaction } from "@solana/web3.js";
2
- import { TxFeeParams } from "../../models";
2
+ import { SolanaTxFee, SolanaTxFeeParams, TxFeeParams } from "../../models";
3
3
  export declare function addUnitLimitAndUnitPriceToTx(transaction: Transaction, txFeeParams: TxFeeParams | undefined, solanaRpcUrl: string): Promise<void>;
4
4
  export declare function addUnitLimitAndUnitPriceToVersionedTx(transaction: VersionedTransaction, txFeeParams: TxFeeParams | undefined, solanaRpcUrl: string): Promise<void>;
5
+ export declare function normalizeSolanaTxFee(solana?: SolanaTxFee | SolanaTxFeeParams): SolanaTxFeeParams | undefined;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addUnitLimitAndUnitPriceToTx = addUnitLimitAndUnitPriceToTx;
4
4
  exports.addUnitLimitAndUnitPriceToVersionedTx = addUnitLimitAndUnitPriceToVersionedTx;
5
+ exports.normalizeSolanaTxFee = normalizeSolanaTxFee;
5
6
  const web3_js_1 = require("@solana/web3.js");
6
7
  const big_js_1 = require("big.js");
7
8
  const exceptions_1 = require("../../../exceptions");
@@ -30,25 +31,42 @@ async function addUnitLimitAndUnitPriceToVersionedTx(transaction, txFeeParams, s
30
31
  transaction.message = message.compileToV0Message(addressLookupTableAccounts);
31
32
  }
32
33
  async function addUnitLimitAndUnitPriceToInstructions(instructions, simUnitsConsumed, txFeeParams, connection) {
33
- if (simUnitsConsumed > 0) {
34
- const units = updateUnitLimit(simUnitsConsumed, instructions);
35
- if (txFeeParams?.solana) {
36
- const solanaTxFee = txFeeParams.solana;
37
- if (solanaTxFee === models_1.SolanaAutoTxFee) {
38
- await updateUnitPrice(instructions, connection);
39
- }
40
- else if ("pricePerUnitInMicroLamports" in solanaTxFee) {
41
- await updateUnitPrice(instructions, connection, solanaTxFee.pricePerUnitInMicroLamports);
42
- }
43
- else {
44
- const pricePerUnitInMicroLamports = (0, big_js_1.Big)(solanaTxFee.extraFeeInLamports)
45
- .div(units)
46
- .mul((0, calculation_1.toPowBase10)(6))
47
- .toFixed(0);
48
- await updateUnitPrice(instructions, connection, pricePerUnitInMicroLamports);
49
- }
50
- }
34
+ if (simUnitsConsumed <= 0)
35
+ return;
36
+ const units = updateUnitLimit(simUnitsConsumed, instructions);
37
+ const solanaFeeParams = normalizeSolanaTxFee(txFeeParams?.solana);
38
+ const solanaFee = solanaFeeParams?.fee;
39
+ // If fee is not provided, treat it as auto fee calculation.
40
+ if (!solanaFee || solanaFee === models_1.SolanaAutoTxFee) {
41
+ await updateUnitPrice(instructions, connection);
42
+ return;
51
43
  }
44
+ if ("pricePerUnitInMicroLamports" in solanaFee) {
45
+ await updateUnitPrice(instructions, connection, solanaFee.pricePerUnitInMicroLamports);
46
+ return;
47
+ }
48
+ // Extra fee in lamports -> convert to microLamports per compute unit
49
+ const pricePerUnitInMicroLamports = (0, big_js_1.Big)(solanaFee.extraFeeInLamports).div(units).mul((0, calculation_1.toPowBase10)(6)).toFixed(0);
50
+ await updateUnitPrice(instructions, connection, pricePerUnitInMicroLamports);
51
+ }
52
+ function normalizeSolanaTxFee(solana) {
53
+ if (!solana)
54
+ return undefined;
55
+ // Legacy format (non-object)
56
+ if (typeof solana !== "object") {
57
+ return { fee: solana };
58
+ }
59
+ // Legacy format (object)
60
+ if ("pricePerUnitInMicroLamports" in solana || "extraFeeInLamports" in solana) {
61
+ return { fee: solana };
62
+ }
63
+ // New format
64
+ if ("fee" in solana || "feePayer" in solana) {
65
+ return solana;
66
+ }
67
+ // This should never happen with current typings.
68
+ // If it does — someone passed an invalid object at runtime.
69
+ throw new exceptions_1.SdkError(`Invalid Solana tx fee params: ${JSON.stringify(solana)}`);
52
70
  }
53
71
  function updateUnitLimit(simUnitsConsumed, instructions) {
54
72
  const computeUnitLimitIndex = instructions.findIndex((instruction) => instruction.programId.equals(web3_js_1.ComputeBudgetProgram.programId) &&
@@ -1 +1 @@
1
- {"version":3,"file":"compute-budget.js","sourceRoot":"","sources":["../../../../../src/services/utils/sol/compute-budget.ts"],"names":[],"mappings":";;AAeA,oEASC;AAED,sFAsBC;AAhDD,6CAQyB;AACzB,mCAA6B;AAC7B,oDAAsD;AACtD,4DAAyD;AACzD,oDAAiF;AACjF,yCAA4D;AAErD,KAAK,UAAU,4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O,CAAC,GAAG,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACtD,CAAC","sourcesContent":["import {\n ComputeBudgetInstruction,\n ComputeBudgetProgram,\n Connection,\n Transaction,\n TransactionInstruction,\n TransactionMessage,\n VersionedTransaction,\n} from \"@solana/web3.js\";\nimport { Big } from \"big.js\";\nimport { TxTooLargeError } from \"../../../exceptions\";\nimport { toPowBase10 } from \"../../../utils/calculation\";\nimport { fetchAddressLookupTableAccountsFromTx } from \"../../../utils/sol/utils\";\nimport { SolanaAutoTxFee, TxFeeParams } from \"../../models\";\n\nexport async function addUnitLimitAndUnitPriceToTx(\n transaction: Transaction,\n txFeeParams: TxFeeParams | undefined,\n solanaRpcUrl: string\n) {\n const connection = new Connection(solanaRpcUrl, \"confirmed\");\n /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n const simUnitsConsumed = (await connection.simulateTransaction(transaction)).value.unitsConsumed!;\n await addUnitLimitAndUnitPriceToInstructions(transaction.instructions, simUnitsConsumed, txFeeParams, connection);\n}\n\nexport async function addUnitLimitAndUnitPriceToVersionedTx(\n transaction: VersionedTransaction,\n txFeeParams: TxFeeParams | undefined,\n solanaRpcUrl: string\n) {\n const connection = new Connection(solanaRpcUrl, \"confirmed\");\n const addressLookupTableAccounts = await fetchAddressLookupTableAccountsFromTx(transaction, connection);\n const message = TransactionMessage.decompile(transaction.message, {\n addressLookupTableAccounts: addressLookupTableAccounts,\n });\n\n if (transaction.serialize().length > 1232) {\n throw new TxTooLargeError();\n }\n\n // const simUnitsConsumed = (await connection.simulateTransaction(transaction, { replaceRecentBlockhash: true })).value\n // .unitsConsumed!;\n const simUnitsConsumed = 769230; // 1000000/1.3\n\n await addUnitLimitAndUnitPriceToInstructions(message.instructions, simUnitsConsumed, txFeeParams, connection);\n\n transaction.message = message.compileToV0Message(addressLookupTableAccounts);\n}\n\nasync function addUnitLimitAndUnitPriceToInstructions(\n instructions: TransactionInstruction[],\n simUnitsConsumed: number,\n txFeeParams: TxFeeParams | undefined,\n connection: Connection\n) {\n if (simUnitsConsumed > 0) {\n const units = updateUnitLimit(simUnitsConsumed, instructions);\n if (txFeeParams?.solana) {\n const solanaTxFee = txFeeParams.solana;\n if (solanaTxFee === SolanaAutoTxFee) {\n await updateUnitPrice(instructions, connection);\n } else if (\"pricePerUnitInMicroLamports\" in solanaTxFee) {\n await updateUnitPrice(instructions, connection, solanaTxFee.pricePerUnitInMicroLamports);\n } else {\n const pricePerUnitInMicroLamports = Big(solanaTxFee.extraFeeInLamports)\n .div(units)\n .mul(toPowBase10(6))\n .toFixed(0);\n await updateUnitPrice(instructions, connection, pricePerUnitInMicroLamports);\n }\n }\n }\n}\n\nfunction updateUnitLimit(simUnitsConsumed: number, instructions: TransactionInstruction[]): string {\n const computeUnitLimitIndex = instructions.findIndex(\n (instruction) =>\n instruction.programId.equals(ComputeBudgetProgram.programId) &&\n ComputeBudgetInstruction.decodeInstructionType(instruction) === \"SetComputeUnitLimit\"\n );\n const units = Number((simUnitsConsumed * 1.3).toFixed(0));\n const computeUnitLimitInstruction = ComputeBudgetProgram.setComputeUnitLimit({\n units: units,\n });\n if (computeUnitLimitIndex >= 0) {\n instructions[computeUnitLimitIndex] = computeUnitLimitInstruction;\n } else {\n instructions.push(computeUnitLimitInstruction);\n }\n return units.toString();\n}\n\nasync function updateUnitPrice(\n instructions: TransactionInstruction[],\n connection: Connection,\n pricePerUnitInMicroLamports?: string\n): Promise<string> {\n const computeUnitPriceIndex = instructions.findIndex(\n (instruction) =>\n instruction.programId.equals(ComputeBudgetProgram.programId) &&\n ComputeBudgetInstruction.decodeInstructionType(instruction) === \"SetComputeUnitPrice\"\n );\n const unitPrice = pricePerUnitInMicroLamports\n ? BigInt(pricePerUnitInMicroLamports)\n : BigInt(await getAveragePrioritizationFee(connection));\n const computeUnitPriceInstruction = ComputeBudgetProgram.setComputeUnitPrice({\n microLamports: unitPrice,\n });\n if (computeUnitPriceIndex >= 0) {\n instructions[computeUnitPriceIndex] = computeUnitPriceInstruction;\n } else {\n instructions.push(computeUnitPriceInstruction);\n }\n return unitPrice.toString();\n}\n\nasync function getAveragePrioritizationFee(connection: Connection) {\n const prioritizationFees = await connection.getRecentPrioritizationFees();\n let sum = 0;\n for (const prioritizationFee of prioritizationFees) {\n sum += prioritizationFee.prioritizationFee;\n }\n return (sum / prioritizationFees.length).toFixed(0);\n}\n"]}
1
+ {"version":3,"file":"compute-budget.js","sourceRoot":"","sources":["../../../../../src/services/utils/sol/compute-budget.ts"],"names":[],"mappings":";;AAeA,oEASC;AAED,sFAsBC;AAgCD,oDAqBC;AArGD,6CAQyB;AACzB,mCAA6B;AAC7B,oDAAgE;AAChE,4DAAyD;AACzD,oDAAiF;AACjF,yCAA4F;AAErF,KAAK,UAAU,4BAA4B,CAChD,WAAwB,EACxB,WAAoC,EACpC,YAAoB;IAEpB,MAAM,UAAU,GAAG,IAAI,oBAAU,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC;IAC7D,uEAAuE;IACvE,MAAM,gBAAgB,GAAG,CAAC,MAAM,UAAU,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,aAAc,CAAC;IAClG,MAAM,sCAAsC,CAAC,WAAW,CAAC,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;AACpH,CAAC;AAEM,KAAK,UAAU,qCAAqC,CACzD,WAAiC,EACjC,WAAoC,EACpC,YAAoB;IAEpB,MAAM,UAAU,GAAG,IAAI,oBAAU,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC;IAC7D,MAAM,0BAA0B,GAAG,MAAM,IAAA,6CAAqC,EAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IACxG,MAAM,OAAO,GAAG,4BAAkB,CAAC,SAAS,CAAC,WAAW,CAAC,OAAO,EAAE;QAChE,0BAA0B,EAAE,0BAA0B;KACvD,CAAC,CAAC;IAEH,IAAI,WAAW,CAAC,SAAS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AACtD,CAAC","sourcesContent":["import {\n ComputeBudgetInstruction,\n ComputeBudgetProgram,\n Connection,\n Transaction,\n TransactionInstruction,\n TransactionMessage,\n VersionedTransaction,\n} from \"@solana/web3.js\";\nimport { Big } from \"big.js\";\nimport { SdkError, TxTooLargeError } from \"../../../exceptions\";\nimport { toPowBase10 } from \"../../../utils/calculation\";\nimport { fetchAddressLookupTableAccountsFromTx } from \"../../../utils/sol/utils\";\nimport { SolanaAutoTxFee, SolanaTxFee, SolanaTxFeeParams, TxFeeParams } from \"../../models\";\n\nexport async function addUnitLimitAndUnitPriceToTx(\n transaction: Transaction,\n txFeeParams: TxFeeParams | undefined,\n solanaRpcUrl: string\n) {\n const connection = new Connection(solanaRpcUrl, \"confirmed\");\n /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n const simUnitsConsumed = (await connection.simulateTransaction(transaction)).value.unitsConsumed!;\n await addUnitLimitAndUnitPriceToInstructions(transaction.instructions, simUnitsConsumed, txFeeParams, connection);\n}\n\nexport async function addUnitLimitAndUnitPriceToVersionedTx(\n transaction: VersionedTransaction,\n txFeeParams: TxFeeParams | undefined,\n solanaRpcUrl: string\n) {\n const connection = new Connection(solanaRpcUrl, \"confirmed\");\n const addressLookupTableAccounts = await fetchAddressLookupTableAccountsFromTx(transaction, connection);\n const message = TransactionMessage.decompile(transaction.message, {\n addressLookupTableAccounts: addressLookupTableAccounts,\n });\n\n if (transaction.serialize().length > 1232) {\n throw new TxTooLargeError();\n }\n\n // const simUnitsConsumed = (await connection.simulateTransaction(transaction, { replaceRecentBlockhash: true })).value\n // .unitsConsumed!;\n const simUnitsConsumed = 769230; // 1000000/1.3\n\n await addUnitLimitAndUnitPriceToInstructions(message.instructions, simUnitsConsumed, txFeeParams, connection);\n\n transaction.message = message.compileToV0Message(addressLookupTableAccounts);\n}\n\nasync function addUnitLimitAndUnitPriceToInstructions(\n instructions: TransactionInstruction[],\n simUnitsConsumed: number,\n txFeeParams: TxFeeParams | undefined,\n connection: Connection\n) {\n if (simUnitsConsumed <= 0) return;\n\n const units = updateUnitLimit(simUnitsConsumed, instructions);\n\n const solanaFeeParams = normalizeSolanaTxFee(txFeeParams?.solana);\n const solanaFee = solanaFeeParams?.fee;\n\n // If fee is not provided, treat it as auto fee calculation.\n if (!solanaFee || solanaFee === SolanaAutoTxFee) {\n await updateUnitPrice(instructions, connection);\n return;\n }\n\n if (\"pricePerUnitInMicroLamports\" in solanaFee) {\n await updateUnitPrice(instructions, connection, solanaFee.pricePerUnitInMicroLamports);\n return;\n }\n\n // Extra fee in lamports -> convert to microLamports per compute unit\n const pricePerUnitInMicroLamports = Big(solanaFee.extraFeeInLamports).div(units).mul(toPowBase10(6)).toFixed(0);\n\n await updateUnitPrice(instructions, connection, pricePerUnitInMicroLamports);\n}\n\nexport function normalizeSolanaTxFee(solana?: SolanaTxFee | SolanaTxFeeParams): SolanaTxFeeParams | undefined {\n if (!solana) return undefined;\n\n // Legacy format (non-object)\n if (typeof solana !== \"object\") {\n return { fee: solana };\n }\n\n // Legacy format (object)\n if (\"pricePerUnitInMicroLamports\" in solana || \"extraFeeInLamports\" in solana) {\n return { fee: solana };\n }\n\n // New format\n if (\"fee\" in solana || \"feePayer\" in solana) {\n return solana;\n }\n\n // This should never happen with current typings.\n // If it does — someone passed an invalid object at runtime.\n throw new SdkError(`Invalid Solana tx fee params: ${JSON.stringify(solana)}`);\n}\n\nfunction updateUnitLimit(simUnitsConsumed: number, instructions: TransactionInstruction[]): string {\n const computeUnitLimitIndex = instructions.findIndex(\n (instruction) =>\n instruction.programId.equals(ComputeBudgetProgram.programId) &&\n ComputeBudgetInstruction.decodeInstructionType(instruction) === \"SetComputeUnitLimit\"\n );\n const units = Number((simUnitsConsumed * 1.3).toFixed(0));\n const computeUnitLimitInstruction = ComputeBudgetProgram.setComputeUnitLimit({\n units: units,\n });\n if (computeUnitLimitIndex >= 0) {\n instructions[computeUnitLimitIndex] = computeUnitLimitInstruction;\n } else {\n instructions.push(computeUnitLimitInstruction);\n }\n return units.toString();\n}\n\nasync function updateUnitPrice(\n instructions: TransactionInstruction[],\n connection: Connection,\n pricePerUnitInMicroLamports?: string\n): Promise<string> {\n const computeUnitPriceIndex = instructions.findIndex(\n (instruction) =>\n instruction.programId.equals(ComputeBudgetProgram.programId) &&\n ComputeBudgetInstruction.decodeInstructionType(instruction) === \"SetComputeUnitPrice\"\n );\n const unitPrice = pricePerUnitInMicroLamports\n ? BigInt(pricePerUnitInMicroLamports)\n : BigInt(await getAveragePrioritizationFee(connection));\n const computeUnitPriceInstruction = ComputeBudgetProgram.setComputeUnitPrice({\n microLamports: unitPrice,\n });\n if (computeUnitPriceIndex >= 0) {\n instructions[computeUnitPriceIndex] = computeUnitPriceInstruction;\n } else {\n instructions.push(computeUnitPriceInstruction);\n }\n return unitPrice.toString();\n}\n\nasync function getAveragePrioritizationFee(connection: Connection) {\n const prioritizationFees = await connection.getRecentPrioritizationFees();\n let sum = 0;\n for (const prioritizationFee of prioritizationFees) {\n sum += prioritizationFee.prioritizationFee;\n }\n return (sum / prioritizationFees.length).toFixed(0);\n}\n"]}
@@ -1,7 +1,9 @@
1
1
  import { Program, Provider } from "@project-serum/anchor";
2
2
  import { PublicKey } from "@solana/web3.js";
3
+ import { TxFeeParams } from "../../models";
3
4
  import { TokenAccountData } from "../../models/sol";
4
5
  import { Bridge as BridgeType } from "../../models/sol/types/bridge";
6
+ export declare function getFeePayer(userAccount: PublicKey, txFeeParams?: TxFeeParams): PublicKey;
5
7
  export declare function getTokenAccountData(account: PublicKey, provider: Provider): Promise<TokenAccountData>;
6
8
  export declare function getVUsdAmount(amount: string, bridge: Program<BridgeType>, poolAccount: PublicKey): Promise<string>;
7
9
  export declare function getMessage(args: {
@@ -3,15 +3,27 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getFeePayer = getFeePayer;
6
7
  exports.getTokenAccountData = getTokenAccountData;
7
8
  exports.getVUsdAmount = getVUsdAmount;
8
9
  exports.getMessage = getMessage;
9
10
  const anchor_1 = require("@project-serum/anchor");
11
+ const web3_js_1 = require("@solana/web3.js");
10
12
  /* eslint-disable-next-line import/no-named-as-default */
11
13
  const big_js_1 = __importDefault(require("big.js"));
12
14
  const web3_1 = require("web3");
13
15
  const exceptions_1 = require("../../../exceptions");
14
16
  const calculation_1 = require("../../../utils/calculation");
17
+ const compute_budget_1 = require("./compute-budget");
18
+ function getFeePayer(userAccount, txFeeParams) {
19
+ if (txFeeParams?.solana) {
20
+ const solanaFeeParams = (0, compute_budget_1.normalizeSolanaTxFee)(txFeeParams.solana);
21
+ if (solanaFeeParams?.feePayer) {
22
+ return new web3_js_1.PublicKey(solanaFeeParams.feePayer);
23
+ }
24
+ }
25
+ return userAccount;
26
+ }
15
27
  async function getTokenAccountData(account, provider) {
16
28
  return await anchor_1.Spl.token(provider).account.token.fetch(account);
17
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/services/utils/sol/index.ts"],"names":[],"mappings":";;;;;AAWA,kDAEC;AAED,sCAiBC;AAED,gCAoDC;AAtFD,kDAA+D;AAE/D,0DAA0D;AAC1D,oDAAyB;AACzB,+BAA4B;AAC5B,oDAA+D;AAE/D,4DAAwD;AAIjD,KAAK,UAAU,mBAAmB,CAAC,OAAkB,EAAE,QAAkB;IAC9E,OAAO,MAAM,YAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAChE,CAAC;AAEM,KAAK,UAAU,aAAa,CACjC,MAAc,EACd,MAA2B,EAC3B,WAAsB;IAEtB,MAAM,eAAe,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IACrE,MAAM,QAAQ,GAAG,eAAe,CAAC,QAAQ,CAAC;IAC1C,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AED,MAAM,cAAc,GAAG,WAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,KAAK,CAAQ,CAAC,CAAC;IAE5G,MAAM,oBAAoB,GAAG,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;IAElF,oBAAoB,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;IACxC,oBAAoB,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;IACxC,OAAO,oBAAoB,CAAC;AAC9B,CAAC","sourcesContent":["import { Program, Provider, Spl } from \"@project-serum/anchor\";\nimport { PublicKey } from \"@solana/web3.js\";\n/* eslint-disable-next-line import/no-named-as-default */\nimport Big from \"big.js\";\nimport { Web3 } from \"web3\";\nimport { InvalidTxError, SdkError } from \"../../../exceptions\";\nimport { PoolInfo } from \"../../../tokens-info\";\nimport { swapToVUsd } from \"../../../utils/calculation\";\nimport { TokenAccountData } from \"../../models/sol\";\nimport { Bridge as BridgeType } from \"../../models/sol/types/bridge\";\n\nexport async function getTokenAccountData(account: PublicKey, provider: Provider): Promise<TokenAccountData> {\n return await Spl.token(provider).account.token.fetch(account);\n}\n\nexport async function getVUsdAmount(\n amount: string,\n bridge: Program<BridgeType>,\n poolAccount: PublicKey\n): Promise<string> {\n const poolAccountInfo = await bridge.account.pool.fetch(poolAccount);\n const decimals = poolAccountInfo.decimals;\n const feeShare = Big(poolAccountInfo.feeShareBp.toString()).div(10000).toFixed();\n const poolInfo: Omit<PoolInfo, \"p\" | \"imbalance\"> = {\n aValue: poolAccountInfo.a.toString(),\n dValue: poolAccountInfo.d.toString(),\n totalLpAmount: poolAccountInfo.totalLpAmount.toString(),\n tokenBalance: poolAccountInfo.tokenBalance.toString(),\n vUsdBalance: poolAccountInfo.vUsdBalance.toString(),\n accRewardPerShareP: poolAccountInfo.accRewardPerShareP.toString(),\n };\n return swapToVUsd(amount, { decimals, feeShare }, poolInfo);\n}\n\nexport function getMessage(args: {\n amount: string;\n recipient: Buffer;\n sourceChainId: number;\n destinationChainId: number;\n receiveToken: Buffer;\n nonce: Buffer;\n chainBridge: Buffer;\n}): Buffer {\n const amount = args.amount;\n const recipient = \"0x\" + args.recipient.toString(\"hex\");\n const sourceChainId = args.sourceChainId;\n const destinationsChainId = args.destinationChainId;\n const receiveToken = \"0x\" + args.receiveToken.toString(\"hex\");\n const nonce = \"0x\" + args.nonce.toString(\"hex\");\n const messenger = 1;\n const chainBridge = \"0x\" + args.chainBridge.toString(\"hex\");\n\n const message = Web3.utils.encodePacked(\n { t: \"uint256\", v: amount },\n { t: \"bytes32\", v: recipient },\n { t: \"uint256\", v: sourceChainId },\n { t: \"bytes32\", v: receiveToken },\n { t: \"uint256\", v: nonce },\n { t: \"uint8\", v: messenger }\n );\n\n if (!message) {\n throw new SdkError(\"message cannot be undefined\");\n }\n const hash = Web3.utils.keccak256(Buffer.from(message.replace(\"0x\", \"\"), \"hex\") as any);\n\n const hashBuffer = Buffer.from(hash.replace(\"0x\", \"\"), \"hex\");\n hashBuffer[0] = sourceChainId;\n hashBuffer[1] = destinationsChainId;\n\n const messageWithSigner = Web3.utils.encodePacked(\n { t: \"bytes32\", v: \"0x\" + hashBuffer.toString(\"hex\") },\n { t: \"bytes32\", v: chainBridge }\n );\n\n if (!messageWithSigner) {\n throw new InvalidTxError(\"messageWithSigner cannot be undefined\");\n }\n\n const hashWithSigner = Web3.utils.keccak256(Buffer.from(messageWithSigner.replace(\"0x\", \"\"), \"hex\") as any);\n\n const hashWithSignerBuffer = Buffer.from(hashWithSigner.replace(\"0x\", \"\"), \"hex\");\n\n hashWithSignerBuffer[0] = hashBuffer[0];\n hashWithSignerBuffer[1] = hashBuffer[1];\n return hashWithSignerBuffer;\n}\n"]}
1
+ {"version":3,"file":"index.js","sour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AK,CAAC,CAAC;IAElF,oBAAoB,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;IACxC,oBAAoB,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;IACxC,OAAO,oBAAoB,CAAC;AAC9B,CAAC","sourcesContent":["import { Program, Provider, Spl } from \"@project-serum/anchor\";\nimport { PublicKey } from \"@solana/web3.js\";\n/* eslint-disable-next-line import/no-named-as-default */\nimport Big from \"big.js\";\nimport { Web3 } from \"web3\";\nimport { InvalidTxError, SdkError } from \"../../../exceptions\";\nimport { PoolInfo } from \"../../../tokens-info\";\nimport { swapToVUsd } from \"../../../utils/calculation\";\nimport { TxFeeParams } from \"../../models\";\nimport { TokenAccountData } from \"../../models/sol\";\nimport { Bridge as BridgeType } from \"../../models/sol/types/bridge\";\nimport { normalizeSolanaTxFee } from \"./compute-budget\";\n\nexport function getFeePayer(userAccount: PublicKey, txFeeParams?: TxFeeParams): PublicKey {\n if (txFeeParams?.solana) {\n const solanaFeeParams = normalizeSolanaTxFee(txFeeParams.solana);\n if (solanaFeeParams?.feePayer) {\n return new PublicKey(solanaFeeParams.feePayer);\n }\n }\n return userAccount;\n}\n\nexport async function getTokenAccountData(account: PublicKey, provider: Provider): Promise<TokenAccountData> {\n return await Spl.token(provider).account.token.fetch(account);\n}\n\nexport async function getVUsdAmount(\n amount: string,\n bridge: Program<BridgeType>,\n poolAccount: PublicKey\n): Promise<string> {\n const poolAccountInfo = await bridge.account.pool.fetch(poolAccount);\n const decimals = poolAccountInfo.decimals;\n const feeShare = Big(poolAccountInfo.feeShareBp.toString()).div(10000).toFixed();\n const poolInfo: Omit<PoolInfo, \"p\" | \"imbalance\"> = {\n aValue: poolAccountInfo.a.toString(),\n dValue: poolAccountInfo.d.toString(),\n totalLpAmount: poolAccountInfo.totalLpAmount.toString(),\n tokenBalance: poolAccountInfo.tokenBalance.toString(),\n vUsdBalance: poolAccountInfo.vUsdBalance.toString(),\n accRewardPerShareP: poolAccountInfo.accRewardPerShareP.toString(),\n };\n return swapToVUsd(amount, { decimals, feeShare }, poolInfo);\n}\n\nexport function getMessage(args: {\n amount: string;\n recipient: Buffer;\n sourceChainId: number;\n destinationChainId: number;\n receiveToken: Buffer;\n nonce: Buffer;\n chainBridge: Buffer;\n}): Buffer {\n const amount = args.amount;\n const recipient = \"0x\" + args.recipient.toString(\"hex\");\n const sourceChainId = args.sourceChainId;\n const destinationsChainId = args.destinationChainId;\n const receiveToken = \"0x\" + args.receiveToken.toString(\"hex\");\n const nonce = \"0x\" + args.nonce.toString(\"hex\");\n const messenger = 1;\n const chainBridge = \"0x\" + args.chainBridge.toString(\"hex\");\n\n const message = Web3.utils.encodePacked(\n { t: \"uint256\", v: amount },\n { t: \"bytes32\", v: recipient },\n { t: \"uint256\", v: sourceChainId },\n { t: \"bytes32\", v: receiveToken },\n { t: \"uint256\", v: nonce },\n { t: \"uint8\", v: messenger }\n );\n\n if (!message) {\n throw new SdkError(\"message cannot be undefined\");\n }\n const hash = Web3.utils.keccak256(Buffer.from(message.replace(\"0x\", \"\"), \"hex\") as any);\n\n const hashBuffer = Buffer.from(hash.replace(\"0x\", \"\"), \"hex\");\n hashBuffer[0] = sourceChainId;\n hashBuffer[1] = destinationsChainId;\n\n const messageWithSigner = Web3.utils.encodePacked(\n { t: \"bytes32\", v: \"0x\" + hashBuffer.toString(\"hex\") },\n { t: \"bytes32\", v: chainBridge }\n );\n\n if (!messageWithSigner) {\n throw new InvalidTxError(\"messageWithSigner cannot be undefined\");\n }\n\n const hashWithSigner = Web3.utils.keccak256(Buffer.from(messageWithSigner.replace(\"0x\", \"\"), \"hex\") as any);\n\n const hashWithSignerBuffer = Buffer.from(hashWithSigner.replace(\"0x\", \"\"), \"hex\");\n\n hashWithSignerBuffer[0] = hashBuffer[0];\n hashWithSignerBuffer[1] = hashBuffer[1];\n return hashWithSignerBuffer;\n}\n"]}
@@ -1 +1 @@
1
- export declare const VERSION = "3.27.0-alpha.20";
1
+ export declare const VERSION = "3.27.0-alpha.21";
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = "3.27.0-alpha.20";
4
+ exports.VERSION = "3.27.0-alpha.21";
5
5
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,iBAAiB,CAAC","sourcesContent":["export const VERSION = \"3.27.0-alpha.20\";\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,iBAAiB,CAAC","sourcesContent":["export const VERSION = \"3.27.0-alpha.21\";\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allbridge/bridge-core-sdk",
3
- "version": "3.27.0-alpha.20",
3
+ "version": "3.27.0-alpha.21",
4
4
  "main": "./dist/cjs/index.js",
5
5
  "module": "./dist/esm/index.js",
6
6
  "types": "./dist/src/index.d.ts",