@reyaxyz/sdk 0.17.1 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/abis/socket/VaultWithPayload.json +5 -0
- package/dist/services/executeTransaction.js +3 -1
- package/dist/services/executeTransaction.js.map +1 -1
- package/dist/services/lp/bridgeAndDepositPassivePool.js +81 -0
- package/dist/services/lp/bridgeAndDepositPassivePool.js.map +1 -0
- package/dist/services/lp/encode.js +18 -1
- package/dist/services/lp/encode.js.map +1 -1
- package/dist/services/lp/index.js +3 -0
- package/dist/services/lp/index.js.map +1 -1
- package/dist/services/lp/types.js.map +1 -1
- package/dist/services/lp/withdrawPassivePoolAndBridge.js +1 -1
- package/dist/services/lp/withdrawPassivePoolAndBridge.js.map +1 -1
- package/dist/services/margin-accounts/bridgeAndDepositExistingMA.js +77 -0
- package/dist/services/margin-accounts/bridgeAndDepositExistingMA.js.map +1 -0
- package/dist/services/margin-accounts/bridgeAndDepositNewMA.js +80 -0
- package/dist/services/margin-accounts/bridgeAndDepositNewMA.js.map +1 -0
- package/dist/services/margin-accounts/encode.js +34 -1
- package/dist/services/margin-accounts/encode.js.map +1 -1
- package/dist/services/margin-accounts/index.js +4 -0
- package/dist/services/margin-accounts/index.js.map +1 -1
- package/dist/services/margin-accounts/types.js.map +1 -1
- package/dist/services/margin-accounts/withdrawMAAndBridge.js +1 -1
- package/dist/services/margin-accounts/withdrawMAAndBridge.js.map +1 -1
- package/dist/types/services/executeTransaction.d.ts +2 -2
- package/dist/types/services/executeTransaction.d.ts.map +1 -1
- package/dist/types/services/lp/bridgeAndDepositPassivePool.d.ts +3 -0
- package/dist/types/services/lp/bridgeAndDepositPassivePool.d.ts.map +1 -0
- package/dist/types/services/lp/encode.d.ts +1 -0
- package/dist/types/services/lp/encode.d.ts.map +1 -1
- package/dist/types/services/lp/index.d.ts +3 -0
- package/dist/types/services/lp/index.d.ts.map +1 -1
- package/dist/types/services/lp/types.d.ts +10 -0
- package/dist/types/services/lp/types.d.ts.map +1 -1
- package/dist/types/services/margin-accounts/bridgeAndDepositExistingMA.d.ts +3 -0
- package/dist/types/services/margin-accounts/bridgeAndDepositExistingMA.d.ts.map +1 -0
- package/dist/types/services/margin-accounts/bridgeAndDepositNewMA.d.ts +3 -0
- package/dist/types/services/margin-accounts/bridgeAndDepositNewMA.d.ts.map +1 -0
- package/dist/types/services/margin-accounts/encode.d.ts +2 -0
- package/dist/types/services/margin-accounts/encode.d.ts.map +1 -1
- package/dist/types/services/margin-accounts/index.d.ts +4 -0
- package/dist/types/services/margin-accounts/index.d.ts.map +1 -1
- package/dist/types/services/margin-accounts/types.d.ts +19 -0
- package/dist/types/services/margin-accounts/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/abis/socket/VaultWithPayload.json +5 -0
- package/src/services/executeTransaction.ts +6 -3
- package/src/services/lp/bridgeAndDepositPassivePool.ts +47 -0
- package/src/services/lp/encode.ts +29 -0
- package/src/services/lp/index.ts +3 -0
- package/src/services/lp/types.ts +21 -9
- package/src/services/lp/withdrawPassivePoolAndBridge.ts +1 -1
- package/src/services/margin-accounts/bridgeAndDepositExistingMA.ts +55 -0
- package/src/services/margin-accounts/bridgeAndDepositNewMA.ts +46 -0
- package/src/services/margin-accounts/encode.ts +56 -0
- package/src/services/margin-accounts/index.ts +4 -0
- package/src/services/margin-accounts/types.ts +27 -4
- package/src/services/margin-accounts/withdrawMAAndBridge.ts +1 -1
|
@@ -4,4 +4,5 @@ export declare const encodeProvideLiquidityCall: (poolId: number, accountOwner:
|
|
|
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, owner: string, minShares: bigint) => MethodParameters;
|
|
6
6
|
export declare const encodeWithdrawPassivePoolAndBridge: (owner: string, poolId: number, sharesAmount: bigint, minOut: bigint, sig: EIP712Signature, socketMsgGasLimit: bigint, sockerConnector: string, socketController: string, receiver: string) => MethodParameters;
|
|
7
|
+
export declare const encodeBridgeAndDepositPassivePool: (receiver: string, msgGasLimit: bigint, connector: string, poolId: number, owner: string, amount: bigint, minShares: bigint) => MethodParameters;
|
|
7
8
|
//# sourceMappingURL=encode.d.ts.map
|
|
@@ -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;
|
|
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,SACP,MAAM,aACF,MAAM,KAChB,gBAMF,CAAC;AAEF,eAAO,MAAM,kCAAkC,UACtC,MAAM,UACL,MAAM,gBACA,MAAM,UACZ,MAAM,OACT,eAAe,qBACD,MAAM,mBACR,MAAM,oBACL,MAAM,YACd,MAAM,KACf,gBAkBF,CAAC;AAEF,eAAO,MAAM,iCAAiC,aAClC,MAAM,eACH,MAAM,aACR,MAAM,UACT,MAAM,SACP,MAAM,UACL,MAAM,aACH,MAAM,KAChB,gBAkBF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["services/lp/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,MAAM,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["services/lp/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,MAAM,CAAC;AACrB,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC"}
|
|
@@ -43,4 +43,14 @@ export type WithdrawPassivePoolAndBridgeParams = {
|
|
|
43
43
|
export type WithdrawPassivePoolAndBridgeResult = {
|
|
44
44
|
transactionHash: string | null;
|
|
45
45
|
};
|
|
46
|
+
export type BridgeAndDepositPassivePoolParams = {
|
|
47
|
+
signer: Signer | JsonRpcSigner;
|
|
48
|
+
poolId: number;
|
|
49
|
+
poolTokenAddress: TokenEntity['address'];
|
|
50
|
+
minShares: bigint;
|
|
51
|
+
amount: number;
|
|
52
|
+
};
|
|
53
|
+
export type BridgeAndDepositPassivePoolResult = {
|
|
54
|
+
transactionHash: string | null;
|
|
55
|
+
};
|
|
46
56
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["services/lp/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE5D,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC;IAC/B,QAAQ,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC;IAC7B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M,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,kCAAkC,GAAG;IAC/C,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,iCAAiC,GAAG;IAC9C,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,iCAAiC,GAAG;IAC9C,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { BridgeAndDepositExisingMAParams, BridgeAndDepositExisingMAResult } from './types';
|
|
2
|
+
export declare const bridgeAndDepositExisingMA: (params: BridgeAndDepositExisingMAParams) => Promise<BridgeAndDepositExisingMAResult>;
|
|
3
|
+
//# sourceMappingURL=bridgeAndDepositExistingMA.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridgeAndDepositExistingMA.d.ts","sourceRoot":"/","sources":["services/margin-accounts/bridgeAndDepositExistingMA.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,+BAA+B,EAC/B,+BAA+B,EAChC,MAAM,SAAS,CAAC;AAGjB,eAAO,MAAM,yBAAyB,WAC5B,+BAA+B,KACtC,QAAQ,+BAA+B,CAyCzC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridgeAndDepositNewMA.d.ts","sourceRoot":"/","sources":["services/margin-accounts/bridgeAndDepositNewMA.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,2BAA2B,EAC3B,2BAA2B,EAC5B,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,qBAAqB,WACxB,2BAA2B,KAClC,QAAQ,2BAA2B,CAiCrC,CAAC"}
|
|
@@ -5,4 +5,6 @@ export declare const encodeDeposit: (accountId: number, token: string, amount: b
|
|
|
5
5
|
export declare const encodeWithdraw: (accountId: number, token: string, amount: bigint) => MethodParameters;
|
|
6
6
|
export declare const encodeTransferMargin: (fromMarginAccountId: number, toMarginAccountId: number, token: string, amount: bigint) => MethodParameters;
|
|
7
7
|
export declare const encodeWithdrawMAAndBridge: (accountId: number, token: string, tokenAmount: bigint, sig: EIP712Signature, socketMsgGasLimit: bigint, socketConnector: string, socketController: string, receiver: string) => MethodParameters;
|
|
8
|
+
export declare const encodeBridgeAndDepositNewMA: (receiver: string, msgGasLimit: bigint, connector: string, accountOwner: string, token: string, tokenAmount: bigint) => MethodParameters;
|
|
9
|
+
export declare const encodeBridgeAndDepositExistingMA: (receiver: string, msgGasLimit: bigint, connector: string, accountId: number, token: string, tokenAmount: bigint, sig: EIP712Signature) => MethodParameters;
|
|
8
10
|
//# sourceMappingURL=encode.d.ts.map
|
|
@@ -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;
|
|
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,EAAE,MAAM,SAAS,CAAC;AAE1C,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,wBACV,MAAM,qBACR,MAAM,SAClB,MAAM,UACL,MAAM,KACb,gBAWF,CAAC;AAEF,eAAO,MAAM,yBAAyB,cACzB,MAAM,SACV,MAAM,eACA,MAAM,OACd,eAAe,qBACD,MAAM,mBACR,MAAM,oBACL,MAAM,YACd,MAAM,KACf,gBAiBF,CAAC;AAEF,eAAO,MAAM,2BAA2B,aAC5B,MAAM,eACH,MAAM,aACR,MAAM,gBACH,MAAM,SACb,MAAM,eACA,MAAM,KAClB,gBAkBF,CAAC;AAEF,eAAO,MAAM,gCAAgC,aACjC,MAAM,eACH,MAAM,aACR,MAAM,aACN,MAAM,SACV,MAAM,eACA,MAAM,OACd,eAAe,KACnB,gBAkBF,CAAC"}
|
|
@@ -4,4 +4,8 @@ export * from './deposit';
|
|
|
4
4
|
export * from './simulateDeposit';
|
|
5
5
|
export * from './simulateWithdraw';
|
|
6
6
|
export * from './withdraw';
|
|
7
|
+
export * from './bridgeAndDepositExistingMA';
|
|
8
|
+
export * from './bridgeAndDepositNewMA';
|
|
9
|
+
export * from './transferMarginBetweenAccounts';
|
|
10
|
+
export * from './withdrawMAAndBridge';
|
|
7
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["services/margin-accounts/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["services/margin-accounts/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,iCAAiC,CAAC;AAChD,cAAc,uBAAuB,CAAC"}
|
|
@@ -70,4 +70,23 @@ export type WithdrawMAAndBridgeParams = {
|
|
|
70
70
|
export type WithdrawMAAndBridgeParamsResult = {
|
|
71
71
|
transactionHash: string | null;
|
|
72
72
|
};
|
|
73
|
+
export type BridgeAndDepositNewMAParams = {
|
|
74
|
+
signer: Signer | JsonRpcSigner;
|
|
75
|
+
tokenAddress: TokenEntity['address'];
|
|
76
|
+
amount: number;
|
|
77
|
+
};
|
|
78
|
+
export type BridgeAndDepositNewMAResult = {
|
|
79
|
+
transactionHash: string | null;
|
|
80
|
+
};
|
|
81
|
+
export type BridgeAndDepositExisingMAParams = {
|
|
82
|
+
signer: Signer | JsonRpcSigner;
|
|
83
|
+
accountId: MarginAccountEntity['id'];
|
|
84
|
+
accountSigNonce: number;
|
|
85
|
+
deadline: number;
|
|
86
|
+
tokenAddress: TokenEntity['address'];
|
|
87
|
+
amount: number;
|
|
88
|
+
};
|
|
89
|
+
export type BridgeAndDepositExisingMAResult = {
|
|
90
|
+
transactionHash: string | null;
|
|
91
|
+
};
|
|
73
92
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["services/margin-accounts/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnE,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC;IAC/B,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,MAAM,GAAG,aAA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MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACxC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC;IAC/B,SAAS,EAAE,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACrC,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IACrC,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reyaxyz/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.1",
|
|
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.
|
|
32
|
+
"@reyaxyz/common": "0.7.1",
|
|
33
33
|
"bignumber.js": "^9.1.2",
|
|
34
34
|
"ethers": "6.9.0"
|
|
35
35
|
},
|
|
36
36
|
"packageManager": "pnpm@8.10.4",
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "4ef35325ffe0b5004996af56173e470523ce1a38"
|
|
38
38
|
}
|
|
@@ -13,10 +13,13 @@ export async function estimateGas(
|
|
|
13
13
|
data: string,
|
|
14
14
|
value: string,
|
|
15
15
|
chainId: number,
|
|
16
|
-
targetContract: ContractType,
|
|
16
|
+
targetContract: ContractType | string,
|
|
17
17
|
): Promise<Transaction & { gasLimit: bigint }> {
|
|
18
18
|
const accountAddress = await signer.getAddress();
|
|
19
|
-
const contractAddress =
|
|
19
|
+
const contractAddress =
|
|
20
|
+
typeof targetContract === 'string'
|
|
21
|
+
? targetContract
|
|
22
|
+
: getAddress(chainId, targetContract);
|
|
20
23
|
const tx = {
|
|
21
24
|
from: accountAddress,
|
|
22
25
|
to: contractAddress,
|
|
@@ -33,7 +36,7 @@ export async function executeTransaction(
|
|
|
33
36
|
data: string,
|
|
34
37
|
value: string,
|
|
35
38
|
chainId: number,
|
|
36
|
-
targetContract: ContractType,
|
|
39
|
+
targetContract: ContractType | string,
|
|
37
40
|
) {
|
|
38
41
|
const txData = await estimateGas(
|
|
39
42
|
signer,
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { getSocketConnector, getSocketVault } from '@reyaxyz/common';
|
|
2
|
+
import { ContractType, getAddress } from '../../utils/contractAddresses';
|
|
3
|
+
import { executeTransaction } from '../executeTransaction';
|
|
4
|
+
import { getTokenDetails, scale } from '../token/common';
|
|
5
|
+
import { encodeBridgeAndDepositPassivePool } from './encode';
|
|
6
|
+
import {
|
|
7
|
+
BridgeAndDepositPassivePoolParams,
|
|
8
|
+
BridgeAndDepositPassivePoolResult,
|
|
9
|
+
} from './types';
|
|
10
|
+
|
|
11
|
+
export const bridgeAndDepositPassivePool = async (
|
|
12
|
+
params: BridgeAndDepositPassivePoolParams,
|
|
13
|
+
): Promise<BridgeAndDepositPassivePoolResult> => {
|
|
14
|
+
const network = await params.signer.provider?.getNetwork();
|
|
15
|
+
const chainId = Number(network?.chainId);
|
|
16
|
+
|
|
17
|
+
const { tokenDecimals } = getTokenDetails(params.poolTokenAddress);
|
|
18
|
+
const amount = scale(tokenDecimals)(params.amount);
|
|
19
|
+
|
|
20
|
+
const { calldata: data, value } = encodeBridgeAndDepositPassivePool(
|
|
21
|
+
getAddress(chainId, ContractType.PERIPHERY_PROXY),
|
|
22
|
+
BigInt('10000000'),
|
|
23
|
+
getSocketConnector({
|
|
24
|
+
chainId: chainId,
|
|
25
|
+
tokenAddress: params.poolTokenAddress,
|
|
26
|
+
}),
|
|
27
|
+
params.poolId,
|
|
28
|
+
await params.signer.getAddress(),
|
|
29
|
+
amount,
|
|
30
|
+
params.minShares,
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
const result = await executeTransaction(
|
|
34
|
+
params.signer,
|
|
35
|
+
data,
|
|
36
|
+
value,
|
|
37
|
+
chainId,
|
|
38
|
+
getSocketVault({
|
|
39
|
+
moneyInOutChainId: chainId,
|
|
40
|
+
tokenAddress: params.poolTokenAddress,
|
|
41
|
+
}),
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
transactionHash: result?.hash || null,
|
|
46
|
+
};
|
|
47
|
+
};
|
|
@@ -2,6 +2,7 @@ import { MethodParameters } from '../../utils/action';
|
|
|
2
2
|
import { Interface } from 'ethers';
|
|
3
3
|
import { EIP712Signature } from '../sign';
|
|
4
4
|
import { abi as peripheryAbi } from '../../abis/Periphery.json';
|
|
5
|
+
import { abi as Socket_VaultWithPayloadAbi } from '../../abis/socket/VaultWithPayload.json';
|
|
5
6
|
|
|
6
7
|
// @todo Update ABI
|
|
7
8
|
const provideLiquidityAbi = [
|
|
@@ -81,3 +82,31 @@ export const encodeWithdrawPassivePoolAndBridge = (
|
|
|
81
82
|
const calldata = INTERFACE.encodeFunctionData(functionSignature, parameters);
|
|
82
83
|
return { calldata: calldata, value: BigInt(0).toString(10) };
|
|
83
84
|
};
|
|
85
|
+
|
|
86
|
+
export const encodeBridgeAndDepositPassivePool = (
|
|
87
|
+
receiver: string,
|
|
88
|
+
msgGasLimit: bigint,
|
|
89
|
+
connector: string,
|
|
90
|
+
poolId: number,
|
|
91
|
+
owner: string,
|
|
92
|
+
amount: bigint,
|
|
93
|
+
minShares: bigint,
|
|
94
|
+
): MethodParameters => {
|
|
95
|
+
const PERIPHERY_INTERFACE = new Interface(peripheryAbi);
|
|
96
|
+
const peripheryCalldata = PERIPHERY_INTERFACE.encodeFunctionData(
|
|
97
|
+
'depositPassivePool',
|
|
98
|
+
[{ poolId, owner, amount, minShares }],
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
const functionSignature = 'depositToAppChain';
|
|
102
|
+
const parameters = [
|
|
103
|
+
receiver,
|
|
104
|
+
amount,
|
|
105
|
+
msgGasLimit,
|
|
106
|
+
connector,
|
|
107
|
+
peripheryCalldata,
|
|
108
|
+
];
|
|
109
|
+
const INTERFACE = new Interface(Socket_VaultWithPayloadAbi);
|
|
110
|
+
const calldata = INTERFACE.encodeFunctionData(functionSignature, parameters);
|
|
111
|
+
return { calldata: calldata, value: BigInt(0).toString(10) };
|
|
112
|
+
};
|
package/src/services/lp/index.ts
CHANGED
package/src/services/lp/types.ts
CHANGED
|
@@ -24,13 +24,13 @@ export type RemoveLiquidityResult = {
|
|
|
24
24
|
export type TransferFromMAToPoolParams = {
|
|
25
25
|
signer: Signer | JsonRpcSigner;
|
|
26
26
|
accountId: number;
|
|
27
|
-
accountSigNonce: number;
|
|
28
|
-
deadline: number;
|
|
29
|
-
poolTokenAddress: TokenEntity['address'];
|
|
27
|
+
accountSigNonce: number; // todo
|
|
28
|
+
deadline: number; // todo
|
|
29
|
+
poolTokenAddress: TokenEntity['address']; // todo
|
|
30
30
|
amount: number;
|
|
31
31
|
poolId: number;
|
|
32
32
|
owner: string;
|
|
33
|
-
minShares: bigint;
|
|
33
|
+
minShares: bigint; // todo
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
export type TransferFromMAToPoolResult = {
|
|
@@ -41,13 +41,25 @@ export type WithdrawPassivePoolAndBridgeParams = {
|
|
|
41
41
|
signer: Signer | JsonRpcSigner;
|
|
42
42
|
ownerAddress: string;
|
|
43
43
|
poolId: number;
|
|
44
|
-
poolTokenAddress: TokenEntity['address'];
|
|
45
|
-
sharesAmount: bigint;
|
|
46
|
-
minOut: bigint;
|
|
47
|
-
ownerSigNonce: number;
|
|
48
|
-
deadline: number;
|
|
44
|
+
poolTokenAddress: TokenEntity['address']; // todo
|
|
45
|
+
sharesAmount: bigint; // todo ?
|
|
46
|
+
minOut: bigint; // todo ?
|
|
47
|
+
ownerSigNonce: number; //todo
|
|
48
|
+
deadline: number; // todo
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
export type WithdrawPassivePoolAndBridgeResult = {
|
|
52
52
|
transactionHash: string | null;
|
|
53
53
|
};
|
|
54
|
+
|
|
55
|
+
export type BridgeAndDepositPassivePoolParams = {
|
|
56
|
+
signer: Signer | JsonRpcSigner;
|
|
57
|
+
poolId: number;
|
|
58
|
+
poolTokenAddress: TokenEntity['address']; // todo
|
|
59
|
+
minShares: bigint; // todo
|
|
60
|
+
amount: number;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export type BridgeAndDepositPassivePoolResult = {
|
|
64
|
+
transactionHash: string | null;
|
|
65
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { getSocketConnector, getSocketVault } from '@reyaxyz/common';
|
|
2
|
+
import { ContractType, getAddress } from '../../utils/contractAddresses';
|
|
3
|
+
import { executeTransaction } from '../executeTransaction';
|
|
4
|
+
import { getTokenDetails, scale } from '../token/common';
|
|
5
|
+
import { encodeBridgeAndDepositExistingMA } from './encode';
|
|
6
|
+
import {
|
|
7
|
+
BridgeAndDepositExisingMAParams,
|
|
8
|
+
BridgeAndDepositExisingMAResult,
|
|
9
|
+
} from './types';
|
|
10
|
+
import { signCoreCommands } from '../sign';
|
|
11
|
+
|
|
12
|
+
export const bridgeAndDepositExisingMA = async (
|
|
13
|
+
params: BridgeAndDepositExisingMAParams,
|
|
14
|
+
): Promise<BridgeAndDepositExisingMAResult> => {
|
|
15
|
+
const network = await params.signer.provider?.getNetwork();
|
|
16
|
+
const chainId = Number(network?.chainId);
|
|
17
|
+
const eip712Signature = await signCoreCommands(
|
|
18
|
+
params.signer,
|
|
19
|
+
chainId,
|
|
20
|
+
params.accountId,
|
|
21
|
+
params.accountSigNonce,
|
|
22
|
+
params.deadline,
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
const { tokenDecimals } = getTokenDetails(params.tokenAddress);
|
|
26
|
+
const amount = scale(tokenDecimals)(params.amount);
|
|
27
|
+
|
|
28
|
+
const { calldata: data, value } = encodeBridgeAndDepositExistingMA(
|
|
29
|
+
getAddress(chainId, ContractType.PERIPHERY_PROXY),
|
|
30
|
+
BigInt('10000000'),
|
|
31
|
+
getSocketConnector({
|
|
32
|
+
chainId: chainId,
|
|
33
|
+
tokenAddress: params.tokenAddress,
|
|
34
|
+
}),
|
|
35
|
+
params.accountId,
|
|
36
|
+
params.tokenAddress,
|
|
37
|
+
amount,
|
|
38
|
+
eip712Signature,
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const result = await executeTransaction(
|
|
42
|
+
params.signer,
|
|
43
|
+
data,
|
|
44
|
+
value,
|
|
45
|
+
chainId,
|
|
46
|
+
getSocketVault({
|
|
47
|
+
moneyInOutChainId: chainId,
|
|
48
|
+
tokenAddress: params.tokenAddress,
|
|
49
|
+
}),
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
transactionHash: result?.hash || null,
|
|
54
|
+
};
|
|
55
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { getSocketConnector, getSocketVault } from '@reyaxyz/common';
|
|
2
|
+
import { ContractType, getAddress } from '../../utils/contractAddresses';
|
|
3
|
+
import { executeTransaction } from '../executeTransaction';
|
|
4
|
+
import { getTokenDetails, scale } from '../token/common';
|
|
5
|
+
import { encodeBridgeAndDepositNewMA } from './encode';
|
|
6
|
+
import {
|
|
7
|
+
BridgeAndDepositNewMAParams,
|
|
8
|
+
BridgeAndDepositNewMAResult,
|
|
9
|
+
} from './types';
|
|
10
|
+
|
|
11
|
+
export const bridgeAndDepositNewMA = async (
|
|
12
|
+
params: BridgeAndDepositNewMAParams,
|
|
13
|
+
): Promise<BridgeAndDepositNewMAResult> => {
|
|
14
|
+
const network = await params.signer.provider?.getNetwork();
|
|
15
|
+
const chainId = Number(network?.chainId);
|
|
16
|
+
|
|
17
|
+
const { tokenDecimals } = getTokenDetails(params.tokenAddress);
|
|
18
|
+
const amount = scale(tokenDecimals)(params.amount);
|
|
19
|
+
|
|
20
|
+
const { calldata: data, value } = encodeBridgeAndDepositNewMA(
|
|
21
|
+
getAddress(chainId, ContractType.PERIPHERY_PROXY),
|
|
22
|
+
BigInt('10000000'),
|
|
23
|
+
getSocketConnector({
|
|
24
|
+
chainId: chainId,
|
|
25
|
+
tokenAddress: params.tokenAddress,
|
|
26
|
+
}),
|
|
27
|
+
await params.signer.getAddress(),
|
|
28
|
+
params.tokenAddress,
|
|
29
|
+
amount,
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
const result = await executeTransaction(
|
|
33
|
+
params.signer,
|
|
34
|
+
data,
|
|
35
|
+
value,
|
|
36
|
+
chainId,
|
|
37
|
+
getSocketVault({
|
|
38
|
+
moneyInOutChainId: chainId,
|
|
39
|
+
tokenAddress: params.tokenAddress,
|
|
40
|
+
}),
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
transactionHash: result?.hash || null,
|
|
45
|
+
};
|
|
46
|
+
};
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
|
|
10
10
|
import { abi } from '../../abis/AccountModule.json';
|
|
11
11
|
import { abi as peripheryAbi } from '../../abis/Periphery.json';
|
|
12
|
+
import { abi as Socket_VaultWithPayloadAbi } from '../../abis/socket/VaultWithPayload.json';
|
|
12
13
|
import { EIP712Signature } from '../sign';
|
|
13
14
|
|
|
14
15
|
export const encodeCreateAccountCall = (
|
|
@@ -100,3 +101,58 @@ export const encodeWithdrawMAAndBridge = (
|
|
|
100
101
|
const calldata = INTERFACE.encodeFunctionData(functionSignature, parameters);
|
|
101
102
|
return { calldata: calldata, value: BigInt(0).toString(10) };
|
|
102
103
|
};
|
|
104
|
+
|
|
105
|
+
export const encodeBridgeAndDepositNewMA = (
|
|
106
|
+
receiver: string,
|
|
107
|
+
msgGasLimit: bigint,
|
|
108
|
+
connector: string,
|
|
109
|
+
accountOwner: string,
|
|
110
|
+
token: string,
|
|
111
|
+
tokenAmount: bigint,
|
|
112
|
+
): MethodParameters => {
|
|
113
|
+
const PERIPHERY_INTERFACE = new Interface(peripheryAbi);
|
|
114
|
+
const peripheryCalldata = PERIPHERY_INTERFACE.encodeFunctionData(
|
|
115
|
+
'depositNewMA',
|
|
116
|
+
[{ accountOwner, token, tokenAmount }],
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
const functionSignature = 'depositToAppChain';
|
|
120
|
+
const parameters = [
|
|
121
|
+
receiver,
|
|
122
|
+
tokenAmount,
|
|
123
|
+
msgGasLimit,
|
|
124
|
+
connector,
|
|
125
|
+
peripheryCalldata,
|
|
126
|
+
];
|
|
127
|
+
const INTERFACE = new Interface(Socket_VaultWithPayloadAbi);
|
|
128
|
+
const calldata = INTERFACE.encodeFunctionData(functionSignature, parameters);
|
|
129
|
+
return { calldata: calldata, value: BigInt(0).toString(10) };
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export const encodeBridgeAndDepositExistingMA = (
|
|
133
|
+
receiver: string,
|
|
134
|
+
msgGasLimit: bigint,
|
|
135
|
+
connector: string,
|
|
136
|
+
accountId: number,
|
|
137
|
+
token: string,
|
|
138
|
+
tokenAmount: bigint,
|
|
139
|
+
sig: EIP712Signature,
|
|
140
|
+
): MethodParameters => {
|
|
141
|
+
const PERIPHERY_INTERFACE = new Interface(peripheryAbi);
|
|
142
|
+
const peripheryCalldata = PERIPHERY_INTERFACE.encodeFunctionData(
|
|
143
|
+
'depositExistingMA',
|
|
144
|
+
[{ accountId, token, tokenAmount, sig }],
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
const functionSignature = 'depositToAppChain';
|
|
148
|
+
const parameters = [
|
|
149
|
+
receiver,
|
|
150
|
+
tokenAmount,
|
|
151
|
+
msgGasLimit,
|
|
152
|
+
connector,
|
|
153
|
+
peripheryCalldata,
|
|
154
|
+
];
|
|
155
|
+
const INTERFACE = new Interface(Socket_VaultWithPayloadAbi);
|
|
156
|
+
const calldata = INTERFACE.encodeFunctionData(functionSignature, parameters);
|
|
157
|
+
return { calldata: calldata, value: BigInt(0).toString(10) };
|
|
158
|
+
};
|
|
@@ -4,3 +4,7 @@ export * from './deposit';
|
|
|
4
4
|
export * from './simulateDeposit';
|
|
5
5
|
export * from './simulateWithdraw';
|
|
6
6
|
export * from './withdraw';
|
|
7
|
+
export * from './bridgeAndDepositExistingMA';
|
|
8
|
+
export * from './bridgeAndDepositNewMA';
|
|
9
|
+
export * from './transferMarginBetweenAccounts';
|
|
10
|
+
export * from './withdrawMAAndBridge';
|
|
@@ -76,14 +76,37 @@ export type TransferMarginBetweenAccountsResult = {
|
|
|
76
76
|
export type WithdrawMAAndBridgeParams = {
|
|
77
77
|
signer: Signer | JsonRpcSigner;
|
|
78
78
|
accountId: MarginAccountEntity['id'];
|
|
79
|
-
accountSigNonce: number;
|
|
80
|
-
deadline: number;
|
|
79
|
+
accountSigNonce: number; // todo
|
|
80
|
+
deadline: number; // todo
|
|
81
81
|
tokenAddress: TokenEntity['address'];
|
|
82
82
|
amount: number;
|
|
83
|
-
poolTokenAddress: TokenEntity['address'];
|
|
84
|
-
receiverAddress: string;
|
|
83
|
+
poolTokenAddress: TokenEntity['address']; // todo
|
|
84
|
+
receiverAddress: string; // todo
|
|
85
85
|
};
|
|
86
86
|
|
|
87
87
|
export type WithdrawMAAndBridgeParamsResult = {
|
|
88
88
|
transactionHash: string | null;
|
|
89
89
|
};
|
|
90
|
+
|
|
91
|
+
export type BridgeAndDepositNewMAParams = {
|
|
92
|
+
signer: Signer | JsonRpcSigner;
|
|
93
|
+
tokenAddress: TokenEntity['address'];
|
|
94
|
+
amount: number;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export type BridgeAndDepositNewMAResult = {
|
|
98
|
+
transactionHash: string | null;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export type BridgeAndDepositExisingMAParams = {
|
|
102
|
+
signer: Signer | JsonRpcSigner;
|
|
103
|
+
accountId: MarginAccountEntity['id'];
|
|
104
|
+
accountSigNonce: number; // todo
|
|
105
|
+
deadline: number; // todo
|
|
106
|
+
tokenAddress: TokenEntity['address'];
|
|
107
|
+
amount: number;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export type BridgeAndDepositExisingMAResult = {
|
|
111
|
+
transactionHash: string | null;
|
|
112
|
+
};
|