@reyaxyz/sdk 0.80.0 → 0.81.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.
Files changed (122) hide show
  1. package/README.md +1 -1
  2. package/dist/services/encode.js +7 -7
  3. package/dist/services/encode.js.map +1 -1
  4. package/dist/services/lp/bridgeAndDepositPassivePool.js +3 -4
  5. package/dist/services/lp/bridgeAndDepositPassivePool.js.map +1 -1
  6. package/dist/services/lp/encode.js +6 -6
  7. package/dist/services/lp/encode.js.map +1 -1
  8. package/dist/services/lp/lp.js +3 -4
  9. package/dist/services/lp/lp.js.map +1 -1
  10. package/dist/services/lp/transferFromMAToPool.js +7 -8
  11. package/dist/services/lp/transferFromMAToPool.js.map +1 -1
  12. package/dist/services/lp/withdrawPassivePoolAndBridge.js +2 -6
  13. package/dist/services/lp/withdrawPassivePoolAndBridge.js.map +1 -1
  14. package/dist/services/margin-accounts/account.js +3 -3
  15. package/dist/services/margin-accounts/account.js.map +1 -1
  16. package/dist/services/margin-accounts/bridgeAndDepositExistingMA.js +5 -6
  17. package/dist/services/margin-accounts/bridgeAndDepositExistingMA.js.map +1 -1
  18. package/dist/services/margin-accounts/bridgeAndDepositNewMA.js +3 -4
  19. package/dist/services/margin-accounts/bridgeAndDepositNewMA.js.map +1 -1
  20. package/dist/services/margin-accounts/deposit.js +4 -5
  21. package/dist/services/margin-accounts/deposit.js.map +1 -1
  22. package/dist/services/margin-accounts/encode.js +14 -19
  23. package/dist/services/margin-accounts/encode.js.map +1 -1
  24. package/dist/services/margin-accounts/transferMarginBetweenAccounts.js +3 -3
  25. package/dist/services/margin-accounts/transferMarginBetweenAccounts.js.map +1 -1
  26. package/dist/services/margin-accounts/withdraw.js +4 -5
  27. package/dist/services/margin-accounts/withdraw.js.map +1 -1
  28. package/dist/services/margin-accounts/withdrawMAAndBridge.js +8 -8
  29. package/dist/services/margin-accounts/withdrawMAAndBridge.js.map +1 -1
  30. package/dist/services/orders/encode.js +7 -9
  31. package/dist/services/orders/encode.js.map +1 -1
  32. package/dist/services/orders/order.js +10 -10
  33. package/dist/services/orders/order.js.map +1 -1
  34. package/dist/services/{executeTransaction.js → signAndBroadcastTransaction.js} +9 -88
  35. package/dist/services/signAndBroadcastTransaction.js.map +1 -0
  36. package/dist/services/token/approve.js +3 -3
  37. package/dist/services/token/approve.js.map +1 -1
  38. package/dist/services/token/getAllowance.js +2 -3
  39. package/dist/services/token/getAllowance.js.map +1 -1
  40. package/dist/types/services/encode.d.ts +1 -1
  41. package/dist/types/services/encode.d.ts.map +1 -1
  42. package/dist/types/services/lp/encode.d.ts +2 -2
  43. package/dist/types/services/lp/encode.d.ts.map +1 -1
  44. package/dist/types/services/lp/lp.d.ts.map +1 -1
  45. package/dist/types/services/lp/transferFromMAToPool.d.ts.map +1 -1
  46. package/dist/types/services/lp/withdrawPassivePoolAndBridge.d.ts.map +1 -1
  47. package/dist/types/services/margin-accounts/bridgeAndDepositExistingMA.d.ts.map +1 -1
  48. package/dist/types/services/margin-accounts/bridgeAndDepositNewMA.d.ts.map +1 -1
  49. package/dist/types/services/margin-accounts/deposit.d.ts.map +1 -1
  50. package/dist/types/services/margin-accounts/encode.d.ts +2 -2
  51. package/dist/types/services/margin-accounts/encode.d.ts.map +1 -1
  52. package/dist/types/services/margin-accounts/withdraw.d.ts.map +1 -1
  53. package/dist/types/services/orders/encode.d.ts +1 -1
  54. package/dist/types/services/orders/encode.d.ts.map +1 -1
  55. package/dist/types/services/signAndBroadcastTransaction.d.ts +8 -0
  56. package/dist/types/services/signAndBroadcastTransaction.d.ts.map +1 -0
  57. package/dist/types/services/token/getAllowance.d.ts.map +1 -1
  58. package/package.json +3 -3
  59. package/src/services/encode.ts +3 -4
  60. package/src/services/lp/bridgeAndDepositPassivePool.ts +2 -2
  61. package/src/services/lp/encode.ts +5 -7
  62. package/src/services/lp/lp.ts +1 -2
  63. package/src/services/lp/transferFromMAToPool.ts +4 -5
  64. package/src/services/lp/withdrawPassivePoolAndBridge.ts +5 -4
  65. package/src/services/margin-accounts/account.ts +2 -2
  66. package/src/services/margin-accounts/bridgeAndDepositExistingMA.ts +2 -3
  67. package/src/services/margin-accounts/bridgeAndDepositNewMA.ts +1 -2
  68. package/src/services/margin-accounts/deposit.ts +1 -2
  69. package/src/services/margin-accounts/encode.ts +15 -12
  70. package/src/services/margin-accounts/transferMarginBetweenAccounts.ts +2 -2
  71. package/src/services/margin-accounts/withdraw.ts +1 -2
  72. package/src/services/margin-accounts/withdrawMAAndBridge.ts +5 -5
  73. package/src/services/orders/encode.ts +12 -6
  74. package/src/services/orders/order.ts +3 -3
  75. package/src/services/signAndBroadcastTransaction.ts +42 -0
  76. package/src/services/token/approve.ts +1 -1
  77. package/src/services/token/getAllowance.ts +2 -1
  78. package/dist/abis/CoreProxy.json +0 -5600
  79. package/dist/abis/Periphery.json +0 -1464
  80. package/dist/abis/socket/VaultWithPayload.json +0 -40
  81. package/dist/services/executeTransaction.js.map +0 -1
  82. package/dist/services/sign.js +0 -146
  83. package/dist/services/sign.js.map +0 -1
  84. package/dist/types/services/executeTransaction.d.ts +0 -20
  85. package/dist/types/services/executeTransaction.d.ts.map +0 -1
  86. package/dist/types/services/sign.d.ts +0 -12
  87. package/dist/types/services/sign.d.ts.map +0 -1
  88. package/dist/types/utils/action.d.ts +0 -27
  89. package/dist/types/utils/action.d.ts.map +0 -1
  90. package/dist/types/utils/consts.d.ts +0 -4
  91. package/dist/types/utils/consts.d.ts.map +0 -1
  92. package/dist/types/utils/contractAddresses.d.ts +0 -8
  93. package/dist/types/utils/contractAddresses.d.ts.map +0 -1
  94. package/dist/types/utils/routerCommands.d.ts +0 -23
  95. package/dist/types/utils/routerCommands.d.ts.map +0 -1
  96. package/dist/types/utils/trade.d.ts +0 -2
  97. package/dist/types/utils/trade.d.ts.map +0 -1
  98. package/dist/types/utils/txHelpers.d.ts +0 -2
  99. package/dist/types/utils/txHelpers.d.ts.map +0 -1
  100. package/dist/utils/action.js +0 -22
  101. package/dist/utils/action.js.map +0 -1
  102. package/dist/utils/consts.js +0 -7
  103. package/dist/utils/consts.js.map +0 -1
  104. package/dist/utils/contractAddresses.js +0 -37
  105. package/dist/utils/contractAddresses.js.map +0 -1
  106. package/dist/utils/routerCommands.js +0 -45
  107. package/dist/utils/routerCommands.js.map +0 -1
  108. package/dist/utils/trade.js +0 -24
  109. package/dist/utils/trade.js.map +0 -1
  110. package/dist/utils/txHelpers.js +0 -8
  111. package/dist/utils/txHelpers.js.map +0 -1
  112. package/src/abis/CoreProxy.json +0 -5600
  113. package/src/abis/Periphery.json +0 -1464
  114. package/src/abis/socket/VaultWithPayload.json +0 -40
  115. package/src/services/executeTransaction.ts +0 -123
  116. package/src/services/sign.ts +0 -135
  117. package/src/utils/action.ts +0 -41
  118. package/src/utils/consts.ts +0 -3
  119. package/src/utils/contractAddresses.ts +0 -43
  120. package/src/utils/routerCommands.ts +0 -62
  121. package/src/utils/trade.ts +0 -25
  122. package/src/utils/txHelpers.ts +0 -3
@@ -1 +1 @@
1
- {"version":3,"file":"approve.js","sourceRoot":"/","sources":["services/token/approve.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAA2D;AAC3D,0CAQyB;AACzB,mEAAyE;AAElE,IAAM,oBAAoB,GAAG,UAClC,MAA0B;;;;;;oBAEV,qBAAM,CAAA,MAAA,MAAM,CAAC,MAAM,CAAC,QAAQ,0CAAE,UAAU,EAAE,CAAA,EAAA;;gBAApD,OAAO,GAAG,SAA0C;gBACpD,OAAO,GAAG,MAAM,CAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,CAAC,CAAC;gBAGrC,SAAS,GAAG,IAAA,8BAAqB,EAAC,MAAM,CAAC,YAAY,CAAC,CAAC;gBAC3D,IAAI,oBAAY,CAAC,MAAM,IAAI,SAAS,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;oBACrD,SAAS,GAAG,IAAA,mCAA0B,EAAC,OAAO,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AAC,uBAAuB,CAAC,CAAC;;;gBAI5B,KAAA,0BAAiB,CAAA;;gBACb,qBAAM,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,EAAA;oBAD1C,qBAAM,mBACX,gBAAa,GAAE,SAAgC;wBAC/C,eAAY,GAAE,SAAS,CAAC,OAAO;wBAC/B,iBAAc,GAAE,oBAAoB;wBACpC,UAAO,GAAE,MAAM,CAAC,MAAM;6BACtB,EAAA;oBALF,sBAAO,SAKL,EAAC;;;gBAEH,OAAO,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;;qBAG5C,sBAAO,CAAC,EAAC;;;KACV,CAAC;AA/DW,QAAA,oBAAoB,wBA+D/B","sourcesContent":["import { ApprovalType, ApproveTokenParams } from './types';\nimport {\n getERC20Allowance,\n getERC20TokenContract,\n getRUSDUnderlyingTokenInfo,\n getSocketVault,\n GetSocketVaultParams,\n getTokenInfoByAddress,\n scale,\n} from '@reyaxyz/common';\nimport { ContractType, getAddress } from '../../utils/contractAddresses';\n\nexport const approveTokenSpending = async (\n params: ApproveTokenParams,\n): Promise<number> => {\n const network = await params.signer.provider?.getNetwork();\n const chainId = Number(network?.chainId);\n\n // todo: to be removed once lp form in offchain/UI is fixed\n let tokenInfo = getTokenInfoByAddress(params.tokenAddress);\n if (ApprovalType.BRIDGE && tokenInfo.name === 'RUSD') {\n tokenInfo = getRUSDUnderlyingTokenInfo(chainId);\n }\n\n const tokenContract = getERC20TokenContract(tokenInfo.address, params.signer);\n\n let contractProxyAddress;\n switch (params.type) {\n case ApprovalType.DEPOSIT:\n contractProxyAddress = getAddress(chainId, ContractType.CORE_PROXY);\n break;\n case ApprovalType.LP:\n contractProxyAddress = getAddress(\n chainId,\n ContractType.PASSIVE_POOL_PROXY,\n );\n break;\n case ApprovalType.BRIDGE:\n contractProxyAddress = getSocketVault({\n moneyInOutChainId: chainId,\n tokenName: tokenInfo.name,\n } as GetSocketVaultParams);\n break;\n default:\n throw new Error('Unexpected approval type in approveTokenSpending');\n }\n\n const scaledTokenAmount = scale(tokenInfo.decimals)(params.amount);\n\n const approvalTransaction = await tokenContract\n .approve(contractProxyAddress, scaledTokenAmount)\n .catch((error) => {\n console.warn('Transaction Confirmation Error');\n console.error(error);\n throw new Error('Transaction Confirmation Error');\n });\n try {\n await approvalTransaction.wait();\n } catch (error) {\n console.warn('Token approval failed');\n throw new Error('Token approval failed');\n }\n\n try {\n return await getERC20Allowance({\n walletAddress: await params.signer.getAddress(),\n tokenAddress: tokenInfo.address,\n spenderAddress: contractProxyAddress,\n subject: params.signer,\n });\n } catch (error) {\n console.warn('Fetching allowance failed');\n }\n\n return 0;\n};\n"]}
1
+ {"version":3,"file":"approve.js","sourceRoot":"/","sources":["services/token/approve.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAA2D;AAC3D,0CAQyB;AACzB,0CAA2D;AAEpD,IAAM,oBAAoB,GAAG,UAClC,MAA0B;;;;;;oBAEV,qBAAM,CAAA,MAAA,MAAM,CAAC,MAAM,CAAC,QAAQ,0CAAE,UAAU,EAAE,CAAA,EAAA;;gBAApD,OAAO,GAAG,SAA0C;gBACpD,OAAO,GAAG,MAAM,CAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,CAAC,CAAC;gBAGrC,SAAS,GAAG,IAAA,8BAAqB,EAAC,MAAM,CAAC,YAAY,CAAC,CAAC;gBAC3D,IAAI,oBAAY,CAAC,MAAM,IAAI,SAAS,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;oBACrD,SAAS,GAAG,IAAA,mCAA0B,EAAC,OAAO,CAAC,CAAC;gBAClD,CAAC;gBAEK,aAAa,GAAG,IAAA,8BAAqB,EAAC,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;gBAG9E,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;oBACpB,KAAK,oBAAY,CAAC,OAAO;wBACvB,oBAAoB,GAAG,IAAA,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BACpC,UAAO,GAAE,MAAM,CAAC,MAAM;6BACtB,EAAA;oBALF,sBAAO,SAKL,EAAC;;;gBAEH,OAAO,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;;qBAG5C,sBAAO,CAAC,EAAC;;;KACV,CAAC;AA/DW,QAAA,oBAAoB,wBA+D/B","sourcesContent":["import { ApprovalType, ApproveTokenParams } from './types';\nimport {\n getERC20Allowance,\n getERC20TokenContract,\n getRUSDUnderlyingTokenInfo,\n getSocketVault,\n GetSocketVaultParams,\n getTokenInfoByAddress,\n scale,\n} from '@reyaxyz/common';\nimport { ContractType, getAddress } from '@reyaxyz/common';\n\nexport const approveTokenSpending = async (\n params: ApproveTokenParams,\n): Promise<number> => {\n const network = await params.signer.provider?.getNetwork();\n const chainId = Number(network?.chainId);\n\n // todo: to be removed once lp form in offchain/UI is fixed\n let tokenInfo = getTokenInfoByAddress(params.tokenAddress);\n if (ApprovalType.BRIDGE && tokenInfo.name === 'RUSD') {\n tokenInfo = getRUSDUnderlyingTokenInfo(chainId);\n }\n\n const tokenContract = getERC20TokenContract(tokenInfo.address, params.signer);\n\n let contractProxyAddress;\n switch (params.type) {\n case ApprovalType.DEPOSIT:\n contractProxyAddress = getAddress(chainId, ContractType.CORE_PROXY);\n break;\n case ApprovalType.LP:\n contractProxyAddress = getAddress(\n chainId,\n ContractType.PASSIVE_POOL_PROXY,\n );\n break;\n case ApprovalType.BRIDGE:\n contractProxyAddress = getSocketVault({\n moneyInOutChainId: chainId,\n tokenName: tokenInfo.name,\n } as GetSocketVaultParams);\n break;\n default:\n throw new Error('Unexpected approval type in approveTokenSpending');\n }\n\n const scaledTokenAmount = scale(tokenInfo.decimals)(params.amount);\n\n const approvalTransaction = await tokenContract\n .approve(contractProxyAddress, scaledTokenAmount)\n .catch((error) => {\n console.warn('Transaction Confirmation Error');\n console.error(error);\n throw new Error('Transaction Confirmation Error');\n });\n try {\n await approvalTransaction.wait();\n } catch (error) {\n console.warn('Token approval failed');\n throw new Error('Token approval failed');\n }\n\n try {\n return await getERC20Allowance({\n walletAddress: await params.signer.getAddress(),\n tokenAddress: tokenInfo.address,\n spenderAddress: contractProxyAddress,\n subject: params.signer,\n });\n } catch (error) {\n console.warn('Fetching allowance failed');\n }\n\n return 0;\n};\n"]}
@@ -39,7 +39,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.getAllowance = void 0;
40
40
  var types_1 = require("./types");
41
41
  var common_1 = require("@reyaxyz/common");
42
- var contractAddresses_1 = require("../../utils/contractAddresses");
43
42
  var getAllowance = function (params) { return __awaiter(void 0, void 0, void 0, function () {
44
43
  var network, chainId, tokenInfo, contractProxyAddress, walletAddress, allowance;
45
44
  var _a;
@@ -55,10 +54,10 @@ var getAllowance = function (params) { return __awaiter(void 0, void 0, void 0,
55
54
  }
56
55
  switch (params.type) {
57
56
  case types_1.ApprovalType.DEPOSIT:
58
- contractProxyAddress = (0, contractAddresses_1.getAddress)(chainId, contractAddresses_1.ContractType.CORE_PROXY);
57
+ contractProxyAddress = (0, common_1.getAddress)(chainId, common_1.ContractType.CORE_PROXY);
59
58
  break;
60
59
  case types_1.ApprovalType.LP:
61
- contractProxyAddress = (0, contractAddresses_1.getAddress)(chainId, contractAddresses_1.ContractType.PASSIVE_POOL_PROXY);
60
+ contractProxyAddress = (0, common_1.getAddress)(chainId, common_1.ContractType.PASSIVE_POOL_PROXY);
62
61
  break;
63
62
  case types_1.ApprovalType.BRIDGE:
64
63
  contractProxyAddress = (0, common_1.getSocketVault)({
@@ -1 +1 @@
1
- {"version":3,"file":"getAllowance.js","sourceRoot":"/","sources":["services/token/getAllowance.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAA2D;AAC3D,0CAMyB;AACzB,mEAAyE;AAElE,IAAM,YAAY,GAAG,UAC1B,MAA0B;;;;;oBAEV,qBAAM,CAAA,MAAA,MAAM,CAAC,MAAM,CAAC,QAAQ,0CAAE,UAAU,EAAE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W,QAAA,YAAY,gBA2CvB","sourcesContent":["import { ApprovalType, GetAllowanceParams } from './types';\nimport {\n GetSocketVaultParams,\n getERC20Allowance,\n getRUSDUnderlyingTokenInfo,\n getSocketVault,\n getTokenInfoByAddress,\n} from '@reyaxyz/common';\nimport { ContractType, getAddress } from '../../utils/contractAddresses';\n\nexport const getAllowance = async (\n params: GetAllowanceParams,\n): Promise<number> => {\n const network = await params.signer.provider?.getNetwork();\n const chainId = Number(network?.chainId);\n\n // todo: to be removed once lp form in offchain/UI is fixed\n let tokenInfo = getTokenInfoByAddress(params.tokenAddress);\n if (ApprovalType.BRIDGE && tokenInfo.name === 'RUSD') {\n tokenInfo = getRUSDUnderlyingTokenInfo(chainId);\n }\n\n let contractProxyAddress;\n switch (params.type) {\n case ApprovalType.DEPOSIT:\n contractProxyAddress = getAddress(chainId, ContractType.CORE_PROXY);\n break;\n case ApprovalType.LP:\n contractProxyAddress = getAddress(\n chainId,\n ContractType.PASSIVE_POOL_PROXY,\n );\n break;\n case ApprovalType.BRIDGE:\n contractProxyAddress = getSocketVault({\n moneyInOutChainId: chainId,\n tokenName: tokenInfo.name,\n } as GetSocketVaultParams);\n break;\n default:\n throw new Error('Unexpected approval type in getAllowance');\n }\n\n const walletAddress: string = await params.signer.getAddress();\n\n const allowance = await getERC20Allowance({\n walletAddress,\n tokenAddress: tokenInfo.address,\n spenderAddress: contractProxyAddress,\n subject: params.signer,\n });\n\n return allowance;\n};\n"]}
1
+ {"version":3,"file":"getAllowance.js","sourceRoot":"/","sources":["services/token/getAllowance.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAA2D;AAC3D,0CAQyB;AAElB,IAAM,YAAY,GAAG,UAC1B,MAA0B;;;;;oBAEV,qBAAM,CAAA,MAAA,MAAM,CAAC,MAAM,CAAC,QAAQ,0CAAE,UAAU,EAAE,CAAA,EAAA;;gBAApD,OAAO,GAAG,SAA0C;gBACpD,OAAO,GAAG,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';\nimport {\n GetSocketVaultParams,\n getERC20Allowance,\n getRUSDUnderlyingTokenInfo,\n getSocketVault,\n getTokenInfoByAddress,\n ContractType,\n getAddress,\n} from '@reyaxyz/common';\n\nexport const getAllowance = async (\n params: GetAllowanceParams,\n): Promise<number> => {\n const network = await params.signer.provider?.getNetwork();\n const chainId = Number(network?.chainId);\n\n // todo: to be removed once lp form in offchain/UI is fixed\n let tokenInfo = getTokenInfoByAddress(params.tokenAddress);\n if (ApprovalType.BRIDGE && tokenInfo.name === 'RUSD') {\n tokenInfo = getRUSDUnderlyingTokenInfo(chainId);\n }\n\n let contractProxyAddress;\n switch (params.type) {\n case ApprovalType.DEPOSIT:\n contractProxyAddress = getAddress(chainId, ContractType.CORE_PROXY);\n break;\n case ApprovalType.LP:\n contractProxyAddress = getAddress(\n chainId,\n ContractType.PASSIVE_POOL_PROXY,\n );\n break;\n case ApprovalType.BRIDGE:\n contractProxyAddress = getSocketVault({\n moneyInOutChainId: chainId,\n tokenName: tokenInfo.name,\n } as GetSocketVaultParams);\n break;\n default:\n throw new Error('Unexpected approval type in getAllowance');\n }\n\n const walletAddress: string = await params.signer.getAddress();\n\n const allowance = await getERC20Allowance({\n walletAddress,\n tokenAddress: tokenInfo.address,\n spenderAddress: contractProxyAddress,\n subject: params.signer,\n });\n\n return allowance;\n};\n"]}
@@ -1,4 +1,4 @@
1
- import { MethodParameters, MultiAction } from '../utils/action';
1
+ import { MethodParameters, MultiAction } from '@reyaxyz/common';
2
2
  export declare const encodeSingleDeposit: (token: string, amount: bigint, multiAction: MultiAction) => void;
3
3
  export declare const encodeSingleWithdraw: (token: string, amount: bigint, multiAction: MultiAction) => void;
4
4
  export declare const encodeSingleTransferMargin: (toMarginAccountId: number, token: string, amount: bigint, multiAction: MultiAction) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"encode.d.ts","sourceRoot":"/","sources":["services/encode.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAOhE,eAAO,MAAM,mBAAmB,UACvB,MAAM,UACL,MAAM,eACD,WAAW,KACvB,IAEF,CAAC;AAEF,eAAO,MAAM,oBAAoB,UACxB,MAAM,UACL,MAAM,eACD,WAAW,KACvB,IAIF,CAAC;AAEF,eAAO,MAAM,0BAA0B,sBAClB,MAAM,SAClB,MAAM,UACL,MAAM,eACD,WAAW,KACvB,IASF,CAAC;AAEF,eAAO,MAAM,iBAAiB,2BACJ,MAAM,EAAE,aACrB,MAAM,mBACA,MAAM,YACb,MAAM,cACJ,MAAM,eACL,WAAW,KACvB,IAeF,CAAC;AAEF,eAAO,MAAM,gBAAgB,gBACd,WAAW,aACb,MAAM,uBACI,MAAM,KAC1B,gBAUF,CAAC"}
1
+ {"version":3,"file":"encode.d.ts","sourceRoot":"/","sources":["services/encode.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAW,MAAM,iBAAiB,CAAC;AAMzE,eAAO,MAAM,mBAAmB,UACvB,MAAM,UACL,MAAM,eACD,WAAW,KACvB,IAEF,CAAC;AAEF,eAAO,MAAM,oBAAoB,UACxB,MAAM,UACL,MAAM,eACD,WAAW,KACvB,IAIF,CAAC;AAEF,eAAO,MAAM,0BAA0B,sBAClB,MAAM,SAClB,MAAM,UACL,MAAM,eACD,WAAW,KACvB,IASF,CAAC;AAEF,eAAO,MAAM,iBAAiB,2BACJ,MAAM,EAAE,aACrB,MAAM,mBACA,MAAM,YACb,MAAM,cACJ,MAAM,eACL,WAAW,KACvB,IAeF,CAAC;AAEF,eAAO,MAAM,gBAAgB,gBACd,WAAW,aACb,MAAM,uBACI,MAAM,KAC1B,gBAUF,CAAC"}
@@ -1,5 +1,5 @@
1
- import { MethodParameters } from '../../utils/action';
2
- import { EIP712Signature } from '../sign';
1
+ import { MethodParameters } from '@reyaxyz/common';
2
+ import { EIP712Signature } from '@reyaxyz/common';
3
3
  export declare const encodeProvideLiquidityCall: (poolId: number, accountOwner: string, amount: bigint, minShares: number) => MethodParameters;
4
4
  export declare const encodeRemoveLiquidityCall: (poolId: number, sharesAmount: bigint, minOut: number) => MethodParameters;
5
5
  export declare const encodeTransferFromMAToPool: (accountId: number, amount: bigint, sig: EIP712Signature, poolId: number, minShares: bigint, receiver: string) => MethodParameters;
@@ -1 +1 @@
1
- {"version":3,"file":"encode.d.ts","sourceRoot":"/","sources":["services/lp/encode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAa1C,eAAO,MAAM,0BAA0B,WAC7B,MAAM,gBACA,MAAM,UACZ,MAAM,aACH,MAAM,KAChB,gBAMF,CAAC;AAEF,eAAO,MAAM,yBAAyB,WAC5B,MAAM,gBACA,MAAM,UACZ,MAAM,KACb,gBAMF,CAAC;AAEF,eAAO,MAAM,0BAA0B,cAC1B,MAAM,UACT,MAAM,OACT,eAAe,UACZ,MAAM,aACH,MAAM,YACP,MAAM,KACf,gBAMF,CAAC;AAEF,eAAO,MAAM,kCAAkC,UACtC,MAAM,UACL,MAAM,gBACA,MAAM,UACZ,MAAM,OACT,eAAe,qBACD,MAAM,WAChB,MAAM,YACL,MAAM,KACf,gBAiBF,CAAC;AAEF,eAAO,MAAM,iCAAiC,aAClC,MAAM,qBACG,MAAM,mBACR,MAAM,uBACF,MAAM,cACf,MAAM,UACV,MAAM,SACP,MAAM,UACL,MAAM,aACH,MAAM,KAChB,gBAoBF,CAAC"}
1
+ {"version":3,"file":"encode.d.ts","sourceRoot":"/","sources":["services/lp/encode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAgB,MAAM,iBAAiB,CAAC;AAEjE,OAAO,EAAE,eAAe,EAA8B,MAAM,iBAAiB,CAAC;AAW9E,eAAO,MAAM,0BAA0B,WAC7B,MAAM,gBACA,MAAM,UACZ,MAAM,aACH,MAAM,KAChB,gBAMF,CAAC;AAEF,eAAO,MAAM,yBAAyB,WAC5B,MAAM,gBACA,MAAM,UACZ,MAAM,KACb,gBAMF,CAAC;AAEF,eAAO,MAAM,0BAA0B,cAC1B,MAAM,UACT,MAAM,OACT,eAAe,UACZ,MAAM,aACH,MAAM,YACP,MAAM,KACf,gBAMF,CAAC;AAEF,eAAO,MAAM,kCAAkC,UACtC,MAAM,UACL,MAAM,gBACA,MAAM,UACZ,MAAM,OACT,eAAe,qBACD,MAAM,WAChB,MAAM,YACL,MAAM,KACf,gBAiBF,CAAC;AAEF,eAAO,MAAM,iCAAiC,aAClC,MAAM,qBACG,MAAM,mBACR,MAAM,uBACF,MAAM,cACf,MAAM,UACV,MAAM,SACP,MAAM,UACL,MAAM,aACH,MAAM,KAChB,gBAoBF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"lp.d.ts","sourceRoot":"/","sources":["services/lp/lp.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,SAAS,CAAC;AAQjB,eAAO,MAAM,gBAAgB,WACnB,sBAAsB,KAC7B,QAAQ,sBAAsB,CA+BhC,CAAC;AAEF,eAAO,MAAM,eAAe,WAClB,qBAAqB,KAC5B,QAAQ,qBAAqB,CA4B/B,CAAC"}
1
+ {"version":3,"file":"lp.d.ts","sourceRoot":"/","sources":["services/lp/lp.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,SAAS,CAAC;AAQjB,eAAO,MAAM,gBAAgB,WACnB,sBAAsB,KAC7B,QAAQ,sBAAsB,CA+BhC,CAAC;AAEF,eAAO,MAAM,eAAe,WAClB,qBAAqB,KAC5B,QAAQ,qBAAqB,CA4B/B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"transferFromMAToPool.d.ts","sourceRoot":"/","sources":["services/lp/transferFromMAToPool.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,EAC3B,MAAM,SAAS,CAAC;AAMjB,eAAO,MAAM,oBAAoB,WACvB,0BAA0B,KACjC,QAAQ,0BAA0B,CA8CpC,CAAC"}
1
+ {"version":3,"file":"transferFromMAToPool.d.ts","sourceRoot":"/","sources":["services/lp/transferFromMAToPool.ts"],"names":[],"mappings":"AASA,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,EAC3B,MAAM,SAAS,CAAC;AAMjB,eAAO,MAAM,oBAAoB,WACvB,0BAA0B,KACjC,QAAQ,0BAA0B,CA8CpC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"withdrawPassivePoolAndBridge.d.ts","sourceRoot":"/","sources":["services/lp/withdrawPassivePoolAndBridge.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,kCAAkC,EAClC,kCAAkC,EACnC,MAAM,SAAS,CAAC;AASjB,eAAO,MAAM,4BAA4B,WAC/B,kCAAkC,KACzC,QAAQ,kCAAkC,CAgD5C,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;AAajB,eAAO,MAAM,4BAA4B,WAC/B,kCAAkC,KACzC,QAAQ,kCAAkC,CAgD5C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"bridgeAndDepositExistingMA.d.ts","sourceRoot":"/","sources":["services/margin-accounts/bridgeAndDepositExistingMA.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,gCAAgC,EAChC,gCAAgC,EACjC,MAAM,SAAS,CAAC;AAIjB,eAAO,MAAM,0BAA0B,WAC7B,gCAAgC,KACvC,QAAQ,gCAAgC,CA4D1C,CAAC"}
1
+ {"version":3,"file":"bridgeAndDepositExistingMA.d.ts","sourceRoot":"/","sources":["services/margin-accounts/bridgeAndDepositExistingMA.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,gCAAgC,EAChC,gCAAgC,EACjC,MAAM,SAAS,CAAC;AAIjB,eAAO,MAAM,0BAA0B,WAC7B,gCAAgC,KACvC,QAAQ,gCAAgC,CA4D1C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"bridgeAndDepositNewMA.d.ts","sourceRoot":"/","sources":["services/margin-accounts/bridgeAndDepositNewMA.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,2BAA2B,EAC3B,2BAA2B,EAC5B,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,qBAAqB,WACxB,2BAA2B,KAClC,QAAQ,2BAA2B,CA6CrC,CAAC"}
1
+ {"version":3,"file":"bridgeAndDepositNewMA.d.ts","sourceRoot":"/","sources":["services/margin-accounts/bridgeAndDepositNewMA.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,2BAA2B,EAC3B,2BAA2B,EAC5B,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,qBAAqB,WACxB,2BAA2B,KAClC,QAAQ,2BAA2B,CA6CrC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"deposit.d.ts","sourceRoot":"/","sources":["services/margin-accounts/deposit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAMvD,eAAO,MAAM,OAAO,WACV,aAAa,KACpB,QAAQ,aAAa,CAuBvB,CAAC"}
1
+ {"version":3,"file":"deposit.d.ts","sourceRoot":"/","sources":["services/margin-accounts/deposit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAKvD,eAAO,MAAM,OAAO,WACV,aAAa,KACpB,QAAQ,aAAa,CAuBvB,CAAC"}
@@ -1,5 +1,5 @@
1
- import { MethodParameters } from '../../utils/action';
2
- import { EIP712Signature } from '../sign';
1
+ import { MethodParameters } from '@reyaxyz/common';
2
+ import { EIP712Signature } from '@reyaxyz/common';
3
3
  import { Signer } from 'ethers';
4
4
  export declare const encodeCreateAccountCall: (accountOwner: string) => MethodParameters;
5
5
  export declare const encodeDeposit: (accountId: number, token: string, amount: bigint) => MethodParameters;
@@ -1 +1 @@
1
- {"version":3,"file":"encode.d.ts","sourceRoot":"/","sources":["services/margin-accounts/encode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAe,MAAM,oBAAoB,CAAC;AAYnE,OAAO,EAAE,eAAe,EAAoB,MAAM,SAAS,CAAC;AAG5D,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,eAAO,MAAM,uBAAuB,iBACpB,MAAM,KACnB,gBAMF,CAAC;AAEF,eAAO,MAAM,aAAa,cACb,MAAM,SACV,MAAM,UACL,MAAM,KACb,gBAWF,CAAC;AAEF,eAAO,MAAM,cAAc,cACd,MAAM,SACV,MAAM,UACL,MAAM,KACb,gBAWF,CAAC;AAEF,eAAO,MAAM,oBAAoB,WACvB,MAAM,WACL,MAAM,gBACD,MAAM,uBACC,MAAM,qBACR,MAAM,SAClB,MAAM,UACL,MAAM,KACb,QAAQ,gBAAgB,CAoC1B,CAAC;AAEF,eAAO,MAAM,yBAAyB,cACzB,MAAM,6BACU,MAAM,4BACP,MAAM,OAC3B,eAAe,qBACD,MAAM,WAChB,MAAM,YACL,MAAM,KACf,gBAgBF,CAAC;AAEF,eAAO,MAAM,2BAA2B,aAC5B,MAAM,qBACG,MAAM,mBACR,MAAM,uBACF,MAAM,cACf,MAAM,gBACJ,MAAM,yBACG,MAAM,wBACP,MAAM,yBACL,MAAM,KAC5B,gBAuBF,CAAC;AAEF,eAAO,MAAM,gCAAgC,aACjC,MAAM,qBACG,MAAM,mBACR,MAAM,uBACF,MAAM,cACf,MAAM,aACP,MAAM,yBACM,MAAM,wBACP,MAAM,yBACL,MAAM,KAC5B,gBAuBF,CAAC"}
1
+ {"version":3,"file":"encode.d.ts","sourceRoot":"/","sources":["services/margin-accounts/encode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAe,MAAM,iBAAiB,CAAC;AAQhE,OAAO,EAKL,eAAe,EAIhB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,eAAO,MAAM,uBAAuB,iBACpB,MAAM,KACnB,gBAMF,CAAC;AAEF,eAAO,MAAM,aAAa,cACb,MAAM,SACV,MAAM,UACL,MAAM,KACb,gBAWF,CAAC;AAEF,eAAO,MAAM,cAAc,cACd,MAAM,SACV,MAAM,UACL,MAAM,KACb,gBAWF,CAAC;AAEF,eAAO,MAAM,oBAAoB,WACvB,MAAM,WACL,MAAM,gBACD,MAAM,uBACC,MAAM,qBACR,MAAM,SAClB,MAAM,UACL,MAAM,KACb,QAAQ,gBAAgB,CAoC1B,CAAC;AAEF,eAAO,MAAM,yBAAyB,cACzB,MAAM,6BACU,MAAM,4BACP,MAAM,OAC3B,eAAe,qBACD,MAAM,WAChB,MAAM,YACL,MAAM,KACf,gBAgBF,CAAC;AAEF,eAAO,MAAM,2BAA2B,aAC5B,MAAM,qBACG,MAAM,mBACR,MAAM,uBACF,MAAM,cACf,MAAM,gBACJ,MAAM,yBACG,MAAM,wBACP,MAAM,yBACL,MAAM,KAC5B,gBAuBF,CAAC;AAEF,eAAO,MAAM,gCAAgC,aACjC,MAAM,qBACG,MAAM,mBACR,MAAM,uBACF,MAAM,cACf,MAAM,aACP,MAAM,yBACM,MAAM,wBACP,MAAM,yBACL,MAAM,KAC5B,gBAuBF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"withdraw.d.ts","sourceRoot":"/","sources":["services/margin-accounts/withdraw.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAMzD,eAAO,MAAM,QAAQ,WACX,cAAc,KACrB,QAAQ,cAAc,CAwBxB,CAAC"}
1
+ {"version":3,"file":"withdraw.d.ts","sourceRoot":"/","sources":["services/margin-accounts/withdraw.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAKzD,eAAO,MAAM,QAAQ,WACX,cAAc,KACrB,QAAQ,cAAc,CAwBxB,CAAC"}
@@ -1,4 +1,4 @@
1
- import { MethodParameters } from '../../utils/action';
1
+ import { MethodParameters } from '@reyaxyz/common';
2
2
  import { Signer } from 'ethers';
3
3
  export declare const encodeMatchOrder: (signer: Signer, chainId: number, coreSigNonce: number, accountId: number, orderBase: bigint, orderPriceLimit: bigint, counterpartyAccountIds: number[], marketId: number, exchangeId: number) => Promise<MethodParameters>;
4
4
  //# sourceMappingURL=encode.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"encode.d.ts","sourceRoot":"/","sources":["services/orders/encode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAe,MAAM,oBAAoB,CAAC;AAKnE,OAAO,EAAa,MAAM,EAAE,MAAM,QAAQ,CAAC;AAI3C,eAAO,MAAM,gBAAgB,WACnB,MAAM,WACL,MAAM,gBACD,MAAM,aACT,MAAM,aACN,MAAM,mBACA,MAAM,0BACC,MAAM,EAAE,YACtB,MAAM,cACJ,MAAM,KACjB,QAAQ,gBAAgB,CAkC1B,CAAC"}
1
+ {"version":3,"file":"encode.d.ts","sourceRoot":"/","sources":["services/orders/encode.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAGjB,MAAM,iBAAiB,CAAC;AASzB,OAAO,EAAa,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE3C,eAAO,MAAM,gBAAgB,WACnB,MAAM,WACL,MAAM,gBACD,MAAM,aACT,MAAM,aACN,MAAM,mBACA,MAAM,0BACC,MAAM,EAAE,YACtB,MAAM,cACJ,MAAM,KACjB,QAAQ,gBAAgB,CAkC1B,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { JsonRpcSigner, Signer } from 'ethers';
2
+ import { BroadcastTransactionMetadata } from '../../../sdk/src/config';
3
+ import { ContractType } from '@reyaxyz/common';
4
+ export declare function signAndBroadcastTransaction(signer: Signer | JsonRpcSigner, data: string, value: string, chainId: number, targetContract: ContractType | string, metadata: BroadcastTransactionMetadata): Promise<{
5
+ hash: string;
6
+ accountId?: string;
7
+ }>;
8
+ //# sourceMappingURL=signAndBroadcastTransaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signAndBroadcastTransaction.d.ts","sourceRoot":"/","sources":["services/signAndBroadcastTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,EACL,4BAA4B,EAE7B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,YAAY,EAA2B,MAAM,iBAAiB,CAAC;AAExE,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,MAAM,GAAG,aAAa,EAC9B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,YAAY,GAAG,MAAM,EACrC,QAAQ,EAAE,4BAA4B,GACrC,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CA2B/C"}
@@ -1 +1 @@
1
- {"version":3,"file":"getAllowance.d.ts","sourceRoot":"/","sources":["services/token/getAllowance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAU3D,eAAO,MAAM,YAAY,WACf,kBAAkB,KACzB,QAAQ,MAAM,CAyChB,CAAC"}
1
+ {"version":3,"file":"getAllowance.d.ts","sourceRoot":"/","sources":["services/token/getAllowance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAW3D,eAAO,MAAM,YAAY,WACf,kBAAkB,KACzB,QAAQ,MAAM,CAyChB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reyaxyz/sdk",
3
- "version": "0.80.0",
3
+ "version": "0.81.0",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -29,10 +29,10 @@
29
29
  "generate:coverage-badges": "npx istanbul-badges-readme --silent"
30
30
  },
31
31
  "dependencies": {
32
- "@reyaxyz/common": "0.96.0",
32
+ "@reyaxyz/common": "0.98.0",
33
33
  "bignumber.js": "^9.1.2",
34
34
  "ethers": "6.9.0"
35
35
  },
36
36
  "packageManager": "pnpm@8.3.1",
37
- "gitHead": "fdc86e930a3a20ba54a175bd7e84c2c68df27443"
37
+ "gitHead": "933d366f78112b99e312d4fbd9c27abda1c5912a"
38
38
  }
@@ -1,9 +1,8 @@
1
1
  //////////////////// ENCODE SINGLE ////////////////////
2
2
 
3
- import { MethodParameters, MultiAction } from '../utils/action';
4
- import { CommandType, getCommand } from '../utils/routerCommands';
3
+ import { MethodParameters, MultiAction, CoreAbi } from '@reyaxyz/common';
4
+ import { CommandType, getCommand } from '@reyaxyz/common';
5
5
  import { AbiCoder, Interface } from 'ethers';
6
- import { abi } from '../abis/CoreProxy.json';
7
6
  // const abi = [
8
7
  // 'function coreExecute(uint128 poolId, uint128 accountId, Command[] commands, EIP712Signature sig)',
9
8
  // ];
@@ -73,7 +72,7 @@ export const encodeRouterCall = (
73
72
  const functionSignature = 'execute';
74
73
  const parameters = [accountId, multiAction.commands];
75
74
 
76
- const INTERFACE = new Interface(abi);
75
+ const INTERFACE = new Interface(CoreAbi);
77
76
  const calldata = INTERFACE.encodeFunctionData(functionSignature, parameters);
78
77
  return {
79
78
  calldata: calldata,
@@ -5,10 +5,10 @@ import {
5
5
  getSocketConnectors,
6
6
  getReyaNetworkFromMoneyInOutChainId,
7
7
  getRUSDUnderlyingTokenInfo,
8
+ executeTransaction,
8
9
  } from '@reyaxyz/common';
9
10
  import { getAlphaTermsModuleClient } from '../../config';
10
- import { ContractType, getAddress } from '../../utils/contractAddresses';
11
- import { executeTransaction } from '../executeTransaction';
11
+ import { ContractType, getAddress } from '@reyaxyz/common';
12
12
  import { encodeBridgeAndDepositPassivePool } from './encode';
13
13
  import {
14
14
  BridgeAndDepositPassivePoolParams,
@@ -1,8 +1,6 @@
1
- import { MethodParameters } from '../../utils/action';
1
+ import { MethodParameters, PeripheryAbi } from '@reyaxyz/common';
2
2
  import { Interface } from 'ethers';
3
- import { EIP712Signature } from '../sign';
4
- import { abi as peripheryAbi } from '../../abis/Periphery.json';
5
- import { abi as Socket_VaultWithPayloadAbi } from '../../abis/socket/VaultWithPayload.json';
3
+ import { EIP712Signature, Socket_VaultWithPayloadAbi } from '@reyaxyz/common';
6
4
 
7
5
  // @todo Update ABI
8
6
  const provideLiquidityAbi = [
@@ -48,7 +46,7 @@ export const encodeTransferFromMAToPool = (
48
46
  ): MethodParameters => {
49
47
  const functionSignature = 'transferFromMAToPool';
50
48
  const parameters = [{ accountId, amount, sig, poolId, minShares, receiver }];
51
- const INTERFACE = new Interface(peripheryAbi);
49
+ const INTERFACE = new Interface(PeripheryAbi);
52
50
  const calldata = INTERFACE.encodeFunctionData(functionSignature, parameters);
53
51
  return { calldata: calldata, value: BigInt(0).toString(10) };
54
52
  };
@@ -76,7 +74,7 @@ export const encodeWithdrawPassivePoolAndBridge = (
76
74
  receiver,
77
75
  },
78
76
  ];
79
- const INTERFACE = new Interface(peripheryAbi);
77
+ const INTERFACE = new Interface(PeripheryAbi);
80
78
  const calldata = INTERFACE.encodeFunctionData(functionSignature, parameters);
81
79
  return { calldata: calldata, value: BigInt(0).toString(10) };
82
80
  };
@@ -92,7 +90,7 @@ export const encodeBridgeAndDepositPassivePool = (
92
90
  amount: bigint,
93
91
  minShares: bigint,
94
92
  ): MethodParameters => {
95
- const PERIPHERY_INTERFACE = new Interface(peripheryAbi);
93
+ const PERIPHERY_INTERFACE = new Interface(PeripheryAbi);
96
94
  const inputs = { poolId, owner, minShares };
97
95
  const peripheryCalldata = PERIPHERY_INTERFACE.encodeFunctionData(
98
96
  'depositPassivePool((uint128,address,uint256))',
@@ -1,4 +1,3 @@
1
- import { executeTransaction } from '../executeTransaction';
2
1
  import {
3
2
  encodeProvideLiquidityCall,
4
3
  encodeRemoveLiquidityCall,
@@ -14,7 +13,7 @@ import {
14
13
  calculateMinSharesForLp,
15
14
  expandLpAmount,
16
15
  } from '../../utils/lp';
17
- import { ContractType } from '../../utils/contractAddresses';
16
+ import { ContractType, executeTransaction } from '@reyaxyz/common';
18
17
 
19
18
  export const provideLiquidity = async (
20
19
  params: ProvideLiquidityParams,
@@ -4,16 +4,15 @@ import {
4
4
  ReyaChainId,
5
5
  getTokenInfoByAddress,
6
6
  } from '@reyaxyz/common';
7
- import { ContractType, getAddress } from '../../utils/contractAddresses';
8
- import { executeTransaction } from '../executeTransaction';
9
- import { signCoreCommands } from '../sign';
7
+ import { ContractType, getAddress, executeTransaction } from '@reyaxyz/common';
8
+ import { signCoreCommands } from '@reyaxyz/common';
10
9
  import { encodeTransferFromMAToPool } from './encode';
11
10
  import {
12
11
  TransferFromMAToPoolParams,
13
12
  TransferFromMAToPoolResult,
14
13
  } from './types';
15
- import { BRIDGE_DEADLINE_IN_SECONDS } from '../../utils/consts';
16
- import { MultiAction } from '../../utils/action';
14
+ import { BRIDGE_DEADLINE_IN_SECONDS } from '@reyaxyz/common';
15
+ import { MultiAction } from '@reyaxyz/common';
17
16
  import { encodeSingleWithdraw } from '../encode';
18
17
  import { ethers } from 'ethers';
19
18
 
@@ -1,6 +1,3 @@
1
- import { ContractType, getAddress } from '../../utils/contractAddresses';
2
- import { executeTransaction } from '../executeTransaction';
3
- import { signPoolRemoveLiquidity } from '../sign';
4
1
  import {
5
2
  WithdrawPassivePoolAndBridgeParams,
6
3
  WithdrawPassivePoolAndBridgeResult,
@@ -10,8 +7,12 @@ import {
10
7
  ReyaChainId,
11
8
  getCurrentTimestampInSeconds,
12
9
  scale,
10
+ signPoolRemoveLiquidity,
11
+ ContractType,
12
+ getAddress,
13
+ BRIDGE_DEADLINE_IN_SECONDS,
14
+ executeTransaction,
13
15
  } from '@reyaxyz/common';
14
- import { BRIDGE_DEADLINE_IN_SECONDS } from '../../utils/consts';
15
16
 
16
17
  export const withdrawPassivePoolAndBridge = async (
17
18
  params: WithdrawPassivePoolAndBridgeParams,
@@ -1,7 +1,7 @@
1
- import { signAndBroadcastTransaction } from '../executeTransaction';
1
+ import { signAndBroadcastTransaction } from '../signAndBroadcastTransaction';
2
2
  import { encodeCreateAccountCall } from './encode';
3
3
  import { CreateAccountParams, CreateAccountResult } from './types';
4
- import { ContractType } from '../../utils/contractAddresses';
4
+ import { ContractType } from '@reyaxyz/common';
5
5
 
6
6
  export const createAccount = async (
7
7
  params: CreateAccountParams,
@@ -7,15 +7,14 @@ import {
7
7
  getTokenInfoByName,
8
8
  getReyaNetworkFromMoneyInOutChainId,
9
9
  } from '@reyaxyz/common';
10
- import { ContractType, getAddress } from '../../utils/contractAddresses';
11
- import { executeTransaction } from '../executeTransaction';
10
+ import { ContractType, getAddress, executeTransaction } from '@reyaxyz/common';
12
11
  import { encodeBridgeAndDepositExistingMA } from './encode';
13
12
  import {
14
13
  BridgeAndDepositExistingMAParams,
15
14
  BridgeAndDepositExistingMAResult,
16
15
  } from './types';
17
16
  import { encodeSingleDeposit } from '../encode';
18
- import { MultiAction } from '../../utils/action';
17
+ import { MultiAction } from '@reyaxyz/common';
19
18
 
20
19
  export const bridgeAndDepositExistingMA = async (
21
20
  params: BridgeAndDepositExistingMAParams,
@@ -7,8 +7,7 @@ import {
7
7
  getTokenInfoByAddress,
8
8
  getReyaNetworkFromMoneyInOutChainId,
9
9
  } from '@reyaxyz/common';
10
- import { ContractType, getAddress } from '../../utils/contractAddresses';
11
- import { executeTransaction } from '../executeTransaction';
10
+ import { ContractType, getAddress, executeTransaction } from '@reyaxyz/common';
12
11
  import { encodeBridgeAndDepositNewMA } from './encode';
13
12
  import {
14
13
  BridgeAndDepositNewMAParams,
@@ -1,7 +1,6 @@
1
1
  import { DepositParams, DepositResult } from './types';
2
2
  import { encodeDeposit } from './encode';
3
- import { executeTransaction } from '../executeTransaction';
4
- import { ContractType } from '../../utils/contractAddresses';
3
+ import { ContractType, executeTransaction } from '@reyaxyz/common';
5
4
  import { getTokenInfoByAddress, scale } from '@reyaxyz/common';
6
5
 
7
6
  export const deposit = async (
@@ -1,4 +1,4 @@
1
- import { MethodParameters, MultiAction } from '../../utils/action';
1
+ import { MethodParameters, MultiAction } from '@reyaxyz/common';
2
2
  import { Interface } from 'ethers';
3
3
  import {
4
4
  encodeRouterCall,
@@ -6,16 +6,19 @@ import {
6
6
  encodeSingleTransferMargin,
7
7
  encodeSingleWithdraw,
8
8
  } from '../encode';
9
-
10
- import { abi } from '../../abis/CoreProxy.json';
11
- import { abi as peripheryAbi } from '../../abis/Periphery.json';
12
- import { abi as Socket_VaultWithPayloadAbi } from '../../abis/socket/VaultWithPayload.json';
13
- import { EIP712Signature, signCoreCommands } from '../sign';
14
- import { CORE_DEADLINE_IN_SECONDS } from '../../utils/consts';
9
+ import {
10
+ CoreAbi as abi,
11
+ PeripheryAbi,
12
+ Socket_VaultWithPayloadAbi,
13
+ CORE_DEADLINE_IN_SECONDS,
14
+ EIP712Signature,
15
+ signCoreCommands,
16
+ ContractType,
17
+ getAddress,
18
+ } from '@reyaxyz/common';
15
19
  import { getCurrentTimestampInSeconds } from '@reyaxyz/common';
16
20
  import { Signer } from 'ethers';
17
21
  import { ethers } from 'ethers';
18
- import { ContractType, getAddress } from '../../utils/contractAddresses';
19
22
 
20
23
  export const encodeCreateAccountCall = (
21
24
  accountOwner: string,
@@ -99,7 +102,7 @@ export const encodeTransferMargin = async (
99
102
  },
100
103
  ];
101
104
 
102
- const INTERFACE = new Interface(peripheryAbi);
105
+ const INTERFACE = new Interface(PeripheryAbi);
103
106
  const calldata = INTERFACE.encodeFunctionData(functionSignature, parameters);
104
107
  return {
105
108
  calldata: calldata,
@@ -128,7 +131,7 @@ export const encodeWithdrawMAAndBridge = (
128
131
  receiver,
129
132
  },
130
133
  ];
131
- const INTERFACE = new Interface(peripheryAbi);
134
+ const INTERFACE = new Interface(PeripheryAbi);
132
135
  const calldata = INTERFACE.encodeFunctionData(functionSignature, parameters);
133
136
  return { calldata: calldata, value: BigInt(0).toString(10) };
134
137
  };
@@ -144,7 +147,7 @@ export const encodeBridgeAndDepositNewMA = (
144
147
  peripheryTokenAmount: bigint,
145
148
  moneyInOutTokenAmount: bigint,
146
149
  ): MethodParameters => {
147
- const PERIPHERY_INTERFACE = new Interface(peripheryAbi);
150
+ const PERIPHERY_INTERFACE = new Interface(PeripheryAbi);
148
151
  const inputs = {
149
152
  accountOwner,
150
153
  token: peripheryTokenAddress,
@@ -179,7 +182,7 @@ export const encodeBridgeAndDepositExistingMA = (
179
182
  peripheryTokenAmount: bigint,
180
183
  moneyInOutTokenAmount: bigint,
181
184
  ): MethodParameters => {
182
- const PERIPHERY_INTERFACE = new Interface(peripheryAbi);
185
+ const PERIPHERY_INTERFACE = new Interface(PeripheryAbi);
183
186
  const inputs = {
184
187
  accountId,
185
188
  token: peripheryTokenAddress,
@@ -1,6 +1,6 @@
1
1
  import { scale, getTokenInfoByAddress } from '@reyaxyz/common';
2
- import { ContractType } from '../../utils/contractAddresses';
3
- import { signAndBroadcastTransaction } from '../executeTransaction';
2
+ import { ContractType } from '@reyaxyz/common';
3
+ import { signAndBroadcastTransaction } from '../signAndBroadcastTransaction';
4
4
  import { encodeTransferMargin } from './encode';
5
5
  import {
6
6
  TransferMarginBetweenAccountsParams,
@@ -1,7 +1,6 @@
1
1
  import { WithdrawParams, WithdrawResult } from './types';
2
2
  import { encodeWithdraw } from './encode';
3
- import { executeTransaction } from '../executeTransaction';
4
- import { ContractType } from '../../utils/contractAddresses';
3
+ import { ContractType, executeTransaction } from '@reyaxyz/common';
5
4
  import { getTokenInfoByAddress, scale } from '@reyaxyz/common';
6
5
 
7
6
  export const withdraw = async (
@@ -4,17 +4,17 @@ import {
4
4
  ReyaChainId,
5
5
  getTokenInfoByAddress,
6
6
  } from '@reyaxyz/common';
7
- import { ContractType, getAddress } from '../../utils/contractAddresses';
8
- import { signAndBroadcastTransaction } from '../executeTransaction';
9
- import { signCoreCommands } from '../sign';
7
+ import { ContractType, getAddress } from '@reyaxyz/common';
8
+ import { signAndBroadcastTransaction } from '../signAndBroadcastTransaction';
9
+ import { signCoreCommands } from '@reyaxyz/common';
10
10
  import { encodeWithdrawMAAndBridge } from './encode';
11
11
  import {
12
12
  WithdrawMAAndBridgeParams,
13
13
  WithdrawMAAndBridgeParamsResult,
14
14
  } from './types';
15
- import { BRIDGE_DEADLINE_IN_SECONDS } from '../../utils/consts';
15
+ import { BRIDGE_DEADLINE_IN_SECONDS } from '@reyaxyz/common';
16
16
  import { encodeSingleWithdraw } from '../encode';
17
- import { MultiAction } from '../../utils/action';
17
+ import { MultiAction } from '@reyaxyz/common';
18
18
  import { ethers } from 'ethers';
19
19
 
20
20
  export const withdrawMAAndBridge = async ({
@@ -1,11 +1,17 @@
1
- import { MethodParameters, MultiAction } from '../../utils/action';
1
+ import {
2
+ MethodParameters,
3
+ MultiAction,
4
+ PeripheryAbi as abi,
5
+ } from '@reyaxyz/common';
2
6
  import { encodeSingleTrade } from '../encode';
3
- import { signCoreCommands } from '../sign';
4
- import { getCurrentTimestampInSeconds } from '@reyaxyz/common';
5
- import { CORE_DEADLINE_IN_SECONDS } from '../../utils/consts';
7
+ import { signCoreCommands } from '@reyaxyz/common';
8
+ import {
9
+ getCurrentTimestampInSeconds,
10
+ ContractType,
11
+ getAddress,
12
+ } from '@reyaxyz/common';
13
+ import { CORE_DEADLINE_IN_SECONDS } from '@reyaxyz/common';
6
14
  import { Interface, Signer } from 'ethers';
7
- import { abi } from '../../abis/Periphery.json';
8
- import { ContractType, getAddress } from '../../utils/contractAddresses';
9
15
  import { ethers } from 'ethers';
10
16
  export const encodeMatchOrder = async (
11
17
  signer: Signer,
@@ -5,10 +5,10 @@ import {
5
5
  MatchOrderResult,
6
6
  } from './types';
7
7
  import { encodeMatchOrder } from './encode';
8
- import { signAndBroadcastTransaction } from '../executeTransaction';
9
- import { calculatePriceLimitForTrade } from '../../utils/trade';
8
+ import { signAndBroadcastTransaction } from '../signAndBroadcastTransaction';
9
+ import { calculatePriceLimitForTrade } from '@reyaxyz/common';
10
10
  import BigNumber from 'bignumber.js';
11
- import { ContractType } from '../../utils/contractAddresses';
11
+ import { ContractType } from '@reyaxyz/common';
12
12
  import { scale } from '@reyaxyz/common';
13
13
 
14
14
  export const matchOrder = async (
@@ -0,0 +1,42 @@
1
+ import { JsonRpcSigner, Signer } from 'ethers';
2
+ import {
3
+ BroadcastTransactionMetadata,
4
+ getTransactionModuleClient,
5
+ } from '../../../sdk/src/config';
6
+ import { ContractType, getAddress, estimateGas } from '@reyaxyz/common';
7
+
8
+ export async function signAndBroadcastTransaction(
9
+ signer: Signer | JsonRpcSigner,
10
+ data: string,
11
+ value: string,
12
+ chainId: number,
13
+ targetContract: ContractType | string,
14
+ metadata: BroadcastTransactionMetadata,
15
+ ): Promise<{ hash: string; accountId?: string }> {
16
+ const contractAddress = Object.values(ContractType).includes(
17
+ targetContract as ContractType,
18
+ )
19
+ ? getAddress(chainId, targetContract as ContractType)
20
+ : targetContract;
21
+
22
+ // used to catch error in advance since gelato is slow in failing down
23
+ // on reya chain usually takes around 100ms, should be monitored!
24
+ await estimateGas(signer, data, value, chainId, targetContract);
25
+ try {
26
+ const transactionModuleClient = getTransactionModuleClient();
27
+ const { txHash, accountId } =
28
+ await transactionModuleClient.executeTransaction(
29
+ { to: contractAddress, data: data },
30
+ contractAddress,
31
+ metadata,
32
+ );
33
+
34
+ if (!txHash) {
35
+ throw new Error('Error sending transaction');
36
+ }
37
+ return { hash: txHash, accountId };
38
+ } catch (error) {
39
+ console.warn(error);
40
+ throw new Error('Transaction Execution Error');
41
+ }
42
+ }
@@ -8,7 +8,7 @@ import {
8
8
  getTokenInfoByAddress,
9
9
  scale,
10
10
  } from '@reyaxyz/common';
11
- import { ContractType, getAddress } from '../../utils/contractAddresses';
11
+ import { ContractType, getAddress } from '@reyaxyz/common';
12
12
 
13
13
  export const approveTokenSpending = async (
14
14
  params: ApproveTokenParams,
@@ -5,8 +5,9 @@ import {
5
5
  getRUSDUnderlyingTokenInfo,
6
6
  getSocketVault,
7
7
  getTokenInfoByAddress,
8
+ ContractType,
9
+ getAddress,
8
10
  } from '@reyaxyz/common';
9
- import { ContractType, getAddress } from '../../utils/contractAddresses';
10
11
 
11
12
  export const getAllowance = async (
12
13
  params: GetAllowanceParams,