@reyaxyz/sdk 0.112.3 → 0.113.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,5 +6,5 @@
6
6
 
7
7
  | Statements | Branches | Functions | Lines |
8
8
  | --------------------------- | ----------------------- | ------------------------- | ----------------- |
9
- | ![Statements](https://img.shields.io/badge/statements-10.1%25-red.svg?style=flat) | ![Branches](https://img.shields.io/badge/branches-4.76%25-red.svg?style=flat) | ![Functions](https://img.shields.io/badge/functions-6.06%25-red.svg?style=flat) | ![Lines](https://img.shields.io/badge/lines-9.5%25-red.svg?style=flat) |
9
+ | ![Statements](https://img.shields.io/badge/statements-10.08%25-red.svg?style=flat) | ![Branches](https://img.shields.io/badge/branches-4.76%25-red.svg?style=flat) | ![Functions](https://img.shields.io/badge/functions-6.06%25-red.svg?style=flat) | ![Lines](https://img.shields.io/badge/lines-9.48%25-red.svg?style=flat) |
10
10
 
@@ -42,7 +42,7 @@ var common_1 = require("@reyaxyz/common");
42
42
  var signAndBroadcastTransaction_1 = require("../signAndBroadcastTransaction");
43
43
  var ethers_1 = require("ethers");
44
44
  var withdrawPassivePoolAndBridge = function (params) { return __awaiter(void 0, void 0, void 0, function () {
45
- var reyaChainId, sharesAmount, eip712Signature, data, result;
45
+ var reyaChainId, sharesAmount, eip712Signature, socketMsgGasLimit, data, result;
46
46
  return __generator(this, function (_a) {
47
47
  switch (_a.label) {
48
48
  case 0:
@@ -56,8 +56,10 @@ var withdrawPassivePoolAndBridge = function (params) { return __awaiter(void 0,
56
56
  return [4 /*yield*/, (0, common_1.signPoolRemoveLiquidity)(params.signer, reyaChainId, (0, common_1.getAddress)(reyaChainId, common_1.ContractType.PERIPHERY_PROXY), params.owner.address, params.pool.id, sharesAmount, BigInt(0), params.owner.poolSigNonce + 1, (0, common_1.getCurrentTimestampInSeconds)() + common_1.BRIDGE_DEADLINE_IN_SECONDS, ethers_1.ethers.AbiCoder.defaultAbiCoder().encode(['address', 'uint256', 'uint256'], [params.owner.address, params.moneyInOutChainId, BigInt('10000000')]))];
57
57
  case 1:
58
58
  eip712Signature = _a.sent();
59
- data = (0, encode_1.encodeWithdrawPassivePoolAndBridge)(params.owner.address, params.pool.id, sharesAmount, BigInt(0), eip712Signature, BigInt('10000000'), //todo
60
- params.moneyInOutChainId, params.owner.address).calldata;
59
+ socketMsgGasLimit = (0, common_1.getSocketWithdrawMsgGasLimit)({
60
+ moneyInOutChainId: params.moneyInOutChainId,
61
+ }).msgGasLimit;
62
+ data = (0, encode_1.encodeWithdrawPassivePoolAndBridge)(params.owner.address, params.pool.id, sharesAmount, BigInt(0), eip712Signature, socketMsgGasLimit, params.moneyInOutChainId, params.owner.address).calldata;
61
63
  return [4 /*yield*/, (0, signAndBroadcastTransaction_1.signAndBroadcastTransaction)(data, reyaChainId, common_1.ContractType.PERIPHERY_PROXY, {
62
64
  destinationType: 'pool',
63
65
  })];
@@ -1 +1 @@
1
- {"version":3,"file":"withdrawPassivePoolAndBridge.js","sourceRoot":"/","sources":["services/lp/withdrawPassivePoolAndBridge.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,mCAA8D;AAC9D,0CAQyB;AACzB,8EAA6E;AAC7E,iCAAgC;AAEzB,IAAM,4BAA4B,GAAG,UAC1C,MAA0C;;;;;gBAEpC,WAAW,GAAG,IAAA,4CAAmC,EACrD,MAAM,CAAC,iBAAiB,CACzB,CAAC;gBAGF,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;oBACvB,YAAY,GAAG,IAAA,cAAK,EAAC,EAAE,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;gBAChD,CAAC;qBAAM,CAAC;oBACN,YAAY,GAAG,IAAA,cAAK,EAAC,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;gBAC9D,CAAC;gBAEuB,qBAAM,IAAA,gCA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sDvC","sourcesContent":["import {\n WithdrawPassivePoolAndBridgeParams,\n WithdrawPassivePoolAndBridgeResult,\n} from './types';\nimport { encodeWithdrawPassivePoolAndBridge } from './encode';\nimport {\n getCurrentTimestampInSeconds,\n scale,\n signPoolRemoveLiquidity,\n ContractType,\n getAddress,\n BRIDGE_DEADLINE_IN_SECONDS,\n getReyaNetworkFromMoneyInOutChainId,\n} from '@reyaxyz/common';\nimport { signAndBroadcastTransaction } from '../signAndBroadcastTransaction';\nimport { ethers } from 'ethers';\n\nexport const withdrawPassivePoolAndBridge = async (\n params: WithdrawPassivePoolAndBridgeParams,\n): Promise<WithdrawPassivePoolAndBridgeResult> => {\n const reyaChainId = getReyaNetworkFromMoneyInOutChainId(\n params.moneyInOutChainId,\n );\n\n let sharesAmount;\n if (params.withdrawMax) {\n sharesAmount = scale(30)(params.sharesAmount);\n } else {\n sharesAmount = scale(30)(params.amount / params.sharePrice);\n }\n\n const eip712Signature = await signPoolRemoveLiquidity(\n params.signer,\n reyaChainId,\n getAddress(reyaChainId, ContractType.PERIPHERY_PROXY),\n params.owner.address,\n params.pool.id,\n sharesAmount,\n BigInt(0),\n params.owner.poolSigNonce + 1,\n getCurrentTimestampInSeconds() + BRIDGE_DEADLINE_IN_SECONDS,\n ethers.AbiCoder.defaultAbiCoder().encode(\n ['address', 'uint256', 'uint256'],\n [params.owner.address, params.moneyInOutChainId, BigInt('10000000')],\n ),\n );\n\n const { calldata: data } = encodeWithdrawPassivePoolAndBridge(\n params.owner.address,\n params.pool.id,\n sharesAmount,\n BigInt(0),\n eip712Signature,\n BigInt('10000000'), //todo\n params.moneyInOutChainId,\n params.owner.address,\n );\n\n const result = await signAndBroadcastTransaction(\n data,\n reyaChainId,\n ContractType.PERIPHERY_PROXY,\n {\n destinationType: 'pool',\n },\n );\n\n return {\n transactionHash: result?.txHash || null,\n poolSigNonce: Number(result?.poolSigNonce) || null,\n };\n};\n"]}
1
+ {"version":3,"file":"withdrawPassivePoolAndBridge.js","sourceR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,CAAC,CAAC,WAAW,CAAC;gBAEG,IAAI,GAAK,IAAA,2CAAkC,EAC3D,MAAM,CAAC,KAAK,CAAC,OAAO,EACpB,MAAM,CAAC,IAAI,CAAC,EAAE,EACd,YAAY,EACZ,MAAM,CAAC,CAAC,CAAC,EACT,eAAe,EACf,iBAAiB,EACjB,MAAM,CAAC,iBAAiB,EACxB,MAAM,CAAC,KAAK,CAAC,OAAO,CACrB,SATqB,CASpB;gBAEa,qBAAM,IAAA,yDAA2B,EAC9C,IAAI,EACJ,WAAW,EACX,qBAAY,CAAC,eAAe,EAC5B;wBACE,eAAe,EAAE,MAAM;qBACxB,CACF,EAAA;;gBAPK,MAAM,GAAG,SAOd;gBAED,sBAAO;wBACL,eAAe,EAAE,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,KAAI,IAAI;wBACvC,YAAY,EAAE,MAAM,CAAC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,YAAY,CAAC,IAAI,IAAI;qBACnD,EAAC;;;KACH,CAAC;AA1DW,QAAA,4BAA4B,gCA0DvC","sourcesContent":["import {\n WithdrawPassivePoolAndBridgeParams,\n WithdrawPassivePoolAndBridgeResult,\n} from './types';\nimport { encodeWithdrawPassivePoolAndBridge } from './encode';\nimport {\n getCurrentTimestampInSeconds,\n scale,\n signPoolRemoveLiquidity,\n ContractType,\n getAddress,\n BRIDGE_DEADLINE_IN_SECONDS,\n getReyaNetworkFromMoneyInOutChainId,\n getSocketWithdrawMsgGasLimit,\n} from '@reyaxyz/common';\nimport { signAndBroadcastTransaction } from '../signAndBroadcastTransaction';\nimport { ethers } from 'ethers';\n\nexport const withdrawPassivePoolAndBridge = async (\n params: WithdrawPassivePoolAndBridgeParams,\n): Promise<WithdrawPassivePoolAndBridgeResult> => {\n const reyaChainId = getReyaNetworkFromMoneyInOutChainId(\n params.moneyInOutChainId,\n );\n\n let sharesAmount;\n if (params.withdrawMax) {\n sharesAmount = scale(30)(params.sharesAmount);\n } else {\n sharesAmount = scale(30)(params.amount / params.sharePrice);\n }\n\n const eip712Signature = await signPoolRemoveLiquidity(\n params.signer,\n reyaChainId,\n getAddress(reyaChainId, ContractType.PERIPHERY_PROXY),\n params.owner.address,\n params.pool.id,\n sharesAmount,\n BigInt(0),\n params.owner.poolSigNonce + 1,\n getCurrentTimestampInSeconds() + BRIDGE_DEADLINE_IN_SECONDS,\n ethers.AbiCoder.defaultAbiCoder().encode(\n ['address', 'uint256', 'uint256'],\n [params.owner.address, params.moneyInOutChainId, BigInt('10000000')],\n ),\n );\n\n const socketMsgGasLimit = getSocketWithdrawMsgGasLimit({\n moneyInOutChainId: params.moneyInOutChainId,\n }).msgGasLimit;\n\n const { calldata: data } = encodeWithdrawPassivePoolAndBridge(\n params.owner.address,\n params.pool.id,\n sharesAmount,\n BigInt(0),\n eip712Signature,\n socketMsgGasLimit,\n params.moneyInOutChainId,\n params.owner.address,\n );\n\n const result = await signAndBroadcastTransaction(\n data,\n reyaChainId,\n ContractType.PERIPHERY_PROXY,\n {\n destinationType: 'pool',\n },\n );\n\n return {\n transactionHash: result?.txHash || null,\n poolSigNonce: Number(result?.poolSigNonce) || null,\n };\n};\n"]}
@@ -59,7 +59,9 @@ var withdrawMAAndBridge = function (_a) {
59
59
  corePeripheryTokenInfo = (0, common_1.getTokenInfoByAddress)(tokenAddress);
60
60
  multiAction = new common_5.MultiAction();
61
61
  (0, encode_2.encodeSingleWithdraw)(corePeripheryTokenInfo.address, (0, common_1.scale)(corePeripheryTokenInfo.decimals)(unscaledAmount), multiAction);
62
- socketMsgGasLimit = BigInt('10000000');
62
+ socketMsgGasLimit = (0, common_1.getSocketWithdrawMsgGasLimit)({
63
+ moneyInOutChainId: moneyInOutChainId,
64
+ }).msgGasLimit;
63
65
  return [4 /*yield*/, (0, common_3.signCoreCommands)(signer, reyaChainId, (0, common_2.getAddress)(reyaChainId, common_2.ContractType.PERIPHERY_PROXY), marginAccountId, multiAction.commands, owner.coreSigNonce + 1, (0, common_1.getCurrentTimestampInSeconds)() + common_4.BRIDGE_DEADLINE_IN_SECONDS, ethers_1.ethers.AbiCoder.defaultAbiCoder().encode(['address', 'uint256', 'uint256'], [receiverAddress, moneyInOutChainId, socketMsgGasLimit]))];
64
66
  case 1:
65
67
  eip712Signature = _c.sent();
@@ -1 +1 @@
1
- {"version":3,"file":"withdrawMAAndBridge.js","sourceRoot":"/","sources":["services/margin-accounts/withdrawMAAndBridge.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAKyB;AACzB,0CAA2D;AAC3D,8EAA6E;AAC7E,0CAAmD;AACnD,mCAAqD;AAKrD,0CAA6D;AAC7D,oCAAiD;AACjD,0CAA8C;AAC9C,iCAAgC;AAChC,uCAA6E;AAEtE,IAAM,mBAAmB,GAAG,UAAO,EAQd;QAP1B,MAAM,YAAA,EACN,iBAAiB,uBAAA,EACjB,eAAe,qBAAA,EACf,KAAK,WAAA,EACG,cAAc,YAAA,EACtB,YAAY,kBAAA,EACZ,uBAA+B,EAA/B,eAAe,mBAAG,KAAK,CAAC,OAAO,KAAA;;;;;;oBAEzB,GAAG,GAAG,IAAA,0BAAiB,GAAE,CAAC;oBAC1B,WAAW,GAAG,IAAA,uBAAc,EAChC,GAAG,KAAK,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAC7C,CAAC;oBAEI,sBAAsB,GAAG,IAAA,8BAAqB,EAAC,YAAY,CAAC,CAAC;oBAE7D,WAAW,GAAG,IAAI,oBAAW,EAAE,CAAC;oBACtC,IAAA,6BAAoB,EAClB,sBAAsB,CAAC,OAAO,EAC9B,IAAA,cAAK,EAAC,sBAAsB,CAAC,QAAQ,CAAC,CAAC,cAAc,CAAC,EACtD,WAAW,CACZ,CAAC;oBAEI,iBAAiB,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;oBACrB,qBAAM,IAAA,yBAAgB,EAC5C,MAAM,EACN,WAAW,EACX,IAAA,mB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AAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,KAAI,IAAI;wBACvC,YAAY,EAAE,MAAM,CAAC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,YAAY,CAAC,IAAI,IAAI;qBACnD,EAAC;;;;CACH,CAAC;AAlFW,QAAA,mBAAmB,uBAkF9B","sourcesContent":["import {\n getCurrentTimestampInSeconds,\n scale,\n getTokenInfoByAddress,\n getReyaNetwork,\n} from '@reyaxyz/common';\nimport { ContractType, getAddress } from '@reyaxyz/common';\nimport { signAndBroadcastTransaction } from '../signAndBroadcastTransaction';\nimport { signCoreCommands } from '@reyaxyz/common';\nimport { encodeWithdrawMAAndBridge } from './encode';\nimport {\n WithdrawMAAndBridgeParams,\n WithdrawMAAndBridgeParamsResult,\n} from './types';\nimport { BRIDGE_DEADLINE_IN_SECONDS } from '@reyaxyz/common';\nimport { encodeSingleWithdraw } from '../encode';\nimport { MultiAction } from '@reyaxyz/common';\nimport { ethers } from 'ethers';\nimport { getSdkEnvironment, getTransactionModuleClient } from '../../config';\n\nexport const withdrawMAAndBridge = async ({\n signer,\n moneyInOutChainId,\n marginAccountId,\n owner,\n amount: unscaledAmount,\n tokenAddress,\n receiverAddress = owner.address,\n}: WithdrawMAAndBridgeParams): Promise<WithdrawMAAndBridgeParamsResult> => {\n const env = getSdkEnvironment();\n const reyaChainId = getReyaNetwork(\n env === 'production' ? 'production' : 'test',\n );\n\n const corePeripheryTokenInfo = getTokenInfoByAddress(tokenAddress);\n\n const multiAction = new MultiAction();\n encodeSingleWithdraw(\n corePeripheryTokenInfo.address,\n scale(corePeripheryTokenInfo.decimals)(unscaledAmount),\n multiAction,\n );\n\n const socketMsgGasLimit = BigInt('10000000');\n const eip712Signature = await signCoreCommands(\n signer,\n reyaChainId,\n getAddress(reyaChainId, ContractType.PERIPHERY_PROXY),\n marginAccountId,\n multiAction.commands,\n owner.coreSigNonce + 1,\n getCurrentTimestampInSeconds() + BRIDGE_DEADLINE_IN_SECONDS,\n ethers.AbiCoder.defaultAbiCoder().encode(\n ['address', 'uint256', 'uint256'],\n [receiverAddress, moneyInOutChainId, socketMsgGasLimit],\n ),\n );\n\n const { calldata: data } = encodeWithdrawMAAndBridge(\n marginAccountId,\n corePeripheryTokenInfo.address,\n scale(corePeripheryTokenInfo.decimals)(unscaledAmount),\n eip712Signature,\n socketMsgGasLimit,\n moneyInOutChainId,\n receiverAddress,\n );\n\n const result = await signAndBroadcastTransaction(\n data,\n reyaChainId,\n ContractType.PERIPHERY_PROXY,\n {\n destinationType: 'account',\n },\n );\n\n if (!result?.txHash) {\n return {\n transactionHash: null,\n coreSigNonce: null,\n };\n }\n\n try {\n const transactionModuleClient = getTransactionModuleClient();\n await transactionModuleClient.pushPendingTransaction(\n marginAccountId,\n result.txHash,\n moneyInOutChainId,\n unscaledAmount,\n corePeripheryTokenInfo.address,\n 'withdrawal',\n );\n } catch (error) {\n console.log('Error persisting pending withdraw transaction', error);\n }\n\n return {\n transactionHash: result?.txHash || null,\n coreSigNonce: Number(result?.coreSigNonce) || null,\n };\n};\n"]}
1
+ {"version":3,"file":"withdrawMAAndBridge.js","sourceRoot":"/","sources":["services/margin-accounts/withdrawMAAndBridge.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAMyB;AACzB,0CAA2D;AAC3D,8EAA6E;AAC7E,0CAAmD;AACnD,mCAAqD;AAKrD,0CAA6D;AAC7D,oCAAiD;AACjD,0CAA8C;AAC9C,iCAAgC;AAChC,uCAA6E;AAEtE,IAAM,mBAAmB,GAAG,UAAO,EAQd;QAP1B,MAAM,YAAA,EACN,iBAAiB,uBAAA,EACjB,eAAe,qBAAA,EACf,KAAK,WAAA,EACG,cAAc,YAAA,EACtB,YAAY,kBAAA,EACZ,uBAA+B,EAA/B,eAAe,mBAAG,KAAK,CAAC,OAAO,KAAA;;;;;;oBAEzB,GAAG,GAAG,IAAA,0BAAiB,GAAE,CAAC;oBAC1B,W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;;oBAPK,MAAM,GAAG,SAOd;oBAED,IAAI,CAAC,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,CAAA,EAAE,CAAC;wBACpB,sBAAO;gCACL,eAAe,EAAE,IAAI;gCACrB,YAAY,EAAE,IAAI;6BACnB,EAAC;oBACJ,CAAC;;;;oBAGO,uBAAuB,GAAG,IAAA,mCAA0B,GAAE,CAAC;oBAC7D,qBAAM,uBAAuB,CAAC,sBAAsB,CAClD,eAAe,EACf,MAAM,CAAC,MAAM,EACb,iBAAiB,EACjB,cAAc,EACd,sBAAsB,CAAC,OAAO,EAC9B,YAAY,CACb,EAAA;;oBAPD,SAOC,CAAC;;;;oBAEF,OAAO,CAAC,GAAG,CAAC,+CAA+C,EAAE,OAAK,CAAC,CAAC;;wBAGtE,sBAAO;wBACL,eAAe,EAAE,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,KAAI,IAAI;wBACvC,YAAY,EAAE,MAAM,CAAC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,YAAY,CAAC,IAAI,IAAI;qBACnD,EAAC;;;;CACH,CAAC;AArFW,QAAA,mBAAmB,uBAqF9B","sourcesContent":["import {\n getCurrentTimestampInSeconds,\n scale,\n getTokenInfoByAddress,\n getReyaNetwork,\n getSocketWithdrawMsgGasLimit,\n} from '@reyaxyz/common';\nimport { ContractType, getAddress } from '@reyaxyz/common';\nimport { signAndBroadcastTransaction } from '../signAndBroadcastTransaction';\nimport { signCoreCommands } from '@reyaxyz/common';\nimport { encodeWithdrawMAAndBridge } from './encode';\nimport {\n WithdrawMAAndBridgeParams,\n WithdrawMAAndBridgeParamsResult,\n} from './types';\nimport { BRIDGE_DEADLINE_IN_SECONDS } from '@reyaxyz/common';\nimport { encodeSingleWithdraw } from '../encode';\nimport { MultiAction } from '@reyaxyz/common';\nimport { ethers } from 'ethers';\nimport { getSdkEnvironment, getTransactionModuleClient } from '../../config';\n\nexport const withdrawMAAndBridge = async ({\n signer,\n moneyInOutChainId,\n marginAccountId,\n owner,\n amount: unscaledAmount,\n tokenAddress,\n receiverAddress = owner.address,\n}: WithdrawMAAndBridgeParams): Promise<WithdrawMAAndBridgeParamsResult> => {\n const env = getSdkEnvironment();\n const reyaChainId = getReyaNetwork(\n env === 'production' ? 'production' : 'test',\n );\n\n const corePeripheryTokenInfo = getTokenInfoByAddress(tokenAddress);\n\n const multiAction = new MultiAction();\n encodeSingleWithdraw(\n corePeripheryTokenInfo.address,\n scale(corePeripheryTokenInfo.decimals)(unscaledAmount),\n multiAction,\n );\n\n const socketMsgGasLimit = getSocketWithdrawMsgGasLimit({\n moneyInOutChainId: moneyInOutChainId,\n }).msgGasLimit;\n\n const eip712Signature = await signCoreCommands(\n signer,\n reyaChainId,\n getAddress(reyaChainId, ContractType.PERIPHERY_PROXY),\n marginAccountId,\n multiAction.commands,\n owner.coreSigNonce + 1,\n getCurrentTimestampInSeconds() + BRIDGE_DEADLINE_IN_SECONDS,\n ethers.AbiCoder.defaultAbiCoder().encode(\n ['address', 'uint256', 'uint256'],\n [receiverAddress, moneyInOutChainId, socketMsgGasLimit],\n ),\n );\n\n const { calldata: data } = encodeWithdrawMAAndBridge(\n marginAccountId,\n corePeripheryTokenInfo.address,\n scale(corePeripheryTokenInfo.decimals)(unscaledAmount),\n eip712Signature,\n socketMsgGasLimit,\n moneyInOutChainId,\n receiverAddress,\n );\n\n const result = await signAndBroadcastTransaction(\n data,\n reyaChainId,\n ContractType.PERIPHERY_PROXY,\n {\n destinationType: 'account',\n },\n );\n\n if (!result?.txHash) {\n return {\n transactionHash: null,\n coreSigNonce: null,\n };\n }\n\n try {\n const transactionModuleClient = getTransactionModuleClient();\n await transactionModuleClient.pushPendingTransaction(\n marginAccountId,\n result.txHash,\n moneyInOutChainId,\n unscaledAmount,\n corePeripheryTokenInfo.address,\n 'withdrawal',\n );\n } catch (error) {\n console.log('Error persisting pending withdraw transaction', error);\n }\n\n return {\n transactionHash: result?.txHash || null,\n coreSigNonce: Number(result?.coreSigNonce) || null,\n };\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"withdrawPassivePoolAndBridge.d.ts","sourceRoot":"/","sources":["services/lp/withdrawPassivePoolAndBridge.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kCAAkC,EAClC,kCAAkC,EACnC,MAAM,SAAS,CAAC;AAcjB,eAAO,MAAM,4BAA4B,WAC/B,kCAAkC,KACzC,QAAQ,kCAAkC,CAoD5C,CAAC"}
1
+ {"version":3,"file":"withdrawPassivePoolAndBridge.d.ts","sourceRoot":"/","sources":["services/lp/withdrawPassivePoolAndBridge.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kCAAkC,EAClC,kCAAkC,EACnC,MAAM,SAAS,CAAC;AAejB,eAAO,MAAM,4BAA4B,WAC/B,kCAAkC,KACzC,QAAQ,kCAAkC,CAwD5C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"withdrawMAAndBridge.d.ts","sourceRoot":"/","sources":["services/margin-accounts/withdrawMAAndBridge.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,yBAAyB,EACzB,+BAA+B,EAChC,MAAM,SAAS,CAAC;AAOjB,eAAO,MAAM,mBAAmB,kHAQ7B,yBAAyB,KAAG,QAAQ,+BAA+B,CA0ErE,CAAC"}
1
+ {"version":3,"file":"withdrawMAAndBridge.d.ts","sourceRoot":"/","sources":["services/margin-accounts/withdrawMAAndBridge.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,yBAAyB,EACzB,+BAA+B,EAChC,MAAM,SAAS,CAAC;AAOjB,eAAO,MAAM,mBAAmB,kHAQ7B,yBAAyB,KAAG,QAAQ,+BAA+B,CA6ErE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reyaxyz/sdk",
3
- "version": "0.112.3",
3
+ "version": "0.113.0",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -29,11 +29,11 @@
29
29
  "generate:coverage-badges": "npx istanbul-badges-readme --silent"
30
30
  },
31
31
  "dependencies": {
32
- "@reyaxyz/common": "0.206.2",
32
+ "@reyaxyz/common": "0.208.0",
33
33
  "axios": "^1.6.2",
34
34
  "bignumber.js": "^9.1.2",
35
35
  "ethers": "6.9.0"
36
36
  },
37
37
  "packageManager": "pnpm@8.3.1",
38
- "gitHead": "a5979a6caad33eff988705ad8152902aca425d5a"
38
+ "gitHead": "6c686e8a34ef6d8977fb14b506ce22c2ad8a38da"
39
39
  }
@@ -11,6 +11,7 @@ import {
11
11
  getAddress,
12
12
  BRIDGE_DEADLINE_IN_SECONDS,
13
13
  getReyaNetworkFromMoneyInOutChainId,
14
+ getSocketWithdrawMsgGasLimit,
14
15
  } from '@reyaxyz/common';
15
16
  import { signAndBroadcastTransaction } from '../signAndBroadcastTransaction';
16
17
  import { ethers } from 'ethers';
@@ -45,13 +46,17 @@ export const withdrawPassivePoolAndBridge = async (
45
46
  ),
46
47
  );
47
48
 
49
+ const socketMsgGasLimit = getSocketWithdrawMsgGasLimit({
50
+ moneyInOutChainId: params.moneyInOutChainId,
51
+ }).msgGasLimit;
52
+
48
53
  const { calldata: data } = encodeWithdrawPassivePoolAndBridge(
49
54
  params.owner.address,
50
55
  params.pool.id,
51
56
  sharesAmount,
52
57
  BigInt(0),
53
58
  eip712Signature,
54
- BigInt('10000000'), //todo
59
+ socketMsgGasLimit,
55
60
  params.moneyInOutChainId,
56
61
  params.owner.address,
57
62
  );
@@ -3,6 +3,7 @@ import {
3
3
  scale,
4
4
  getTokenInfoByAddress,
5
5
  getReyaNetwork,
6
+ getSocketWithdrawMsgGasLimit,
6
7
  } from '@reyaxyz/common';
7
8
  import { ContractType, getAddress } from '@reyaxyz/common';
8
9
  import { signAndBroadcastTransaction } from '../signAndBroadcastTransaction';
@@ -41,7 +42,10 @@ export const withdrawMAAndBridge = async ({
41
42
  multiAction,
42
43
  );
43
44
 
44
- const socketMsgGasLimit = BigInt('10000000');
45
+ const socketMsgGasLimit = getSocketWithdrawMsgGasLimit({
46
+ moneyInOutChainId: moneyInOutChainId,
47
+ }).msgGasLimit;
48
+
45
49
  const eip712Signature = await signCoreCommands(
46
50
  signer,
47
51
  reyaChainId,