@allbridge/bridge-core-sdk 3.27.0-alpha.13 → 3.27.0-alpha.15

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.
Files changed (58) hide show
  1. package/dist/browser/index.js +2 -2
  2. package/dist/browser/index.js.map +4 -4
  3. package/dist/cjs/index.js +2 -2
  4. package/dist/cjs/index.js.map +4 -4
  5. package/dist/esm/index.js +2 -2
  6. package/dist/esm/index.js.map +4 -4
  7. package/dist/src/chains/models.d.ts +2 -2
  8. package/dist/src/chains/models.js.map +1 -1
  9. package/dist/src/client/core-api/api-client.js +1 -0
  10. package/dist/src/client/core-api/api-client.js.map +1 -1
  11. package/dist/src/client/core-api/core-api-mapper.js +29 -0
  12. package/dist/src/client/core-api/core-api-mapper.js.map +1 -1
  13. package/dist/src/client/core-api/core-api.model.d.ts +13 -2
  14. package/dist/src/client/core-api/core-api.model.js.map +1 -1
  15. package/dist/src/models/index.d.ts +12 -4
  16. package/dist/src/models/index.js +4 -0
  17. package/dist/src/models/index.js.map +1 -1
  18. package/dist/src/services/bridge/alg/index.js +52 -43
  19. package/dist/src/services/bridge/alg/index.js.map +1 -1
  20. package/dist/src/services/bridge/evm/index.d.ts +1 -0
  21. package/dist/src/services/bridge/evm/index.js +108 -33
  22. package/dist/src/services/bridge/evm/index.js.map +1 -1
  23. package/dist/src/services/bridge/index.d.ts +2 -2
  24. package/dist/src/services/bridge/index.js +10 -4
  25. package/dist/src/services/bridge/index.js.map +1 -1
  26. package/dist/src/services/bridge/models/bridge.model.d.ts +9 -2
  27. package/dist/src/services/bridge/models/bridge.model.js.map +1 -1
  28. package/dist/src/services/bridge/raw-bridge-transaction-builder.js +1 -1
  29. package/dist/src/services/bridge/raw-bridge-transaction-builder.js.map +1 -1
  30. package/dist/src/services/bridge/srb/index.js +36 -28
  31. package/dist/src/services/bridge/srb/index.js.map +1 -1
  32. package/dist/src/services/bridge/stx/index.js +23 -14
  33. package/dist/src/services/bridge/stx/index.js.map +1 -1
  34. package/dist/src/services/bridge/sui/index.js +166 -138
  35. package/dist/src/services/bridge/sui/index.js.map +1 -1
  36. package/dist/src/services/bridge/trx/index.js +98 -70
  37. package/dist/src/services/bridge/trx/index.js.map +1 -1
  38. package/dist/src/services/bridge/utils.js +63 -8
  39. package/dist/src/services/bridge/utils.js.map +1 -1
  40. package/dist/src/services/models/abi/PayerWithAbr.d.ts +203 -0
  41. package/dist/src/services/models/abi/PayerWithAbr.js +266 -0
  42. package/dist/src/services/models/abi/PayerWithAbr.js.map +1 -0
  43. package/dist/src/services/token/index.js +2 -2
  44. package/dist/src/services/token/index.js.map +1 -1
  45. package/dist/src/services/token/models/token.model.d.ts +4 -4
  46. package/dist/src/services/token/models/token.model.js.map +1 -1
  47. package/dist/src/services/token/trx/index.d.ts +2 -1
  48. package/dist/src/services/token/trx/index.js +7 -3
  49. package/dist/src/services/token/trx/index.js.map +1 -1
  50. package/dist/src/tokens-info/tokens-info.model.d.ts +17 -0
  51. package/dist/src/tokens-info/tokens-info.model.js.map +1 -1
  52. package/dist/src/utils/utils.d.ts +2 -0
  53. package/dist/src/utils/utils.js +11 -0
  54. package/dist/src/utils/utils.js.map +1 -1
  55. package/dist/src/version.d.ts +1 -1
  56. package/dist/src/version.js +1 -1
  57. package/dist/src/version.js.map +1 -1
  58. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { ChainSymbol, ChainType } from "./chain.enums";
1
+ import { ChainType } from "./chain.enums";
2
2
  /**
3
3
  * Contains blockchain's basic information
4
4
  */
@@ -6,7 +6,7 @@ export interface BasicChainProperties {
6
6
  /**
7
7
  * The symbol of the chain representing one of the supported blockchain networks (e.g., "ETH" for Ethereum). For more details, see: {@link ChainSymbol}.
8
8
  */
9
- chainSymbol: ChainSymbol;
9
+ chainSymbol: string;
10
10
  /**
11
11
  * Common Blockchain Id</br>
12
12
  * A 0x-prefixed hexadecimal string</br>
@@ -1 +1 @@
1
- {"version":3,"file":"models.js","sourceRoot":"","sources":["../../../src/chains/models.ts"],"names":[],"mappings":"","sourcesContent":["import { ChainSymbol, ChainType } from \"./chain.enums\";\n\n/**\n * Contains blockchain's basic information\n */\nexport interface BasicChainProperties {\n /**\n * The symbol of the chain representing one of the supported blockchain networks (e.g., \"ETH\" for Ethereum). For more details, see: {@link ChainSymbol}.\n */\n chainSymbol: ChainSymbol;\n /**\n * Common Blockchain Id</br>\n * A 0x-prefixed hexadecimal string</br>\n * Optional.\n */\n chainId?: string; // A 0x-prefixed hexadecimal string\n /**\n * Blockchain name\n */\n name: string;\n /**\n * Blockchain type. For more details, see: {@link ChainType}.\n */\n chainType: ChainType;\n}\nexport interface AdditionalBasicChainProperties extends Omit<BasicChainProperties, \"chainSymbol\"> {\n /**\n * The symbol of the chain representing one of the supported blockchain networks (e.g., \"ETH\" for Ethereum). For more details, see: {@link ChainSymbol}.\n */\n chainSymbol: string;\n}\n"]}
1
+ {"version":3,"file":"models.js","sourceRoot":"","sources":["../../../src/chains/models.ts"],"names":[],"mappings":"","sourcesContent":["import { ChainType } from \"./chain.enums\";\n\n/**\n * Contains blockchain's basic information\n */\nexport interface BasicChainProperties {\n /**\n * The symbol of the chain representing one of the supported blockchain networks (e.g., \"ETH\" for Ethereum). For more details, see: {@link ChainSymbol}.\n */\n chainSymbol: string;\n /**\n * Common Blockchain Id</br>\n * A 0x-prefixed hexadecimal string</br>\n * Optional.\n */\n chainId?: string; // A 0x-prefixed hexadecimal string\n /**\n * Blockchain name\n */\n name: string;\n /**\n * Blockchain type. For more details, see: {@link ChainType}.\n */\n chainType: ChainType;\n}\nexport interface AdditionalBasicChainProperties extends Omit<BasicChainProperties, \"chainSymbol\"> {\n /**\n * The symbol of the chain representing one of the supported blockchain networks (e.g., \"ETH\" for Ethereum). For more details, see: {@link ChainSymbol}.\n */\n chainSymbol: string;\n}\n"]}
@@ -54,6 +54,7 @@ class ApiClientImpl {
54
54
  exchangeRate: data.exchangeRate,
55
55
  fee: data.fee,
56
56
  sourceNativeTokenPrice: data.sourceNativeTokenPrice,
57
+ abrExchangeRate: data.abrExchangeRate ?? "50000", //TODO remove
57
58
  adminFeeShareWithExtras: data.adminFeeShareWithExtras,
58
59
  };
59
60
  }
@@ -1 +1 @@
1
- {"version":3,"file":"api-client.js","sourceRoot":"","sources":["../../../../src/client/core-api/api-client.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAqC;AACrC,iDAA+D;AAE/D,2CAAwC;AACxC,uDAI2B;AAC3B,qDAS0B;AAsB1B,MAAa,aAAa;IAChB,GAAG,CAAQ;IAEnB,YAAY,MAAiC;QAC3C,IAAI,CAAC,GAAG,GAAG,eAAK,CAAC,MAAM,CAAC;YACtB,OAAO,EAAE,MAAM,CAAC,UAAU;YAC1B,OAAO,EAAE;gBACP,MAAM,EAAE,kBAAkB;gBAC1B,GAAG,MAAM,CAAC,cAAc;gBACxB,aAAa,EAAE,mBAAmB,GAAG,iBAAO;aAC7C;YACD,MAAM,EAAE,MAAM,CAAC,kBAAkB;SAClC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAuB,aAAa,EAAE,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QACxG,OAAO;YACL,eAAe,EAAE,IAAA,0DAAwC,EAAC,IAAI,CAAC;YAC/D,WAAW,EAAE,IAAA,sDAAoC,EAAC,IAAI,CAAC;SACxD,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,cAAc;QAClB,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAsB,eAAe,CAAC,CAAC;QAC1E,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,WAAmB,EAAE,OAAe;QACtD,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,C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C,CAAC;IAChD,CAAC;CACF;AApED,sCAoEC","sourcesContent":["import axios, { Axios } from \"axios\";\nimport { InvalidMessengerOptionError } from \"../../exceptions\";\nimport { ChainDetailsMapWithFlags, PoolInfoMap, PoolKeyObject } from \"../../tokens-info\";\nimport { VERSION } from \"../../version\";\nimport {\n mapChainDetailsResponseToChainDetailsMap,\n mapChainDetailsResponseToPoolInfoMap,\n mapPoolInfoResponseToPoolInfoMap,\n} from \"./core-api-mapper\";\nimport {\n ChainDetailsResponse,\n GasBalanceResponse,\n Messenger,\n PendingInfoResponse,\n PoolInfoResponse,\n ReceiveTransactionCostRequest,\n ReceiveTransactionCostResponse,\n TransferStatusResponse,\n} from \"./core-api.model\";\nimport { AllbridgeCoreClientParams } from \"./core-client-base\";\n\nexport interface TokenInfo {\n chainDetailsMap: ChainDetailsMapWithFlags;\n poolInfoMap: PoolInfoMap;\n}\n\nexport interface ApiClient {\n getTokenInfo(): Promise<TokenInfo>;\n\n getPendingInfo(): Promise<PendingInfoResponse>;\n\n getGasBalance(chainSymbol: string, address: string): Promise<GasBalanceResponse>;\n\n getTransferStatus(chainSymbol: string, txId: string): Promise<TransferStatusResponse>;\n\n getReceiveTransactionCost(args: ReceiveTransactionCostRequest): Promise<ReceiveTransactionCostResponse>;\n\n getPoolInfoMap(pools: PoolKeyObject[] | PoolKeyObject): Promise<PoolInfoMap>;\n}\n\nexport class ApiClientImpl implements ApiClient {\n private api: Axios;\n\n constructor(params: AllbridgeCoreClientParams) {\n this.api = axios.create({\n baseURL: params.coreApiUrl,\n headers: {\n Accept: \"application/json\",\n ...params.coreApiHeaders,\n \"x-Sdk-Agent\": \"AllbridgeCoreSDK/\" + VERSION,\n },\n params: params.coreApiQueryParams,\n });\n }\n\n async getTokenInfo(): Promise<TokenInfo> {\n const { data } = await this.api.get<ChainDetailsResponse>(\"/token-info\", { params: { filter: \"all\" } });\n return {\n chainDetailsMap: mapChainDetailsResponseToChainDetailsMap(data),\n poolInfoMap: mapChainDetailsResponseToPoolInfoMap(data),\n };\n }\n\n async getPendingInfo(): Promise<PendingInfoResponse> {\n const { data } = await this.api.get<PendingInfoResponse>(\"/pending-info\");\n return data;\n }\n\n async getGasBalance(chainSymbol: string, address: string): Promise<GasBalanceResponse> {\n const { data } = await this.api.get<GasBalanceResponse>(`/check/${chainSymbol}/${address}`);\n return data;\n }\n\n async getTransferStatus(chainSymbol: string, txId: string): Promise<TransferStatusResponse> {\n const { data } = await this.api.get<TransferStatusResponse>(`/chain/${chainSymbol}/${txId}`);\n return data;\n }\n\n async getReceiveTransactionCost(args: ReceiveTransactionCostRequest): Promise<ReceiveTransactionCostResponse> {\n if (args.messenger === Messenger.OFT && !args.sourceToken) {\n throw new InvalidMessengerOptionError(\"For OFT sourceToken required\");\n }\n const { data } = await this.api.post<ReceiveTransactionCostResponse>(\"/receive-fee\", args, {\n headers: {\n \"Content-Type\": \"application/json\",\n },\n });\n return {\n exchangeRate: data.exchangeRate,\n fee: data.fee,\n sourceNativeTokenPrice: data.sourceNativeTokenPrice,\n adminFeeShareWithExtras: data.adminFeeShareWithExtras,\n };\n }\n\n async getPoolInfoMap(pools: PoolKeyObject[] | PoolKeyObject): Promise<PoolInfoMap> {\n const poolKeys = pools instanceof Array ? pools : [pools];\n const { data } = await this.api.post<PoolInfoResponse>(\n \"/pool-info\",\n { pools: poolKeys },\n {\n headers: {\n \"Content-Type\": \"application/json\",\n },\n }\n );\n return mapPoolInfoResponseToPoolInfoMap(data);\n }\n}\n"]}
1
+ {"version":3,"file":"api-client.js","sourceRoot":"","sources":["../../../../src/client/core-api/api-client.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAqC;AACrC,iDAA+D;AAE/D,2CAAwC;AACxC,uDAI2B;AAC3B,qDAS0B;AAsB1B,MAAa,aAAa;IAChB,GAAG,CAAQ;IAEnB,YAAY,MAAiC;QAC3C,IAAI,CAAC,GAAG,GAAG,eAAK,CAAC,MAAM,CAAC;YACtB,OAAO,EAAE,MAAM,CAAC,UAAU;YA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,wCAA2B,CAAC,8BAA8B,CAAC,CAAC;QACxE,CAAC;QACD,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAiC,cAAc,EAAE,IAAI,EAAE;YACzF,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;SACF,CAAC,CAAC;QACH,OAAO;YACL,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,sBAAsB,EAAE,IAAI,CAAC,sBAAsB;YACnD,eAAe,EAAE,IAAI,CAAC,eAAe,IAAI,OAAO,EAAE,aAAa;YAC/D,uBAAuB,EAAE,IAAI,CAAC,uBAAuB;SACtD,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,KAAsC;QACzD,MAAM,QAAQ,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAC1D,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAClC,YAAY,EACZ,EAAE,KAAK,EAAE,QAAQ,EAAE,EACnB;YACE,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;SACF,CACF,CAAC;QACF,OAAO,IAAA,kDAAgC,EAAC,IAAI,CAAC,CAAC;IAChD,CAAC;CACF;AArED,sCAqEC","sourcesContent":["import axios, { Axios } from \"axios\";\nimport { InvalidMessengerOptionError } from \"../../exceptions\";\nimport { ChainDetailsMapWithFlags, PoolInfoMap, PoolKeyObject } from \"../../tokens-info\";\nimport { VERSION } from \"../../version\";\nimport {\n mapChainDetailsResponseToChainDetailsMap,\n mapChainDetailsResponseToPoolInfoMap,\n mapPoolInfoResponseToPoolInfoMap,\n} from \"./core-api-mapper\";\nimport {\n ChainDetailsResponse,\n GasBalanceResponse,\n Messenger,\n PendingInfoResponse,\n PoolInfoResponse,\n ReceiveTransactionCostRequest,\n ReceiveTransactionCostResponse,\n TransferStatusResponse,\n} from \"./core-api.model\";\nimport { AllbridgeCoreClientParams } from \"./core-client-base\";\n\nexport interface TokenInfo {\n chainDetailsMap: ChainDetailsMapWithFlags;\n poolInfoMap: PoolInfoMap;\n}\n\nexport interface ApiClient {\n getTokenInfo(): Promise<TokenInfo>;\n\n getPendingInfo(): Promise<PendingInfoResponse>;\n\n getGasBalance(chainSymbol: string, address: string): Promise<GasBalanceResponse>;\n\n getTransferStatus(chainSymbol: string, txId: string): Promise<TransferStatusResponse>;\n\n getReceiveTransactionCost(args: ReceiveTransactionCostRequest): Promise<ReceiveTransactionCostResponse>;\n\n getPoolInfoMap(pools: PoolKeyObject[] | PoolKeyObject): Promise<PoolInfoMap>;\n}\n\nexport class ApiClientImpl implements ApiClient {\n private api: Axios;\n\n constructor(params: AllbridgeCoreClientParams) {\n this.api = axios.create({\n baseURL: params.coreApiUrl,\n headers: {\n Accept: \"application/json\",\n ...params.coreApiHeaders,\n \"x-Sdk-Agent\": \"AllbridgeCoreSDK/\" + VERSION,\n },\n params: params.coreApiQueryParams,\n });\n }\n\n async getTokenInfo(): Promise<TokenInfo> {\n const { data } = await this.api.get<ChainDetailsResponse>(\"/token-info\", { params: { filter: \"all\" } });\n return {\n chainDetailsMap: mapChainDetailsResponseToChainDetailsMap(data),\n poolInfoMap: mapChainDetailsResponseToPoolInfoMap(data),\n };\n }\n\n async getPendingInfo(): Promise<PendingInfoResponse> {\n const { data } = await this.api.get<PendingInfoResponse>(\"/pending-info\");\n return data;\n }\n\n async getGasBalance(chainSymbol: string, address: string): Promise<GasBalanceResponse> {\n const { data } = await this.api.get<GasBalanceResponse>(`/check/${chainSymbol}/${address}`);\n return data;\n }\n\n async getTransferStatus(chainSymbol: string, txId: string): Promise<TransferStatusResponse> {\n const { data } = await this.api.get<TransferStatusResponse>(`/chain/${chainSymbol}/${txId}`);\n return data;\n }\n\n async getReceiveTransactionCost(args: ReceiveTransactionCostRequest): Promise<ReceiveTransactionCostResponse> {\n if (args.messenger === Messenger.OFT && !args.sourceToken) {\n throw new InvalidMessengerOptionError(\"For OFT sourceToken required\");\n }\n const { data } = await this.api.post<ReceiveTransactionCostResponse>(\"/receive-fee\", args, {\n headers: {\n \"Content-Type\": \"application/json\",\n },\n });\n return {\n exchangeRate: data.exchangeRate,\n fee: data.fee,\n sourceNativeTokenPrice: data.sourceNativeTokenPrice,\n abrExchangeRate: data.abrExchangeRate ?? \"50000\", //TODO remove\n adminFeeShareWithExtras: data.adminFeeShareWithExtras,\n };\n }\n\n async getPoolInfoMap(pools: PoolKeyObject[] | PoolKeyObject): Promise<PoolInfoMap> {\n const poolKeys = pools instanceof Array ? pools : [pools];\n const { data } = await this.api.post<PoolInfoResponse>(\n \"/pool-info\",\n { pools: poolKeys },\n {\n headers: {\n \"Content-Type\": \"application/json\",\n },\n }\n );\n return mapPoolInfoResponseToPoolInfoMap(data);\n }\n}\n"]}
@@ -86,6 +86,17 @@ function mapChainDetailsFromDto(chainSymbol, dto) {
86
86
  bridgeAddress: dto.bridgeAddress,
87
87
  oftBridgeAddress: dto.oftBridgeAddress,
88
88
  yieldAddress: dto.yieldAddress,
89
+ abrPayer: dto.abrPayer
90
+ ? {
91
+ payerAddress: dto.abrPayer.payerAddress,
92
+ abrToken: {
93
+ chainSymbol,
94
+ tokenAddress: dto.abrPayer.tokenAddress,
95
+ decimals: dto.abrPayer.tokenDecimals,
96
+ },
97
+ payerAvailability: mapAbrPayerAvailabilityFromDto(dto.abrPayer.payerAvailability),
98
+ }
99
+ : undefined,
89
100
  transferTime: mapTransferTimeFromDto(dto.transferTime),
90
101
  txCostAmount: dto.txCostAmount,
91
102
  confirmations: dto.confirmations,
@@ -96,6 +107,24 @@ function mapChainDetailsFromDto(chainSymbol, dto) {
96
107
  tokens: dto.tokens.map((tokenDto) => mapTokenWithChainDetailsFromDto(chainDetails, tokenDto)),
97
108
  };
98
109
  }
110
+ function mapAbrPayerAvailabilityFromDto(dto) {
111
+ if (!dto)
112
+ return {};
113
+ const out = {};
114
+ for (const [humanReadableKey, isAvailable] of Object.entries(dto)) {
115
+ if (!isAvailable)
116
+ continue;
117
+ const messengerKey = dtoKeyToMessengerKey[humanReadableKey];
118
+ if (messengerKey) {
119
+ out[messengerKey] = true;
120
+ }
121
+ }
122
+ return out;
123
+ }
124
+ // Build mapping from human-readable DTO key ("Allbridge") to Messenger key ("ALLBRIDGE")
125
+ const dtoKeyToMessengerKey = Object.fromEntries(Object.entries(core_api_model_1.MessengerKeyDTO).map(([enumKey, humanReadable]) => {
126
+ return [humanReadable, enumKey];
127
+ }));
99
128
  function mapPoolKeyToPoolKeyObject(poolKey) {
100
129
  const dividerPosition = poolKey.indexOf("_");
101
130
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"core-api-mapper.js","sourceRoot":"","sources":["../../../../src/client/core-api/core-api-mapper.ts"],"names":[],"mappings":";;AAyBA,4FAUC;AAED,oFAcC;AAoED,8DAMC;AAED,8DAEC;AAED,gFAYC;AAED,4EAUC;AA3JD,yCAAsC;AAatC,yDAAqE;AACrE,qDAS0B;AAE1B,SAAgB,wCAAwC,CAAC,QAA8B;IACrF,OAAO,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,CAA2B,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;QAC9E,MAAM,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QAC7B,MAAM,eAAe,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACjC,MAAM,YAAY,GAAG,sBAAsB,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;QAC1E,IAAI,YAAY,EAAE,CAAC;YACjB,GAAG,CAAC,WAAW,CAAC,GAAG,YAAY,CAAC;QAClC,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC;AAED,SAAgB,oCAAoC,CAAC,QAA8B;IACjF,MAAM,WAAW,GAAgB,EAAE,CAAC;IACpC,KAA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;IACpC,KAAK,MAAM,CAAC,gBAAgB,EAAE,iBAAiB,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;QACjF,MAAM,WAAW,GAAG,gBAAgB,CAAC;QACrC,KAAK,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,EAAE,CAAC;YACxE,QAAQ,CAAC,SAAS,GAAG,IAAA,wCAA0B,EAAC,QAAQ,CAAC,CAAC;YAC1D,WAAW,CAAC,yBAAyB,CAAC,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC,CAAC,GAAG,QAAQ,CAAC;QAClF,CAAC;IACH,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import { Chains } from \"../../chains\";\nimport { ChainSymbol } from \"../../chains/chain.enums\";\nimport {\n ChainDetails,\n ChainDetailsMap,\n ChainDetailsMapWithFlags,\n ChainDetailsWithTokensWithFlags,\n MessengerTransferTime,\n PoolInfoMap,\n PoolKeyObject,\n TokenWithChainDetailsWithFlags,\n TransferTime,\n} from \"../../tokens-info\";\nimport { calculatePoolInfoImbalance } from \"../../utils/calculation\";\nimport {\n ChainDetailsDTO,\n ChainDetailsResponse,\n Messenger,\n MessengerKeyDTO,\n MessengerTransferTimeDTO,\n PoolInfoResponse,\n TokenDTO,\n TransferTimeDTO,\n} from \"./core-api.model\";\n\nexport function mapChainDetailsResponseToChainDetailsMap(response: ChainDetailsResponse): ChainDetailsMapWithFlags {\n return Object.entries(response).reduce<ChainDetailsMapWithFlags>((map, entry) => {\n const chainSymbol = entry[0];\n const chainDetailsDTO = entry[1];\n const chainDetails = mapChainDetailsFromDto(chainSymbol, chainDetailsDTO);\n if (chainDetails) {\n map[chainSymbol] = chainDetails;\n }\n return map;\n }, {});\n}\n\nexport function mapChainDetailsResponseToPoolInfoMap(response: ChainDetailsResponse): PoolInfoMap {\n const poolInfoMap: PoolInfoMap = {};\n for (const [chainSymbolValue, chainDetailsDTO] of Object.entries(response)) {\n const chainSymbol = chainSymbolValue;\n for (const token of chainDetailsDTO.tokens) {\n const poolKey = mapPoolKeyObjectToPoolKey({\n chainSymbol,\n poolAddress: token.poolAddress,\n });\n const imbalance = calculatePoolInfoImbalance(token.poolInfo);\n poolInfoMap[poolKey] = { ...token.poolInfo, imbalance };\n }\n }\n return poolInfoMap;\n}\n\nfunction mapTokenWithChainDetailsFromDto(chainDetails: ChainDetails, dto: TokenDTO): TokenWithChainDetailsWithFlags {\n const { name: chainName, ...chainDetailsWithoutName } = chainDetails;\n const { poolInfo: _poolInfo, ...dtoWithoutPoolInfo } = dto;\n return {\n ...dtoWithoutPoolInfo,\n ...chainDetailsWithoutName,\n chainName,\n };\n}\n\nfunction mapMessengerKeyDtoToMessenger(dto: MessengerKeyDTO): Messenger | null {\n switch (dto) {\n case MessengerKeyDTO.ALLBRIDGE:\n return Messenger.ALLBRIDGE;\n case MessengerKeyDTO.WORMHOLE:\n return Messenger.WORMHOLE;\n case MessengerKeyDTO.CCTP:\n return Messenger.CCTP;\n case MessengerKeyDTO.CCTP_V2:\n return Messenger.CCTP_V2;\n case MessengerKeyDTO.OFT:\n return Messenger.OFT;\n }\n}\n\nfunction mapTransferTimeFromDto(dto: TransferTimeDTO): TransferTime {\n return Object.entries(dto).reduce<TransferTime>((result, [key, value]) => {\n result[key as ChainSymbol] = mapMessengerTransferTimeFromDto(value);\n return result;\n }, {});\n}\n\nfunction mapMessengerTransferTimeFromDto(dto: MessengerTransferTimeDTO): MessengerTransferTime {\n return Object.entries(dto).reduce<MessengerTransferTime>((messengerTransferTime, [key, value]) => {\n const messenger = mapMessengerKeyDtoToMessenger(key as MessengerKeyDTO);\n if (messenger && value != null) {\n messengerTransferTime[messenger] = value;\n }\n return messengerTransferTime;\n }, {});\n}\n\nfunction mapChainDetailsFromDto(chainSymbol: string, dto: ChainDetailsDTO): ChainDetailsWithTokensWithFlags | null {\n const basicChainProperties = Chains.getChainsProperties()[chainSymbol];\n if (!basicChainProperties) {\n return null;\n }\n const chainDetails: ChainDetails = {\n ...basicChainProperties,\n allbridgeChainId: dto.chainId,\n bridgeId: dto.bridgeId,\n paddingUtilId: dto.paddingUtilId,\n bridgeAddress: dto.bridgeAddress,\n oftBridgeAddress: dto.oftBridgeAddress,\n yieldAddress: dto.yieldAddress,\n transferTime: mapTransferTimeFromDto(dto.transferTime),\n txCostAmount: dto.txCostAmount,\n confirmations: dto.confirmations,\n suiAddresses: dto.suiAddresses,\n };\n return {\n ...chainDetails,\n tokens: dto.tokens.map((tokenDto) => mapTokenWithChainDetailsFromDto(chainDetails, tokenDto)),\n };\n}\n\nexport function mapPoolKeyToPoolKeyObject(poolKey: string): PoolKeyObject {\n const dividerPosition = poolKey.indexOf(\"_\");\n return {\n chainSymbol: poolKey.substring(0, dividerPosition),\n poolAddress: poolKey.substring(dividerPosition + 1),\n };\n}\n\nexport function mapPoolKeyObjectToPoolKey(poolKeyObject: PoolKeyObject): string {\n return poolKeyObject.chainSymbol + \"_\" + poolKeyObject.poolAddress;\n}\n\nexport function mapChainDetailsMapToPoolKeyObjects(chainDetailsMap: ChainDetailsMap): PoolKeyObject[] {\n const result = [];\n for (const [chainSymbolValue, chainDetails] of Object.entries(chainDetailsMap)) {\n const chainSymbol = chainSymbolValue;\n for (const token of chainDetails.tokens) {\n result.push({\n chainSymbol,\n poolAddress: token.poolAddress,\n });\n }\n }\n return result;\n}\n\nexport function mapPoolInfoResponseToPoolInfoMap(responseBody: PoolInfoResponse): PoolInfoMap {\n const poolInfoMap: PoolInfoMap = {};\n for (const [chainSymbolValue, poolInfoByAddress] of Object.entries(responseBody)) {\n const chainSymbol = chainSymbolValue;\n for (const [poolAddress, poolInfo] of Object.entries(poolInfoByAddress)) {\n poolInfo.imbalance = calculatePoolInfoImbalance(poolInfo);\n poolInfoMap[mapPoolKeyObjectToPoolKey({ chainSymbol, poolAddress })] = poolInfo;\n }\n }\n return poolInfoMap;\n}\n"]}
1
+ {"version":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pE,OAAO,aAAa,CAAC,WAAW,GAAG,GAAG,GAAG,aAAa,CAAC,WAAW,CAAC;AACrE,CAAC;AAED,SAAgB,kCAAkC,CAAC,eAAgC;IACjF,MAAM,MAAM,GAAG,EAAE,CAAC;IAClB,KAAK,MAAM,CAAC,gBAAgB,EAAE,YAAY,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC;QAC/E,MAAM,WAAW,GAAG,gBAAgB,CAAC;QACrC,KAAK,MAAM,KAAK,IAAI,YAAY,CAAC,MAAM,EAAE,CAAC;YACxC,MAAM,CAAC,IAAI,CAAC;gBACV,WAAW;gBACX,WAAW,EAAE,KAAK,CAAC,WAAW;aAC/B,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAgB,gCAAgC,CAAC,YAA8B;IAC7E,MAAM,WAAW,GAAgB,EAAE,CAAC;IACpC,KAAK,MAAM,CAAC,gBAAgB,EAAE,iBAAiB,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;QACjF,MAAM,WAAW,GAAG,gBAAgB,CAAC;QACrC,KAAK,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,EAAE,CAAC;YACxE,QAAQ,CAAC,SAAS,GAAG,IAAA,wCAA0B,EAAC,QAAQ,CAAC,CAAC;YAC1D,WAAW,CAAC,yBAAyB,CAAC,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC,CAAC,GAAG,QAAQ,CAAC;QAClF,CAAC;IACH,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import { Chains } from \"../../chains\";\nimport { ChainSymbol } from \"../../chains/chain.enums\";\nimport {\n AbrPayerAvailability,\n ChainDetails,\n ChainDetailsMap,\n ChainDetailsMapWithFlags,\n ChainDetailsWithTokensWithFlags,\n MessengerTransferTime,\n PoolInfoMap,\n PoolKeyObject,\n TokenWithChainDetailsWithFlags,\n TransferTime,\n} from \"../../tokens-info\";\nimport { calculatePoolInfoImbalance } from \"../../utils/calculation\";\nimport {\n AbrPayerAvailabilityTypeDTO,\n ChainDetailsDTO,\n ChainDetailsResponse,\n Messenger,\n MessengerKeyDTO,\n MessengerTransferTimeDTO,\n PoolInfoResponse,\n TokenDTO,\n TransferTimeDTO,\n} from \"./core-api.model\";\n\nexport function mapChainDetailsResponseToChainDetailsMap(response: ChainDetailsResponse): ChainDetailsMapWithFlags {\n return Object.entries(response).reduce<ChainDetailsMapWithFlags>((map, entry) => {\n const chainSymbol = entry[0];\n const chainDetailsDTO = entry[1];\n const chainDetails = mapChainDetailsFromDto(chainSymbol, chainDetailsDTO);\n if (chainDetails) {\n map[chainSymbol] = chainDetails;\n }\n return map;\n }, {});\n}\n\nexport function mapChainDetailsResponseToPoolInfoMap(response: ChainDetailsResponse): PoolInfoMap {\n const poolInfoMap: PoolInfoMap = {};\n for (const [chainSymbolValue, chainDetailsDTO] of Object.entries(response)) {\n const chainSymbol = chainSymbolValue;\n for (const token of chainDetailsDTO.tokens) {\n const poolKey = mapPoolKeyObjectToPoolKey({\n chainSymbol,\n poolAddress: token.poolAddress,\n });\n const imbalance = calculatePoolInfoImbalance(token.poolInfo);\n poolInfoMap[poolKey] = { ...token.poolInfo, imbalance };\n }\n }\n return poolInfoMap;\n}\n\nfunction mapTokenWithChainDetailsFromDto(chainDetails: ChainDetails, dto: TokenDTO): TokenWithChainDetailsWithFlags {\n const { name: chainName, ...chainDetailsWithoutName } = chainDetails;\n const { poolInfo: _poolInfo, ...dtoWithoutPoolInfo } = dto;\n return {\n ...dtoWithoutPoolInfo,\n ...chainDetailsWithoutName,\n chainName,\n };\n}\n\nfunction mapMessengerKeyDtoToMessenger(dto: MessengerKeyDTO): Messenger | null {\n switch (dto) {\n case MessengerKeyDTO.ALLBRIDGE:\n return Messenger.ALLBRIDGE;\n case MessengerKeyDTO.WORMHOLE:\n return Messenger.WORMHOLE;\n case MessengerKeyDTO.CCTP:\n return Messenger.CCTP;\n case MessengerKeyDTO.CCTP_V2:\n return Messenger.CCTP_V2;\n case MessengerKeyDTO.OFT:\n return Messenger.OFT;\n }\n}\n\nfunction mapTransferTimeFromDto(dto: TransferTimeDTO): TransferTime {\n return Object.entries(dto).reduce<TransferTime>((result, [key, value]) => {\n result[key as ChainSymbol] = mapMessengerTransferTimeFromDto(value);\n return result;\n }, {});\n}\n\nfunction mapMessengerTransferTimeFromDto(dto: MessengerTransferTimeDTO): MessengerTransferTime {\n return Object.entries(dto).reduce<MessengerTransferTime>((messengerTransferTime, [key, value]) => {\n const messenger = mapMessengerKeyDtoToMessenger(key as MessengerKeyDTO);\n if (messenger && value != null) {\n messengerTransferTime[messenger] = value;\n }\n return messengerTransferTime;\n }, {});\n}\n\nfunction mapChainDetailsFromDto(chainSymbol: string, dto: ChainDetailsDTO): ChainDetailsWithTokensWithFlags | null {\n const basicChainProperties = Chains.getChainsProperties()[chainSymbol];\n if (!basicChainProperties) {\n return null;\n }\n const chainDetails: ChainDetails = {\n ...basicChainProperties,\n allbridgeChainId: dto.chainId,\n bridgeId: dto.bridgeId,\n paddingUtilId: dto.paddingUtilId,\n bridgeAddress: dto.bridgeAddress,\n oftBridgeAddress: dto.oftBridgeAddress,\n yieldAddress: dto.yieldAddress,\n abrPayer: dto.abrPayer\n ? {\n payerAddress: dto.abrPayer.payerAddress,\n abrToken: {\n chainSymbol,\n tokenAddress: dto.abrPayer.tokenAddress,\n decimals: dto.abrPayer.tokenDecimals,\n },\n payerAvailability: mapAbrPayerAvailabilityFromDto(dto.abrPayer.payerAvailability),\n }\n : undefined,\n transferTime: mapTransferTimeFromDto(dto.transferTime),\n txCostAmount: dto.txCostAmount,\n confirmations: dto.confirmations,\n suiAddresses: dto.suiAddresses,\n };\n return {\n ...chainDetails,\n tokens: dto.tokens.map((tokenDto) => mapTokenWithChainDetailsFromDto(chainDetails, tokenDto)),\n };\n}\n\nfunction mapAbrPayerAvailabilityFromDto(dto: AbrPayerAvailabilityTypeDTO): AbrPayerAvailability {\n if (!dto) return {};\n const out: AbrPayerAvailability = {};\n\n for (const [humanReadableKey, isAvailable] of Object.entries(dto)) {\n if (!isAvailable) continue;\n\n const messengerKey =\n dtoKeyToMessengerKey[humanReadableKey as (typeof MessengerKeyDTO)[keyof typeof MessengerKeyDTO]];\n\n if (messengerKey) {\n out[messengerKey] = true;\n }\n }\n\n return out;\n}\n\n// Build mapping from human-readable DTO key (\"Allbridge\") to Messenger key (\"ALLBRIDGE\")\nconst dtoKeyToMessengerKey: Record<(typeof MessengerKeyDTO)[keyof typeof MessengerKeyDTO], keyof typeof Messenger> =\n Object.fromEntries(\n Object.entries(MessengerKeyDTO).map(([enumKey, humanReadable]) => {\n return [humanReadable, enumKey as keyof typeof Messenger];\n })\n ) as any;\n\nexport function mapPoolKeyToPoolKeyObject(poolKey: string): PoolKeyObject {\n const dividerPosition = poolKey.indexOf(\"_\");\n return {\n chainSymbol: poolKey.substring(0, dividerPosition),\n poolAddress: poolKey.substring(dividerPosition + 1),\n };\n}\n\nexport function mapPoolKeyObjectToPoolKey(poolKeyObject: PoolKeyObject): string {\n return poolKeyObject.chainSymbol + \"_\" + poolKeyObject.poolAddress;\n}\n\nexport function mapChainDetailsMapToPoolKeyObjects(chainDetailsMap: ChainDetailsMap): PoolKeyObject[] {\n const result = [];\n for (const [chainSymbolValue, chainDetails] of Object.entries(chainDetailsMap)) {\n const chainSymbol = chainSymbolValue;\n for (const token of chainDetails.tokens) {\n result.push({\n chainSymbol,\n poolAddress: token.poolAddress,\n });\n }\n }\n return result;\n}\n\nexport function mapPoolInfoResponseToPoolInfoMap(responseBody: PoolInfoResponse): PoolInfoMap {\n const poolInfoMap: PoolInfoMap = {};\n for (const [chainSymbolValue, poolInfoByAddress] of Object.entries(responseBody)) {\n const chainSymbol = chainSymbolValue;\n for (const [poolAddress, poolInfo] of Object.entries(poolInfoByAddress)) {\n poolInfo.imbalance = calculatePoolInfoImbalance(poolInfo);\n poolInfoMap[mapPoolKeyObjectToPoolKey({ chainSymbol, poolAddress })] = poolInfo;\n }\n }\n return poolInfoMap;\n}\n"]}
@@ -1,6 +1,12 @@
1
1
  import { ChainSymbol } from "../../chains/chain.enums";
2
2
  import { PoolInfo, SuiAddresses } from "../../tokens-info";
3
3
  export type ChainDetailsResponse = Record<string, ChainDetailsDTO>;
4
+ export interface AbrPayerChainInfoDTO {
5
+ payerAddress: string;
6
+ tokenAddress: string;
7
+ tokenDecimals: number;
8
+ payerAvailability: AbrPayerAvailabilityTypeDTO;
9
+ }
4
10
  export interface ChainDetailsDTO {
5
11
  tokens: TokenDTO[];
6
12
  chainId: number;
@@ -8,6 +14,7 @@ export interface ChainDetailsDTO {
8
14
  paddingUtilId?: string;
9
15
  bridgeAddress: string;
10
16
  oftBridgeAddress?: string;
17
+ abrPayer?: AbrPayerChainInfoDTO;
11
18
  swapAddress: string;
12
19
  yieldAddress?: string;
13
20
  transferTime: TransferTimeDTO;
@@ -60,6 +67,8 @@ export declare enum MessengerKeyDTO {
60
67
  CCTP_V2 = "cctpV2",
61
68
  OFT = "oft"
62
69
  }
70
+ type AbrPayerAvailabilityKeyDTO = (typeof MessengerKeyDTO)[keyof typeof MessengerKeyDTO];
71
+ export type AbrPayerAvailabilityTypeDTO = Partial<Record<AbrPayerAvailabilityKeyDTO, boolean>>;
63
72
  export type TransferTimeDTO = Record<string, MessengerTransferTimeDTO>;
64
73
  export interface TxCostAmountDTO {
65
74
  maxAmount: string;
@@ -86,6 +95,7 @@ export interface ReceiveTransactionCostResponse {
86
95
  exchangeRate: string;
87
96
  fee: string;
88
97
  sourceNativeTokenPrice: string;
98
+ abrExchangeRate?: string;
89
99
  adminFeeShareWithExtras?: string;
90
100
  }
91
101
  export interface GasBalanceResponse {
@@ -142,10 +152,11 @@ export interface BridgeTransaction {
142
152
  confirmationsNeeded: number;
143
153
  isClaimable?: boolean;
144
154
  }
145
- export type PoolInfoResponse = Record<ChainSymbol, PoolInfo>;
146
- export type PendingInfoResponse = Partial<Record<ChainSymbol, TokenPendingInfoDTO>>;
155
+ export type PoolInfoResponse = Record<string, PoolInfo>;
156
+ export type PendingInfoResponse = Partial<Record<string, TokenPendingInfoDTO>>;
147
157
  export type TokenPendingInfoDTO = Record<string, PendingInfoDTO>;
148
158
  export interface PendingInfoDTO {
149
159
  pendingTxs: number;
150
160
  totalSentAmount: string;
151
161
  }
162
+ export {};
@@ -1 +1 @@
1
- {"version":3,"file":"core-api.model.js","sourceRoot":"","sources":["../../../../src/client/core-api/core-api.model.ts"],"names":[],"mappings":";;;AAoBA,IAAY,aAOX;AAPD,WAAY,aAAa;IACvB,0BAAS,CAAA;IACT,oCAAmB,CAAA;IACnB,wCAAuB,CAAA;IACvB,gDAA+B,CAAA;IAC/B,sDAAqC,CAAA;IACrC,kFAAiE,CAAA;AACnE,CAAC,EAPW,aAAa,6BAAb,aAAa,QAOxB;AAkCD,IAAY,eAMX;AAND,WAAY,eAAe;IACzB,0CAAuB,CAAA;IACvB,wCAAqB,CAAA;IACrB,gCAAa,CAAA;IACb,qCAAkB,CAAA;IAClB,8BAAW,CAAA;AACb,CAAC,EANW,eAAe,+BAAf,eAAe,QAM1B;AAcD,IAAY,SAMX;AAND,WAAY,SAAS;IACnB,mDAAa,CAAA;IACb,iDAAY,CAAA;IACZ,yCAAQ,CAAA;IACR,+CAAW,CAAA;IACX,uCAAO,CAAA;AACT,CAAC,EANW,SAAS,yBAAT,SAAS,QAMpB","sourcesContent":["import { ChainSymbol } from \"../../chains/chain.enums\";\nimport { PoolInfo, SuiAddresses } from \"../../tokens-info\";\n\nexport type ChainDetailsResponse = Record<string, ChainDetailsDTO>;\n\nexport interface ChainDetailsDTO {\n tokens: TokenDTO[];\n chainId: number;\n bridgeId?: string;\n paddingUtilId?: string;\n bridgeAddress: string;\n oftBridgeAddress?: string;\n swapAddress: string;\n yieldAddress?: string;\n transferTime: TransferTimeDTO;\n txCostAmount: TxCostAmountDTO;\n confirmations: number;\n suiAddresses?: SuiAddresses;\n}\n\nexport enum AddressStatus {\n OK = \"OK\",\n INVALID = \"INVALID\",\n FORBIDDEN = \"FORBIDDEN\",\n UNINITIALIZED = \"UNINITIALIZED\",\n CONTRACT_ADDRESS = \"CONTRACT_ADDRESS\",\n WRONG_ASSOCIATED_ACCOUNT_OWNER = \"WRONG_ASSOCIATED_ACCOUNT_OWNER\",\n}\n\nexport interface TokenDTO {\n symbol: string;\n name: string;\n decimals: number;\n poolAddress: string;\n tokenAddress: string;\n poolInfo: PoolInfoDTO;\n oftId?: string;\n feeShare: string;\n apr: string;\n apr7d: string;\n apr30d: string;\n lpRate: string;\n cctpAddress?: string;\n cctpFeeShare?: string;\n yieldId?: number;\n flags: {\n swap: boolean;\n pool: boolean;\n };\n}\n\nexport interface PoolInfoDTO {\n aValue: string;\n dValue: string;\n tokenBalance: string;\n vUsdBalance: string;\n totalLpAmount: string;\n accRewardPerShareP: string;\n p: number;\n}\n\nexport enum MessengerKeyDTO {\n ALLBRIDGE = \"allbridge\",\n WORMHOLE = \"wormhole\",\n CCTP = \"cctp\",\n CCTP_V2 = \"cctpV2\",\n OFT = \"oft\",\n}\n\nexport type TransferTimeDTO = Record<string, MessengerTransferTimeDTO>;\n\nexport interface TxCostAmountDTO {\n maxAmount: string;\n swap: string;\n transfer: string;\n}\n\nexport type MessengerTransferTimeDTO = {\n [messenger in MessengerKeyDTO]: number | null;\n};\n\nexport enum Messenger {\n ALLBRIDGE = 1,\n WORMHOLE = 2,\n CCTP = 3,\n CCTP_V2 = 4,\n OFT = 5,\n}\n\nexport interface ReceiveTransactionCostRequest {\n sourceChainId: number;\n destinationChainId: number;\n messenger: Messenger;\n sourceToken?: string;\n}\n\nexport interface ReceiveTransactionCostResponse {\n exchangeRate: string;\n fee: string;\n sourceNativeTokenPrice: string;\n adminFeeShareWithExtras?: string;\n}\n\nexport interface GasBalanceResponse {\n gasBalance: string | null;\n status: AddressStatus;\n}\n\nexport interface CheckAddressResponse {\n gasBalance: string | null;\n status: AddressStatus;\n}\n\nexport interface TransferStatusResponse {\n txId: string;\n\n sourceChainSymbol: ChainSymbol;\n destinationChainSymbol: ChainSymbol;\n\n sendAmount: string;\n sendAmountFormatted: number;\n\n stableFee: string;\n stableFeeFormatted: number;\n\n sourceTokenAddress: string;\n destinationTokenAddress: string;\n\n originSourceTokenAddress?: string;\n originDestinationTokenAddress?: string;\n\n senderAddress: string;\n recipientAddress: string;\n\n signaturesCount: number;\n signaturesNeeded: number;\n\n send: BridgeTransaction;\n receive?: BridgeTransaction;\n\n responseTime?: number;\n}\n\nexport interface BridgeTransaction {\n txId: string;\n\n sourceChainId: number;\n destinationChainId: number;\n\n fee: string;\n feeFormatted: number;\n\n stableFee: string;\n stableFeeFormatted: number;\n\n amount: string;\n amountFormatted: number;\n virtualAmount: string;\n\n bridgeContract: string;\n sender: string;\n recipient: string;\n\n sourceTokenAddress: string;\n destinationTokenAddress: string;\n\n originSourceTokenAddress?: string;\n originDestinationTokenAddress?: string;\n\n hash: string;\n\n messenger: Messenger;\n\n blockTime: number;\n blockId: string;\n\n confirmations: number;\n confirmationsNeeded: number;\n\n isClaimable?: boolean;\n}\n\nexport type PoolInfoResponse = Record<ChainSymbol, PoolInfo>;\nexport type PendingInfoResponse = Partial<Record<ChainSymbol, TokenPendingInfoDTO>>;\nexport type TokenPendingInfoDTO = Record<string, PendingInfoDTO>;\n\nexport interface PendingInfoDTO {\n pendingTxs: number;\n totalSentAmount: string;\n}\n"]}
1
+ {"version":3,"file":"core-api.model.js","sourceRoot":"","sources":["../../../../src/client/core-api/core-api.model.ts"],"names":[],"mappings":";;;AA4BA,IAAY,aAOX;AAPD,WAAY,aAAa;IACvB,0BAAS,CAAA;IACT,oCAAmB,CAAA;IACnB,wCAAuB,CAAA;IACvB,gDAA+B,CAAA;IAC/B,sDAAqC,CAAA;IACrC,kFAAiE,CAAA;AACnE,CAAC,EAPW,aAAa,6BAAb,aAAa,QAOxB;AAkCD,IAAY,eAMX;AAND,WAAY,eAAe;IACzB,0CAAuB,CAAA;IACvB,wCAAqB,CAAA;IACrB,gCAAa,CAAA;IACb,qCAAkB,CAAA;IAClB,8BAAW,CAAA;AACb,CAAC,EANW,eAAe,+BAAf,eAAe,QAM1B;AAkBD,IAAY,SAMX;AAND,WAAY,SAAS;IACnB,mDAAa,CAAA;IACb,iDAAY,CAAA;IACZ,yCAAQ,CAAA;IACR,+CAAW,CAAA;IACX,uCAAO,CAAA;AACT,CAAC,EANW,SAAS,yBAAT,SAAS,QAMpB","sourcesContent":["import { ChainSymbol } from \"../../chains/chain.enums\";\nimport { PoolInfo, SuiAddresses } from \"../../tokens-info\";\n\nexport type ChainDetailsResponse = Record<string, ChainDetailsDTO>;\n\nexport interface AbrPayerChainInfoDTO {\n payerAddress: string;\n tokenAddress: string;\n tokenDecimals: number;\n payerAvailability: AbrPayerAvailabilityTypeDTO;\n}\n\nexport interface ChainDetailsDTO {\n tokens: TokenDTO[];\n chainId: number;\n bridgeId?: string;\n paddingUtilId?: string;\n bridgeAddress: string;\n oftBridgeAddress?: string;\n abrPayer?: AbrPayerChainInfoDTO;\n swapAddress: string;\n yieldAddress?: string;\n transferTime: TransferTimeDTO;\n txCostAmount: TxCostAmountDTO;\n confirmations: number;\n suiAddresses?: SuiAddresses;\n}\n\nexport enum AddressStatus {\n OK = \"OK\",\n INVALID = \"INVALID\",\n FORBIDDEN = \"FORBIDDEN\",\n UNINITIALIZED = \"UNINITIALIZED\",\n CONTRACT_ADDRESS = \"CONTRACT_ADDRESS\",\n WRONG_ASSOCIATED_ACCOUNT_OWNER = \"WRONG_ASSOCIATED_ACCOUNT_OWNER\",\n}\n\nexport interface TokenDTO {\n symbol: string;\n name: string;\n decimals: number;\n poolAddress: string;\n tokenAddress: string;\n poolInfo: PoolInfoDTO;\n oftId?: string;\n feeShare: string;\n apr: string;\n apr7d: string;\n apr30d: string;\n lpRate: string;\n cctpAddress?: string;\n cctpFeeShare?: string;\n yieldId?: number;\n flags: {\n swap: boolean;\n pool: boolean;\n };\n}\n\nexport interface PoolInfoDTO {\n aValue: string;\n dValue: string;\n tokenBalance: string;\n vUsdBalance: string;\n totalLpAmount: string;\n accRewardPerShareP: string;\n p: number;\n}\n\nexport enum MessengerKeyDTO {\n ALLBRIDGE = \"allbridge\",\n WORMHOLE = \"wormhole\",\n CCTP = \"cctp\",\n CCTP_V2 = \"cctpV2\",\n OFT = \"oft\",\n}\n\ntype AbrPayerAvailabilityKeyDTO = (typeof MessengerKeyDTO)[keyof typeof MessengerKeyDTO];\n\nexport type AbrPayerAvailabilityTypeDTO = Partial<Record<AbrPayerAvailabilityKeyDTO, boolean>>;\n\nexport type TransferTimeDTO = Record<string, MessengerTransferTimeDTO>;\n\nexport interface TxCostAmountDTO {\n maxAmount: string;\n swap: string;\n transfer: string;\n}\n\nexport type MessengerTransferTimeDTO = {\n [messenger in MessengerKeyDTO]: number | null;\n};\n\nexport enum Messenger {\n ALLBRIDGE = 1,\n WORMHOLE = 2,\n CCTP = 3,\n CCTP_V2 = 4,\n OFT = 5,\n}\n\nexport interface ReceiveTransactionCostRequest {\n sourceChainId: number;\n destinationChainId: number;\n messenger: Messenger;\n sourceToken?: string;\n}\n\nexport interface ReceiveTransactionCostResponse {\n exchangeRate: string;\n fee: string;\n sourceNativeTokenPrice: string;\n abrExchangeRate?: string;\n adminFeeShareWithExtras?: string;\n}\n\nexport interface GasBalanceResponse {\n gasBalance: string | null;\n status: AddressStatus;\n}\n\nexport interface CheckAddressResponse {\n gasBalance: string | null;\n status: AddressStatus;\n}\n\nexport interface TransferStatusResponse {\n txId: string;\n\n sourceChainSymbol: ChainSymbol;\n destinationChainSymbol: ChainSymbol;\n\n sendAmount: string;\n sendAmountFormatted: number;\n\n stableFee: string;\n stableFeeFormatted: number;\n\n sourceTokenAddress: string;\n destinationTokenAddress: string;\n\n originSourceTokenAddress?: string;\n originDestinationTokenAddress?: string;\n\n senderAddress: string;\n recipientAddress: string;\n\n signaturesCount: number;\n signaturesNeeded: number;\n\n send: BridgeTransaction;\n receive?: BridgeTransaction;\n\n responseTime?: number;\n}\n\nexport interface BridgeTransaction {\n txId: string;\n\n sourceChainId: number;\n destinationChainId: number;\n\n fee: string;\n feeFormatted: number;\n\n stableFee: string;\n stableFeeFormatted: number;\n\n amount: string;\n amountFormatted: number;\n virtualAmount: string;\n\n bridgeContract: string;\n sender: string;\n recipient: string;\n\n sourceTokenAddress: string;\n destinationTokenAddress: string;\n\n originSourceTokenAddress?: string;\n originDestinationTokenAddress?: string;\n\n hash: string;\n\n messenger: Messenger;\n\n blockTime: number;\n blockId: string;\n\n confirmations: number;\n confirmationsNeeded: number;\n\n isClaimable?: boolean;\n}\n\nexport type PoolInfoResponse = Record<string, PoolInfo>;\nexport type PendingInfoResponse = Partial<Record<string, TokenPendingInfoDTO>>;\nexport type TokenPendingInfoDTO = Record<string, PendingInfoDTO>;\n\nexport interface PendingInfoDTO {\n pendingTxs: number;\n totalSentAmount: string;\n}\n"]}
@@ -5,16 +5,15 @@ export { LiquidityPoolService } from "../services/liquidity-pool/index";
5
5
  export { Messenger, TransferStatusResponse, BridgeTransaction, GasBalanceResponse, CheckAddressResponse, AddressStatus, } from "../client/core-api/core-api.model";
6
6
  export { RawBridgeTransactionBuilder } from "../services/bridge/raw-bridge-transaction-builder";
7
7
  export { RawPoolTransactionBuilder } from "../services/liquidity-pool/raw-pool-transaction-builder";
8
- export { PoolInfo, TokenWithChainDetails, TransferTime, TxCostAmount, SuiAddresses, MessengerTransferTime, } from "../tokens-info/tokens-info.model";
9
8
  export { UserBalanceInfo, UserBalanceInfoDTO, LiquidityPoolsParams, LiquidityPoolsParamsWithAmount, ApproveParams as LiquidityPoolsApproveParams, CheckAllowanceParams as LiquidityPoolsCheckAllowanceParams, GetAllowanceParams as LiquidityPoolsGetAllowanceParams, } from "../services/liquidity-pool/models/pool.model";
10
9
  export * from "../services/models/index";
11
10
  export { YieldService } from "../services/yield/index";
12
11
  export { assertYieldIsSupported, isYieldSupported } from "../services/yield/validations";
13
- export { TokenWithChainDetailsYield, CYDToken, YieldGetAllowanceParams, YieldCheckAllowanceParams, YieldBalanceParams, YieldGetEstimatedAmountOnDepositParams, YieldGetWithdrawProportionAmountParams, YieldWithdrawAmount, YieldApproveParams, YieldDepositParams, YieldWithdrawParams, } from "../services/yield//models/yield.model";
12
+ export { TokenWithChainDetailsYield, CYDToken, YieldGetAllowanceParams, YieldCheckAllowanceParams, YieldBalanceParams, YieldGetEstimatedAmountOnDepositParams, YieldGetWithdrawProportionAmountParams, YieldWithdrawAmount, YieldApproveParams, YieldDepositParams, YieldWithdrawParams, } from "../services/yield/models/yield.model";
14
13
  export { RawYieldTransactionBuilder } from "../services/yield/raw-yield-transaction-builder";
15
14
  export { SwapAndBridgeCalculationData, SwapFromVUsdCalcResult, SwapToVUsdCalcResult, } from "../utils/calculation/swap-and-bridge-fee-calc";
16
15
  export { SendAmountDetails, AmountImpact } from "../utils/calculation/swap-and-bridge-details";
17
- export { ChainDetailsMap, ChainDetailsWithTokens } from "../tokens-info";
16
+ export { PoolInfo, TokenCoreFields, TokenWithChainDetails, TransferTime, TxCostAmount, SuiAddresses, MessengerTransferTime, ChainDetailsMap, ChainDetailsWithTokens, } from "../tokens-info";
18
17
  export { Utils } from "../utils";
19
18
  export { SrbUtils, TrustLineParams } from "../utils/srb";
20
19
  export { SolUtils } from "../utils/sol";
@@ -29,7 +28,11 @@ export declare enum FeePaymentMethod {
29
28
  /**
30
29
  * The fee is paid with the stablecoin token.
31
30
  */
32
- WITH_STABLECOIN = "stablecoin"
31
+ WITH_STABLECOIN = "stablecoin",
32
+ /**
33
+ * The fee is paid with the ABR token.
34
+ */
35
+ WITH_ARB = "abr"
33
36
  }
34
37
  export interface AmountsAndGasFeeOptions {
35
38
  /**
@@ -58,6 +61,7 @@ type GasFeeOptionsType = {
58
61
  export interface GasFeeOptions extends GasFeeOptionsType {
59
62
  [FeePaymentMethod.WITH_NATIVE_CURRENCY]: AmountFormatted;
60
63
  [FeePaymentMethod.WITH_STABLECOIN]?: AmountFormatted;
64
+ [FeePaymentMethod.WITH_ARB]?: AmountFormatted;
61
65
  adminFeeShareWithExtras?: string;
62
66
  }
63
67
  /**
@@ -128,6 +132,10 @@ export interface ExtraGasMaxLimitResponse {
128
132
  * Exchange rate
129
133
  */
130
134
  exchangeRate: string;
135
+ /**
136
+ * Exchange rate
137
+ */
138
+ abrExchangeRate?: string;
131
139
  /**
132
140
  * Source native token price
133
141
  */
@@ -36,6 +36,10 @@ var FeePaymentMethod;
36
36
  * The fee is paid with the stablecoin token.
37
37
  */
38
38
  FeePaymentMethod["WITH_STABLECOIN"] = "stablecoin";
39
+ /**
40
+ * The fee is paid with the ABR token.
41
+ */
42
+ FeePaymentMethod["WITH_ARB"] = "abr";
39
43
  })(FeePaymentMethod || (exports.FeePaymentMethod = FeePaymentMethod = {}));
40
44
  /**
41
45
  * Define the type of amount data<p/>
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/models/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAaA,oEAO2C;AANzC,2GAAA,SAAS,OAAA;AAKT,+GAAA,aAAa,OAAA;AAqBf,2DAAyC;AAEzC,6DAAyF;AAAhF,qHAAA,sBAAsB,OAAA;AAAE,+GAAA,gBAAgB,OAAA;AAyBjD,gDAA8B;AAC9B,qDAA+D;AAAtD,0GAAA,WAAW,OAAA;AAAE,wGAAA,SAAS,OAAA;AAG/B,IAAY,gBAUX;AAVD,WAAY,gBAAgB;IAC1B;;OAEG;IACH,mDAA+B,CAAA;IAE/B;;OAEG;IACH,kDAA8B,CAAA;AAChC,CAAC,EAVW,gBAAgB,gCAAhB,gBAAgB,QAU3B;AAoCD;;;;GAIG;AACH,IAAY,YASX;AATD,WAAY,YAAY;IACtB;;OAEG;IACH,2BAAW,CAAA;IACX;;OAEG;IACH,+BAAe,CAAA;AACjB,CAAC,EATW,YAAY,4BAAZ,YAAY,QASvB","sourcesContent":["export {\n ApproveParams as BridgeApproveParams,\n BaseSendParams,\n CheckAllowanceParams,\n GetAllowanceParams,\n GetTokenBalanceParams,\n SendParams,\n SwapParams,\n GetNativeTokenBalanceParams,\n} from \"../services/bridge/models/bridge.model\";\nexport { BridgeService } from \"../services/bridge/index\";\nexport { CctpParams, CctpDomains } from \"../services/bridge/sol\";\nexport { LiquidityPoolService } from \"../services/liquidity-pool/index\";\nexport {\n Messenger,\n TransferStatusResponse,\n BridgeTransaction,\n GasBalanceResponse,\n CheckAddressResponse,\n AddressStatus,\n} from \"../client/core-api/core-api.model\";\nexport { RawBridgeTransactionBuilder } from \"../services/bridge/raw-bridge-transaction-builder\";\nexport { RawPoolTransactionBuilder } from \"../services/liquidity-pool/raw-pool-transaction-builder\";\nexport {\n PoolInfo,\n TokenWithChainDetails,\n TransferTime,\n TxCostAmount,\n SuiAddresses,\n MessengerTransferTime,\n} from \"../tokens-info/tokens-info.model\";\nexport {\n UserBalanceInfo,\n UserBalanceInfoDTO,\n LiquidityPoolsParams,\n LiquidityPoolsParamsWithAmount,\n ApproveParams as LiquidityPoolsApproveParams,\n CheckAllowanceParams as LiquidityPoolsCheckAllowanceParams,\n GetAllowanceParams as LiquidityPoolsGetAllowanceParams,\n} from \"../services/liquidity-pool/models/pool.model\";\nexport * from \"../services/models/index\";\nexport { YieldService } from \"../services/yield/index\";\nexport { assertYieldIsSupported, isYieldSupported } from \"../services/yield/validations\";\nexport {\n TokenWithChainDetailsYield,\n CYDToken,\n YieldGetAllowanceParams,\n YieldCheckAllowanceParams,\n YieldBalanceParams,\n YieldGetEstimatedAmountOnDepositParams,\n YieldGetWithdrawProportionAmountParams,\n YieldWithdrawAmount,\n YieldApproveParams,\n YieldDepositParams,\n YieldWithdrawParams,\n} from \"../services/yield//models/yield.model\";\nexport { RawYieldTransactionBuilder } from \"../services/yield/raw-yield-transaction-builder\";\nexport {\n SwapAndBridgeCalculationData,\n SwapFromVUsdCalcResult,\n SwapToVUsdCalcResult,\n} from \"../utils/calculation/swap-and-bridge-fee-calc\";\nexport { SendAmountDetails, AmountImpact } from \"../utils/calculation/swap-and-bridge-details\";\nexport { ChainDetailsMap, ChainDetailsWithTokens } from \"../tokens-info\";\nexport { Utils } from \"../utils\";\nexport { SrbUtils, TrustLineParams } from \"../utils/srb\";\nexport { SolUtils } from \"../utils/sol\";\nexport * from \"../exceptions\";\nexport { ChainSymbol, ChainType } from \"../chains/chain.enums\";\nexport { AdditionalBasicChainProperties, BasicChainProperties } from \"../chains/models\";\n\nexport enum FeePaymentMethod {\n /**\n * The fee is paid in the native currency of the source chain.\n */\n WITH_NATIVE_CURRENCY = \"native\",\n\n /**\n * The fee is paid with the stablecoin token.\n */\n WITH_STABLECOIN = \"stablecoin\",\n}\n\nexport interface AmountsAndGasFeeOptions {\n /**\n * The floating point amount of tokens to be sent (not including gas fee).\n */\n amountToSendFloat: string;\n\n /**\n * The floating point amount of tokens to be received.\n */\n amountToBeReceivedFloat: string;\n\n /**\n * Available ways to pay the transfer gas fee and gas fee amount.\n */\n gasFeeOptions: GasFeeOptions;\n}\n\ntype GasFeeOptionsType = {\n [key in FeePaymentMethod]?: AmountFormatted;\n};\n\n/**\n * Describes available options of paying the gas fee and the amount to pay when using the corresponding method.\n *\n * For {@link FeePaymentMethod.WITH_NATIVE_CURRENCY} value contains the amount in the smallest denomination of the source chain currency\n *\n * For {@link FeePaymentMethod.WITH_STABLECOIN} value contains the amount in the smallest denomination of the source token\n */\nexport interface GasFeeOptions extends GasFeeOptionsType {\n [FeePaymentMethod.WITH_NATIVE_CURRENCY]: AmountFormatted;\n [FeePaymentMethod.WITH_STABLECOIN]?: AmountFormatted;\n adminFeeShareWithExtras?: string;\n}\n\n/**\n * Define the type of amount data<p/>\n * Example:<p/>\n * \"1500000\" USDC {@link AmountFormat.INT} = \"1.5\" USDC {@link AmountFormat.FLOAT}, if USDC.decimals = 6\n */\nexport enum AmountFormat {\n /**\n * denominated in the smallest unit of the source token\n */\n INT = \"int\",\n /**\n * denominated in the unit of the source token\n */\n FLOAT = \"float\",\n}\n\n/**\n * Describes the same amount in two variation formats.\n *\n * For {@link AmountFormat.INT} value contains the amount in the smallest denomination\n *\n * For {@link AmountFormat.FLOAT} value contains the amount in tokens denomination\n */\nexport type AmountFormatted = {\n [key in AmountFormat]: string;\n};\n\n/**\n * Describes MAX extra gas value can to be passed when using the corresponding method.\n *\n * For {@link FeePaymentMethod.WITH_NATIVE_CURRENCY} value contains {@link ExtraGasMaxLimit} the amount of the source chain currency\n *\n * For {@link FeePaymentMethod.WITH_STABLECOIN} value contains {@link ExtraGasMaxLimit} the amount of the source token\n */\nexport type ExtraGasMaxLimits = {\n [key in FeePaymentMethod]?: ExtraGasMaxLimit;\n};\n\n/**\n * Describes the same MAX extra gas amount.\n */\nexport type ExtraGasMaxLimit = AmountFormatted;\n\n/**\n * Provide extra gas information\n */\nexport interface ExtraGasMaxLimitResponse {\n /**\n * See {@link ExtraGasMaxLimits}\n */\n extraGasMax: ExtraGasMaxLimits;\n /**\n * Information due to destination chain\n */\n destinationChain: {\n /**\n * gasAmountMax maximum amount you can receive as extra gas on dest chain\n */\n gasAmountMax: ExtraGasMaxLimit;\n /**\n * cost of swap tx on chain\n */\n swap: AmountFormatted;\n /**\n * cost of send tx on chain\n */\n transfer: AmountFormatted;\n };\n /**\n * Exchange rate\n */\n exchangeRate: string;\n /**\n * Source native token price\n */\n sourceNativeTokenPrice: string;\n}\n\n/**\n * Provide pending status information\n */\nexport interface PendingStatusInfoResponse {\n /**\n * Number of pending transactions\n */\n pendingTxs: number;\n /**\n * Total amount of pending transactions\n */\n pendingAmount: AmountFormatted;\n /**\n * The amount of tokens can be received as a result of transfer considering pending transactions\n */\n estimatedAmount: { min: AmountFormatted; max: AmountFormatted };\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/models/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAaA,oEAO2C;AANzC,2GAAA,SAAS,OAAA;AAKT,+GAAA,aAAa,OAAA;AAaf,2DAAyC;AAEzC,6DAAyF;AAAhF,qHAAA,sBAAsB,OAAA;AAAE,+GAAA,gBAAgB,OAAA;AAmCjD,gDAA8B;AAC9B,qDAA+D;AAAtD,0GAAA,WAAW,OAAA;AAAE,wGAAA,SAAS,OAAA;AAG/B,IAAY,gBAeX;AAfD,WAAY,gBAAgB;IAC1B;;OAEG;IACH,mDAA+B,CAAA;IAE/B;;OAEG;IACH,kDAA8B,CAAA;IAE9B;;OAEG;IACH,oCAAgB,CAAA;AAClB,CAAC,EAfW,gBAAgB,gCAAhB,gBAAgB,QAe3B;AAqCD;;;;GAIG;AACH,IAAY,YASX;AATD,WAAY,YAAY;IACtB;;OAEG;IACH,2BAAW,CAAA;IACX;;OAEG;IACH,+BAAe,CAAA;AACjB,CAAC,EATW,YAAY,4BAAZ,YAAY,QASvB","sourcesContent":["export {\n ApproveParams as BridgeApproveParams,\n BaseSendParams,\n CheckAllowanceParams,\n GetAllowanceParams,\n GetTokenBalanceParams,\n SendParams,\n SwapParams,\n GetNativeTokenBalanceParams,\n} from \"../services/bridge/models/bridge.model\";\nexport { BridgeService } from \"../services/bridge/index\";\nexport { CctpParams, CctpDomains } from \"../services/bridge/sol\";\nexport { LiquidityPoolService } from \"../services/liquidity-pool/index\";\nexport {\n Messenger,\n TransferStatusResponse,\n BridgeTransaction,\n GasBalanceResponse,\n CheckAddressResponse,\n AddressStatus,\n} from \"../client/core-api/core-api.model\";\nexport { RawBridgeTransactionBuilder } from \"../services/bridge/raw-bridge-transaction-builder\";\nexport { RawPoolTransactionBuilder } from \"../services/liquidity-pool/raw-pool-transaction-builder\";\nexport {\n UserBalanceInfo,\n UserBalanceInfoDTO,\n LiquidityPoolsParams,\n LiquidityPoolsParamsWithAmount,\n ApproveParams as LiquidityPoolsApproveParams,\n CheckAllowanceParams as LiquidityPoolsCheckAllowanceParams,\n GetAllowanceParams as LiquidityPoolsGetAllowanceParams,\n} from \"../services/liquidity-pool/models/pool.model\";\nexport * from \"../services/models/index\";\nexport { YieldService } from \"../services/yield/index\";\nexport { assertYieldIsSupported, isYieldSupported } from \"../services/yield/validations\";\nexport {\n TokenWithChainDetailsYield,\n CYDToken,\n YieldGetAllowanceParams,\n YieldCheckAllowanceParams,\n YieldBalanceParams,\n YieldGetEstimatedAmountOnDepositParams,\n YieldGetWithdrawProportionAmountParams,\n YieldWithdrawAmount,\n YieldApproveParams,\n YieldDepositParams,\n YieldWithdrawParams,\n} from \"../services/yield/models/yield.model\";\nexport { RawYieldTransactionBuilder } from \"../services/yield/raw-yield-transaction-builder\";\nexport {\n SwapAndBridgeCalculationData,\n SwapFromVUsdCalcResult,\n SwapToVUsdCalcResult,\n} from \"../utils/calculation/swap-and-bridge-fee-calc\";\nexport { SendAmountDetails, AmountImpact } from \"../utils/calculation/swap-and-bridge-details\";\nexport {\n PoolInfo,\n TokenCoreFields,\n TokenWithChainDetails,\n TransferTime,\n TxCostAmount,\n SuiAddresses,\n MessengerTransferTime,\n ChainDetailsMap,\n ChainDetailsWithTokens,\n} from \"../tokens-info\";\nexport { Utils } from \"../utils\";\nexport { SrbUtils, TrustLineParams } from \"../utils/srb\";\nexport { SolUtils } from \"../utils/sol\";\nexport * from \"../exceptions\";\nexport { ChainSymbol, ChainType } from \"../chains/chain.enums\";\nexport { AdditionalBasicChainProperties, BasicChainProperties } from \"../chains/models\";\n\nexport enum FeePaymentMethod {\n /**\n * The fee is paid in the native currency of the source chain.\n */\n WITH_NATIVE_CURRENCY = \"native\",\n\n /**\n * The fee is paid with the stablecoin token.\n */\n WITH_STABLECOIN = \"stablecoin\",\n\n /**\n * The fee is paid with the ABR token.\n */\n WITH_ARB = \"abr\",\n}\n\nexport interface AmountsAndGasFeeOptions {\n /**\n * The floating point amount of tokens to be sent (not including gas fee).\n */\n amountToSendFloat: string;\n\n /**\n * The floating point amount of tokens to be received.\n */\n amountToBeReceivedFloat: string;\n\n /**\n * Available ways to pay the transfer gas fee and gas fee amount.\n */\n gasFeeOptions: GasFeeOptions;\n}\n\ntype GasFeeOptionsType = {\n [key in FeePaymentMethod]?: AmountFormatted;\n};\n\n/**\n * Describes available options of paying the gas fee and the amount to pay when using the corresponding method.\n *\n * For {@link FeePaymentMethod.WITH_NATIVE_CURRENCY} value contains the amount in the smallest denomination of the source chain currency\n *\n * For {@link FeePaymentMethod.WITH_STABLECOIN} value contains the amount in the smallest denomination of the source token\n */\nexport interface GasFeeOptions extends GasFeeOptionsType {\n [FeePaymentMethod.WITH_NATIVE_CURRENCY]: AmountFormatted;\n [FeePaymentMethod.WITH_STABLECOIN]?: AmountFormatted;\n [FeePaymentMethod.WITH_ARB]?: AmountFormatted;\n adminFeeShareWithExtras?: string;\n}\n\n/**\n * Define the type of amount data<p/>\n * Example:<p/>\n * \"1500000\" USDC {@link AmountFormat.INT} = \"1.5\" USDC {@link AmountFormat.FLOAT}, if USDC.decimals = 6\n */\nexport enum AmountFormat {\n /**\n * denominated in the smallest unit of the source token\n */\n INT = \"int\",\n /**\n * denominated in the unit of the source token\n */\n FLOAT = \"float\",\n}\n\n/**\n * Describes the same amount in two variation formats.\n *\n * For {@link AmountFormat.INT} value contains the amount in the smallest denomination\n *\n * For {@link AmountFormat.FLOAT} value contains the amount in tokens denomination\n */\nexport type AmountFormatted = {\n [key in AmountFormat]: string;\n};\n\n/**\n * Describes MAX extra gas value can to be passed when using the corresponding method.\n *\n * For {@link FeePaymentMethod.WITH_NATIVE_CURRENCY} value contains {@link ExtraGasMaxLimit} the amount of the source chain currency\n *\n * For {@link FeePaymentMethod.WITH_STABLECOIN} value contains {@link ExtraGasMaxLimit} the amount of the source token\n */\nexport type ExtraGasMaxLimits = {\n [key in FeePaymentMethod]?: ExtraGasMaxLimit;\n};\n\n/**\n * Describes the same MAX extra gas amount.\n */\nexport type ExtraGasMaxLimit = AmountFormatted;\n\n/**\n * Provide extra gas information\n */\nexport interface ExtraGasMaxLimitResponse {\n /**\n * See {@link ExtraGasMaxLimits}\n */\n extraGasMax: ExtraGasMaxLimits;\n /**\n * Information due to destination chain\n */\n destinationChain: {\n /**\n * gasAmountMax maximum amount you can receive as extra gas on dest chain\n */\n gasAmountMax: ExtraGasMaxLimit;\n /**\n * cost of swap tx on chain\n */\n swap: AmountFormatted;\n /**\n * cost of send tx on chain\n */\n transfer: AmountFormatted;\n };\n /**\n * Exchange rate\n */\n exchangeRate: string;\n /**\n * Exchange rate\n */\n abrExchangeRate?: string;\n /**\n * Source native token price\n */\n sourceNativeTokenPrice: string;\n}\n\n/**\n * Provide pending status information\n */\nexport interface PendingStatusInfoResponse {\n /**\n * Number of pending transactions\n */\n pendingTxs: number;\n /**\n * Total amount of pending transactions\n */\n pendingAmount: AmountFormatted;\n /**\n * The amount of tokens can be received as a result of transfer considering pending transactions\n */\n estimatedAmount: { min: AmountFormatted; max: AmountFormatted };\n}\n"]}
@@ -29,11 +29,12 @@ const algosdk_1 = __importStar(require("algosdk"));
29
29
  const chain_enums_1 = require("../../../chains/chain.enums");
30
30
  const exceptions_1 = require("../../../exceptions");
31
31
  const models_1 = require("../../../models");
32
+ const utils_1 = require("../../../utils/utils");
32
33
  const BridgeClient_1 = require("../../models/alg/BridgeClient");
33
34
  const PaddingUtilClient_1 = require("../../models/alg/PaddingUtilClient");
34
35
  const alg_1 = require("../../utils/alg");
35
36
  const models_2 = require("../models");
36
- const utils_1 = require("../utils");
37
+ const utils_2 = require("../utils");
37
38
  class AlgBridgeService extends models_2.ChainBridgeService {
38
39
  algorand;
39
40
  api;
@@ -48,7 +49,7 @@ class AlgBridgeService extends models_2.ChainBridgeService {
48
49
  throw new exceptions_1.MethodNotSupportedError();
49
50
  }
50
51
  async buildRawTransactionSend(params) {
51
- const txSendParams = await (0, utils_1.prepareTxSendParams)(this.chainType, params, this.api);
52
+ const txSendParams = await (0, utils_2.prepareTxSendParams)(this.chainType, params, this.api);
52
53
  if (!params.sourceToken.bridgeId) {
53
54
  throw new exceptions_1.SdkError("ALG sourceToken must contain 'bridgeId'");
54
55
  }
@@ -64,13 +65,12 @@ class AlgBridgeService extends models_2.ChainBridgeService {
64
65
  const destinationChainId = txSendParams.toChainId;
65
66
  const recipient = txSendParams.toAccountAddress;
66
67
  const receiveToken = txSendParams.toTokenAddress;
67
- const nonce = (0, utils_1.getNonce)();
68
+ const nonce = (0, utils_2.getNonce)();
68
69
  const amount = BigInt(txSendParams.amount);
69
70
  let totalFee = BigInt(txSendParams.fee);
70
71
  if (txSendParams.extraGas) {
71
72
  totalFee = totalFee + BigInt(txSendParams.extraGas);
72
73
  }
73
- const isPayWithStable = txSendParams.gasFeePaymentMethod === models_1.FeePaymentMethod.WITH_STABLECOIN;
74
74
  const composer = this.algorand.newGroup();
75
75
  const assetTransferTx = await this.algorand.createTransaction.assetTransfer({
76
76
  amount,
@@ -78,44 +78,53 @@ class AlgBridgeService extends models_2.ChainBridgeService {
78
78
  receiver: bridge.appAddress,
79
79
  sender,
80
80
  });
81
- if (isPayWithStable) {
82
- composer.addAppCallMethodCall(await bridge.params.swapAndBridgeWithStable({
83
- args: {
84
- assetTransferRef: assetTransferTx,
85
- recipient,
86
- destinationChainId,
87
- receiveToken,
88
- nonce,
89
- feeTokenAmount: totalFee,
90
- },
91
- sender,
92
- extraFee: (0, alg_1.feeForInner)(9),
93
- }));
94
- const paddingTx = await this.algorand.createTransaction.appCall({
95
- appId: paddingUtil.appId,
96
- sender,
97
- note: "padding_1",
98
- });
99
- composer.addTransaction(paddingTx);
100
- }
101
- else {
102
- const paymentTx = await this.algorand.createTransaction.payment({
103
- amount: amount_1.AlgoAmount.MicroAlgo(totalFee),
104
- receiver: bridge.appAddress,
105
- sender,
106
- });
107
- composer.addAppCallMethodCall(await bridge.params.swapAndBridge({
108
- args: {
109
- paymentRef: paymentTx,
110
- assetTransferRef: assetTransferTx,
111
- recipient,
112
- destinationChainId,
113
- receiveToken,
114
- nonce,
115
- },
116
- sender,
117
- extraFee: (0, alg_1.feeForInner)(8),
118
- }));
81
+ switch (txSendParams.gasFeePaymentMethod) {
82
+ case models_1.FeePaymentMethod.WITH_NATIVE_CURRENCY: {
83
+ const paymentTx = await this.algorand.createTransaction.payment({
84
+ amount: amount_1.AlgoAmount.MicroAlgo(totalFee),
85
+ receiver: bridge.appAddress,
86
+ sender,
87
+ });
88
+ composer.addAppCallMethodCall(await bridge.params.swapAndBridge({
89
+ args: {
90
+ paymentRef: paymentTx,
91
+ assetTransferRef: assetTransferTx,
92
+ recipient,
93
+ destinationChainId,
94
+ receiveToken,
95
+ nonce,
96
+ },
97
+ sender,
98
+ extraFee: (0, alg_1.feeForInner)(8),
99
+ }));
100
+ break;
101
+ }
102
+ case models_1.FeePaymentMethod.WITH_STABLECOIN: {
103
+ composer.addAppCallMethodCall(await bridge.params.swapAndBridgeWithStable({
104
+ args: {
105
+ assetTransferRef: assetTransferTx,
106
+ recipient,
107
+ destinationChainId,
108
+ receiveToken,
109
+ nonce,
110
+ feeTokenAmount: totalFee,
111
+ },
112
+ sender,
113
+ extraFee: (0, alg_1.feeForInner)(9),
114
+ }));
115
+ const paddingTx = await this.algorand.createTransaction.appCall({
116
+ appId: paddingUtil.appId,
117
+ sender,
118
+ note: "padding_1",
119
+ });
120
+ composer.addTransaction(paddingTx);
121
+ break;
122
+ }
123
+ case models_1.FeePaymentMethod.WITH_ARB:
124
+ throw new exceptions_1.SdkError("ALG bridge does not support ARB0 payment method");
125
+ default: {
126
+ return (0, utils_1.assertNever)(txSendParams.gasFeePaymentMethod, "Unhandled FeePaymentMethod");
127
+ }
119
128
  }
120
129
  const paddingTx = await this.algorand.createTransaction.appCall({
121
130
  appId: paddingUtil.appId,
@@ -127,7 +136,7 @@ class AlgBridgeService extends models_2.ChainBridgeService {
127
136
  return (0, alg_1.populateAndEncodeTxs)(transactions, sender, this.algorand.client.algod);
128
137
  }
129
138
  async buildRawTransactionSwap(params) {
130
- const txSwapParams = (0, utils_1.prepareTxSwapParams)(this.chainType, params);
139
+ const txSwapParams = (0, utils_2.prepareTxSwapParams)(this.chainType, params);
131
140
  const sender = algosdk_1.Address.fromString(params.fromAccountAddress);
132
141
  const recipient = params.toAccountAddress;
133
142
  const tokenId = BigInt(params.sourceToken.tokenAddress);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/services/bridge/alg/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2EAA4E;AAC5E,mDAA2C;AAC3C,6DAAwD;AAExD,oDAAwE;AACxE,4CAAmD;AAEnD,gEAA6D;AAC7D,0EAAuE;AACvE,yCAAqF;AACrF,sCAAuE;AACvE,oCAA8E;AAE9E,MAAa,gBAAiB,SAAQ,2BAAkB;IAI7C;IACA;IAJT,SAAS,GAAkB,uBAAS,CAAC,GAAG,CAAC;IAEzC,YACS,QAAwB,EACxB,GAAwB;QAE/B,KAAK,EAAE,CAAC;QAHD,aAAQ,GAAR,QAAQ,CAAgB;QACxB,QAAG,GAAH,GAAG,CAAqB;QAG/B,QAAQ,CAAC,gBAAgB,CACvB,iBAAO,CAAC,iCAAiC,CACvC,iBAAO,CAAC,mBAAmB,CACzB,+KAA+K,CAChL,CACF,CACF,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,OAAmB;QACtB,MAAM,IAAI,oCAAuB,EAAE,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,uBAAuB,CAAC,MAAkB;QAC9C,MAAM,YAAY,GAAG,MAAM,IAAA,2BAAmB,EAAC,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;QAEjF,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;YACjC,MAAM,IAAI,qBAAQ,CAAC,yCAAyC,CAAC,CAAC;QAChE,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,aAAa,EAAE,CAAC;YACtC,MAAM,IAAI,qBAAQ,CAAC,8CAA8C,CAAC,CAAC;QACrE,CAAC;QACD,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ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IAAA,0BAAoB,EAAC,YAAY,EAAE,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAChF,CAAC;IAEO,SAAS,CAAC,KAAa;QAC7B,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,qBAAqB,CAAC,2BAAY,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAC7E,CAAC;IAEO,cAAc,CAAC,KAAa;QAClC,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,qBAAqB,CAAC,qCAAiB,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAClF,CAAC;CACF;AA1KD,4CA0KC","sourcesContent":["import { AlgorandClient } from \"@algorandfoundation/algokit-utils\";\nimport { AlgoAmount } from \"@algorandfoundation/algokit-utils/types/amount\";\nimport algosdk, { Address } from \"algosdk\";\nimport { ChainType } from \"../../../chains/chain.enums\";\nimport { AllbridgeCoreClient } from \"../../../client/core-api/core-client-base\";\nimport { MethodNotSupportedError, SdkError } from \"../../../exceptions\";\nimport { FeePaymentMethod } from \"../../../models\";\nimport { RawTransaction, TransactionResponse } from \"../../models\";\nimport { BridgeClient } from \"../../models/alg/BridgeClient\";\nimport { PaddingUtilClient } from \"../../models/alg/PaddingUtilClient\";\nimport { checkAssetOptIn, feeForInner, populateAndEncodeTxs } from \"../../utils/alg\";\nimport { ChainBridgeService, SendParams, SwapParams } from \"../models\";\nimport { getNonce, prepareTxSendParams, prepareTxSwapParams } from \"../utils\";\n\nexport class AlgBridgeService extends ChainBridgeService {\n chainType: ChainType.ALG = ChainType.ALG;\n\n constructor(\n public algorand: AlgorandClient,\n public api: AllbridgeCoreClient\n ) {\n super();\n algorand.setDefaultSigner(\n algosdk.makeBasicAccountTransactionSigner(\n algosdk.mnemonicToSecretKey(\n \"tunnel gym elevator pulse motor evolve release orange culture make sister approve winter chair armor grocery distance festival tiger holiday dish wisdom region absorb secret\"\n )\n )\n );\n }\n\n send(_params: SendParams): Promise<TransactionResponse> {\n throw new MethodNotSupportedError();\n }\n\n async buildRawTransactionSend(params: SendParams): Promise<RawTransaction> {\n const txSendParams = await prepareTxSendParams(this.chainType, params, this.api);\n\n if (!params.sourceToken.bridgeId) {\n throw new SdkError(\"ALG sourceToken must contain 'bridgeId'\");\n }\n if (!params.sourceToken.paddingUtilId) {\n throw new SdkError(\"ALG sourceToken must contain 'paddingUtilId'\");\n }\n const bridgeId = BigInt(params.sourceToken.bridgeId);\n const bridge = this.getBridge(bridgeId);\n const paddingUtilId = BigInt(params.sourceToken.paddingUtilId);\n const paddingUtil = this.getPaddingUtil(paddingUtilId);\n const sender = Address.fromString(params.fromAccountAddress);\n const tokenId = BigInt(params.sourceToken.tokenAddress);\n const destinationChainId = txSendParams.toChainId;\n const recipient = txSendParams.toAccountAddress;\n const receiveToken = txSendParams.toTokenAddress;\n const nonce = getNonce();\n const amount = BigInt(txSendParams.amount);\n\n let totalFee = BigInt(txSendParams.fee);\n if (txSendParams.extraGas) {\n totalFee = totalFee + BigInt(txSendParams.extraGas);\n }\n const isPayWithStable = txSendParams.gasFeePaymentMethod === FeePaymentMethod.WITH_STABLECOIN;\n\n const composer = this.algorand.newGroup();\n\n const assetTransferTx = await this.algorand.createTransaction.assetTransfer({\n amount,\n assetId: tokenId,\n receiver: bridge.appAddress,\n sender,\n });\n\n if (isPayWithStable) {\n composer.addAppCallMethodCall(\n await bridge.params.swapAndBridgeWithStable({\n args: {\n assetTransferRef: assetTransferTx,\n recipient,\n destinationChainId,\n receiveToken,\n nonce,\n feeTokenAmount: totalFee,\n },\n sender,\n extraFee: feeForInner(9),\n })\n );\n const paddingTx = await this.algorand.createTransaction.appCall({\n appId: paddingUtil.appId,\n sender,\n note: \"padding_1\",\n });\n composer.addTransaction(paddingTx);\n } else {\n const paymentTx = await this.algorand.createTransaction.payment({\n amount: AlgoAmount.MicroAlgo(totalFee),\n receiver: bridge.appAddress,\n sender,\n });\n composer.addAppCallMethodCall(\n await bridge.params.swapAndBridge({\n args: {\n paymentRef: paymentTx,\n assetTransferRef: assetTransferTx,\n recipient,\n destinationChainId,\n receiveToken,\n nonce,\n },\n sender,\n extraFee: feeForInner(8),\n })\n );\n }\n\n const paddingTx = await this.algorand.createTransaction.appCall({\n appId: paddingUtil.appId,\n sender,\n note: \"padding\",\n });\n composer.addTransaction(paddingTx);\n\n const { transactions } = await composer.buildTransactions();\n return populateAndEncodeTxs(transactions, sender, this.algorand.client.algod);\n }\n\n async buildRawTransactionSwap(params: SwapParams): Promise<RawTransaction> {\n const txSwapParams = prepareTxSwapParams(this.chainType, params);\n\n const sender = Address.fromString(params.fromAccountAddress);\n const recipient = params.toAccountAddress;\n const tokenId = BigInt(params.sourceToken.tokenAddress);\n const receiveTokenId = BigInt(params.destinationToken.tokenAddress);\n const receiveAmountMin = BigInt(txSwapParams.minimumReceiveAmount);\n const amount = BigInt(txSwapParams.amount);\n\n if (!params.sourceToken.bridgeId) {\n throw new SdkError(\"ALG sourceToken must contain 'bridgeId'\");\n }\n if (!params.sourceToken.paddingUtilId) {\n throw new SdkError(\"ALG sourceToken must contain 'paddingUtilId'\");\n }\n const bridgeId = BigInt(params.sourceToken.bridgeId);\n const bridge = this.getBridge(bridgeId);\n const paddingUtilId = BigInt(params.sourceToken.paddingUtilId);\n const paddingUtil = this.getPaddingUtil(paddingUtilId);\n\n const composer = this.algorand.newGroup();\n\n if (params.fromAccountAddress === recipient) {\n const optIn = await checkAssetOptIn(receiveTokenId, recipient, this.algorand);\n if (!optIn) {\n composer.addAssetOptIn({ sender: sender, assetId: receiveTokenId });\n }\n }\n\n const assetTransfer = this.algorand.createTransaction.assetTransfer({\n assetId: tokenId,\n amount: amount,\n sender,\n receiver: bridge.appAddress,\n });\n composer.addAppCallMethodCall(\n await bridge.params.swap({\n args: { assetTransferRef: assetTransfer, recipient, receiveAsset: receiveTokenId, receiveAmountMin },\n sender,\n extraFee: feeForInner(4),\n })\n );\n const paddingTx = await this.algorand.createTransaction.appCall({\n appId: paddingUtil.appId,\n sender,\n });\n composer.addTransaction(paddingTx);\n const { transactions } = await composer.buildTransactions();\n return populateAndEncodeTxs(transactions, sender, this.algorand.client.algod);\n }\n\n private getBridge(appId: bigint): BridgeClient {\n return this.algorand.client.getTypedAppClientById(BridgeClient, { appId });\n }\n\n private getPaddingUtil(appId: bigint): PaddingUtilClient {\n return this.algorand.client.getTypedAppClientById(PaddingUtilClient, { appId });\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/services/bridge/alg/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2EAA4E;AAC5E,mDAA2C;AAC3C,6DAAwD;AAExD,oDAAwE;AACxE,4CAAmD;AACnD,gDAAmD;AAEnD,gEAA6D;AAC7D,0EAAuE;AACvE,yCAAqF;AACrF,sCAAuE;AACvE,oCAA8E;AAE9E,MAAa,gBAAiB,SAAQ,2BAAkB;IAI7C;IACA;IAJT,SAAS,GAAkB,uBAAS,CAAC,GAAG,CAAC;IAEzC,YACS,QAAwB,EACxB,GAAwB;QAE/B,KAAK,EAAE,CAAC;QAHD,aAAQ,GAAR,QAAQ,CAAgB;QACxB,QAAG,GAAH,GAAG,CAAqB;QAG/B,QAAQ,CAAC,gBAAgB,CACvB,iBAAO,CAAC,iCAAiC,CACvC,iBAAO,CAAC,mBAAmB,CACzB,+KAA+K,CAChL,CACF,CACF,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,OAAmB;QACtB,MAAM,IAAI,oCAAuB,EAAE,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,uBAAuB,CAAC,MAAkB;QAC9C,MAAM,YAAY,GAAG,MAAM,IAAA,2BAAmB,EAAC,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;QAEjF,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;YACjC,MAAM,IAAI,qBAAQ,CAAC,yCAAyC,CAAC,CAA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CAAC,IAAI,CAAC;YACvB,IAAI,EAAE,EAAE,gBAAgB,EAAE,aAAa,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE;YACpG,MAAM;YACN,QAAQ,EAAE,IAAA,iBAAW,EAAC,CAAC,CAAC;SACzB,CAAC,CACH,CAAC;QACF,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,OAAO,CAAC;YAC9D,KAAK,EAAE,WAAW,CAAC,KAAK;YACxB,MAAM;SACP,CAAC,CAAC;QACH,QAAQ,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QACnC,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,QAAQ,CAAC,iBAAiB,EAAE,CAAC;QAC5D,OAAO,IAAA,0BAAoB,EAAC,YAAY,EAAE,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAChF,CAAC;IAEO,SAAS,CAAC,KAAa;QAC7B,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,qBAAqB,CAAC,2BAAY,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAC7E,CAAC;IAEO,cAAc,CAAC,KAAa;QAClC,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,qBAAqB,CAAC,qCAAiB,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAClF,CAAC;CACF;AAnLD,4CAmLC","sourcesContent":["import { AlgorandClient } from \"@algorandfoundation/algokit-utils\";\nimport { AlgoAmount } from \"@algorandfoundation/algokit-utils/types/amount\";\nimport algosdk, { Address } from \"algosdk\";\nimport { ChainType } from \"../../../chains/chain.enums\";\nimport { AllbridgeCoreClient } from \"../../../client/core-api/core-client-base\";\nimport { MethodNotSupportedError, SdkError } from \"../../../exceptions\";\nimport { FeePaymentMethod } from \"../../../models\";\nimport { assertNever } from \"../../../utils/utils\";\nimport { RawTransaction, TransactionResponse } from \"../../models\";\nimport { BridgeClient } from \"../../models/alg/BridgeClient\";\nimport { PaddingUtilClient } from \"../../models/alg/PaddingUtilClient\";\nimport { checkAssetOptIn, feeForInner, populateAndEncodeTxs } from \"../../utils/alg\";\nimport { ChainBridgeService, SendParams, SwapParams } from \"../models\";\nimport { getNonce, prepareTxSendParams, prepareTxSwapParams } from \"../utils\";\n\nexport class AlgBridgeService extends ChainBridgeService {\n chainType: ChainType.ALG = ChainType.ALG;\n\n constructor(\n public algorand: AlgorandClient,\n public api: AllbridgeCoreClient\n ) {\n super();\n algorand.setDefaultSigner(\n algosdk.makeBasicAccountTransactionSigner(\n algosdk.mnemonicToSecretKey(\n \"tunnel gym elevator pulse motor evolve release orange culture make sister approve winter chair armor grocery distance festival tiger holiday dish wisdom region absorb secret\"\n )\n )\n );\n }\n\n send(_params: SendParams): Promise<TransactionResponse> {\n throw new MethodNotSupportedError();\n }\n\n async buildRawTransactionSend(params: SendParams): Promise<RawTransaction> {\n const txSendParams = await prepareTxSendParams(this.chainType, params, this.api);\n\n if (!params.sourceToken.bridgeId) {\n throw new SdkError(\"ALG sourceToken must contain 'bridgeId'\");\n }\n if (!params.sourceToken.paddingUtilId) {\n throw new SdkError(\"ALG sourceToken must contain 'paddingUtilId'\");\n }\n const bridgeId = BigInt(params.sourceToken.bridgeId);\n const bridge = this.getBridge(bridgeId);\n const paddingUtilId = BigInt(params.sourceToken.paddingUtilId);\n const paddingUtil = this.getPaddingUtil(paddingUtilId);\n const sender = Address.fromString(params.fromAccountAddress);\n const tokenId = BigInt(params.sourceToken.tokenAddress);\n const destinationChainId = txSendParams.toChainId;\n const recipient = txSendParams.toAccountAddress;\n const receiveToken = txSendParams.toTokenAddress;\n const nonce = getNonce();\n const amount = BigInt(txSendParams.amount);\n\n let totalFee = BigInt(txSendParams.fee);\n if (txSendParams.extraGas) {\n totalFee = totalFee + BigInt(txSendParams.extraGas);\n }\n\n const composer = this.algorand.newGroup();\n\n const assetTransferTx = await this.algorand.createTransaction.assetTransfer({\n amount,\n assetId: tokenId,\n receiver: bridge.appAddress,\n sender,\n });\n\n switch (txSendParams.gasFeePaymentMethod) {\n case FeePaymentMethod.WITH_NATIVE_CURRENCY: {\n const paymentTx = await this.algorand.createTransaction.payment({\n amount: AlgoAmount.MicroAlgo(totalFee),\n receiver: bridge.appAddress,\n sender,\n });\n composer.addAppCallMethodCall(\n await bridge.params.swapAndBridge({\n args: {\n paymentRef: paymentTx,\n assetTransferRef: assetTransferTx,\n recipient,\n destinationChainId,\n receiveToken,\n nonce,\n },\n sender,\n extraFee: feeForInner(8),\n })\n );\n break;\n }\n case FeePaymentMethod.WITH_STABLECOIN: {\n composer.addAppCallMethodCall(\n await bridge.params.swapAndBridgeWithStable({\n args: {\n assetTransferRef: assetTransferTx,\n recipient,\n destinationChainId,\n receiveToken,\n nonce,\n feeTokenAmount: totalFee,\n },\n sender,\n extraFee: feeForInner(9),\n })\n );\n const paddingTx = await this.algorand.createTransaction.appCall({\n appId: paddingUtil.appId,\n sender,\n note: \"padding_1\",\n });\n composer.addTransaction(paddingTx);\n break;\n }\n case FeePaymentMethod.WITH_ARB:\n throw new SdkError(\"ALG bridge does not support ARB0 payment method\");\n default: {\n return assertNever(txSendParams.gasFeePaymentMethod, \"Unhandled FeePaymentMethod\");\n }\n }\n\n const paddingTx = await this.algorand.createTransaction.appCall({\n appId: paddingUtil.appId,\n sender,\n note: \"padding\",\n });\n composer.addTransaction(paddingTx);\n\n const { transactions } = await composer.buildTransactions();\n return populateAndEncodeTxs(transactions, sender, this.algorand.client.algod);\n }\n\n async buildRawTransactionSwap(params: SwapParams): Promise<RawTransaction> {\n const txSwapParams = prepareTxSwapParams(this.chainType, params);\n\n const sender = Address.fromString(params.fromAccountAddress);\n const recipient = params.toAccountAddress;\n const tokenId = BigInt(params.sourceToken.tokenAddress);\n const receiveTokenId = BigInt(params.destinationToken.tokenAddress);\n const receiveAmountMin = BigInt(txSwapParams.minimumReceiveAmount);\n const amount = BigInt(txSwapParams.amount);\n\n if (!params.sourceToken.bridgeId) {\n throw new SdkError(\"ALG sourceToken must contain 'bridgeId'\");\n }\n if (!params.sourceToken.paddingUtilId) {\n throw new SdkError(\"ALG sourceToken must contain 'paddingUtilId'\");\n }\n const bridgeId = BigInt(params.sourceToken.bridgeId);\n const bridge = this.getBridge(bridgeId);\n const paddingUtilId = BigInt(params.sourceToken.paddingUtilId);\n const paddingUtil = this.getPaddingUtil(paddingUtilId);\n\n const composer = this.algorand.newGroup();\n\n if (params.fromAccountAddress === recipient) {\n const optIn = await checkAssetOptIn(receiveTokenId, recipient, this.algorand);\n if (!optIn) {\n composer.addAssetOptIn({ sender: sender, assetId: receiveTokenId });\n }\n }\n\n const assetTransfer = this.algorand.createTransaction.assetTransfer({\n assetId: tokenId,\n amount: amount,\n sender,\n receiver: bridge.appAddress,\n });\n composer.addAppCallMethodCall(\n await bridge.params.swap({\n args: { assetTransferRef: assetTransfer, recipient, receiveAsset: receiveTokenId, receiveAmountMin },\n sender,\n extraFee: feeForInner(4),\n })\n );\n const paddingTx = await this.algorand.createTransaction.appCall({\n appId: paddingUtil.appId,\n sender,\n });\n composer.addTransaction(paddingTx);\n const { transactions } = await composer.buildTransactions();\n return populateAndEncodeTxs(transactions, sender, this.algorand.client.algod);\n }\n\n private getBridge(appId: bigint): BridgeClient {\n return this.algorand.client.getTypedAppClientById(BridgeClient, { appId });\n }\n\n private getPaddingUtil(appId: bigint): PaddingUtilClient {\n return this.algorand.client.getTypedAppClientById(PaddingUtilClient, { appId });\n }\n}\n"]}
@@ -19,4 +19,5 @@ export declare class EvmBridgeService extends ChainBridgeService {
19
19
  private getBridgeContract;
20
20
  private getCctpBridgeContract;
21
21
  private getOftBridgeContract;
22
+ private getAbrPayerContract;
22
23
  }