@allbridge/bridge-core-sdk 3.21.1-alpha.2 → 3.22.0-alpha.1
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/browser/index.js +1 -1
- package/dist/browser/index.js.map +3 -3
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +3 -3
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +3 -3
- package/dist/src/configs/mainnet.js +1 -1
- package/dist/src/configs/mainnet.js.map +1 -1
- package/dist/src/index.d.ts +8 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/services/bridge/index.js +5 -2
- package/dist/src/services/bridge/index.js.map +1 -1
- package/dist/src/services/bridge/sol/index.d.ts +4 -0
- package/dist/src/services/bridge/sol/index.js +1 -1
- package/dist/src/services/bridge/sol/index.js.map +1 -1
- package/dist/src/services/bridge/sol/jupiter.d.ts +3 -1
- package/dist/src/services/bridge/sol/jupiter.js +10 -4
- package/dist/src/services/bridge/sol/jupiter.js.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@ exports.mainnet = {
|
|
|
5
5
|
coreApiUrl: "https://core.api.allbridgecoreapi.net",
|
|
6
6
|
coreApiQueryParams: {},
|
|
7
7
|
coreApiHeaders: {},
|
|
8
|
-
jupiterUrl: "https://
|
|
8
|
+
jupiterUrl: "https://lite-api.jup.ag/swap/v1",
|
|
9
9
|
wormholeMessengerProgramId: "worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth",
|
|
10
10
|
solanaLookUpTable: "2JcBAEVnAwVo4u8d61iqgHPrzZuugur7cVTjWubsVLHj",
|
|
11
11
|
sorobanNetworkPassphrase: "Public Global Stellar Network ; September 2015",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mainnet.js","sourceRoot":"","sources":["../../../src/configs/mainnet.ts"],"names":[],"mappings":";;;AAEa,QAAA,OAAO,GAA4B;IAC9C,UAAU,EAAE,uCAAuC;IACnD,kBAAkB,EAAE,EAAE;IACtB,cAAc,EAAE,EAAE;IAClB,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"mainnet.js","sourceRoot":"","sources":["../../../src/configs/mainnet.ts"],"names":[],"mappings":";;;AAEa,QAAA,OAAO,GAA4B;IAC9C,UAAU,EAAE,uCAAuC;IACnD,kBAAkB,EAAE,EAAE;IACtB,cAAc,EAAE,EAAE;IAClB,UAAU,EAAE,iCAAiC;IAC7C,0BAA0B,EAAE,6CAA6C;IACzE,iBAAiB,EAAE,8CAA8C;IACjE,wBAAwB,EAAE,gDAAgD;IAC1E,WAAW,EAAE,iCAAiC;IAC9C,UAAU,EAAE;QACV,wBAAwB,EAAE,8CAA8C;QACxE,wBAAwB,EAAE,8CAA8C;QACxE,WAAW,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE;KAChF;IACD,qBAAqB,EAAE,EAAE;CAC1B,CAAC;AAEF;;;GAGG;AACU,QAAA,eAAe,GAAmB;IAC7C,YAAY,EAAE,qCAAqC;IACnD,UAAU,EAAE,yBAAyB;CACtC,CAAC;AAEF;;GAEG;AACU,QAAA,kBAAkB,GAAgB;IAC7C,GAAG,EAAE,qCAAqC;IAC1C,GAAG,EAAE,yBAAyB;IAC9B,GAAG,EAAE,6BAA6B;IAClC,IAAI,EAAE,6BAA6B;IACnC,GAAG,EAAE,iCAAiC;CACvC,CAAC","sourcesContent":["import { AllbridgeCoreSdkOptions, NodeRpcUrls, NodeUrlsConfig } from \"../index\";\n\nexport const mainnet: AllbridgeCoreSdkOptions = {\n coreApiUrl: \"https://core.api.allbridgecoreapi.net\",\n coreApiQueryParams: {},\n coreApiHeaders: {},\n jupiterUrl: \"https://lite-api.jup.ag/swap/v1\",\n wormholeMessengerProgramId: \"worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth\",\n solanaLookUpTable: \"2JcBAEVnAwVo4u8d61iqgHPrzZuugur7cVTjWubsVLHj\",\n sorobanNetworkPassphrase: \"Public Global Stellar Network ; September 2015\",\n tronJsonRpc: \"https://api.trongrid.io/jsonrpc\",\n cctpParams: {\n cctpTransmitterProgramId: \"CCTPmbSD7gX1bxKPAmg77w8oFzNFpaQiQUWD43TKaecd\",\n cctpTokenMessengerMinter: \"CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3\",\n cctpDomains: { ETH: 0, AVA: 1, OPT: 2, ARB: 3, SOL: 5, BAS: 6, POL: 7, SUI: 8 },\n },\n cachePoolInfoChainSec: 20,\n};\n\n/**\n * This is default rpc urls for Solana and Tron,<p/> Override and use your own for proper and stable work\n * @deprecated use {@link nodeRpcUrlsDefault}\n */\nexport const nodeUrlsDefault: NodeUrlsConfig = {\n solanaRpcUrl: \"https://api.mainnet-beta.solana.com\",\n tronRpcUrl: \"https://api.trongrid.io\",\n};\n\n/**\n * This is default rpc urls for Solana and Tron,<p/> Override and use your own for proper and stable work\n */\nexport const nodeRpcUrlsDefault: NodeRpcUrls = {\n SOL: \"https://api.mainnet-beta.solana.com\",\n TRX: \"https://api.trongrid.io\",\n SRB: \"https://rpc.stellar.org:443\",\n STLR: \"https://horizon.stellar.org\",\n SUI: \"https://fullnode.mainnet.sui.io\",\n};\n"]}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -16,9 +16,16 @@ export interface AllbridgeCoreSdkOptions {
|
|
|
16
16
|
*/
|
|
17
17
|
coreApiHeaders?: Record<string, string>;
|
|
18
18
|
/**
|
|
19
|
-
* Jupiter
|
|
19
|
+
* Jupiter Swap Api</br>
|
|
20
|
+
* Default: https://lite-api.jup.ag/swap/v1</br>
|
|
21
|
+
* {@link https://dev.jup.ag/docs/swap-api/}
|
|
20
22
|
*/
|
|
21
23
|
jupiterUrl: string;
|
|
24
|
+
/**
|
|
25
|
+
* Jupiter Api Key Header</br>
|
|
26
|
+
* {@link https://dev.jup.ag/docs/api-setup}
|
|
27
|
+
*/
|
|
28
|
+
jupiterApiKeyHeader?: string;
|
|
22
29
|
/**
|
|
23
30
|
* Jupiter v6 'maxAccounts' parameter</br>
|
|
24
31
|
* Rough estimate of the max accounts to be used for the quote, so that you can compose with your own accounts</br>
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAEA,uCAAoC;AAuBpC,yCAAwE;AAExE,mCAA8C;AAE9C,4CAA0B;AAC1B,2CAAyB;AAiEzB;;GAEG;AACH,SAAS,gBAAgB,CAAC,QAAsC;IAC9D,OAAO,cAAc,IAAI,QAAQ,CAAC;AACpC,CAAC;AAED,MAAa,gBAAgB;IAClB,MAAM,CAA0B;IAEzC,MAAM,CAAgB;IACtB,IAAI,CAAuB;IAC3B,KAAK,CAAQ;IAEL,OAAO,CAA0B;IAEzC;;;;;;OAMG;IACH,YAAY,QAAsC,EAAE,SAAkC,iBAAO;QAC3F,IAAI,iBAAoC,CAAC;QACzC,IAAI,gBAAgB,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC/B,iBAAiB,GAAG,IAAI,4BAAiB,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;QACtG,CAAC;aAAM,CAAC;YACN,iBAAiB,GAAG,IAAI,4BAAiB,CAAC,QAAQ,CAAC,CAAC;QACtD,CAAC;QACD,IAAI,CAAC,OAAO,GAAG,IAAI,kCAAuB,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;QACtE,IAAI,CAAC,MAAM,GAAG,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AAoB,CACxB,gBAAuC,EACvC,qBAA4C;QAE5C,OAAO,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,gBAAgB,EAAE,qBAAqB,CAAC,CAAC;IACpF,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,iBAAiB,CACrB,MAAc,EACd,YAA0B,EAC1B,WAAkC;QAElC,OAAO,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,MAAM,EAAE,YAAY,EAAE,WAAW,CAAC,CAAC;IAC3E,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,iBAAiB,CAAC,UAAkB,EAAE,SAAgC;QAC1E,OAAO,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;IAC/D,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,2BAA2B,CAC/B,sBAA8B,EAC9B,WAAkC,EAClC,SAAgC;QAEhC,OAAO,IAAI,CAAC,OAAO,CAAC,2BAA2B,CAAC,sBAAsB,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;IAClG,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,kCAAkC,CACtC,sBAA8B,EAC9B,WAAkC,EAClC,SAAgC;QAEhC,OAAO,IAAI,CAAC,OAAO,CAAC,kCAAkC,CAAC,sBAAsB,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;IACzG,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,oBAAoB,CACxB,MAAc,EACd,YAA0B,EAC1B,WAAkC,EAClC,SAAgC;QAEhC,OAAO,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;IACzF,CAAC;CACF;AA5fD,4CA4fC","sourcesContent":["import { BigSource } from \"big.js\";\nimport { AdditionalBasicChainProperties } from \"./chains/models\";\nimport { mainnet } from \"./configs\";\nimport {\n AmountFormat,\n AmountFormatted,\n AmountsAndGasFeeOptions,\n BridgeService,\n ChainDetailsMap,\n CheckAddressResponse,\n ExtraGasMaxLimitResponse,\n GasBalanceResponse,\n GasFeeOptions,\n GetNativeTokenBalanceParams,\n GetTokenBalanceParams,\n LiquidityPoolService,\n Messenger,\n PendingStatusInfoResponse,\n PoolInfo,\n Provider,\n SendAmountDetails,\n SwapAndBridgeCalculationData,\n TokenWithChainDetails,\n TransferStatusResponse,\n} from \"./models\";\nimport { AllbridgeCoreSdkService, NodeRpcUrlsConfig } from \"./services\";\nimport { CctpParams } from \"./services/bridge/sol\";\nimport { DefaultUtils, Utils } from \"./utils\";\n\nexport * from \"./configs\";\nexport * from \"./models\";\n\nexport interface AllbridgeCoreSdkOptions {\n coreApiUrl: string;\n /**\n * A set of query parameters to be added to all requests to the Core API.\n */\n coreApiQueryParams?: Record<string, string>;\n /**\n * A set of headers to be added to all requests to the Core API.\n */\n coreApiHeaders?: Record<string, string>;\n /**\n * Jupiter v6 Swap Api\n */\n jupiterUrl: string;\n /**\n * Jupiter v6 'maxAccounts' parameter</br>\n * Rough estimate of the max accounts to be used for the quote, so that you can compose with your own accounts</br>\n * {@link https://station.jup.ag/docs/apis/swap-api#using-maxaccounts}\n */\n jupiterMaxAccounts?: number;\n wormholeMessengerProgramId: string;\n solanaLookUpTable: string;\n sorobanNetworkPassphrase: string;\n /**\n * Optional. Will be used in methods</br>\n * {@link LiquidityPoolService.getPoolInfoFromChain} and {@link LiquidityPoolService.getAmountToBeWithdrawn}</br>\n * to fetch information from the blockchain with fewer HTTP requests using JSON-RPC API\n */\n tronJsonRpc?: string;\n cctpParams: CctpParams;\n /**\n * The number of seconds that pool information taken from the chain will be cached.\n *\n * @type {number}\n */\n cachePoolInfoChainSec: number;\n\n /**\n * @internal\n * Optional additional properties to merge with the default properties.\n */\n additionalChainsProperties?: Record<string, AdditionalBasicChainProperties>;\n}\n\n/**\n * Type representing RPC node URLs for different blockchain chains.</br>\n * Provide node RPC URL for chain connection you intend to communicate with</br>\n * - required for SOL, TRX chains</br>\n * - optional for EVM chains -- you can interact by passing a {@link Provider} that will be used to communicate with the chain</br>\n * @typedef {Record<string, string>} NodeRpcUrls\n * @property {string} chainSymbol - The symbol of the chain representing one of the supported blockchain networks (e.g., \"ETH\" for Ethereum). For more details, see: {@link ChainSymbol}.\n * @property {string} rpcUrl - The RPC node URL for the specified chain.\n */\nexport type NodeRpcUrls = Record<string, string>;\n\n/**\n * @deprecated Use {@link NodeRpcUrls}\n */\nexport interface NodeUrlsConfig {\n solanaRpcUrl: string;\n tronRpcUrl: string;\n}\n\n/**\n * @deprecated Use {@link NodeRpcUrls}\n */\nfunction isNodeUrlsConfig(nodeUrls: NodeUrlsConfig | NodeRpcUrls): nodeUrls is NodeUrlsConfig {\n return \"solanaRpcUrl\" in nodeUrls;\n}\n\nexport class AllbridgeCoreSdk {\n readonly params: AllbridgeCoreSdkOptions;\n\n bridge: BridgeService;\n pool: LiquidityPoolService;\n utils: Utils;\n\n private service: AllbridgeCoreSdkService;\n\n /**\n * Initializes the SDK object.\n * @param nodeUrls node rpc urls for full functionality\n * @param params\n * Optional.\n * If not defined, the default {@link mainnet} parameters are used.\n */\n constructor(nodeUrls: NodeUrlsConfig | NodeRpcUrls, params: AllbridgeCoreSdkOptions = mainnet) {\n let nodeRpcUrlsConfig: NodeRpcUrlsConfig;\n if (isNodeUrlsConfig(nodeUrls)) {\n nodeRpcUrlsConfig = new NodeRpcUrlsConfig({ SOL: nodeUrls.solanaRpcUrl, TRX: nodeUrls.tronRpcUrl });\n } else {\n nodeRpcUrlsConfig = new NodeRpcUrlsConfig(nodeUrls);\n }\n this.service = new AllbridgeCoreSdkService(nodeRpcUrlsConfig, params);\n this.bridge = this.service.bridge;\n this.pool = this.service.pool;\n this.utils = new DefaultUtils(nodeRpcUrlsConfig, params);\n this.params = params;\n }\n\n /**\n * Returns {@link ChainDetailsMap} containing a list of supported tokens groped by chain.\n *\n * @param type - A string value which specifies ChainDetailsMap to retrieve.\n * Can be either 'swap' for send or 'pool' for liquidity pools setup.\n * Defaults to 'swap'.\n */\n async chainDetailsMap(type: \"swap\" | \"pool\" = \"swap\"): Promise<ChainDetailsMap> {\n return this.service.chainDetailsMap(type);\n }\n\n /**\n * Returns a list of supported {@link TokenWithChainDetails | tokens}.\n *\n * @param type - A string value which specifies a set of tokens to retrieve.\n * Can be either 'swap' for tokens to send or 'pool' for liquidity pools operations.\n * Defaults to 'swap'.\n * @returns A promise that resolves to an array of {@link TokenWithChainDetails}.\n */\n async tokens(type: \"swap\" | \"pool\" = \"swap\"): Promise<TokenWithChainDetails[]> {\n return this.service.tokens(type);\n }\n\n /**\n * Returns a list of supported {@link TokenWithChainDetails | tokens} on the selected chain.\n * @param chainSymbol - The symbol of the chain representing one of the supported blockchain networks (e.g., \"ETH\" for Ethereum). For more details, see: {@link ChainSymbol}.\n * @param type - A string value which specifies a set of tokens to retrieve.\n * Can be either 'swap' for tokens to send or 'pool' for liquidity pools operations.\n * Defaults to 'swap'.\n */\n async tokensByChain(chainSymbol: string, type: \"swap\" | \"pool\" = \"swap\"): Promise<TokenWithChainDetails[]> {\n return this.service.tokensByChain(chainSymbol, type);\n }\n\n /**\n * Fetches information about tokens transfer by chosen chainSymbol and transaction Id from the Allbridge Core API.\n * @param chainSymbol - The symbol of the chain representing one of the supported blockchain networks (e.g., \"ETH\" for Ethereum). For more details, see: {@link ChainSymbol}.\n * @param txId\n */\n async getTransferStatus(chainSymbol: string, txId: string): Promise<TransferStatusResponse> {\n return this.service.getTransferStatus(chainSymbol, txId);\n }\n\n /**\n * Get gas balance\n * @param chainSymbol - The symbol of the chain representing one of the supported blockchain networks (e.g., \"ETH\" for Ethereum). For more details, see: {@link ChainSymbol}.\n * @param address\n */\n async getGasBalance(chainSymbol: string, address: string): Promise<GasBalanceResponse> {\n return this.service.getGasBalance(chainSymbol, address);\n }\n\n /**\n * Check address and show gas balance\n * @deprecated\n * @param chainSymbol - The symbol of the chain representing one of the supported blockchain networks (e.g., \"ETH\" for Ethereum). For more details, see: {@link ChainSymbol}.\n * @param recipientAddress\n * @param tokenAddress\n */\n async checkAddress(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n chainSymbol: string,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n recipientAddress: string,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n tokenAddress?: string\n ): Promise<CheckAddressResponse> {\n return await this.service.checkAddress();\n }\n\n /**\n * Returns information about pending transactions for the same destination chain and the amount of tokens can be received as a result of transfer considering pending transactions.\n * @param amount the amount of tokens that will be sent\n * @param amountFormat amount format\n * @param sourceToken selected token transfer from\n * @param destToken selected token transfer to\n * @returns range of possible amount based on already pending transactions\n */\n async getPendingStatusInfo(\n amount: string,\n amountFormat: AmountFormat,\n sourceToken: TokenWithChainDetails,\n destToken: TokenWithChainDetails\n ): Promise<PendingStatusInfoResponse> {\n return this.service.getPendingStatusInfo(amount, amountFormat, sourceToken, destToken);\n }\n\n /**\n * Get token balance\n * @param params\n * @param provider\n * @returns Token balance\n */\n async getTokenBalance(params: GetTokenBalanceParams, provider?: Provider): Promise<string> {\n return this.service.getTokenBalance(params, provider);\n }\n\n /**\n * Get native (gas) token balance\n * @param params\n * @param provider\n * @returns Token balance\n */\n async getNativeTokenBalance(params: GetNativeTokenBalanceParams, provider?: Provider): Promise<AmountFormatted> {\n return this.service.getNativeTokenBalance(params, provider);\n }\n\n /**\n * @deprecated\n * Calculates the percentage of fee from the initial amount that is charged when swapping from the selected source chain.\n * (Does not include fee related to the destination chain. Does not include gas fee)\n * @param amountFloat initial amount of tokens to swap\n * @param sourceChainToken selected token on the source chain\n * @returns fee percent\n */\n async calculateFeePercentOnSourceChain(\n amountFloat: BigSource,\n sourceChainToken: TokenWithChainDetails\n ): Promise<number> {\n return this.service.calculateFeePercentOnSourceChain(amountFloat, sourceChainToken);\n }\n\n /**\n * @deprecated\n * Calculates the percentage of fee that is charged when swapping to the selected destination chain. The destination chain fee percent applies to the amount after the source chain fee.\n * (Does not include fee related to the source chain. Does not include gas fee)\n * @see {@link calculateFeePercentOnSourceChain}\n * @param amountFloat initial amount of tokens to swap\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @returns fee percent\n */\n async calculateFeePercentOnDestinationChain(\n amountFloat: BigSource,\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails\n ): Promise<number> {\n return this.service.calculateFeePercentOnDestinationChain(amountFloat, sourceChainToken, destinationChainToken);\n }\n\n /**\n * Calculates the amount of tokens to be received as a result of transfer\n * and fetches {@link GasFeeOptions} which contains available ways to pay the gas fee.\n * @param amountToSendFloat the amount of tokens that will be sent\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @param messenger\n */\n async getAmountToBeReceivedAndGasFeeOptions(\n amountToSendFloat: BigSource,\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n messenger: Messenger\n ): Promise<AmountsAndGasFeeOptions> {\n return this.service.getAmountToBeReceivedAndGasFeeOptions(\n amountToSendFloat,\n sourceChainToken,\n destinationChainToken,\n messenger\n );\n }\n\n /**\n * Calculates the amount of tokens to send based on requested tokens amount be received as a result of transfer.\n * and fetches {@link GasFeeOptions} which contains available ways to pay the gas fee.\n * @param amountToBeReceivedFloat the amount of tokens that should be received\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @param messenger\n */\n async getAmountToSendAndGasFeeOptions(\n amountToBeReceivedFloat: BigSource,\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n messenger: Messenger\n ): Promise<AmountsAndGasFeeOptions> {\n return this.service.getAmountToSendAndGasFeeOptions(\n amountToBeReceivedFloat,\n sourceChainToken,\n destinationChainToken,\n messenger\n );\n }\n\n /**\n * Calculates the amount of tokens to be received as a result of transfer.\n * @param amountToSendFloat the amount of tokens that will be sent\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @param messenger Optional. selected messenger\n */\n async getAmountToBeReceived(\n amountToSendFloat: BigSource,\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n /**\n * The Messengers for different routes.\n * Optional.\n * The {@link Messenger.ALLBRIDGE}, {@link Messenger.WORMHOLE} by default.\n */\n messenger?: Messenger\n ): Promise<string> {\n return this.service.getAmountToBeReceived(amountToSendFloat, sourceChainToken, destinationChainToken, messenger);\n }\n\n /**\n * Calculates the amount of tokens to be received as a result of transfer based on actual blockchain pool state.\n * @param amountToSendFloat the amount of tokens that will be sent\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @param messenger Optional. selected messenger\n * @param sourceProvider Optional. source chain Provider\n * @param destinationProvider Optional. destination chain Provider\n */\n async getAmountToBeReceivedFromChain(\n amountToSendFloat: BigSource,\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n /**\n * The Messengers for different routes.\n * Optional.\n * The {@link Messenger.ALLBRIDGE}, {@link Messenger.WORMHOLE} by default.\n */\n messenger?: Messenger,\n sourceProvider?: Provider,\n destinationProvider?: Provider\n ): Promise<string> {\n return this.service.getAmountToBeReceivedFromChain(\n amountToSendFloat,\n sourceChainToken,\n destinationChainToken,\n messenger,\n sourceProvider,\n destinationProvider\n );\n }\n\n /**\n * Calculates the amount of tokens to be received as a result of transfer based on passed pool state.\n * @param amountToSendFloat the amount of tokens that will be sent\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @param sourcePool source token pool state\n * @param destinationPool destination token pool state\n * @param messenger Optional. selected messenger\n */\n getAmountToBeReceivedFromPools(\n amountToSendFloat: BigSource,\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n sourcePool: PoolInfo,\n destinationPool: PoolInfo,\n messenger?: Messenger\n ): string {\n return this.service.getAmountToBeReceivedFromPools(\n amountToSendFloat,\n sourceChainToken,\n destinationChainToken,\n sourcePool,\n destinationPool,\n messenger\n );\n }\n\n /**\n * Calculates the amount of tokens to send based on requested tokens amount be received as a result of transfer.\n * @param amountToBeReceivedFloat the amount of tokens that should be received\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @param messenger Optional. selected messenger\n */\n async getAmountToSend(\n amountToBeReceivedFloat: BigSource,\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n /**\n * The Messengers for different routes.\n * Optional.\n * The {@link Messenger.ALLBRIDGE}, {@link Messenger.WORMHOLE} by default.\n */\n messenger?: Messenger\n ): Promise<string> {\n return this.service.getAmountToSend(amountToBeReceivedFloat, sourceChainToken, destinationChainToken, messenger);\n }\n\n /**\n * Calculates the amount of tokens to send based on requested tokens amount be received as a result of transfer based on actual blockchain pool state.\n * @param amountToBeReceivedFloat the amount of tokens that should be received\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @param messenger Optional. selected messenger\n * @param sourceProvider Optional. source chain Provider\n * @param destinationProvider Optional. destination chain Provider\n */\n async getAmountToSendFromChain(\n amountToBeReceivedFloat: BigSource,\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n /**\n * The Messengers for different routes.\n * Optional.\n * The {@link Messenger.ALLBRIDGE}, {@link Messenger.WORMHOLE} by default.\n */\n messenger?: Messenger,\n sourceProvider?: Provider,\n destinationProvider?: Provider\n ): Promise<string> {\n return this.service.getAmountToSendFromChain(\n amountToBeReceivedFloat,\n sourceChainToken,\n destinationChainToken,\n messenger,\n sourceProvider,\n destinationProvider\n );\n }\n\n /**\n * Calculates the amount of tokens to send based on requested tokens amount be received as a result of transfer based on passed pool state.\n * @param amountToBeReceivedFloat the amount of tokens that should be received\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @param sourcePool source token pool state\n * @param destinationPool destination token pool state\n * @param messenger Optional. selected messenger\n */\n getAmountToSendFromPools(\n amountToBeReceivedFloat: BigSource,\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n sourcePool: PoolInfo,\n destinationPool: PoolInfo,\n messenger?: Messenger\n ): string {\n return this.service.getAmountToSendFromPools(\n amountToBeReceivedFloat,\n sourceChainToken,\n destinationChainToken,\n sourcePool,\n destinationPool,\n messenger\n );\n }\n\n /**\n * Fetches possible ways to pay the transfer gas fee.\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @param messenger\n * @returns {@link GasFeeOptions}\n */\n async getGasFeeOptions(\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n messenger: Messenger\n ): Promise<GasFeeOptions> {\n return this.service.getGasFeeOptions(sourceChainToken, destinationChainToken, messenger);\n }\n\n /**\n * Gets the average time in ms to complete a transfer for given tokens and messenger.\n * @param sourceChainToken selected token on the source chain.\n * @param destinationChainToken selected token on the destination chain.\n * @param messenger\n * @returns Average transfer time in milliseconds or null if a given combination of tokens and messenger is not supported.\n */\n getAverageTransferTime(\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n messenger: Messenger\n ): number | null {\n return this.service.getAverageTransferTime(sourceChainToken, destinationChainToken, messenger);\n }\n\n /**\n * Gets information about the poolInfo by token\n * @param token\n * @returns poolInfo\n */\n async getPoolInfoByToken(token: TokenWithChainDetails): Promise<PoolInfo> {\n return this.service.getPoolInfoByToken(token);\n }\n\n /**\n * Forces refresh of cached information about the state of liquidity pools.\n * Outdated cache leads to calculated amounts being less accurate.\n * The cache is invalidated at regular intervals, but it can be forced to be refreshed by calling this method.+\n *\n * @param tokens if present, the corresponding liquidity pools will be updated\n */\n async refreshPoolInfo(tokens?: TokenWithChainDetails | TokenWithChainDetails[]): Promise<void> {\n return this.service.refreshPoolInfo(tokens);\n }\n\n /**\n * Convert APR to percentage view\n * @param apr\n * @returns aprPercentageView\n */\n aprInPercents(apr: string): string {\n return this.service.aprInPercents(apr);\n }\n\n /**\n * Get possible limit of extra gas amount.\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @returns {@link ExtraGasMaxLimitResponse}\n */\n async getExtraGasMaxLimits(\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails\n ): Promise<ExtraGasMaxLimitResponse> {\n return this.service.getExtraGasMaxLimits(sourceChainToken, destinationChainToken);\n }\n\n /**\n * @param amount - amount\n * @param amountFormat - AmountFormat\n * @param sourceToken - selected token on the source chain\n * @return virtual amount\n */\n async getVUsdFromAmount(\n amount: string,\n amountFormat: AmountFormat,\n sourceToken: TokenWithChainDetails\n ): Promise<AmountFormatted> {\n return this.service.getVUsdFromAmount(amount, amountFormat, sourceToken);\n }\n\n /**\n * @param vUsdAmount - amount of vUsd, int format\n * @param destToken selected token on the destination chain\n * @return amount of destToken\n */\n async getAmountFromVUsd(vUsdAmount: string, destToken: TokenWithChainDetails): Promise<AmountFormatted> {\n return this.service.getAmountFromVUsd(vUsdAmount, destToken);\n }\n\n /**\n * @deprecated Use {@link getSendAmountDetails}\n * @param amountInTokenPrecision\n * @param sourceToken\n * @param destToken\n */\n async swapAndBridgeFeeCalculation(\n amountInTokenPrecision: string,\n sourceToken: TokenWithChainDetails,\n destToken: TokenWithChainDetails\n ): Promise<SwapAndBridgeCalculationData> {\n return this.service.swapAndBridgeFeeCalculation(amountInTokenPrecision, sourceToken, destToken);\n }\n\n /**\n * @deprecated Use {@link getAmountToBeReceived} and then {@link getSendAmountDetails}\n * @param amountInTokenPrecision\n * @param sourceToken\n * @param destToken\n */\n async swapAndBridgeFeeCalculationReverse(\n amountInTokenPrecision: string,\n sourceToken: TokenWithChainDetails,\n destToken: TokenWithChainDetails\n ): Promise<SwapAndBridgeCalculationData> {\n return this.service.swapAndBridgeFeeCalculationReverse(amountInTokenPrecision, sourceToken, destToken);\n }\n\n /**\n * Show amount changes (fee and amount adjustment) during send through pools on source and destination chains\n */\n async getSendAmountDetails(\n amount: string,\n amountFormat: AmountFormat,\n sourceToken: TokenWithChainDetails,\n destToken: TokenWithChainDetails\n ): Promise<SendAmountDetails> {\n return this.service.getSendAmountDetails(amount, amountFormat, sourceToken, destToken);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAEA,uCAAoC;AAuBpC,yCAAwE;AAExE,mCAA8C;AAE9C,4CAA0B;AAC1B,2CAAyB;AAwEzB;;GAEG;AACH,SAAS,gBAAgB,CAAC,QAAsC;IAC9D,OAAO,cAAc,IAAI,QAAQ,CAAC;AACpC,CAAC;AAED,MAAa,gBAAgB;IAClB,MAAM,CAA0B;IAEzC,MAAM,CAAgB;IACtB,IAAI,CAAuB;IAC3B,KAAK,CAAQ;IAEL,OAAO,CAA0B;IAEzC;;;;;;OAMG;IACH,YAAY,QAAsC,EAAE,SAAkC,iBAAO;QAC3F,IAAI,iBAAoC,CAAC;QACzC,IAAI,gBAAgB,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC/B,iBAAiB,GAAG,IAAI,4BAAiB,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;QACtG,CAAC;aAAM,CAAC;YACN,iBAAiB,GAAG,IAAI,4BAAiB,CAAC,QAAQ,CAAC,CAAC;QACtD,CAAC;QACD,IAAI,CAAC,OAAO,GAAG,IAAI,kCAAuB,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;QACtE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;QAClC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;QAC9B,IAAI,CAAC,KAAK,GAAG,IAAI,oBAAY,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;QACzD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,eAAe,CA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EAAE,WAAW,CAAC,CAAC;IAC3E,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,iBAAiB,CAAC,UAAkB,EAAE,SAAgC;QAC1E,OAAO,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;IAC/D,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,2BAA2B,CAC/B,sBAA8B,EAC9B,WAAkC,EAClC,SAAgC;QAEhC,OAAO,IAAI,CAAC,OAAO,CAAC,2BAA2B,CAAC,sBAAsB,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;IAClG,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,kCAAkC,CACtC,sBAA8B,EAC9B,WAAkC,EAClC,SAAgC;QAEhC,OAAO,IAAI,CAAC,OAAO,CAAC,kCAAkC,CAAC,sBAAsB,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;IACzG,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,oBAAoB,CACxB,MAAc,EACd,YAA0B,EAC1B,WAAkC,EAClC,SAAgC;QAEhC,OAAO,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;IACzF,CAAC;CACF;AA5fD,4CA4fC","sourcesContent":["import { BigSource } from \"big.js\";\nimport { AdditionalBasicChainProperties } from \"./chains/models\";\nimport { mainnet } from \"./configs\";\nimport {\n AmountFormat,\n AmountFormatted,\n AmountsAndGasFeeOptions,\n BridgeService,\n ChainDetailsMap,\n CheckAddressResponse,\n ExtraGasMaxLimitResponse,\n GasBalanceResponse,\n GasFeeOptions,\n GetNativeTokenBalanceParams,\n GetTokenBalanceParams,\n LiquidityPoolService,\n Messenger,\n PendingStatusInfoResponse,\n PoolInfo,\n Provider,\n SendAmountDetails,\n SwapAndBridgeCalculationData,\n TokenWithChainDetails,\n TransferStatusResponse,\n} from \"./models\";\nimport { AllbridgeCoreSdkService, NodeRpcUrlsConfig } from \"./services\";\nimport { CctpParams } from \"./services/bridge/sol\";\nimport { DefaultUtils, Utils } from \"./utils\";\n\nexport * from \"./configs\";\nexport * from \"./models\";\n\nexport interface AllbridgeCoreSdkOptions {\n coreApiUrl: string;\n /**\n * A set of query parameters to be added to all requests to the Core API.\n */\n coreApiQueryParams?: Record<string, string>;\n /**\n * A set of headers to be added to all requests to the Core API.\n */\n coreApiHeaders?: Record<string, string>;\n /**\n * Jupiter Swap Api</br>\n * Default: https://lite-api.jup.ag/swap/v1</br>\n * {@link https://dev.jup.ag/docs/swap-api/}\n */\n jupiterUrl: string;\n /**\n * Jupiter Api Key Header</br>\n * {@link https://dev.jup.ag/docs/api-setup}\n */\n jupiterApiKeyHeader?: string;\n /**\n * Jupiter v6 'maxAccounts' parameter</br>\n * Rough estimate of the max accounts to be used for the quote, so that you can compose with your own accounts</br>\n * {@link https://station.jup.ag/docs/apis/swap-api#using-maxaccounts}\n */\n jupiterMaxAccounts?: number;\n wormholeMessengerProgramId: string;\n solanaLookUpTable: string;\n sorobanNetworkPassphrase: string;\n /**\n * Optional. Will be used in methods</br>\n * {@link LiquidityPoolService.getPoolInfoFromChain} and {@link LiquidityPoolService.getAmountToBeWithdrawn}</br>\n * to fetch information from the blockchain with fewer HTTP requests using JSON-RPC API\n */\n tronJsonRpc?: string;\n cctpParams: CctpParams;\n /**\n * The number of seconds that pool information taken from the chain will be cached.\n *\n * @type {number}\n */\n cachePoolInfoChainSec: number;\n\n /**\n * @internal\n * Optional additional properties to merge with the default properties.\n */\n additionalChainsProperties?: Record<string, AdditionalBasicChainProperties>;\n}\n\n/**\n * Type representing RPC node URLs for different blockchain chains.</br>\n * Provide node RPC URL for chain connection you intend to communicate with</br>\n * - required for SOL, TRX chains</br>\n * - optional for EVM chains -- you can interact by passing a {@link Provider} that will be used to communicate with the chain</br>\n * @typedef {Record<string, string>} NodeRpcUrls\n * @property {string} chainSymbol - The symbol of the chain representing one of the supported blockchain networks (e.g., \"ETH\" for Ethereum). For more details, see: {@link ChainSymbol}.\n * @property {string} rpcUrl - The RPC node URL for the specified chain.\n */\nexport type NodeRpcUrls = Record<string, string>;\n\n/**\n * @deprecated Use {@link NodeRpcUrls}\n */\nexport interface NodeUrlsConfig {\n solanaRpcUrl: string;\n tronRpcUrl: string;\n}\n\n/**\n * @deprecated Use {@link NodeRpcUrls}\n */\nfunction isNodeUrlsConfig(nodeUrls: NodeUrlsConfig | NodeRpcUrls): nodeUrls is NodeUrlsConfig {\n return \"solanaRpcUrl\" in nodeUrls;\n}\n\nexport class AllbridgeCoreSdk {\n readonly params: AllbridgeCoreSdkOptions;\n\n bridge: BridgeService;\n pool: LiquidityPoolService;\n utils: Utils;\n\n private service: AllbridgeCoreSdkService;\n\n /**\n * Initializes the SDK object.\n * @param nodeUrls node rpc urls for full functionality\n * @param params\n * Optional.\n * If not defined, the default {@link mainnet} parameters are used.\n */\n constructor(nodeUrls: NodeUrlsConfig | NodeRpcUrls, params: AllbridgeCoreSdkOptions = mainnet) {\n let nodeRpcUrlsConfig: NodeRpcUrlsConfig;\n if (isNodeUrlsConfig(nodeUrls)) {\n nodeRpcUrlsConfig = new NodeRpcUrlsConfig({ SOL: nodeUrls.solanaRpcUrl, TRX: nodeUrls.tronRpcUrl });\n } else {\n nodeRpcUrlsConfig = new NodeRpcUrlsConfig(nodeUrls);\n }\n this.service = new AllbridgeCoreSdkService(nodeRpcUrlsConfig, params);\n this.bridge = this.service.bridge;\n this.pool = this.service.pool;\n this.utils = new DefaultUtils(nodeRpcUrlsConfig, params);\n this.params = params;\n }\n\n /**\n * Returns {@link ChainDetailsMap} containing a list of supported tokens groped by chain.\n *\n * @param type - A string value which specifies ChainDetailsMap to retrieve.\n * Can be either 'swap' for send or 'pool' for liquidity pools setup.\n * Defaults to 'swap'.\n */\n async chainDetailsMap(type: \"swap\" | \"pool\" = \"swap\"): Promise<ChainDetailsMap> {\n return this.service.chainDetailsMap(type);\n }\n\n /**\n * Returns a list of supported {@link TokenWithChainDetails | tokens}.\n *\n * @param type - A string value which specifies a set of tokens to retrieve.\n * Can be either 'swap' for tokens to send or 'pool' for liquidity pools operations.\n * Defaults to 'swap'.\n * @returns A promise that resolves to an array of {@link TokenWithChainDetails}.\n */\n async tokens(type: \"swap\" | \"pool\" = \"swap\"): Promise<TokenWithChainDetails[]> {\n return this.service.tokens(type);\n }\n\n /**\n * Returns a list of supported {@link TokenWithChainDetails | tokens} on the selected chain.\n * @param chainSymbol - The symbol of the chain representing one of the supported blockchain networks (e.g., \"ETH\" for Ethereum). For more details, see: {@link ChainSymbol}.\n * @param type - A string value which specifies a set of tokens to retrieve.\n * Can be either 'swap' for tokens to send or 'pool' for liquidity pools operations.\n * Defaults to 'swap'.\n */\n async tokensByChain(chainSymbol: string, type: \"swap\" | \"pool\" = \"swap\"): Promise<TokenWithChainDetails[]> {\n return this.service.tokensByChain(chainSymbol, type);\n }\n\n /**\n * Fetches information about tokens transfer by chosen chainSymbol and transaction Id from the Allbridge Core API.\n * @param chainSymbol - The symbol of the chain representing one of the supported blockchain networks (e.g., \"ETH\" for Ethereum). For more details, see: {@link ChainSymbol}.\n * @param txId\n */\n async getTransferStatus(chainSymbol: string, txId: string): Promise<TransferStatusResponse> {\n return this.service.getTransferStatus(chainSymbol, txId);\n }\n\n /**\n * Get gas balance\n * @param chainSymbol - The symbol of the chain representing one of the supported blockchain networks (e.g., \"ETH\" for Ethereum). For more details, see: {@link ChainSymbol}.\n * @param address\n */\n async getGasBalance(chainSymbol: string, address: string): Promise<GasBalanceResponse> {\n return this.service.getGasBalance(chainSymbol, address);\n }\n\n /**\n * Check address and show gas balance\n * @deprecated\n * @param chainSymbol - The symbol of the chain representing one of the supported blockchain networks (e.g., \"ETH\" for Ethereum). For more details, see: {@link ChainSymbol}.\n * @param recipientAddress\n * @param tokenAddress\n */\n async checkAddress(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n chainSymbol: string,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n recipientAddress: string,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n tokenAddress?: string\n ): Promise<CheckAddressResponse> {\n return await this.service.checkAddress();\n }\n\n /**\n * Returns information about pending transactions for the same destination chain and the amount of tokens can be received as a result of transfer considering pending transactions.\n * @param amount the amount of tokens that will be sent\n * @param amountFormat amount format\n * @param sourceToken selected token transfer from\n * @param destToken selected token transfer to\n * @returns range of possible amount based on already pending transactions\n */\n async getPendingStatusInfo(\n amount: string,\n amountFormat: AmountFormat,\n sourceToken: TokenWithChainDetails,\n destToken: TokenWithChainDetails\n ): Promise<PendingStatusInfoResponse> {\n return this.service.getPendingStatusInfo(amount, amountFormat, sourceToken, destToken);\n }\n\n /**\n * Get token balance\n * @param params\n * @param provider\n * @returns Token balance\n */\n async getTokenBalance(params: GetTokenBalanceParams, provider?: Provider): Promise<string> {\n return this.service.getTokenBalance(params, provider);\n }\n\n /**\n * Get native (gas) token balance\n * @param params\n * @param provider\n * @returns Token balance\n */\n async getNativeTokenBalance(params: GetNativeTokenBalanceParams, provider?: Provider): Promise<AmountFormatted> {\n return this.service.getNativeTokenBalance(params, provider);\n }\n\n /**\n * @deprecated\n * Calculates the percentage of fee from the initial amount that is charged when swapping from the selected source chain.\n * (Does not include fee related to the destination chain. Does not include gas fee)\n * @param amountFloat initial amount of tokens to swap\n * @param sourceChainToken selected token on the source chain\n * @returns fee percent\n */\n async calculateFeePercentOnSourceChain(\n amountFloat: BigSource,\n sourceChainToken: TokenWithChainDetails\n ): Promise<number> {\n return this.service.calculateFeePercentOnSourceChain(amountFloat, sourceChainToken);\n }\n\n /**\n * @deprecated\n * Calculates the percentage of fee that is charged when swapping to the selected destination chain. The destination chain fee percent applies to the amount after the source chain fee.\n * (Does not include fee related to the source chain. Does not include gas fee)\n * @see {@link calculateFeePercentOnSourceChain}\n * @param amountFloat initial amount of tokens to swap\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @returns fee percent\n */\n async calculateFeePercentOnDestinationChain(\n amountFloat: BigSource,\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails\n ): Promise<number> {\n return this.service.calculateFeePercentOnDestinationChain(amountFloat, sourceChainToken, destinationChainToken);\n }\n\n /**\n * Calculates the amount of tokens to be received as a result of transfer\n * and fetches {@link GasFeeOptions} which contains available ways to pay the gas fee.\n * @param amountToSendFloat the amount of tokens that will be sent\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @param messenger\n */\n async getAmountToBeReceivedAndGasFeeOptions(\n amountToSendFloat: BigSource,\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n messenger: Messenger\n ): Promise<AmountsAndGasFeeOptions> {\n return this.service.getAmountToBeReceivedAndGasFeeOptions(\n amountToSendFloat,\n sourceChainToken,\n destinationChainToken,\n messenger\n );\n }\n\n /**\n * Calculates the amount of tokens to send based on requested tokens amount be received as a result of transfer.\n * and fetches {@link GasFeeOptions} which contains available ways to pay the gas fee.\n * @param amountToBeReceivedFloat the amount of tokens that should be received\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @param messenger\n */\n async getAmountToSendAndGasFeeOptions(\n amountToBeReceivedFloat: BigSource,\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n messenger: Messenger\n ): Promise<AmountsAndGasFeeOptions> {\n return this.service.getAmountToSendAndGasFeeOptions(\n amountToBeReceivedFloat,\n sourceChainToken,\n destinationChainToken,\n messenger\n );\n }\n\n /**\n * Calculates the amount of tokens to be received as a result of transfer.\n * @param amountToSendFloat the amount of tokens that will be sent\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @param messenger Optional. selected messenger\n */\n async getAmountToBeReceived(\n amountToSendFloat: BigSource,\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n /**\n * The Messengers for different routes.\n * Optional.\n * The {@link Messenger.ALLBRIDGE}, {@link Messenger.WORMHOLE} by default.\n */\n messenger?: Messenger\n ): Promise<string> {\n return this.service.getAmountToBeReceived(amountToSendFloat, sourceChainToken, destinationChainToken, messenger);\n }\n\n /**\n * Calculates the amount of tokens to be received as a result of transfer based on actual blockchain pool state.\n * @param amountToSendFloat the amount of tokens that will be sent\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @param messenger Optional. selected messenger\n * @param sourceProvider Optional. source chain Provider\n * @param destinationProvider Optional. destination chain Provider\n */\n async getAmountToBeReceivedFromChain(\n amountToSendFloat: BigSource,\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n /**\n * The Messengers for different routes.\n * Optional.\n * The {@link Messenger.ALLBRIDGE}, {@link Messenger.WORMHOLE} by default.\n */\n messenger?: Messenger,\n sourceProvider?: Provider,\n destinationProvider?: Provider\n ): Promise<string> {\n return this.service.getAmountToBeReceivedFromChain(\n amountToSendFloat,\n sourceChainToken,\n destinationChainToken,\n messenger,\n sourceProvider,\n destinationProvider\n );\n }\n\n /**\n * Calculates the amount of tokens to be received as a result of transfer based on passed pool state.\n * @param amountToSendFloat the amount of tokens that will be sent\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @param sourcePool source token pool state\n * @param destinationPool destination token pool state\n * @param messenger Optional. selected messenger\n */\n getAmountToBeReceivedFromPools(\n amountToSendFloat: BigSource,\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n sourcePool: PoolInfo,\n destinationPool: PoolInfo,\n messenger?: Messenger\n ): string {\n return this.service.getAmountToBeReceivedFromPools(\n amountToSendFloat,\n sourceChainToken,\n destinationChainToken,\n sourcePool,\n destinationPool,\n messenger\n );\n }\n\n /**\n * Calculates the amount of tokens to send based on requested tokens amount be received as a result of transfer.\n * @param amountToBeReceivedFloat the amount of tokens that should be received\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @param messenger Optional. selected messenger\n */\n async getAmountToSend(\n amountToBeReceivedFloat: BigSource,\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n /**\n * The Messengers for different routes.\n * Optional.\n * The {@link Messenger.ALLBRIDGE}, {@link Messenger.WORMHOLE} by default.\n */\n messenger?: Messenger\n ): Promise<string> {\n return this.service.getAmountToSend(amountToBeReceivedFloat, sourceChainToken, destinationChainToken, messenger);\n }\n\n /**\n * Calculates the amount of tokens to send based on requested tokens amount be received as a result of transfer based on actual blockchain pool state.\n * @param amountToBeReceivedFloat the amount of tokens that should be received\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @param messenger Optional. selected messenger\n * @param sourceProvider Optional. source chain Provider\n * @param destinationProvider Optional. destination chain Provider\n */\n async getAmountToSendFromChain(\n amountToBeReceivedFloat: BigSource,\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n /**\n * The Messengers for different routes.\n * Optional.\n * The {@link Messenger.ALLBRIDGE}, {@link Messenger.WORMHOLE} by default.\n */\n messenger?: Messenger,\n sourceProvider?: Provider,\n destinationProvider?: Provider\n ): Promise<string> {\n return this.service.getAmountToSendFromChain(\n amountToBeReceivedFloat,\n sourceChainToken,\n destinationChainToken,\n messenger,\n sourceProvider,\n destinationProvider\n );\n }\n\n /**\n * Calculates the amount of tokens to send based on requested tokens amount be received as a result of transfer based on passed pool state.\n * @param amountToBeReceivedFloat the amount of tokens that should be received\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @param sourcePool source token pool state\n * @param destinationPool destination token pool state\n * @param messenger Optional. selected messenger\n */\n getAmountToSendFromPools(\n amountToBeReceivedFloat: BigSource,\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n sourcePool: PoolInfo,\n destinationPool: PoolInfo,\n messenger?: Messenger\n ): string {\n return this.service.getAmountToSendFromPools(\n amountToBeReceivedFloat,\n sourceChainToken,\n destinationChainToken,\n sourcePool,\n destinationPool,\n messenger\n );\n }\n\n /**\n * Fetches possible ways to pay the transfer gas fee.\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @param messenger\n * @returns {@link GasFeeOptions}\n */\n async getGasFeeOptions(\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n messenger: Messenger\n ): Promise<GasFeeOptions> {\n return this.service.getGasFeeOptions(sourceChainToken, destinationChainToken, messenger);\n }\n\n /**\n * Gets the average time in ms to complete a transfer for given tokens and messenger.\n * @param sourceChainToken selected token on the source chain.\n * @param destinationChainToken selected token on the destination chain.\n * @param messenger\n * @returns Average transfer time in milliseconds or null if a given combination of tokens and messenger is not supported.\n */\n getAverageTransferTime(\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails,\n messenger: Messenger\n ): number | null {\n return this.service.getAverageTransferTime(sourceChainToken, destinationChainToken, messenger);\n }\n\n /**\n * Gets information about the poolInfo by token\n * @param token\n * @returns poolInfo\n */\n async getPoolInfoByToken(token: TokenWithChainDetails): Promise<PoolInfo> {\n return this.service.getPoolInfoByToken(token);\n }\n\n /**\n * Forces refresh of cached information about the state of liquidity pools.\n * Outdated cache leads to calculated amounts being less accurate.\n * The cache is invalidated at regular intervals, but it can be forced to be refreshed by calling this method.+\n *\n * @param tokens if present, the corresponding liquidity pools will be updated\n */\n async refreshPoolInfo(tokens?: TokenWithChainDetails | TokenWithChainDetails[]): Promise<void> {\n return this.service.refreshPoolInfo(tokens);\n }\n\n /**\n * Convert APR to percentage view\n * @param apr\n * @returns aprPercentageView\n */\n aprInPercents(apr: string): string {\n return this.service.aprInPercents(apr);\n }\n\n /**\n * Get possible limit of extra gas amount.\n * @param sourceChainToken selected token on the source chain\n * @param destinationChainToken selected token on the destination chain\n * @returns {@link ExtraGasMaxLimitResponse}\n */\n async getExtraGasMaxLimits(\n sourceChainToken: TokenWithChainDetails,\n destinationChainToken: TokenWithChainDetails\n ): Promise<ExtraGasMaxLimitResponse> {\n return this.service.getExtraGasMaxLimits(sourceChainToken, destinationChainToken);\n }\n\n /**\n * @param amount - amount\n * @param amountFormat - AmountFormat\n * @param sourceToken - selected token on the source chain\n * @return virtual amount\n */\n async getVUsdFromAmount(\n amount: string,\n amountFormat: AmountFormat,\n sourceToken: TokenWithChainDetails\n ): Promise<AmountFormatted> {\n return this.service.getVUsdFromAmount(amount, amountFormat, sourceToken);\n }\n\n /**\n * @param vUsdAmount - amount of vUsd, int format\n * @param destToken selected token on the destination chain\n * @return amount of destToken\n */\n async getAmountFromVUsd(vUsdAmount: string, destToken: TokenWithChainDetails): Promise<AmountFormatted> {\n return this.service.getAmountFromVUsd(vUsdAmount, destToken);\n }\n\n /**\n * @deprecated Use {@link getSendAmountDetails}\n * @param amountInTokenPrecision\n * @param sourceToken\n * @param destToken\n */\n async swapAndBridgeFeeCalculation(\n amountInTokenPrecision: string,\n sourceToken: TokenWithChainDetails,\n destToken: TokenWithChainDetails\n ): Promise<SwapAndBridgeCalculationData> {\n return this.service.swapAndBridgeFeeCalculation(amountInTokenPrecision, sourceToken, destToken);\n }\n\n /**\n * @deprecated Use {@link getAmountToBeReceived} and then {@link getSendAmountDetails}\n * @param amountInTokenPrecision\n * @param sourceToken\n * @param destToken\n */\n async swapAndBridgeFeeCalculationReverse(\n amountInTokenPrecision: string,\n sourceToken: TokenWithChainDetails,\n destToken: TokenWithChainDetails\n ): Promise<SwapAndBridgeCalculationData> {\n return this.service.swapAndBridgeFeeCalculationReverse(amountInTokenPrecision, sourceToken, destToken);\n }\n\n /**\n * Show amount changes (fee and amount adjustment) during send through pools on source and destination chains\n */\n async getSendAmountDetails(\n amount: string,\n amountFormat: AmountFormat,\n sourceToken: TokenWithChainDetails,\n destToken: TokenWithChainDetails\n ): Promise<SendAmountDetails> {\n return this.service.getSendAmountDetails(amount, amountFormat, sourceToken, destToken);\n }\n}\n"]}
|
|
@@ -108,8 +108,11 @@ function getChainBridgeService(chainSymbol, api, nodeRpcUrlsConfig, params, prov
|
|
|
108
108
|
wormholeMessengerProgramId: params.wormholeMessengerProgramId,
|
|
109
109
|
solanaLookUpTable: params.solanaLookUpTable,
|
|
110
110
|
cctpParams: params.cctpParams,
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
jupiterParams: {
|
|
112
|
+
jupiterUrl: params.jupiterUrl,
|
|
113
|
+
jupiterApiKeyHeader: params.jupiterApiKeyHeader,
|
|
114
|
+
jupiterMaxAccounts: params.jupiterMaxAccounts,
|
|
115
|
+
},
|
|
113
116
|
}, api);
|
|
114
117
|
}
|
|
115
118
|
case index_1.ChainType.SRB: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/services/bridge/index.ts"],"names":[],"mappings":";;;AAiIA,gCAUC;AAED,sDAmDC;AAhMD,qCAAkC;AAClC,+BAA4B;AAE5B,yCAAsC;AACtC,yEAAiE;AAEjE,iDAA6D;AAC7D,uCAA6F;AAE7F,6CAAiF;AAGjF,+BAAyC;AAEzC,qFAAmH;AACnH,+BAA4C;AAC5C,+BAAyC;AACzC,+BAAyC;AACzC,+BAA0C;AAuD1C,MAAa,oBAAoB;IAIrB;IACA;IACA;IACA;IANH,YAAY,CAA8B;IAEjD,YACU,GAAwB,EACxB,iBAAoC,EACpC,MAA+B,EAC/B,YAA0B;QAH1B,QAAG,GAAH,GAAG,CAAqB;QACxB,sBAAiB,GAAjB,iBAAiB,CAAmB;QACpC,WAAM,GAAN,MAAM,CAAyB;QAC/B,iBAAY,GAAZ,YAAY,CAAc;QAElC,IAAI,CAAC,YAAY,GAAG,IAAI,mEAAkC,CAAC,GAAG,EAAE,iBAAiB,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;IAC3G,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,CAAgC,EAAE,CAAsB;QACzE,IAAI,QAA8B,CAAC;QACnC,IAAI,MAA0B,CAAC;QAC/B,IAAI,CAAC,EAAE,CAAC;Y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YACnB,IAAI,QAAQ,EAAE,CAAC;gBACb,OAAO,IAAI,uBAAiB,CAAC,QAAmB,EAAE,GAAG,CAAC,CAAC;YACzD,CAAC;iBAAM,CAAC;gBACN,MAAM,UAAU,GAAG,iBAAiB,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;gBAChE,OAAO,IAAI,uBAAiB,CAC1B,IAAI,iBAAO,CAAC;oBACV,QAAQ,EAAE,UAAU;oBACpB,YAAY,EAAE,UAAU;oBACxB,WAAW,EAAE,UAAU;iBACxB,CAAC,EACF,GAAG,CACJ,CAAC;YACJ,CAAC;QACH,CAAC;QACD,KAAK,iBAAS,CAAC,MAAM,CAAC,CAAC,CAAC;YACtB,OAAO,IAAI,yBAAmB,CAC5B,iBAAiB,CAAC,aAAa,CAAC,mBAAW,CAAC,GAAG,CAAC,EAChD;gBACE,0BAA0B,EAAE,MAAM,CAAC,0BAA0B;gBAC7D,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;gBAC3C,UAAU,EAAE,MAAM,CAAC,UAAU;gBAC7B,UAAU,EAAE,MAAM,CAAC,UAAU;gBAC7B,kBAAkB,EAAE,MAAM,CAAC,kBAAkB;aAC9C,EACD,GAAG,CACJ,CAAC;QACJ,CAAC;QACD,KAAK,iBAAS,CAAC,GAAG,CAAC,CAAC,CAAC;YACnB,OAAO,IAAI,sBAAgB,CAAC,iBAAiB,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;QAC9D,CAAC;QACD,KAAK,iBAAS,CAAC,GAAG,CAAC,CAAC,CAAC;YACnB,OAAO,IAAI,sBAAgB,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { TronWeb } from \"tronweb\";\nimport { Web3 } from \"web3\";\nimport { NodeRpcUrlsConfig } from \"..\";\nimport { Chains } from \"../../chains\";\nimport { Messenger } from \"../../client/core-api/core-api.model\";\nimport { AllbridgeCoreClient } from \"../../client/core-api/core-client-base\";\nimport { CCTPDoesNotSupportedError } from \"../../exceptions\";\nimport { AllbridgeCoreSdkOptions, ChainSymbol, ChainType, EssentialWeb3 } from \"../../index\";\nimport { TokenWithChainDetails } from \"../../tokens-info\";\nimport { validateAmountDecimals, validateAmountGtZero } from \"../../utils/utils\";\nimport { Provider, TransactionResponse } from \"../models\";\nimport { TokenService } from \"../token\";\nimport { EvmBridgeService } from \"./evm\";\nimport { ApproveParams, CheckAllowanceParams, GetAllowanceParams, SendParams, ChainBridgeService } from \"./models\";\nimport { DefaultRawBridgeTransactionBuilder, RawBridgeTransactionBuilder } from \"./raw-bridge-transaction-builder\";\nimport { SolanaBridgeService } from \"./sol\";\nimport { SrbBridgeService } from \"./srb\";\nimport { SuiBridgeService } from \"./sui\";\nimport { TronBridgeService } from \"./trx\";\n\nexport interface BridgeService {\n rawTxBuilder: RawBridgeTransactionBuilder;\n\n /**\n * Get amount of tokens approved to be sent by the bridge\n * @param provider - will be used to access the network\n * @param params See {@link GetAllowanceParams}\n * @returns the amount of approved tokens\n */\n getAllowance(provider: Provider, params: GetAllowanceParams): Promise<string>;\n\n /**\n * Get amount of tokens approved to be sent by the bridge\n * @param params See {@link GetAllowanceParams}\n * @returns the amount of approved tokens\n */\n getAllowance(params: GetAllowanceParams): Promise<string>;\n\n /**\n * Check if the amount of approved tokens is enough to make a transfer\n * @param provider - will be used to access the network\n * @param params See {@link CheckAllowanceParams}\n * @returns true if the amount of approved tokens is enough to make a transfer\n */\n checkAllowance(provider: Provider, params: CheckAllowanceParams): Promise<boolean>;\n\n /**\n * Check if the amount of approved tokens is enough to make a transfer\n * @param params See {@link CheckAllowanceParams}\n * @returns true if the amount of approved tokens is enough to make a transfer\n */\n checkAllowance(params: CheckAllowanceParams): Promise<boolean>;\n\n /**\n * @deprecated Use {@link rawTxBuilder}.{@link RawBridgeTransactionBuilder.approve}<p>\n * Approve tokens usage by another address on chains\n * <p>\n * For ETH/USDT: due to specificity of the USDT contract:<br/>\n * If the current allowance is not 0, this function will perform an additional transaction to set allowance to 0 before setting the new allowance value.\n * @param provider - will be used to access the network\n * @param approveData\n */\n approve(provider: Provider, approveData: ApproveParams): Promise<TransactionResponse>;\n\n /**\n * @deprecated Use {@link rawTxBuilder}.{@link RawBridgeTransactionBuilder.send}<p>\n * Send tokens through the ChainBridgeService\n * @param provider - will be used to access the network\n * @param params\n */\n send(provider: Provider, params: SendParams): Promise<TransactionResponse>;\n}\n\nexport class DefaultBridgeService implements BridgeService {\n public rawTxBuilder: RawBridgeTransactionBuilder;\n\n constructor(\n private api: AllbridgeCoreClient,\n private nodeRpcUrlsConfig: NodeRpcUrlsConfig,\n private params: AllbridgeCoreSdkOptions,\n private tokenService: TokenService\n ) {\n this.rawTxBuilder = new DefaultRawBridgeTransactionBuilder(api, nodeRpcUrlsConfig, params, tokenService);\n }\n\n async getAllowance(a: Provider | GetAllowanceParams, b?: GetAllowanceParams): Promise<string> {\n let provider: Provider | undefined;\n let params: GetAllowanceParams;\n if (b) {\n provider = a as Provider;\n params = b;\n } else {\n params = a as GetAllowanceParams;\n }\n const spender = getSpender(params.token, params.messenger);\n return await this.tokenService.getAllowance({ ...params, spender }, provider);\n }\n\n async checkAllowance(a: Provider | CheckAllowanceParams, b?: CheckAllowanceParams): Promise<boolean> {\n let provider: Provider | undefined;\n let params: CheckAllowanceParams;\n if (b) {\n provider = a as Provider;\n params = b;\n } else {\n params = a as CheckAllowanceParams;\n }\n const spender = getSpender(params.token, params.messenger);\n return this.tokenService.checkAllowance({ ...params, spender }, provider);\n }\n\n async approve(provider: Provider, approveData: ApproveParams): Promise<TransactionResponse> {\n const spender = getSpender(approveData.token, approveData.messenger);\n return this.tokenService.approve(provider, { ...approveData, spender });\n }\n\n async send(provider: Provider, params: SendParams): Promise<TransactionResponse> {\n validateAmountGtZero(params.amount);\n validateAmountDecimals(\"amount\", params.amount, params.sourceToken.decimals);\n return getChainBridgeService(\n params.sourceToken.chainSymbol,\n this.api,\n this.nodeRpcUrlsConfig,\n this.params,\n provider\n ).send(params);\n }\n}\n\nexport function getSpender(token: TokenWithChainDetails, messenger?: Messenger): string {\n if (messenger && messenger == Messenger.CCTP) {\n if (token.cctpAddress) {\n return token.cctpAddress;\n } else {\n throw new CCTPDoesNotSupportedError(\"Such route does not support CCTP protocol\");\n }\n } else {\n return token.bridgeAddress;\n }\n}\n\nexport function getChainBridgeService(\n chainSymbol: string,\n api: AllbridgeCoreClient,\n nodeRpcUrlsConfig: NodeRpcUrlsConfig,\n params: AllbridgeCoreSdkOptions,\n provider?: Provider\n): ChainBridgeService {\n switch (Chains.getChainProperty(chainSymbol).chainType) {\n case ChainType.EVM: {\n if (provider) {\n return new EvmBridgeService(provider as EssentialWeb3, api, nodeRpcUrlsConfig);\n } else {\n const nodeRpcUrl = nodeRpcUrlsConfig.getNodeRpcUrl(chainSymbol);\n return new EvmBridgeService(new Web3(nodeRpcUrl), api, nodeRpcUrlsConfig);\n }\n }\n case ChainType.TRX: {\n if (provider) {\n return new TronBridgeService(provider as TronWeb, api);\n } else {\n const nodeRpcUrl = nodeRpcUrlsConfig.getNodeRpcUrl(chainSymbol);\n return new TronBridgeService(\n new TronWeb({\n fullHost: nodeRpcUrl,\n solidityNode: nodeRpcUrl,\n eventServer: nodeRpcUrl,\n }),\n api\n );\n }\n }\n case ChainType.SOLANA: {\n return new SolanaBridgeService(\n nodeRpcUrlsConfig.getNodeRpcUrl(ChainSymbol.SOL),\n {\n wormholeMessengerProgramId: params.wormholeMessengerProgramId,\n solanaLookUpTable: params.solanaLookUpTable,\n cctpParams: params.cctpParams,\n jupiterUrl: params.jupiterUrl,\n jupiterMaxAccounts: params.jupiterMaxAccounts,\n },\n api\n );\n }\n case ChainType.SRB: {\n return new SrbBridgeService(nodeRpcUrlsConfig, params, api);\n }\n case ChainType.SUI: {\n return new SuiBridgeService(nodeRpcUrlsConfig, api);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/services/bridge/index.ts"],"names":[],"mappings":";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CAAC,GAAG,CAAC,EAChD;gBACE,0BAA0B,EAAE,MAAM,CAAC,0BAA0B;gBAC7D,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;gBAC3C,UAAU,EAAE,MAAM,CAAC,UAAU;gBAC7B,aAAa,EAAE;oBACb,UAAU,EAAE,MAAM,CAAC,UAAU;oBAC7B,mBAAmB,EAAE,MAAM,CAAC,mBAAmB;oBAC/C,kBAAkB,EAAE,MAAM,CAAC,kBAAkB;iBAC9C;aACF,EACD,GAAG,CACJ,CAAC;QACJ,CAAC;QACD,KAAK,iBAAS,CAAC,GAAG,CAAC,CAAC,CAAC;YACnB,OAAO,IAAI,sBAAgB,CAAC,iBAAiB,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;QAC9D,CAAC;QACD,KAAK,iBAAS,CAAC,GAAG,CAAC,CAAC,CAAC;YACnB,OAAO,IAAI,sBAAgB,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { TronWeb } from \"tronweb\";\nimport { Web3 } from \"web3\";\nimport { NodeRpcUrlsConfig } from \"..\";\nimport { Chains } from \"../../chains\";\nimport { Messenger } from \"../../client/core-api/core-api.model\";\nimport { AllbridgeCoreClient } from \"../../client/core-api/core-client-base\";\nimport { CCTPDoesNotSupportedError } from \"../../exceptions\";\nimport { AllbridgeCoreSdkOptions, ChainSymbol, ChainType, EssentialWeb3 } from \"../../index\";\nimport { TokenWithChainDetails } from \"../../tokens-info\";\nimport { validateAmountDecimals, validateAmountGtZero } from \"../../utils/utils\";\nimport { Provider, TransactionResponse } from \"../models\";\nimport { TokenService } from \"../token\";\nimport { EvmBridgeService } from \"./evm\";\nimport { ApproveParams, CheckAllowanceParams, GetAllowanceParams, SendParams, ChainBridgeService } from \"./models\";\nimport { DefaultRawBridgeTransactionBuilder, RawBridgeTransactionBuilder } from \"./raw-bridge-transaction-builder\";\nimport { SolanaBridgeService } from \"./sol\";\nimport { SrbBridgeService } from \"./srb\";\nimport { SuiBridgeService } from \"./sui\";\nimport { TronBridgeService } from \"./trx\";\n\nexport interface BridgeService {\n rawTxBuilder: RawBridgeTransactionBuilder;\n\n /**\n * Get amount of tokens approved to be sent by the bridge\n * @param provider - will be used to access the network\n * @param params See {@link GetAllowanceParams}\n * @returns the amount of approved tokens\n */\n getAllowance(provider: Provider, params: GetAllowanceParams): Promise<string>;\n\n /**\n * Get amount of tokens approved to be sent by the bridge\n * @param params See {@link GetAllowanceParams}\n * @returns the amount of approved tokens\n */\n getAllowance(params: GetAllowanceParams): Promise<string>;\n\n /**\n * Check if the amount of approved tokens is enough to make a transfer\n * @param provider - will be used to access the network\n * @param params See {@link CheckAllowanceParams}\n * @returns true if the amount of approved tokens is enough to make a transfer\n */\n checkAllowance(provider: Provider, params: CheckAllowanceParams): Promise<boolean>;\n\n /**\n * Check if the amount of approved tokens is enough to make a transfer\n * @param params See {@link CheckAllowanceParams}\n * @returns true if the amount of approved tokens is enough to make a transfer\n */\n checkAllowance(params: CheckAllowanceParams): Promise<boolean>;\n\n /**\n * @deprecated Use {@link rawTxBuilder}.{@link RawBridgeTransactionBuilder.approve}<p>\n * Approve tokens usage by another address on chains\n * <p>\n * For ETH/USDT: due to specificity of the USDT contract:<br/>\n * If the current allowance is not 0, this function will perform an additional transaction to set allowance to 0 before setting the new allowance value.\n * @param provider - will be used to access the network\n * @param approveData\n */\n approve(provider: Provider, approveData: ApproveParams): Promise<TransactionResponse>;\n\n /**\n * @deprecated Use {@link rawTxBuilder}.{@link RawBridgeTransactionBuilder.send}<p>\n * Send tokens through the ChainBridgeService\n * @param provider - will be used to access the network\n * @param params\n */\n send(provider: Provider, params: SendParams): Promise<TransactionResponse>;\n}\n\nexport class DefaultBridgeService implements BridgeService {\n public rawTxBuilder: RawBridgeTransactionBuilder;\n\n constructor(\n private api: AllbridgeCoreClient,\n private nodeRpcUrlsConfig: NodeRpcUrlsConfig,\n private params: AllbridgeCoreSdkOptions,\n private tokenService: TokenService\n ) {\n this.rawTxBuilder = new DefaultRawBridgeTransactionBuilder(api, nodeRpcUrlsConfig, params, tokenService);\n }\n\n async getAllowance(a: Provider | GetAllowanceParams, b?: GetAllowanceParams): Promise<string> {\n let provider: Provider | undefined;\n let params: GetAllowanceParams;\n if (b) {\n provider = a as Provider;\n params = b;\n } else {\n params = a as GetAllowanceParams;\n }\n const spender = getSpender(params.token, params.messenger);\n return await this.tokenService.getAllowance({ ...params, spender }, provider);\n }\n\n async checkAllowance(a: Provider | CheckAllowanceParams, b?: CheckAllowanceParams): Promise<boolean> {\n let provider: Provider | undefined;\n let params: CheckAllowanceParams;\n if (b) {\n provider = a as Provider;\n params = b;\n } else {\n params = a as CheckAllowanceParams;\n }\n const spender = getSpender(params.token, params.messenger);\n return this.tokenService.checkAllowance({ ...params, spender }, provider);\n }\n\n async approve(provider: Provider, approveData: ApproveParams): Promise<TransactionResponse> {\n const spender = getSpender(approveData.token, approveData.messenger);\n return this.tokenService.approve(provider, { ...approveData, spender });\n }\n\n async send(provider: Provider, params: SendParams): Promise<TransactionResponse> {\n validateAmountGtZero(params.amount);\n validateAmountDecimals(\"amount\", params.amount, params.sourceToken.decimals);\n return getChainBridgeService(\n params.sourceToken.chainSymbol,\n this.api,\n this.nodeRpcUrlsConfig,\n this.params,\n provider\n ).send(params);\n }\n}\n\nexport function getSpender(token: TokenWithChainDetails, messenger?: Messenger): string {\n if (messenger && messenger == Messenger.CCTP) {\n if (token.cctpAddress) {\n return token.cctpAddress;\n } else {\n throw new CCTPDoesNotSupportedError(\"Such route does not support CCTP protocol\");\n }\n } else {\n return token.bridgeAddress;\n }\n}\n\nexport function getChainBridgeService(\n chainSymbol: string,\n api: AllbridgeCoreClient,\n nodeRpcUrlsConfig: NodeRpcUrlsConfig,\n params: AllbridgeCoreSdkOptions,\n provider?: Provider\n): ChainBridgeService {\n switch (Chains.getChainProperty(chainSymbol).chainType) {\n case ChainType.EVM: {\n if (provider) {\n return new EvmBridgeService(provider as EssentialWeb3, api, nodeRpcUrlsConfig);\n } else {\n const nodeRpcUrl = nodeRpcUrlsConfig.getNodeRpcUrl(chainSymbol);\n return new EvmBridgeService(new Web3(nodeRpcUrl), api, nodeRpcUrlsConfig);\n }\n }\n case ChainType.TRX: {\n if (provider) {\n return new TronBridgeService(provider as TronWeb, api);\n } else {\n const nodeRpcUrl = nodeRpcUrlsConfig.getNodeRpcUrl(chainSymbol);\n return new TronBridgeService(\n new TronWeb({\n fullHost: nodeRpcUrl,\n solidityNode: nodeRpcUrl,\n eventServer: nodeRpcUrl,\n }),\n api\n );\n }\n }\n case ChainType.SOLANA: {\n return new SolanaBridgeService(\n nodeRpcUrlsConfig.getNodeRpcUrl(ChainSymbol.SOL),\n {\n wormholeMessengerProgramId: params.wormholeMessengerProgramId,\n solanaLookUpTable: params.solanaLookUpTable,\n cctpParams: params.cctpParams,\n jupiterParams: {\n jupiterUrl: params.jupiterUrl,\n jupiterApiKeyHeader: params.jupiterApiKeyHeader,\n jupiterMaxAccounts: params.jupiterMaxAccounts,\n },\n },\n api\n );\n }\n case ChainType.SRB: {\n return new SrbBridgeService(nodeRpcUrlsConfig, params, api);\n }\n case ChainType.SUI: {\n return new SuiBridgeService(nodeRpcUrlsConfig, api);\n }\n }\n}\n"]}
|
|
@@ -10,7 +10,11 @@ export interface SolanaBridgeParams {
|
|
|
10
10
|
wormholeMessengerProgramId: string;
|
|
11
11
|
solanaLookUpTable: string;
|
|
12
12
|
cctpParams: CctpParams;
|
|
13
|
+
jupiterParams: JupiterParams;
|
|
14
|
+
}
|
|
15
|
+
export interface JupiterParams {
|
|
13
16
|
jupiterUrl: string;
|
|
17
|
+
jupiterApiKeyHeader?: string;
|
|
14
18
|
jupiterMaxAccounts?: number;
|
|
15
19
|
}
|
|
16
20
|
export interface CctpParams {
|
|
@@ -33,7 +33,7 @@ class SolanaBridgeService extends bridge_2.ChainBridgeService {
|
|
|
33
33
|
this.solanaRpcUrl = solanaRpcUrl;
|
|
34
34
|
this.params = params;
|
|
35
35
|
this.api = api;
|
|
36
|
-
this.jupiterService = new jupiter_1.JupiterService(solanaRpcUrl, params.
|
|
36
|
+
this.jupiterService = new jupiter_1.JupiterService(solanaRpcUrl, params.jupiterParams);
|
|
37
37
|
}
|
|
38
38
|
async buildRawTransactionSwap(params) {
|
|
39
39
|
const txSwapParams = (0, utils_1.prepareTxSwapParams)(this.chainType, params);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/services/bridge/sol/index.ts"],"names":[],"mappings":";;;AAAA,sDAAsD;AACtD,sDAAsD;AACtD,kDAA+D;AAC/D,6CASyB;AACzB,mCAA6B;AAC7B,4CAAyC;AACzC,4EAAoE;AAEpE,oDAO6B;AAC7B,4CAAuF;AACvF,4DAAqE;AAGrE,0DAAuF;AACvF,oEAAwG;AACxG,yCAAiF;AACjF,uDAgBkC;AAClC,qEAAsE;AACtE,mEAAqH;AAErH,6CAAsD;AACtD,oCAA8E;AAC9E,uCAA2C;AAyB3C,MAAM,kBAAkB,GAAG,OAAO,CAAC;AAEnC,MAAM,aAAa,GAAG,GAAG,CAAC;AAE1B,MAAa,mBAAoB,SAAQ,2BAAkB;IAKhD;IACA;IACA;IANT,SAAS,GAAqB,kBAAS,CAAC,MAAM,CAAC;IAC/C,cAAc,CAAiB;IAE/B,YACS,YAAoB,EACpB,MAA0B,EAC1B,GAAwB;QAE/B,KAAK,EAAE,CAAC;QAJD,iBAAY,GAAZ,YAAY,CAAQ;QACpB,WAAM,GAAN,MAAM,CAAoB;QAC1B,QAAG,GAAH,GAAG,CAAqB;QAG/B,IAAI,CAAC,cAAc,GAAG,IAAI,wBAAc,CAAC,YAAY,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,kBAAkB,CAAC,CAAC;IACvG,CAAC;IAED,KAAK,CAAC,uBAAuB,CAAC,MAAkB;QAC9C,MAAM,YAAY,GAAG,IAAA,2BAAmB,EAAC,IAAI,CAAC,SAAS,EAAE,M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ChH,CAAC;IAED,IAAI,CAAC,MAAkB;QACrB,MAAM,IAAI,oCAAuB,EAAE,CAAC;IACtC,CAAC;CACF;AAnuBD,kDAmuBC","sourcesContent":["/* eslint-disable @typescript-eslint/ban-ts-comment */\n/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { BN, Program, Spl, web3 } from \"@project-serum/anchor\";\nimport {\n Connection,\n Keypair,\n PublicKey,\n SystemProgram,\n Transaction,\n TransactionInstruction,\n TransactionMessageArgs,\n VersionedTransaction,\n} from \"@solana/web3.js\";\nimport { Big } from \"big.js\";\nimport { Chains } from \"../../../chains\";\nimport { Messenger } from \"../../../client/core-api/core-api.model\";\nimport { AllbridgeCoreClient } from \"../../../client/core-api/core-client-base\";\nimport {\n AmountNotEnoughError,\n CCTPDoesNotSupportedError,\n JupiterError,\n MethodNotSupportedError,\n SdkError,\n SdkRootError,\n} from \"../../../exceptions\";\nimport { ChainType, FeePaymentMethod, SwapParams, TxFeeParams } from \"../../../models\";\nimport { convertIntAmountToFloat } from \"../../../utils/calculation\";\nimport { RawTransaction, TransactionResponse } from \"../../models\";\nimport { SwapAndBridgeSolData, SwapAndBridgeSolDataCctpData } from \"../../models/sol\";\nimport { Bridge as BridgeType, IDL as bridgeIdl } from \"../../models/sol/types/bridge\";\nimport { CctpBridge as CctpBridgeType, IDL as cctpBridgeIdl } from \"../../models/sol/types/cctp_bridge\";\nimport { getMessage, getTokenAccountData, getVUsdAmount } from \"../../utils/sol\";\nimport {\n getAssociatedAccount,\n getAuthorityAccount,\n getBridgeTokenAccount,\n getCctpAccounts,\n getCctpAuthorityAccount,\n getCctpBridgeAccount,\n getCctpBridgeTokenAccount,\n getCctpLockAccount,\n getChainBridgeAccount,\n getConfigAccount,\n getGasUsageAccount,\n getLockAccount,\n getOtherChainTokenAccount,\n getPriceAccount,\n getSendMessageAccount,\n} from \"../../utils/sol/accounts\";\nimport { buildAnchorProvider } from \"../../utils/sol/anchor-provider\";\nimport { addUnitLimitAndUnitPriceToTx, addUnitLimitAndUnitPriceToVersionedTx } from \"../../utils/sol/compute-budget\";\nimport { SendParams, TxSendParamsSol, TxSwapParamsSol } from \"../models\";\nimport { ChainBridgeService } from \"../models/bridge\";\nimport { getNonce, prepareTxSendParams, prepareTxSwapParams } from \"../utils\";\nimport { JupiterService } from \"./jupiter\";\n\nexport interface SolanaBridgeParams {\n wormholeMessengerProgramId: string;\n solanaLookUpTable: string;\n cctpParams: CctpParams;\n jupiterUrl: string;\n jupiterMaxAccounts?: number;\n}\n\nexport interface CctpParams {\n cctpTransmitterProgramId: string;\n cctpTokenMessengerMinter: string;\n cctpDomains: CctpDomains;\n}\n\n/**\n * Type representing a map of CCTP domains to their corresponding numeric values.\n *\n * @typedef {Record<string, number>} CctpDomains\n * @property {string} chainSymbol - The symbol of the chain representing one of the supported blockchain networks (e.g., \"ETH\" for Ethereum). For more details, see: {@link ChainSymbol}.\n * @property {number} value - The numeric value associated with the specified chain.\n */\nexport type CctpDomains = Record<string, number>;\n\nconst COMPUTE_UNIT_LIMIT = 1000000;\n\nconst JUP_ADD_INDEX = 1.1;\n\nexport class SolanaBridgeService extends ChainBridgeService {\n chainType: ChainType.SOLANA = ChainType.SOLANA;\n jupiterService: JupiterService;\n\n constructor(\n public solanaRpcUrl: string,\n public params: SolanaBridgeParams,\n public api: AllbridgeCoreClient\n ) {\n super();\n this.jupiterService = new JupiterService(solanaRpcUrl, params.jupiterUrl, params.jupiterMaxAccounts);\n }\n\n async buildRawTransactionSwap(params: SwapParams): Promise<RawTransaction> {\n const txSwapParams = prepareTxSwapParams(this.chainType, params);\n return await this.buildSwapTransaction(\n txSwapParams,\n params.sourceToken.poolAddress,\n params.destinationToken.poolAddress,\n params.txFeeParams\n );\n }\n\n private async buildSwapTransaction(\n params: TxSwapParamsSol,\n poolAddress: string,\n toPoolAddress: string,\n txFeeParams?: TxFeeParams\n ): Promise<VersionedTransaction> {\n const {\n fromAccountAddress,\n amount,\n contractAddress,\n fromTokenAddress,\n toTokenAddress,\n toAccountAddress,\n minimumReceiveAmount,\n } = params;\n const account = fromAccountAddress;\n const bridgeAddress = contractAddress;\n const tokenAddress = fromTokenAddress;\n const receiveTokenAddress = toTokenAddress;\n const receivePoolAddress = toPoolAddress;\n const receiverOriginal = toAccountAddress;\n\n const userAccount = new PublicKey(account);\n const provider = buildAnchorProvider(this.solanaRpcUrl, userAccount.toString());\n const bridge = new Program<BridgeType>(bridgeIdl, bridgeAddress, provider);\n\n const bridgeAuthority = await getAuthorityAccount(bridge.programId);\n const configAccount = await getConfigAccount(bridge.programId);\n\n const sendMint = new PublicKey(tokenAddress);\n const sendBridgeToken = await getBridgeTokenAccount(sendMint, bridge.programId);\n const sendPool = new PublicKey(poolAddress);\n const sendUserToken = await getAssociatedAccount(userAccount, sendMint);\n\n const receiverAccount = new PublicKey(receiverOriginal);\n const receiveMint = new PublicKey(receiveTokenAddress);\n const receiveBridgeToken = await getBridgeTokenAccount(receiveMint, bridge.programId);\n const receivePool = new PublicKey(receivePoolAddress);\n const receiveUserToken = await getAssociatedAccount(receiverAccount, receiveMint);\n\n const preInstructions: TransactionInstruction[] = [\n web3.ComputeBudgetProgram.setComputeUnitLimit({\n units: COMPUTE_UNIT_LIMIT,\n }),\n ];\n\n try {\n await getTokenAccountData(receiveUserToken, provider);\n } catch (e) {\n const associatedProgram = Spl.associatedToken(provider);\n const createReceiveUserTokenInstruction: TransactionInstruction = await associatedProgram.methods\n .create()\n .accounts({\n mint: receiveMint,\n owner: receiverAccount,\n associatedAccount: receiveUserToken,\n })\n .instruction();\n preInstructions.push(createReceiveUserTokenInstruction);\n }\n const transaction = await bridge.methods\n .swap(new BN(amount), new BN(minimumReceiveAmount || 0))\n .accounts({\n payer: userAccount,\n config: configAccount,\n bridgeAuthority,\n user: userAccount,\n sendBridgeToken,\n sendMint,\n sendPool,\n sendUserToken,\n receiveBridgeToken,\n receiveMint,\n receivePool,\n receiveUserToken,\n })\n .preInstructions(preInstructions)\n .transaction();\n\n const connection = provider.connection;\n transaction.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;\n transaction.feePayer = userAccount;\n await addUnitLimitAndUnitPriceToTx(transaction, txFeeParams, this.solanaRpcUrl);\n return await this.convertToVersionedTransaction(transaction, connection);\n }\n\n async buildRawTransactionSend(params: SendParams): Promise<RawTransaction> {\n const txSendParams = await prepareTxSendParams(this.chainType, params, this.api);\n let solTxSendParams = this.addPoolAddress(params, txSendParams);\n\n const isJupiterForStableCoin = solTxSendParams.gasFeePaymentMethod == FeePaymentMethod.WITH_STABLECOIN;\n\n let jupTx;\n if (isJupiterForStableCoin) {\n try {\n const { tx, solTxSendUpdatedParams } = await this.processJup(solTxSendParams, params, true);\n jupTx = tx;\n solTxSendParams = { ...solTxSendParams, ...solTxSendUpdatedParams };\n } catch (e) {\n try {\n const { tx, solTxSendUpdatedParams } = await this.processJup(solTxSendParams, params, false);\n jupTx = tx;\n solTxSendParams = { ...solTxSendParams, ...solTxSendUpdatedParams };\n } catch (e) {\n if (e instanceof SdkRootError) {\n throw e;\n }\n if (e instanceof Error && e.message) {\n throw new JupiterError(`Some error occurred during creation Jupiter swap transaction. ${e.message}`);\n }\n throw new JupiterError(\"Some error occurred during creation Jupiter swap transaction\");\n }\n }\n }\n\n let swapAndBridgeTx: VersionedTransaction;\n let requiredMessageSigner: Keypair | undefined = undefined;\n switch (txSendParams.messenger) {\n case Messenger.ALLBRIDGE: {\n const swapAndBridgeSolData = await this.prepareSwapAndBridgeData(solTxSendParams);\n swapAndBridgeTx = await this.buildSwapAndBridgeAllbridgeTransaction(swapAndBridgeSolData);\n break;\n }\n case Messenger.WORMHOLE: {\n const swapAndBridgeSolData = await this.prepareSwapAndBridgeData(solTxSendParams);\n const { transaction, messageAccount } = await this.buildSwapAndBridgeWormholeTransaction(swapAndBridgeSolData);\n swapAndBridgeTx = transaction;\n requiredMessageSigner = messageAccount;\n break;\n }\n case Messenger.CCTP: {\n const swapAndBridgeSolData = await this.prepareSwapAndBridgeCctpData(solTxSendParams);\n const { transaction, messageSentEventDataKeypair } = await this.buildSwapAndBridgeCctpTransaction(\n params.destinationToken.chainSymbol,\n swapAndBridgeSolData\n );\n swapAndBridgeTx = transaction;\n requiredMessageSigner = messageSentEventDataKeypair;\n break;\n }\n }\n\n if (isJupiterForStableCoin) {\n if (!jupTx) {\n throw new JupiterError(\"Swap tx is absent\");\n }\n swapAndBridgeTx = await this.jupiterService.amendJupiterWithSdkTx(jupTx, swapAndBridgeTx);\n }\n\n await addUnitLimitAndUnitPriceToVersionedTx(swapAndBridgeTx, params.txFeeParams, this.solanaRpcUrl);\n\n if (requiredMessageSigner) {\n swapAndBridgeTx.sign([requiredMessageSigner]);\n }\n return swapAndBridgeTx;\n }\n\n private async processJup(\n solTxSendParams: SolTxSendParams,\n params: SendParams,\n exactOut: boolean\n ): Promise<{\n tx: VersionedTransaction;\n solTxSendUpdatedParams: {\n amount: string;\n fee: string;\n extraGas?: string;\n gasFeePaymentMethod: FeePaymentMethod;\n };\n }> {\n const { fee, extraGas, gasFeePaymentMethod } = await this.convertStableCoinFeeAndExtraGasToNativeCurrency(\n params.sourceToken.decimals,\n solTxSendParams\n );\n\n let amountToProcess = exactOut ? Big(fee) : Big(solTxSendParams.fee);\n if (extraGas) {\n amountToProcess = amountToProcess.plus(extraGas);\n }\n if (!exactOut) {\n amountToProcess = amountToProcess.mul(JUP_ADD_INDEX);\n }\n\n const { tx, amountIn } = await this.jupiterService.getJupiterSwapTx(\n params.fromAccountAddress,\n params.sourceToken.tokenAddress,\n amountToProcess.toFixed(0),\n exactOut\n );\n\n let newAmount: string;\n if (exactOut) {\n if (!amountIn) {\n throw new JupiterError(\"Cannot get inAmount\");\n }\n newAmount = Big(solTxSendParams.amount).minus(Big(amountIn).mul(JUP_ADD_INDEX)).toFixed(0);\n } else {\n newAmount = Big(solTxSendParams.amount).minus(amountToProcess).toFixed(0);\n }\n if (Big(newAmount).lte(0)) {\n throw new AmountNotEnoughError(\n `Amount not enough to pay fee, ${convertIntAmountToFloat(\n Big(newAmount).minus(1).neg(),\n params.sourceToken.decimals\n ).toFixed()} stables is missing`\n );\n }\n return {\n tx: tx,\n solTxSendUpdatedParams: {\n amount: newAmount,\n fee: fee,\n extraGas: extraGas,\n gasFeePaymentMethod: gasFeePaymentMethod,\n },\n };\n }\n\n private addPoolAddress(params: SendParams, txSendParams: TxSendParamsSol): SolTxSendParams {\n return {\n ...txSendParams,\n poolAddress: params.sourceToken.poolAddress,\n };\n }\n\n async convertStableCoinFeeAndExtraGasToNativeCurrency(\n tokenDecimals: number,\n solTxSendParams: SolTxSendParams\n ): Promise<{ fee: string; extraGas?: string; gasFeePaymentMethod: FeePaymentMethod }> {\n if (solTxSendParams.gasFeePaymentMethod == FeePaymentMethod.WITH_STABLECOIN) {\n const sourceNativeTokenPrice = (\n await this.api.getReceiveTransactionCost({\n sourceChainId: solTxSendParams.fromChainId,\n destinationChainId: solTxSendParams.toChainId,\n messenger: solTxSendParams.messenger,\n })\n ).sourceNativeTokenPrice;\n const fee = Big(solTxSendParams.fee)\n .div(sourceNativeTokenPrice)\n .mul(Big(10).pow(Chains.getChainDecimalsByType(ChainType.SOLANA) - tokenDecimals))\n .toFixed(0);\n let extraGas;\n if (solTxSendParams.extraGas) {\n extraGas = Big(solTxSendParams.extraGas)\n .div(sourceNativeTokenPrice)\n .mul(Big(10).pow(Chains.getChainDecimalsByType(ChainType.SOLANA) - tokenDecimals))\n .toFixed(0);\n }\n return { fee, extraGas, gasFeePaymentMethod: FeePaymentMethod.WITH_NATIVE_CURRENCY };\n }\n return {\n fee: solTxSendParams.fee,\n extraGas: solTxSendParams.extraGas,\n gasFeePaymentMethod: FeePaymentMethod.WITH_NATIVE_CURRENCY,\n };\n }\n\n private getExtraGasInstruction(\n extraGas: string,\n userAccount: PublicKey,\n configAccount: PublicKey\n ): TransactionInstruction | undefined {\n return web3.SystemProgram.transfer({\n fromPubkey: userAccount,\n toPubkey: configAccount,\n lamports: +extraGas,\n });\n }\n\n private async prepareSwapAndBridgeData(txSendParams: SolTxSendParams): Promise<SwapAndBridgeSolData> {\n const {\n amount,\n contractAddress,\n fromChainId,\n fromAccountAddress,\n fromTokenAddress,\n toChainId,\n toAccountAddress,\n toTokenAddress,\n poolAddress,\n extraGas,\n } = txSendParams;\n const tokenAddress = fromTokenAddress;\n const account = fromAccountAddress;\n const destinationChainId = toChainId;\n const receiveTokenAddress = toTokenAddress;\n const receiverInBuffer32 = toAccountAddress;\n const bridgeAddress = contractAddress;\n const sourceChainId = fromChainId;\n\n const provider = buildAnchorProvider(this.solanaRpcUrl, account);\n const bridge = new Program<BridgeType>(bridgeIdl, bridgeAddress, provider);\n const nonce = Array.from(getNonce());\n const poolAccount = new PublicKey(poolAddress);\n const vUsdAmount = await getVUsdAmount(amount, bridge, poolAccount);\n\n const lockAccount = await getLockAccount(nonce, bridge.programId);\n const bridgeAuthority = await getAuthorityAccount(bridge.programId);\n const userToken = await getAssociatedAccount(new PublicKey(account), new PublicKey(tokenAddress));\n const bridgeTokenAccount = await getBridgeTokenAccount(new PublicKey(tokenAddress), bridge.programId);\n const chainBridgeAccount = await getChainBridgeAccount(destinationChainId, bridge.programId);\n const otherBridgeTokenAccount = await getOtherChainTokenAccount(\n destinationChainId,\n Buffer.from(receiveTokenAddress),\n bridge.programId\n );\n\n const configAccount = await getConfigAccount(bridge.programId);\n const configAccountInfo = await bridge.account.config.fetch(configAccount);\n const priceAccount = await getPriceAccount(destinationChainId, configAccountInfo.gasOracleProgramId);\n const thisGasPriceAccount = await getPriceAccount(sourceChainId, configAccountInfo.gasOracleProgramId);\n\n const message = getMessage({\n amount: vUsdAmount,\n recipient: Buffer.from(receiverInBuffer32),\n nonce: Buffer.from(nonce),\n receiveToken: Buffer.from(receiveTokenAddress),\n destinationChainId,\n sourceChainId,\n chainBridge: (await getAuthorityAccount(bridge.programId)).toBuffer(),\n });\n\n const swapAndBridgeData = {} as SwapAndBridgeSolData;\n\n swapAndBridgeData.bridge = bridge;\n swapAndBridgeData.amount = new BN(amount);\n swapAndBridgeData.vusdAmount = new BN(vUsdAmount);\n swapAndBridgeData.nonce = nonce;\n swapAndBridgeData.recipient = Array.from(receiverInBuffer32);\n swapAndBridgeData.receiveToken = Array.from(receiveTokenAddress);\n swapAndBridgeData.poolAccount = poolAccount;\n swapAndBridgeData.lockAccount = lockAccount;\n swapAndBridgeData.bridgeAuthority = bridgeAuthority;\n swapAndBridgeData.userToken = userToken;\n swapAndBridgeData.bridgeTokenAccount = bridgeTokenAccount;\n swapAndBridgeData.chainBridgeAccount = chainBridgeAccount;\n swapAndBridgeData.otherBridgeTokenAccount = otherBridgeTokenAccount;\n swapAndBridgeData.userAccount = new PublicKey(account);\n swapAndBridgeData.destinationChainId = destinationChainId;\n // @ts-expect-error\n swapAndBridgeData.mint = new PublicKey(tokenAddress);\n swapAndBridgeData.config = configAccount;\n swapAndBridgeData.configAccountInfo = configAccountInfo;\n swapAndBridgeData.gasPrice = priceAccount;\n swapAndBridgeData.thisGasPrice = thisGasPriceAccount;\n swapAndBridgeData.message = message;\n\n if (extraGas) {\n swapAndBridgeData.extraGasInstruction = this.getExtraGasInstruction(\n extraGas,\n swapAndBridgeData.userAccount,\n configAccount\n );\n }\n return swapAndBridgeData;\n }\n\n private async buildSwapAndBridgeAllbridgeTransaction(\n swapAndBridgeData: SwapAndBridgeSolData\n ): Promise<VersionedTransaction> {\n const {\n bridge,\n vusdAmount,\n nonce,\n recipient,\n receiveToken,\n poolAccount,\n lockAccount,\n bridgeAuthority,\n userToken,\n bridgeTokenAccount,\n chainBridgeAccount,\n otherBridgeTokenAccount,\n userAccount,\n destinationChainId,\n mint,\n config,\n configAccountInfo,\n gasPrice,\n thisGasPrice,\n message,\n extraGasInstruction,\n } = swapAndBridgeData;\n const allbridgeMessengerProgramId = configAccountInfo.allbridgeMessengerProgramId;\n const messengerGasUsageAccount = await getGasUsageAccount(destinationChainId, allbridgeMessengerProgramId);\n const messengerConfig = await getConfigAccount(allbridgeMessengerProgramId);\n\n const sentMessageAccount = await getSendMessageAccount(message, allbridgeMessengerProgramId);\n\n const instructions: TransactionInstruction[] = [];\n if (extraGasInstruction) {\n instructions.push(extraGasInstruction);\n }\n\n const transaction = await bridge.methods\n .swapAndBridge({\n vusdAmount,\n nonce,\n destinationChainId,\n recipient,\n receiveToken,\n })\n .accounts({\n mint,\n user: userAccount,\n config,\n lock: lockAccount,\n pool: poolAccount,\n gasPrice,\n thisGasPrice,\n bridgeAuthority,\n userToken,\n bridgeToken: bridgeTokenAccount,\n chainBridge: chainBridgeAccount,\n messenger: allbridgeMessengerProgramId,\n messengerGasUsage: messengerGasUsageAccount,\n messengerConfig,\n sentMessageAccount,\n otherBridgeToken: otherBridgeTokenAccount,\n })\n .preInstructions([\n web3.ComputeBudgetProgram.setComputeUnitLimit({\n units: COMPUTE_UNIT_LIMIT,\n }),\n ])\n .postInstructions(instructions)\n .transaction();\n const connection = buildAnchorProvider(this.solanaRpcUrl, userAccount.toString()).connection;\n transaction.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;\n transaction.feePayer = userAccount;\n return await this.convertToVersionedTransaction(transaction, connection);\n }\n\n private async convertToVersionedTransaction(tx: Transaction, connection: Connection): Promise<VersionedTransaction> {\n const allbridgeTableAccount = await connection\n .getAddressLookupTable(new PublicKey(this.params.solanaLookUpTable))\n .then((res) => res.value);\n if (!allbridgeTableAccount) {\n throw new SdkError(\"Cannot find allbridgeLookupTableAccount\");\n }\n const messageV0 = new web3.TransactionMessage({\n payerKey: tx.feePayer,\n recentBlockhash: tx.recentBlockhash,\n instructions: tx.instructions,\n } as TransactionMessageArgs).compileToV0Message([allbridgeTableAccount]);\n return new web3.VersionedTransaction(messageV0);\n }\n\n private async buildSwapAndBridgeWormholeTransaction(\n swapAndBridgeData: SwapAndBridgeSolData\n ): Promise<{ transaction: VersionedTransaction; messageAccount: Keypair }> {\n const {\n bridge,\n vusdAmount,\n nonce,\n recipient,\n receiveToken,\n poolAccount,\n lockAccount,\n bridgeAuthority,\n userToken,\n bridgeTokenAccount,\n chainBridgeAccount,\n otherBridgeTokenAccount,\n userAccount,\n destinationChainId,\n mint,\n config,\n configAccountInfo,\n gasPrice,\n thisGasPrice,\n message,\n extraGasInstruction,\n } = swapAndBridgeData;\n const wormholeProgramId = this.params.wormholeMessengerProgramId;\n\n const [whBridgeAccount] = PublicKey.findProgramAddressSync(\n [Buffer.from(\"Bridge\")],\n new PublicKey(wormholeProgramId)\n );\n const [whFeeCollectorAccount] = PublicKey.findProgramAddressSync(\n [Buffer.from(\"fee_collector\")],\n new PublicKey(wormholeProgramId)\n );\n const [whSequenceAccount] = PublicKey.findProgramAddressSync(\n [Buffer.from(\"Sequence\"), bridgeAuthority.toBuffer()],\n new PublicKey(wormholeProgramId)\n );\n\n const messengerGasUsageAccount = await getGasUsageAccount(\n destinationChainId,\n configAccountInfo.wormholeMessengerProgramId\n );\n const wormholeMessengerConfigAccount = await getConfigAccount(configAccountInfo.wormholeMessengerProgramId);\n const messageAccount = Keypair.generate();\n\n const provider = buildAnchorProvider(this.solanaRpcUrl, userAccount.toString());\n\n const bridgeAccountInfo = await provider.connection.getAccountInfo(whBridgeAccount);\n if (bridgeAccountInfo == null) {\n throw new SdkError(\"Cannot fetch wormhole bridge account info\");\n }\n const feeLamports = new BN(bridgeAccountInfo.data.slice(16, 24), \"le\").toString();\n\n const feeInstruction = SystemProgram.transfer({\n fromPubkey: userAccount,\n toPubkey: whFeeCollectorAccount,\n lamports: +feeLamports,\n });\n\n const instructions: TransactionInstruction[] = [];\n if (extraGasInstruction) {\n instructions.push(extraGasInstruction);\n }\n\n const accounts = {\n mint,\n user: userAccount,\n config,\n lock: lockAccount,\n pool: poolAccount,\n gasPrice,\n thisGasPrice,\n bridgeAuthority,\n userToken,\n bridgeToken: bridgeTokenAccount,\n chainBridge: chainBridgeAccount,\n otherBridgeToken: otherBridgeTokenAccount,\n messengerGasUsage: messengerGasUsageAccount,\n wormholeProgram: wormholeProgramId,\n bridge: whBridgeAccount,\n message: messageAccount.publicKey,\n wormholeMessenger: configAccountInfo.wormholeMessengerProgramId,\n sequence: whSequenceAccount,\n feeCollector: whFeeCollectorAccount,\n wormholeMessengerConfig: wormholeMessengerConfigAccount,\n clock: web3.SYSVAR_CLOCK_PUBKEY,\n };\n\n const transaction = await bridge.methods\n .swapAndBridgeWormhole({\n vusdAmount,\n nonce: nonce,\n destinationChainId,\n recipient,\n receiveToken,\n })\n .accounts(accounts)\n .preInstructions([\n web3.ComputeBudgetProgram.setComputeUnitLimit({\n units: COMPUTE_UNIT_LIMIT,\n }),\n feeInstruction,\n ])\n .postInstructions(instructions)\n .signers([messageAccount])\n .transaction();\n transaction.recentBlockhash = (await provider.connection.getLatestBlockhash()).blockhash;\n transaction.feePayer = userAccount;\n return { transaction: await this.convertToVersionedTransaction(transaction, provider.connection), messageAccount };\n }\n\n private async prepareSwapAndBridgeCctpData(txSendParams: SolTxSendParams): Promise<SwapAndBridgeSolDataCctpData> {\n const {\n contractAddress,\n amount,\n fromAccountAddress,\n fromTokenAddress,\n toChainId,\n toAccountAddress,\n toTokenAddress,\n extraGas,\n } = txSendParams;\n const cctpAddress = contractAddress;\n if (!cctpAddress) {\n throw new CCTPDoesNotSupportedError(\"Such route does not support CCTP protocol\");\n }\n const CHAIN_ID = 4;\n\n const account = fromAccountAddress;\n const receiveTokenAddress = toTokenAddress;\n const receiverInBuffer32 = toAccountAddress;\n\n const provider = buildAnchorProvider(this.solanaRpcUrl, account);\n const cctpBridge: Program<CctpBridgeType> = new Program<CctpBridgeType>(cctpBridgeIdl, cctpAddress, provider);\n const mint = new PublicKey(fromTokenAddress);\n const cctpBridgeAccount = await getCctpBridgeAccount(mint, cctpBridge.programId);\n const userAccount = new PublicKey(account);\n\n const configAccountInfo = await cctpBridge.account.cctpBridge.fetch(cctpBridgeAccount);\n\n const swapAndBridgeData = {} as SwapAndBridgeSolDataCctpData;\n\n swapAndBridgeData.cctpBridge = cctpBridge;\n swapAndBridgeData.cctpBridgeAccount = cctpBridgeAccount;\n swapAndBridgeData.cctpAddressAccount = new PublicKey(cctpAddress);\n swapAndBridgeData.amount = new BN(amount);\n swapAndBridgeData.recipient = Array.from(receiverInBuffer32);\n swapAndBridgeData.receiveToken = Array.from(receiveTokenAddress);\n swapAndBridgeData.userToken = await getAssociatedAccount(userAccount, mint);\n swapAndBridgeData.bridgeAuthority = await getCctpAuthorityAccount(cctpBridgeAccount, cctpBridge.programId);\n swapAndBridgeData.bridgeTokenAccount = await getCctpBridgeTokenAccount(mint, cctpBridge.programId);\n swapAndBridgeData.chainBridgeAccount = await getChainBridgeAccount(toChainId, cctpBridge.programId);\n swapAndBridgeData.userAccount = userAccount;\n swapAndBridgeData.destinationChainId = toChainId;\n swapAndBridgeData.mint = mint;\n swapAndBridgeData.gasPrice = await getPriceAccount(toChainId, configAccountInfo.gasOracleProgramId);\n swapAndBridgeData.thisGasPrice = await getPriceAccount(CHAIN_ID, configAccountInfo.gasOracleProgramId);\n swapAndBridgeData.provider = provider;\n\n if (extraGas) {\n swapAndBridgeData.extraGasInstruction = this.getExtraGasInstruction(\n extraGas,\n swapAndBridgeData.userAccount,\n cctpBridgeAccount\n );\n }\n return swapAndBridgeData;\n }\n\n async buildSwapAndBridgeCctpTransaction(\n destinationChainSymbol: string,\n swapAndBridgeData: SwapAndBridgeSolDataCctpData\n ): Promise<{ transaction: VersionedTransaction; messageSentEventDataKeypair: Keypair }> {\n const {\n cctpBridge,\n cctpBridgeAccount,\n amount,\n recipient,\n receiveToken,\n bridgeAuthority,\n userToken,\n bridgeTokenAccount,\n chainBridgeAccount,\n userAccount,\n destinationChainId,\n mint,\n gasPrice,\n thisGasPrice,\n extraGasInstruction,\n provider,\n } = swapAndBridgeData;\n const domain = this.params.cctpParams.cctpDomains[destinationChainSymbol];\n const cctpTransmitterProgramIdAddress = this.params.cctpParams.cctpTransmitterProgramId;\n const cctpTokenMessengerMinterAddress = this.params.cctpParams.cctpTokenMessengerMinter;\n if (domain == undefined || !cctpTransmitterProgramIdAddress || !cctpTokenMessengerMinterAddress) {\n throw new SdkError(\"CCTP is not configured\");\n }\n const cctpTransmitterProgramId = new PublicKey(cctpTransmitterProgramIdAddress);\n const cctpTokenMessengerMinter = new PublicKey(cctpTokenMessengerMinterAddress);\n const {\n messageTransmitterAccount,\n tokenMessenger,\n tokenMessengerEventAuthority,\n tokenMinter,\n localToken,\n remoteTokenMessengerKey,\n authorityPda,\n } = getCctpAccounts(domain, mint, cctpTransmitterProgramId, cctpTokenMessengerMinter);\n\n const instructions: TransactionInstruction[] = [];\n if (extraGasInstruction) {\n instructions.push(extraGasInstruction);\n }\n\n const messageSentEventDataKeypair = Keypair.generate();\n const lockAccount = getCctpLockAccount(cctpBridge.programId, messageSentEventDataKeypair.publicKey);\n\n const tx = await cctpBridge.methods\n .bridge({\n amount,\n destinationChainId,\n recipient,\n receiveToken,\n })\n .accounts({\n mint: mint,\n user: userAccount,\n cctpBridge: cctpBridgeAccount,\n\n messageSentEventData: messageSentEventDataKeypair.publicKey,\n lock: lockAccount,\n\n cctpMessenger: cctpTokenMessengerMinter,\n messageTransmitterProgram: cctpTransmitterProgramId,\n messageTransmitterAccount: messageTransmitterAccount,\n tokenMessenger: tokenMessenger,\n tokenMinter: tokenMinter,\n localToken: localToken,\n remoteTokenMessengerKey: remoteTokenMessengerKey,\n authorityPda: authorityPda,\n eventAuthority: tokenMessengerEventAuthority,\n\n bridgeToken: bridgeTokenAccount,\n gasPrice: gasPrice,\n thisGasPrice: thisGasPrice,\n chainBridge: chainBridgeAccount,\n userToken,\n bridgeAuthority: bridgeAuthority,\n })\n .preInstructions([\n web3.ComputeBudgetProgram.setComputeUnitLimit({\n units: 2000000,\n }),\n ])\n .postInstructions(instructions)\n .transaction();\n const connection = provider.connection;\n tx.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;\n tx.feePayer = userAccount;\n return { transaction: await this.convertToVersionedTransaction(tx, connection), messageSentEventDataKeypair };\n }\n\n send(params: SendParams): Promise<TransactionResponse> {\n throw new MethodNotSupportedError();\n }\n}\n\ninterface SolTxSendParams extends TxSendParamsSol {\n poolAddress: string;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/services/bridge/sol/index.ts"],"names":[],"mappings":";;;AAAA,sDAAsD;AACtD,sDAAsD;AACtD,kDAA+D;AAC/D,6CASyB;AACzB,mCAA6B;AAC7B,4CAAyC;AACzC,4EAAoE;AAEpE,oDAO6B;AAC7B,4CAAuF;AACvF,4DAAqE;AAGrE,0DAAuF;AACvF,oEAAwG;AACxG,yCAAiF;AACjF,uDAgBkC;AAClC,qEAAsE;AACtE,mEAAqH;AAErH,6CAAsD;AACtD,oCAA8E;AAC9E,uCAA2C;AA8B3C,MAAM,kBAAkB,GAAG,OAAO,CAAC;AAEnC,MAAM,aAAa,GAAG,GAAG,CAAC;AAE1B,MAAa,mBAAoB,SAAQ,2BAAkB;IAKhD;IACA;IACA;IANT,SAAS,GAAqB,kBAAS,CAAC,MAAM,CAAC;IAC/C,cAAc,CAAiB;IAE/B,YACS,YAAoB,EACpB,MAA0B,EAC1B,GAAwB;QAE/B,KAAK,EAAE,CAAC;QAJD,iBAAY,GAAZ,YAAY,CAAQ;QACpB,WAAM,GAAN,MAAM,CAAoB;QAC1B,QAAG,GAAH,GAAG,CAAqB;QAG/B,IAAI,CAAC,cAAc,GAAG,IAAI,wBAAc,CAAC,YAAY,EAAE,MAAM,CAAC,aAAa,CAAC,CAAC;IAC/E,CAAC;IAED,KAAK,CAAC,uBAAuB,CAAC,MAAkB;QAC9C,MAAM,YAAY,GAAG,IAAA,2BAAmB,EAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QACjE,OAAO,MAAM,IAAI,CAAC,oBAAoB,CACpC,YAAY,EACZ,MAAM,CAAC,WAAW,CAAC,WAAW,EAC9B,MAAM,CAAC,gBAAgB,CAAC,WAAW,EACnC,MAAM,CAAC,WAAW,CACnB,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,oBAAoB,CAChC,MAAuB,EACvB,WA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EAAE,IAAI;YACV,IAAI,EAAE,WAAW;YACjB,UAAU,EAAE,iBAAiB;YAE7B,oBAAoB,EAAE,2BAA2B,CAAC,SAAS;YAC3D,IAAI,EAAE,WAAW;YAEjB,aAAa,EAAE,wBAAwB;YACvC,yBAAyB,EAAE,wBAAwB;YACnD,yBAAyB,EAAE,yBAAyB;YACpD,cAAc,EAAE,cAAc;YAC9B,WAAW,EAAE,WAAW;YACxB,UAAU,EAAE,UAAU;YACtB,uBAAuB,EAAE,uBAAuB;YAChD,YAAY,EAAE,YAAY;YAC1B,cAAc,EAAE,4BAA4B;YAE5C,WAAW,EAAE,kBAAkB;YAC/B,QAAQ,EAAE,QAAQ;YAClB,YAAY,EAAE,YAAY;YAC1B,WAAW,EAAE,kBAAkB;YAC/B,SAAS;YACT,eAAe,EAAE,eAAe;SACjC,CAAC;aACD,eAAe,CAAC;YACf,aAAI,CAAC,oBAAoB,CAAC,mBAAmB,CAAC;gBAC5C,KAAK,EAAE,OAAO;aACf,CAAC;SACH,CAAC;aACD,gBAAgB,CAAC,YAAY,CAAC;aAC9B,WAAW,EAAE,CAAC;QACjB,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC;QACvC,EAAE,CAAC,eAAe,GAAG,CAAC,MAAM,UAAU,CAAC,kBAAkB,EAAE,CAAC,CAAC,SAAS,CAAC;QACvE,EAAE,CAAC,QAAQ,GAAG,WAAW,CAAC;QAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC,6BAA6B,CAAC,EAAE,EAAE,UAAU,CAAC,EAAE,2BAA2B,EAAE,CAAC;IAChH,CAAC;IAED,IAAI,CAAC,MAAkB;QACrB,MAAM,IAAI,oCAAuB,EAAE,CAAC;IACtC,CAAC;CACF;AAnuBD,kDAmuBC","sourcesContent":["/* eslint-disable @typescript-eslint/ban-ts-comment */\n/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { BN, Program, Spl, web3 } from \"@project-serum/anchor\";\nimport {\n Connection,\n Keypair,\n PublicKey,\n SystemProgram,\n Transaction,\n TransactionInstruction,\n TransactionMessageArgs,\n VersionedTransaction,\n} from \"@solana/web3.js\";\nimport { Big } from \"big.js\";\nimport { Chains } from \"../../../chains\";\nimport { Messenger } from \"../../../client/core-api/core-api.model\";\nimport { AllbridgeCoreClient } from \"../../../client/core-api/core-client-base\";\nimport {\n AmountNotEnoughError,\n CCTPDoesNotSupportedError,\n JupiterError,\n MethodNotSupportedError,\n SdkError,\n SdkRootError,\n} from \"../../../exceptions\";\nimport { ChainType, FeePaymentMethod, SwapParams, TxFeeParams } from \"../../../models\";\nimport { convertIntAmountToFloat } from \"../../../utils/calculation\";\nimport { RawTransaction, TransactionResponse } from \"../../models\";\nimport { SwapAndBridgeSolData, SwapAndBridgeSolDataCctpData } from \"../../models/sol\";\nimport { Bridge as BridgeType, IDL as bridgeIdl } from \"../../models/sol/types/bridge\";\nimport { CctpBridge as CctpBridgeType, IDL as cctpBridgeIdl } from \"../../models/sol/types/cctp_bridge\";\nimport { getMessage, getTokenAccountData, getVUsdAmount } from \"../../utils/sol\";\nimport {\n getAssociatedAccount,\n getAuthorityAccount,\n getBridgeTokenAccount,\n getCctpAccounts,\n getCctpAuthorityAccount,\n getCctpBridgeAccount,\n getCctpBridgeTokenAccount,\n getCctpLockAccount,\n getChainBridgeAccount,\n getConfigAccount,\n getGasUsageAccount,\n getLockAccount,\n getOtherChainTokenAccount,\n getPriceAccount,\n getSendMessageAccount,\n} from \"../../utils/sol/accounts\";\nimport { buildAnchorProvider } from \"../../utils/sol/anchor-provider\";\nimport { addUnitLimitAndUnitPriceToTx, addUnitLimitAndUnitPriceToVersionedTx } from \"../../utils/sol/compute-budget\";\nimport { SendParams, TxSendParamsSol, TxSwapParamsSol } from \"../models\";\nimport { ChainBridgeService } from \"../models/bridge\";\nimport { getNonce, prepareTxSendParams, prepareTxSwapParams } from \"../utils\";\nimport { JupiterService } from \"./jupiter\";\n\nexport interface SolanaBridgeParams {\n wormholeMessengerProgramId: string;\n solanaLookUpTable: string;\n cctpParams: CctpParams;\n jupiterParams: JupiterParams;\n}\n\nexport interface JupiterParams {\n jupiterUrl: string;\n jupiterApiKeyHeader?: string;\n jupiterMaxAccounts?: number;\n}\n\nexport interface CctpParams {\n cctpTransmitterProgramId: string;\n cctpTokenMessengerMinter: string;\n cctpDomains: CctpDomains;\n}\n\n/**\n * Type representing a map of CCTP domains to their corresponding numeric values.\n *\n * @typedef {Record<string, number>} CctpDomains\n * @property {string} chainSymbol - The symbol of the chain representing one of the supported blockchain networks (e.g., \"ETH\" for Ethereum). For more details, see: {@link ChainSymbol}.\n * @property {number} value - The numeric value associated with the specified chain.\n */\nexport type CctpDomains = Record<string, number>;\n\nconst COMPUTE_UNIT_LIMIT = 1000000;\n\nconst JUP_ADD_INDEX = 1.1;\n\nexport class SolanaBridgeService extends ChainBridgeService {\n chainType: ChainType.SOLANA = ChainType.SOLANA;\n jupiterService: JupiterService;\n\n constructor(\n public solanaRpcUrl: string,\n public params: SolanaBridgeParams,\n public api: AllbridgeCoreClient\n ) {\n super();\n this.jupiterService = new JupiterService(solanaRpcUrl, params.jupiterParams);\n }\n\n async buildRawTransactionSwap(params: SwapParams): Promise<RawTransaction> {\n const txSwapParams = prepareTxSwapParams(this.chainType, params);\n return await this.buildSwapTransaction(\n txSwapParams,\n params.sourceToken.poolAddress,\n params.destinationToken.poolAddress,\n params.txFeeParams\n );\n }\n\n private async buildSwapTransaction(\n params: TxSwapParamsSol,\n poolAddress: string,\n toPoolAddress: string,\n txFeeParams?: TxFeeParams\n ): Promise<VersionedTransaction> {\n const {\n fromAccountAddress,\n amount,\n contractAddress,\n fromTokenAddress,\n toTokenAddress,\n toAccountAddress,\n minimumReceiveAmount,\n } = params;\n const account = fromAccountAddress;\n const bridgeAddress = contractAddress;\n const tokenAddress = fromTokenAddress;\n const receiveTokenAddress = toTokenAddress;\n const receivePoolAddress = toPoolAddress;\n const receiverOriginal = toAccountAddress;\n\n const userAccount = new PublicKey(account);\n const provider = buildAnchorProvider(this.solanaRpcUrl, userAccount.toString());\n const bridge = new Program<BridgeType>(bridgeIdl, bridgeAddress, provider);\n\n const bridgeAuthority = await getAuthorityAccount(bridge.programId);\n const configAccount = await getConfigAccount(bridge.programId);\n\n const sendMint = new PublicKey(tokenAddress);\n const sendBridgeToken = await getBridgeTokenAccount(sendMint, bridge.programId);\n const sendPool = new PublicKey(poolAddress);\n const sendUserToken = await getAssociatedAccount(userAccount, sendMint);\n\n const receiverAccount = new PublicKey(receiverOriginal);\n const receiveMint = new PublicKey(receiveTokenAddress);\n const receiveBridgeToken = await getBridgeTokenAccount(receiveMint, bridge.programId);\n const receivePool = new PublicKey(receivePoolAddress);\n const receiveUserToken = await getAssociatedAccount(receiverAccount, receiveMint);\n\n const preInstructions: TransactionInstruction[] = [\n web3.ComputeBudgetProgram.setComputeUnitLimit({\n units: COMPUTE_UNIT_LIMIT,\n }),\n ];\n\n try {\n await getTokenAccountData(receiveUserToken, provider);\n } catch (e) {\n const associatedProgram = Spl.associatedToken(provider);\n const createReceiveUserTokenInstruction: TransactionInstruction = await associatedProgram.methods\n .create()\n .accounts({\n mint: receiveMint,\n owner: receiverAccount,\n associatedAccount: receiveUserToken,\n })\n .instruction();\n preInstructions.push(createReceiveUserTokenInstruction);\n }\n const transaction = await bridge.methods\n .swap(new BN(amount), new BN(minimumReceiveAmount || 0))\n .accounts({\n payer: userAccount,\n config: configAccount,\n bridgeAuthority,\n user: userAccount,\n sendBridgeToken,\n sendMint,\n sendPool,\n sendUserToken,\n receiveBridgeToken,\n receiveMint,\n receivePool,\n receiveUserToken,\n })\n .preInstructions(preInstructions)\n .transaction();\n\n const connection = provider.connection;\n transaction.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;\n transaction.feePayer = userAccount;\n await addUnitLimitAndUnitPriceToTx(transaction, txFeeParams, this.solanaRpcUrl);\n return await this.convertToVersionedTransaction(transaction, connection);\n }\n\n async buildRawTransactionSend(params: SendParams): Promise<RawTransaction> {\n const txSendParams = await prepareTxSendParams(this.chainType, params, this.api);\n let solTxSendParams = this.addPoolAddress(params, txSendParams);\n\n const isJupiterForStableCoin = solTxSendParams.gasFeePaymentMethod == FeePaymentMethod.WITH_STABLECOIN;\n\n let jupTx;\n if (isJupiterForStableCoin) {\n try {\n const { tx, solTxSendUpdatedParams } = await this.processJup(solTxSendParams, params, true);\n jupTx = tx;\n solTxSendParams = { ...solTxSendParams, ...solTxSendUpdatedParams };\n } catch (e) {\n try {\n const { tx, solTxSendUpdatedParams } = await this.processJup(solTxSendParams, params, false);\n jupTx = tx;\n solTxSendParams = { ...solTxSendParams, ...solTxSendUpdatedParams };\n } catch (e) {\n if (e instanceof SdkRootError) {\n throw e;\n }\n if (e instanceof Error && e.message) {\n throw new JupiterError(`Some error occurred during creation Jupiter swap transaction. ${e.message}`);\n }\n throw new JupiterError(\"Some error occurred during creation Jupiter swap transaction\");\n }\n }\n }\n\n let swapAndBridgeTx: VersionedTransaction;\n let requiredMessageSigner: Keypair | undefined = undefined;\n switch (txSendParams.messenger) {\n case Messenger.ALLBRIDGE: {\n const swapAndBridgeSolData = await this.prepareSwapAndBridgeData(solTxSendParams);\n swapAndBridgeTx = await this.buildSwapAndBridgeAllbridgeTransaction(swapAndBridgeSolData);\n break;\n }\n case Messenger.WORMHOLE: {\n const swapAndBridgeSolData = await this.prepareSwapAndBridgeData(solTxSendParams);\n const { transaction, messageAccount } = await this.buildSwapAndBridgeWormholeTransaction(swapAndBridgeSolData);\n swapAndBridgeTx = transaction;\n requiredMessageSigner = messageAccount;\n break;\n }\n case Messenger.CCTP: {\n const swapAndBridgeSolData = await this.prepareSwapAndBridgeCctpData(solTxSendParams);\n const { transaction, messageSentEventDataKeypair } = await this.buildSwapAndBridgeCctpTransaction(\n params.destinationToken.chainSymbol,\n swapAndBridgeSolData\n );\n swapAndBridgeTx = transaction;\n requiredMessageSigner = messageSentEventDataKeypair;\n break;\n }\n }\n\n if (isJupiterForStableCoin) {\n if (!jupTx) {\n throw new JupiterError(\"Swap tx is absent\");\n }\n swapAndBridgeTx = await this.jupiterService.amendJupiterWithSdkTx(jupTx, swapAndBridgeTx);\n }\n\n await addUnitLimitAndUnitPriceToVersionedTx(swapAndBridgeTx, params.txFeeParams, this.solanaRpcUrl);\n\n if (requiredMessageSigner) {\n swapAndBridgeTx.sign([requiredMessageSigner]);\n }\n return swapAndBridgeTx;\n }\n\n private async processJup(\n solTxSendParams: SolTxSendParams,\n params: SendParams,\n exactOut: boolean\n ): Promise<{\n tx: VersionedTransaction;\n solTxSendUpdatedParams: {\n amount: string;\n fee: string;\n extraGas?: string;\n gasFeePaymentMethod: FeePaymentMethod;\n };\n }> {\n const { fee, extraGas, gasFeePaymentMethod } = await this.convertStableCoinFeeAndExtraGasToNativeCurrency(\n params.sourceToken.decimals,\n solTxSendParams\n );\n\n let amountToProcess = exactOut ? Big(fee) : Big(solTxSendParams.fee);\n if (extraGas) {\n amountToProcess = amountToProcess.plus(extraGas);\n }\n if (!exactOut) {\n amountToProcess = amountToProcess.mul(JUP_ADD_INDEX);\n }\n\n const { tx, amountIn } = await this.jupiterService.getJupiterSwapTx(\n params.fromAccountAddress,\n params.sourceToken.tokenAddress,\n amountToProcess.toFixed(0),\n exactOut\n );\n\n let newAmount: string;\n if (exactOut) {\n if (!amountIn) {\n throw new JupiterError(\"Cannot get inAmount\");\n }\n newAmount = Big(solTxSendParams.amount).minus(Big(amountIn).mul(JUP_ADD_INDEX)).toFixed(0);\n } else {\n newAmount = Big(solTxSendParams.amount).minus(amountToProcess).toFixed(0);\n }\n if (Big(newAmount).lte(0)) {\n throw new AmountNotEnoughError(\n `Amount not enough to pay fee, ${convertIntAmountToFloat(\n Big(newAmount).minus(1).neg(),\n params.sourceToken.decimals\n ).toFixed()} stables is missing`\n );\n }\n return {\n tx: tx,\n solTxSendUpdatedParams: {\n amount: newAmount,\n fee: fee,\n extraGas: extraGas,\n gasFeePaymentMethod: gasFeePaymentMethod,\n },\n };\n }\n\n private addPoolAddress(params: SendParams, txSendParams: TxSendParamsSol): SolTxSendParams {\n return {\n ...txSendParams,\n poolAddress: params.sourceToken.poolAddress,\n };\n }\n\n async convertStableCoinFeeAndExtraGasToNativeCurrency(\n tokenDecimals: number,\n solTxSendParams: SolTxSendParams\n ): Promise<{ fee: string; extraGas?: string; gasFeePaymentMethod: FeePaymentMethod }> {\n if (solTxSendParams.gasFeePaymentMethod == FeePaymentMethod.WITH_STABLECOIN) {\n const sourceNativeTokenPrice = (\n await this.api.getReceiveTransactionCost({\n sourceChainId: solTxSendParams.fromChainId,\n destinationChainId: solTxSendParams.toChainId,\n messenger: solTxSendParams.messenger,\n })\n ).sourceNativeTokenPrice;\n const fee = Big(solTxSendParams.fee)\n .div(sourceNativeTokenPrice)\n .mul(Big(10).pow(Chains.getChainDecimalsByType(ChainType.SOLANA) - tokenDecimals))\n .toFixed(0);\n let extraGas;\n if (solTxSendParams.extraGas) {\n extraGas = Big(solTxSendParams.extraGas)\n .div(sourceNativeTokenPrice)\n .mul(Big(10).pow(Chains.getChainDecimalsByType(ChainType.SOLANA) - tokenDecimals))\n .toFixed(0);\n }\n return { fee, extraGas, gasFeePaymentMethod: FeePaymentMethod.WITH_NATIVE_CURRENCY };\n }\n return {\n fee: solTxSendParams.fee,\n extraGas: solTxSendParams.extraGas,\n gasFeePaymentMethod: FeePaymentMethod.WITH_NATIVE_CURRENCY,\n };\n }\n\n private getExtraGasInstruction(\n extraGas: string,\n userAccount: PublicKey,\n configAccount: PublicKey\n ): TransactionInstruction | undefined {\n return web3.SystemProgram.transfer({\n fromPubkey: userAccount,\n toPubkey: configAccount,\n lamports: +extraGas,\n });\n }\n\n private async prepareSwapAndBridgeData(txSendParams: SolTxSendParams): Promise<SwapAndBridgeSolData> {\n const {\n amount,\n contractAddress,\n fromChainId,\n fromAccountAddress,\n fromTokenAddress,\n toChainId,\n toAccountAddress,\n toTokenAddress,\n poolAddress,\n extraGas,\n } = txSendParams;\n const tokenAddress = fromTokenAddress;\n const account = fromAccountAddress;\n const destinationChainId = toChainId;\n const receiveTokenAddress = toTokenAddress;\n const receiverInBuffer32 = toAccountAddress;\n const bridgeAddress = contractAddress;\n const sourceChainId = fromChainId;\n\n const provider = buildAnchorProvider(this.solanaRpcUrl, account);\n const bridge = new Program<BridgeType>(bridgeIdl, bridgeAddress, provider);\n const nonce = Array.from(getNonce());\n const poolAccount = new PublicKey(poolAddress);\n const vUsdAmount = await getVUsdAmount(amount, bridge, poolAccount);\n\n const lockAccount = await getLockAccount(nonce, bridge.programId);\n const bridgeAuthority = await getAuthorityAccount(bridge.programId);\n const userToken = await getAssociatedAccount(new PublicKey(account), new PublicKey(tokenAddress));\n const bridgeTokenAccount = await getBridgeTokenAccount(new PublicKey(tokenAddress), bridge.programId);\n const chainBridgeAccount = await getChainBridgeAccount(destinationChainId, bridge.programId);\n const otherBridgeTokenAccount = await getOtherChainTokenAccount(\n destinationChainId,\n Buffer.from(receiveTokenAddress),\n bridge.programId\n );\n\n const configAccount = await getConfigAccount(bridge.programId);\n const configAccountInfo = await bridge.account.config.fetch(configAccount);\n const priceAccount = await getPriceAccount(destinationChainId, configAccountInfo.gasOracleProgramId);\n const thisGasPriceAccount = await getPriceAccount(sourceChainId, configAccountInfo.gasOracleProgramId);\n\n const message = getMessage({\n amount: vUsdAmount,\n recipient: Buffer.from(receiverInBuffer32),\n nonce: Buffer.from(nonce),\n receiveToken: Buffer.from(receiveTokenAddress),\n destinationChainId,\n sourceChainId,\n chainBridge: (await getAuthorityAccount(bridge.programId)).toBuffer(),\n });\n\n const swapAndBridgeData = {} as SwapAndBridgeSolData;\n\n swapAndBridgeData.bridge = bridge;\n swapAndBridgeData.amount = new BN(amount);\n swapAndBridgeData.vusdAmount = new BN(vUsdAmount);\n swapAndBridgeData.nonce = nonce;\n swapAndBridgeData.recipient = Array.from(receiverInBuffer32);\n swapAndBridgeData.receiveToken = Array.from(receiveTokenAddress);\n swapAndBridgeData.poolAccount = poolAccount;\n swapAndBridgeData.lockAccount = lockAccount;\n swapAndBridgeData.bridgeAuthority = bridgeAuthority;\n swapAndBridgeData.userToken = userToken;\n swapAndBridgeData.bridgeTokenAccount = bridgeTokenAccount;\n swapAndBridgeData.chainBridgeAccount = chainBridgeAccount;\n swapAndBridgeData.otherBridgeTokenAccount = otherBridgeTokenAccount;\n swapAndBridgeData.userAccount = new PublicKey(account);\n swapAndBridgeData.destinationChainId = destinationChainId;\n // @ts-expect-error\n swapAndBridgeData.mint = new PublicKey(tokenAddress);\n swapAndBridgeData.config = configAccount;\n swapAndBridgeData.configAccountInfo = configAccountInfo;\n swapAndBridgeData.gasPrice = priceAccount;\n swapAndBridgeData.thisGasPrice = thisGasPriceAccount;\n swapAndBridgeData.message = message;\n\n if (extraGas) {\n swapAndBridgeData.extraGasInstruction = this.getExtraGasInstruction(\n extraGas,\n swapAndBridgeData.userAccount,\n configAccount\n );\n }\n return swapAndBridgeData;\n }\n\n private async buildSwapAndBridgeAllbridgeTransaction(\n swapAndBridgeData: SwapAndBridgeSolData\n ): Promise<VersionedTransaction> {\n const {\n bridge,\n vusdAmount,\n nonce,\n recipient,\n receiveToken,\n poolAccount,\n lockAccount,\n bridgeAuthority,\n userToken,\n bridgeTokenAccount,\n chainBridgeAccount,\n otherBridgeTokenAccount,\n userAccount,\n destinationChainId,\n mint,\n config,\n configAccountInfo,\n gasPrice,\n thisGasPrice,\n message,\n extraGasInstruction,\n } = swapAndBridgeData;\n const allbridgeMessengerProgramId = configAccountInfo.allbridgeMessengerProgramId;\n const messengerGasUsageAccount = await getGasUsageAccount(destinationChainId, allbridgeMessengerProgramId);\n const messengerConfig = await getConfigAccount(allbridgeMessengerProgramId);\n\n const sentMessageAccount = await getSendMessageAccount(message, allbridgeMessengerProgramId);\n\n const instructions: TransactionInstruction[] = [];\n if (extraGasInstruction) {\n instructions.push(extraGasInstruction);\n }\n\n const transaction = await bridge.methods\n .swapAndBridge({\n vusdAmount,\n nonce,\n destinationChainId,\n recipient,\n receiveToken,\n })\n .accounts({\n mint,\n user: userAccount,\n config,\n lock: lockAccount,\n pool: poolAccount,\n gasPrice,\n thisGasPrice,\n bridgeAuthority,\n userToken,\n bridgeToken: bridgeTokenAccount,\n chainBridge: chainBridgeAccount,\n messenger: allbridgeMessengerProgramId,\n messengerGasUsage: messengerGasUsageAccount,\n messengerConfig,\n sentMessageAccount,\n otherBridgeToken: otherBridgeTokenAccount,\n })\n .preInstructions([\n web3.ComputeBudgetProgram.setComputeUnitLimit({\n units: COMPUTE_UNIT_LIMIT,\n }),\n ])\n .postInstructions(instructions)\n .transaction();\n const connection = buildAnchorProvider(this.solanaRpcUrl, userAccount.toString()).connection;\n transaction.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;\n transaction.feePayer = userAccount;\n return await this.convertToVersionedTransaction(transaction, connection);\n }\n\n private async convertToVersionedTransaction(tx: Transaction, connection: Connection): Promise<VersionedTransaction> {\n const allbridgeTableAccount = await connection\n .getAddressLookupTable(new PublicKey(this.params.solanaLookUpTable))\n .then((res) => res.value);\n if (!allbridgeTableAccount) {\n throw new SdkError(\"Cannot find allbridgeLookupTableAccount\");\n }\n const messageV0 = new web3.TransactionMessage({\n payerKey: tx.feePayer,\n recentBlockhash: tx.recentBlockhash,\n instructions: tx.instructions,\n } as TransactionMessageArgs).compileToV0Message([allbridgeTableAccount]);\n return new web3.VersionedTransaction(messageV0);\n }\n\n private async buildSwapAndBridgeWormholeTransaction(\n swapAndBridgeData: SwapAndBridgeSolData\n ): Promise<{ transaction: VersionedTransaction; messageAccount: Keypair }> {\n const {\n bridge,\n vusdAmount,\n nonce,\n recipient,\n receiveToken,\n poolAccount,\n lockAccount,\n bridgeAuthority,\n userToken,\n bridgeTokenAccount,\n chainBridgeAccount,\n otherBridgeTokenAccount,\n userAccount,\n destinationChainId,\n mint,\n config,\n configAccountInfo,\n gasPrice,\n thisGasPrice,\n message,\n extraGasInstruction,\n } = swapAndBridgeData;\n const wormholeProgramId = this.params.wormholeMessengerProgramId;\n\n const [whBridgeAccount] = PublicKey.findProgramAddressSync(\n [Buffer.from(\"Bridge\")],\n new PublicKey(wormholeProgramId)\n );\n const [whFeeCollectorAccount] = PublicKey.findProgramAddressSync(\n [Buffer.from(\"fee_collector\")],\n new PublicKey(wormholeProgramId)\n );\n const [whSequenceAccount] = PublicKey.findProgramAddressSync(\n [Buffer.from(\"Sequence\"), bridgeAuthority.toBuffer()],\n new PublicKey(wormholeProgramId)\n );\n\n const messengerGasUsageAccount = await getGasUsageAccount(\n destinationChainId,\n configAccountInfo.wormholeMessengerProgramId\n );\n const wormholeMessengerConfigAccount = await getConfigAccount(configAccountInfo.wormholeMessengerProgramId);\n const messageAccount = Keypair.generate();\n\n const provider = buildAnchorProvider(this.solanaRpcUrl, userAccount.toString());\n\n const bridgeAccountInfo = await provider.connection.getAccountInfo(whBridgeAccount);\n if (bridgeAccountInfo == null) {\n throw new SdkError(\"Cannot fetch wormhole bridge account info\");\n }\n const feeLamports = new BN(bridgeAccountInfo.data.slice(16, 24), \"le\").toString();\n\n const feeInstruction = SystemProgram.transfer({\n fromPubkey: userAccount,\n toPubkey: whFeeCollectorAccount,\n lamports: +feeLamports,\n });\n\n const instructions: TransactionInstruction[] = [];\n if (extraGasInstruction) {\n instructions.push(extraGasInstruction);\n }\n\n const accounts = {\n mint,\n user: userAccount,\n config,\n lock: lockAccount,\n pool: poolAccount,\n gasPrice,\n thisGasPrice,\n bridgeAuthority,\n userToken,\n bridgeToken: bridgeTokenAccount,\n chainBridge: chainBridgeAccount,\n otherBridgeToken: otherBridgeTokenAccount,\n messengerGasUsage: messengerGasUsageAccount,\n wormholeProgram: wormholeProgramId,\n bridge: whBridgeAccount,\n message: messageAccount.publicKey,\n wormholeMessenger: configAccountInfo.wormholeMessengerProgramId,\n sequence: whSequenceAccount,\n feeCollector: whFeeCollectorAccount,\n wormholeMessengerConfig: wormholeMessengerConfigAccount,\n clock: web3.SYSVAR_CLOCK_PUBKEY,\n };\n\n const transaction = await bridge.methods\n .swapAndBridgeWormhole({\n vusdAmount,\n nonce: nonce,\n destinationChainId,\n recipient,\n receiveToken,\n })\n .accounts(accounts)\n .preInstructions([\n web3.ComputeBudgetProgram.setComputeUnitLimit({\n units: COMPUTE_UNIT_LIMIT,\n }),\n feeInstruction,\n ])\n .postInstructions(instructions)\n .signers([messageAccount])\n .transaction();\n transaction.recentBlockhash = (await provider.connection.getLatestBlockhash()).blockhash;\n transaction.feePayer = userAccount;\n return { transaction: await this.convertToVersionedTransaction(transaction, provider.connection), messageAccount };\n }\n\n private async prepareSwapAndBridgeCctpData(txSendParams: SolTxSendParams): Promise<SwapAndBridgeSolDataCctpData> {\n const {\n contractAddress,\n amount,\n fromAccountAddress,\n fromTokenAddress,\n toChainId,\n toAccountAddress,\n toTokenAddress,\n extraGas,\n } = txSendParams;\n const cctpAddress = contractAddress;\n if (!cctpAddress) {\n throw new CCTPDoesNotSupportedError(\"Such route does not support CCTP protocol\");\n }\n const CHAIN_ID = 4;\n\n const account = fromAccountAddress;\n const receiveTokenAddress = toTokenAddress;\n const receiverInBuffer32 = toAccountAddress;\n\n const provider = buildAnchorProvider(this.solanaRpcUrl, account);\n const cctpBridge: Program<CctpBridgeType> = new Program<CctpBridgeType>(cctpBridgeIdl, cctpAddress, provider);\n const mint = new PublicKey(fromTokenAddress);\n const cctpBridgeAccount = await getCctpBridgeAccount(mint, cctpBridge.programId);\n const userAccount = new PublicKey(account);\n\n const configAccountInfo = await cctpBridge.account.cctpBridge.fetch(cctpBridgeAccount);\n\n const swapAndBridgeData = {} as SwapAndBridgeSolDataCctpData;\n\n swapAndBridgeData.cctpBridge = cctpBridge;\n swapAndBridgeData.cctpBridgeAccount = cctpBridgeAccount;\n swapAndBridgeData.cctpAddressAccount = new PublicKey(cctpAddress);\n swapAndBridgeData.amount = new BN(amount);\n swapAndBridgeData.recipient = Array.from(receiverInBuffer32);\n swapAndBridgeData.receiveToken = Array.from(receiveTokenAddress);\n swapAndBridgeData.userToken = await getAssociatedAccount(userAccount, mint);\n swapAndBridgeData.bridgeAuthority = await getCctpAuthorityAccount(cctpBridgeAccount, cctpBridge.programId);\n swapAndBridgeData.bridgeTokenAccount = await getCctpBridgeTokenAccount(mint, cctpBridge.programId);\n swapAndBridgeData.chainBridgeAccount = await getChainBridgeAccount(toChainId, cctpBridge.programId);\n swapAndBridgeData.userAccount = userAccount;\n swapAndBridgeData.destinationChainId = toChainId;\n swapAndBridgeData.mint = mint;\n swapAndBridgeData.gasPrice = await getPriceAccount(toChainId, configAccountInfo.gasOracleProgramId);\n swapAndBridgeData.thisGasPrice = await getPriceAccount(CHAIN_ID, configAccountInfo.gasOracleProgramId);\n swapAndBridgeData.provider = provider;\n\n if (extraGas) {\n swapAndBridgeData.extraGasInstruction = this.getExtraGasInstruction(\n extraGas,\n swapAndBridgeData.userAccount,\n cctpBridgeAccount\n );\n }\n return swapAndBridgeData;\n }\n\n async buildSwapAndBridgeCctpTransaction(\n destinationChainSymbol: string,\n swapAndBridgeData: SwapAndBridgeSolDataCctpData\n ): Promise<{ transaction: VersionedTransaction; messageSentEventDataKeypair: Keypair }> {\n const {\n cctpBridge,\n cctpBridgeAccount,\n amount,\n recipient,\n receiveToken,\n bridgeAuthority,\n userToken,\n bridgeTokenAccount,\n chainBridgeAccount,\n userAccount,\n destinationChainId,\n mint,\n gasPrice,\n thisGasPrice,\n extraGasInstruction,\n provider,\n } = swapAndBridgeData;\n const domain = this.params.cctpParams.cctpDomains[destinationChainSymbol];\n const cctpTransmitterProgramIdAddress = this.params.cctpParams.cctpTransmitterProgramId;\n const cctpTokenMessengerMinterAddress = this.params.cctpParams.cctpTokenMessengerMinter;\n if (domain == undefined || !cctpTransmitterProgramIdAddress || !cctpTokenMessengerMinterAddress) {\n throw new SdkError(\"CCTP is not configured\");\n }\n const cctpTransmitterProgramId = new PublicKey(cctpTransmitterProgramIdAddress);\n const cctpTokenMessengerMinter = new PublicKey(cctpTokenMessengerMinterAddress);\n const {\n messageTransmitterAccount,\n tokenMessenger,\n tokenMessengerEventAuthority,\n tokenMinter,\n localToken,\n remoteTokenMessengerKey,\n authorityPda,\n } = getCctpAccounts(domain, mint, cctpTransmitterProgramId, cctpTokenMessengerMinter);\n\n const instructions: TransactionInstruction[] = [];\n if (extraGasInstruction) {\n instructions.push(extraGasInstruction);\n }\n\n const messageSentEventDataKeypair = Keypair.generate();\n const lockAccount = getCctpLockAccount(cctpBridge.programId, messageSentEventDataKeypair.publicKey);\n\n const tx = await cctpBridge.methods\n .bridge({\n amount,\n destinationChainId,\n recipient,\n receiveToken,\n })\n .accounts({\n mint: mint,\n user: userAccount,\n cctpBridge: cctpBridgeAccount,\n\n messageSentEventData: messageSentEventDataKeypair.publicKey,\n lock: lockAccount,\n\n cctpMessenger: cctpTokenMessengerMinter,\n messageTransmitterProgram: cctpTransmitterProgramId,\n messageTransmitterAccount: messageTransmitterAccount,\n tokenMessenger: tokenMessenger,\n tokenMinter: tokenMinter,\n localToken: localToken,\n remoteTokenMessengerKey: remoteTokenMessengerKey,\n authorityPda: authorityPda,\n eventAuthority: tokenMessengerEventAuthority,\n\n bridgeToken: bridgeTokenAccount,\n gasPrice: gasPrice,\n thisGasPrice: thisGasPrice,\n chainBridge: chainBridgeAccount,\n userToken,\n bridgeAuthority: bridgeAuthority,\n })\n .preInstructions([\n web3.ComputeBudgetProgram.setComputeUnitLimit({\n units: 2000000,\n }),\n ])\n .postInstructions(instructions)\n .transaction();\n const connection = provider.connection;\n tx.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;\n tx.feePayer = userAccount;\n return { transaction: await this.convertToVersionedTransaction(tx, connection), messageSentEventDataKeypair };\n }\n\n send(params: SendParams): Promise<TransactionResponse> {\n throw new MethodNotSupportedError();\n }\n}\n\ninterface SolTxSendParams extends TxSendParamsSol {\n poolAddress: string;\n}\n"]}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Connection, VersionedTransaction } from "@solana/web3.js";
|
|
2
|
+
import { JupiterParams } from "./index";
|
|
2
3
|
export declare class JupiterService {
|
|
3
4
|
connection: Connection;
|
|
4
5
|
jupiterUrl: string;
|
|
6
|
+
apiKeyHeader?: string;
|
|
5
7
|
maxAccounts?: number;
|
|
6
|
-
constructor(solanaRpcUrl: string,
|
|
8
|
+
constructor(solanaRpcUrl: string, jupiterParams: JupiterParams);
|
|
7
9
|
getJupiterSwapTx(userAddress: string, stableTokenAddress: string, amount: string, exactOut: boolean): Promise<{
|
|
8
10
|
tx: VersionedTransaction;
|
|
9
11
|
amountIn?: string;
|
|
@@ -32,11 +32,13 @@ const utils_1 = require("../../../utils/sol/utils");
|
|
|
32
32
|
class JupiterService {
|
|
33
33
|
connection;
|
|
34
34
|
jupiterUrl;
|
|
35
|
+
apiKeyHeader;
|
|
35
36
|
maxAccounts;
|
|
36
|
-
constructor(solanaRpcUrl,
|
|
37
|
+
constructor(solanaRpcUrl, jupiterParams) {
|
|
37
38
|
this.connection = new web3_js_1.Connection(solanaRpcUrl);
|
|
38
|
-
this.jupiterUrl = jupiterUrl.replace(/\/$/, ""); // trim last "/" if exist
|
|
39
|
-
this.
|
|
39
|
+
this.jupiterUrl = jupiterParams.jupiterUrl.replace(/\/$/, ""); // trim last "/" if exist
|
|
40
|
+
this.apiKeyHeader = jupiterParams.jupiterApiKeyHeader;
|
|
41
|
+
this.maxAccounts = jupiterParams.jupiterMaxAccounts;
|
|
40
42
|
}
|
|
41
43
|
async getJupiterSwapTx(userAddress, stableTokenAddress, amount, exactOut) {
|
|
42
44
|
let quoteResponse;
|
|
@@ -46,7 +48,9 @@ class JupiterService {
|
|
|
46
48
|
if (this.maxAccounts) {
|
|
47
49
|
url += `&maxAccounts=${this.maxAccounts}`;
|
|
48
50
|
}
|
|
49
|
-
quoteResponse = await axios_1.default.get(url
|
|
51
|
+
quoteResponse = await axios_1.default.get(url, {
|
|
52
|
+
headers: this.apiKeyHeader ? { "x-api-key": this.apiKeyHeader } : undefined,
|
|
53
|
+
});
|
|
50
54
|
}
|
|
51
55
|
catch (err) {
|
|
52
56
|
if (err instanceof axios_1.AxiosError && err.response && err.response.data && err.response.data.error) {
|
|
@@ -67,6 +71,8 @@ class JupiterService {
|
|
|
67
71
|
quoteResponse: quoteResponse.data,
|
|
68
72
|
userPublicKey: userAddress,
|
|
69
73
|
wrapAndUnwrapSol: true,
|
|
74
|
+
}, {
|
|
75
|
+
headers: this.apiKeyHeader ? { "x-api-key": this.apiKeyHeader } : undefined,
|
|
70
76
|
});
|
|
71
77
|
}
|
|
72
78
|
catch (err) {
|