@pendle/sdk-boros 0.4.24 → 0.4.26

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.
@@ -6,3 +6,4 @@ export * from './accManager';
6
6
  export * from './Distributor';
7
7
  export * from './multiTokenMerkleDistributor';
8
8
  export * from './wrappedEth';
9
+ export * from './subaccount';
@@ -22,4 +22,5 @@ __exportStar(require("./accManager"), exports);
22
22
  __exportStar(require("./Distributor"), exports);
23
23
  __exportStar(require("./multiTokenMerkleDistributor"), exports);
24
24
  __exportStar(require("./wrappedEth"), exports);
25
+ __exportStar(require("./subaccount"), exports);
25
26
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/entities/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,2CAAyB;AACzB,6CAA2B;AAC3B,wCAAsB;AACtB,+CAA6B;AAC7B,gDAA8B;AAC9B,gEAA8C;AAC9C,+CAA6B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/entities/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,2CAAyB;AACzB,6CAA2B;AAC3B,wCAAsB;AACtB,+CAA6B;AAC7B,gDAA8B;AAC9B,gEAA8C;AAC9C,+CAA6B;AAC7B,+CAA6B"}
@@ -0,0 +1 @@
1
+ export * from './subaccount';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./subaccount"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/entities/subaccount/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B"}
@@ -0,0 +1,19 @@
1
+ import { Address } from 'viem';
2
+ export declare class Subaccount {
3
+ private explorerContract;
4
+ private routerContract;
5
+ constructor();
6
+ getMarketAccCash(userAddress: Address, accountId: number, tokenId: number, marketId: number): Promise<bigint>;
7
+ withdrawCash(userAddress: Address, accountId: number, tokenId: number, marketId: number, amount: bigint): Promise<{
8
+ from: `0x${string}`;
9
+ to: `0x${string}`;
10
+ data: `0x${string}`;
11
+ gas: bigint;
12
+ }>;
13
+ depositCash(userAddress: Address, accountId: number, tokenId: number, marketId: number, amount: bigint): Promise<{
14
+ from: `0x${string}`;
15
+ to: `0x${string}`;
16
+ data: `0x${string}`;
17
+ gas: bigint;
18
+ }>;
19
+ }
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Subaccount = void 0;
4
+ const viem_1 = require("viem");
5
+ const addresses_1 = require("../../addresses");
6
+ const contracts_1 = require("../../contracts");
7
+ const chains_1 = require("viem/chains");
8
+ const common_1 = require("../../common");
9
+ const utils_1 = require("../../utils");
10
+ class Subaccount {
11
+ explorerContract;
12
+ routerContract;
13
+ constructor() {
14
+ this.explorerContract = (0, viem_1.getContract)({
15
+ address: (0, addresses_1.getExplorerContractAddress)(),
16
+ abi: contracts_1.iExplorerAbi,
17
+ client: (0, viem_1.createPublicClient)({
18
+ chain: chains_1.arbitrum,
19
+ transport: (0, viem_1.http)(common_1.RPC_URL),
20
+ }),
21
+ });
22
+ this.routerContract = (0, viem_1.getContract)({
23
+ address: (0, addresses_1.getRouterAddress)(),
24
+ abi: contracts_1.iRouterAbi,
25
+ client: (0, viem_1.createPublicClient)({
26
+ chain: chains_1.arbitrum,
27
+ transport: (0, viem_1.http)(common_1.RPC_URL),
28
+ }),
29
+ });
30
+ }
31
+ async getMarketAccCash(userAddress, accountId, tokenId, marketId) {
32
+ const marketAcc = utils_1.MarketAccLib.pack(userAddress, accountId, tokenId, marketId);
33
+ const userInfo = await this.explorerContract.simulate.getUserInfo([marketAcc]);
34
+ return userInfo.result.totalCash;
35
+ }
36
+ async withdrawCash(userAddress, accountId, tokenId, marketId, amount) {
37
+ const data = (0, viem_1.encodeFunctionData)({
38
+ abi: contracts_1.iRouterAbi,
39
+ functionName: 'subaccountTransfer',
40
+ args: [accountId, tokenId, marketId, amount, false],
41
+ });
42
+ const gas = await this.routerContract.estimateGas.subaccountTransfer([accountId, tokenId, marketId, amount, false], {
43
+ account: userAddress,
44
+ });
45
+ return {
46
+ from: userAddress,
47
+ to: (0, addresses_1.getRouterAddress)(),
48
+ data,
49
+ gas: gas * 2n,
50
+ };
51
+ }
52
+ async depositCash(userAddress, accountId, tokenId, marketId, amount) {
53
+ const data = (0, viem_1.encodeFunctionData)({
54
+ abi: contracts_1.iRouterAbi,
55
+ functionName: 'subaccountTransfer',
56
+ args: [accountId, tokenId, marketId, amount, true],
57
+ });
58
+ const gas = await this.routerContract.estimateGas.subaccountTransfer([accountId, tokenId, marketId, amount, true], {
59
+ account: userAddress,
60
+ });
61
+ return {
62
+ from: userAddress,
63
+ to: (0, addresses_1.getRouterAddress)(),
64
+ data,
65
+ gas: gas * 2n,
66
+ };
67
+ }
68
+ }
69
+ exports.Subaccount = Subaccount;
70
+ //# sourceMappingURL=subaccount.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subaccount.js","sourceRoot":"","sources":["../../../src/entities/subaccount/subaccount.ts"],"names":[],"mappings":";;;AAAA,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E,CAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC;SACpD,CAAC,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,kBAAkB,CAClE,CAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAC7C;YACE,OAAO,EAAE,WAAW;SACrB,CACF,CAAC;QACF,OAAO;YACL,IAAI,EAAE,WAAW;YACjB,EAAE,EAAE,IAAA,4BAAgB,GAAE;YACtB,IAAI;YACJ,GAAG,EAAE,GAAG,GAAG,EAAE;SACd,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,WAAoB,EAAE,SAAiB,EAAE,OAAe,EAAE,QAAgB,EAAE,MAAc;QAC1G,MAAM,IAAI,GAAG,IAAA,yBAAkB,EAAC;YAC9B,GAAG,EAAE,sBAAU;YACf,YAAY,EAAE,oBAAoB;YAClC,IAAI,EAAE,CAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC;SACnD,CAAC,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;YACjH,OAAO,EAAE,WAAW;SACrB,CAAC,CAAC;QACH,OAAO;YACL,IAAI,EAAE,WAAW;YACjB,EAAE,EAAE,IAAA,4BAAgB,GAAE;YACtB,IAAI;YACJ,GAAG,EAAE,GAAG,GAAG,EAAE;SACd,CAAC;IACJ,CAAC;CACF;AAhED,gCAgEC"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@pendle/sdk-boros",
3
3
  "description": "Pendle SDK for Boros",
4
4
  "license": "MIT",
5
- "version": "0.4.24",
5
+ "version": "0.4.26",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "files": [