@pendle/sdk-boros 0.0.12 → 0.0.14
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/constants.d.ts +2 -1
- package/dist/constants.js +3 -2
- package/dist/constants.js.map +1 -1
- package/dist/entities/agent/agent.d.ts +2 -0
- package/dist/entities/agent/agent.js +20 -8
- package/dist/entities/agent/agent.js.map +1 -1
- package/dist/entities/marketHub.d.ts +3 -0
- package/dist/entities/marketHub.js +17 -0
- package/dist/entities/marketHub.js.map +1 -0
- package/dist/entities/router.d.ts +12 -12
- package/dist/utils/index.d.ts +4 -1
- package/dist/utils/index.js +13 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/signing/agent.js +1 -1
- package/dist/utils/signing/agent.js.map +1 -1
- package/dist/utils/signing/common.d.ts +1 -1
- package/dist/utils/signing/sensitive.js +2 -1
- package/dist/utils/signing/sensitive.js.map +1 -1
- package/package.json +1 -1
package/dist/constants.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export declare const ROUTER_ADDRESS: "
|
|
1
|
+
export declare const ROUTER_ADDRESS: "0xb18f37f4b37b6b4f56e15f2e9f3fe78cf5c6fe9e";
|
|
2
|
+
export declare const MARKET_HUB_ADDRESS: "0x737ccb5c38e7343e8bfe1027c1df87544d0c651f";
|
|
2
3
|
export declare const CHAIN_ID = 8453;
|
package/dist/constants.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CHAIN_ID = exports.ROUTER_ADDRESS = void 0;
|
|
4
|
-
exports.ROUTER_ADDRESS = '
|
|
3
|
+
exports.CHAIN_ID = exports.MARKET_HUB_ADDRESS = exports.ROUTER_ADDRESS = void 0;
|
|
4
|
+
exports.ROUTER_ADDRESS = '0xb18f37f4b37b6b4f56e15f2e9f3fe78cf5c6fe9e';
|
|
5
|
+
exports.MARKET_HUB_ADDRESS = '0x737ccb5c38e7343e8bfe1027c1df87544d0c651f';
|
|
5
6
|
exports.CHAIN_ID = 8453;
|
|
6
7
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AACa,QAAA,cAAc,GAAG,4CAAqD,CAAC;AACvE,QAAA,QAAQ,GAAG,IAAI,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AACa,QAAA,cAAc,GAAG,4CAAqD,CAAC;AACvE,QAAA,kBAAkB,GAAG,4CAAqD,CAAC;AAC3E,QAAA,QAAQ,GAAG,IAAI,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Address, Hex, WalletClient } from 'viem';
|
|
2
|
+
import { Account } from '../../types';
|
|
2
3
|
export declare function setInternalAgent(agent: Agent): void;
|
|
3
4
|
export declare function getInternalAgent(): Agent;
|
|
4
5
|
export declare class Agent {
|
|
@@ -13,5 +14,6 @@ export declare class Agent {
|
|
|
13
14
|
privateKey: Hex;
|
|
14
15
|
}>;
|
|
15
16
|
approveAgent(userWalletClient: WalletClient, expiry_s: number): Promise<Hex>;
|
|
17
|
+
getExpiry(account: Account): Promise<number>;
|
|
16
18
|
getAddress(): Promise<Address>;
|
|
17
19
|
}
|
|
@@ -4,12 +4,13 @@ exports.Agent = void 0;
|
|
|
4
4
|
exports.setInternalAgent = setInternalAgent;
|
|
5
5
|
exports.getInternalAgent = getInternalAgent;
|
|
6
6
|
const viem_1 = require("viem");
|
|
7
|
+
const accounts_1 = require("viem/accounts");
|
|
7
8
|
const chains_1 = require("viem/chains");
|
|
8
|
-
const
|
|
9
|
+
const common_1 = require("../../common");
|
|
9
10
|
const viemAbis_1 = require("../../contracts/viemAbis");
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
11
|
+
const utils_1 = require("../../utils");
|
|
12
|
+
const common_2 = require("../../utils/signing/common");
|
|
13
|
+
const router_1 = require("../router");
|
|
13
14
|
let internalAgent;
|
|
14
15
|
function setInternalAgent(agent) {
|
|
15
16
|
internalAgent = agent;
|
|
@@ -26,7 +27,7 @@ class Agent {
|
|
|
26
27
|
constructor(privateKey) {
|
|
27
28
|
this.privateKey = privateKey;
|
|
28
29
|
const account = (0, accounts_1.privateKeyToAccount)(this.privateKey);
|
|
29
|
-
this.walletClient = (0, viem_1.createWalletClient)({ account, transport: (0, viem_1.http)(
|
|
30
|
+
this.walletClient = (0, viem_1.createWalletClient)({ account, transport: (0, viem_1.http)(common_1.RPC_URL), chain: chains_1.base });
|
|
30
31
|
}
|
|
31
32
|
async createApproveAgentStruct(userAddress, expiry_s) {
|
|
32
33
|
const agentAddress = await this.getAddress();
|
|
@@ -50,19 +51,30 @@ class Agent {
|
|
|
50
51
|
return new Agent(privateKey);
|
|
51
52
|
}
|
|
52
53
|
static async create(userWalletClient) {
|
|
53
|
-
const message = (0,
|
|
54
|
+
const message = (0, common_2.getWelcomeMessage)();
|
|
54
55
|
const [userAddress] = await userWalletClient.getAddresses();
|
|
55
56
|
const signature = await userWalletClient.signMessage({ account: userWalletClient.account ?? userAddress, message });
|
|
56
|
-
const privateKey = (0, viem_1.toHex)(BigInt(signature) & BigInt('0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'));
|
|
57
|
+
const privateKey = (0, viem_1.toHex)(BigInt(signature) & BigInt('0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'), { size: 32 });
|
|
57
58
|
const agent = new Agent(privateKey);
|
|
58
59
|
return { agent, privateKey };
|
|
59
60
|
}
|
|
60
61
|
async approveAgent(userWalletClient, expiry_s) {
|
|
61
|
-
const
|
|
62
|
+
const userAddress = await (0, utils_1.getUserAddressFromWalletClient)(userWalletClient);
|
|
62
63
|
const approveAgentStruct = await this.createApproveAgentStruct(userAddress, expiry_s);
|
|
63
64
|
const approveSignature = await (0, utils_1.signApproveAgentMessage)(userWalletClient, approveAgentStruct);
|
|
64
65
|
return this.getApproveAgentData(approveAgentStruct, approveSignature);
|
|
65
66
|
}
|
|
67
|
+
async getExpiry(account) {
|
|
68
|
+
const agentAddress = await this.getAddress();
|
|
69
|
+
const expiry = await router_1.router.read.viewCall([
|
|
70
|
+
(0, viem_1.encodeFunctionData)({
|
|
71
|
+
abi: viemAbis_1.iAuthModuleAbi,
|
|
72
|
+
functionName: 'agentExpiry',
|
|
73
|
+
args: [account, agentAddress],
|
|
74
|
+
}),
|
|
75
|
+
]);
|
|
76
|
+
return Number(expiry);
|
|
77
|
+
}
|
|
66
78
|
async getAddress() {
|
|
67
79
|
const [agentAddress] = await this.walletClient.getAddresses();
|
|
68
80
|
return agentAddress;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../../../src/entities/agent/agent.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../../../src/entities/agent/agent.ts"],"names":[],"mappings":";;;AAWA,4CAEC;AAED,4CAKC;AApBD,+BAAuG;AACvG,4CAAoD;AACpD,wCAAmC;AACnC,yCAAuC;AACvC,uDAA0D;AAE1D,uCAAkG;AAClG,uDAA+D;AAC/D,sCAAmC;AAEnC,IAAI,aAAgC,CAAC;AACrC,SAAgB,gBAAgB,CAAC,KAAY;IAC3C,aAAa,GAAG,KAAK,CAAC;AACxB,CAAC;AAED,SAAgB,gBAAgB;IAC9B,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAC/C,CAAC;IACD,OAAO,aAAa,CAAC;AACvB,CAAC;AACD,MAAa,KAAK;IAGqB;IAFrC,YAAY,CAAe;IAE3B,YAAqC,UAAe;QAAf,eAAU,GAAV,UAAU,CAAK;QAClD,MAAM,OAAO,GAAG,IAAA,8B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;CACF;AArED,sBAqEC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.marketHub = void 0;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
const chains_1 = require("viem/chains");
|
|
6
|
+
const common_1 = require("../common");
|
|
7
|
+
const constants_1 = require("../constants");
|
|
8
|
+
const viemAbis_1 = require("../contracts/viemAbis");
|
|
9
|
+
exports.marketHub = (0, viem_1.getContract)({
|
|
10
|
+
address: constants_1.MARKET_HUB_ADDRESS,
|
|
11
|
+
abi: viemAbis_1.iMarketHubAbi,
|
|
12
|
+
client: (0, viem_1.createPublicClient)({
|
|
13
|
+
chain: chains_1.base,
|
|
14
|
+
transport: (0, viem_1.http)(common_1.RPC_URL),
|
|
15
|
+
}),
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=marketHub.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marketHub.js","sourceRoot":"","sources":["../../src/entities/marketHub.ts"],"names":[],"mappings":";;;AAAA,+BAAkG;AAClG,wCAAmC;AACnC,sCAAoC;AACpC,4CAAkD;AAClD,oDAAsD;AAEzC,QAAA,SAAS,GAA8D,IAAA,kBAAW,EAAC;IAC9F,OAAO,EAAE,8BAAkB;IAC3B,GAAG,EAAE,wBAAa;IAClB,MAAM,EAAE,IAAA,yBAAkB,EAAC;QACzB,KAAK,EAAE,aAAI;QACX,SAAS,EAAE,IAAA,WAAI,EAAC,gBAAO,CAAC;KACzB,CAAC;CACH,CAAC,CAAC"}
|
|
@@ -68,7 +68,7 @@ export declare const router: {
|
|
|
68
68
|
}];
|
|
69
69
|
readonly stateMutability: "view";
|
|
70
70
|
readonly type: "function";
|
|
71
|
-
}], "viewCall", readonly [`0x${string}`]>, "address" | "
|
|
71
|
+
}], "viewCall", readonly [`0x${string}`]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<`0x${string}`>;
|
|
72
72
|
};
|
|
73
73
|
estimateGas: {
|
|
74
74
|
batchSimulate: (args: readonly [readonly {
|
|
@@ -451,7 +451,7 @@ export declare const router: {
|
|
|
451
451
|
serializers: {
|
|
452
452
|
readonly transaction: typeof import("viem/chains").serializeTransactionOpStack;
|
|
453
453
|
};
|
|
454
|
-
}>, "address" | "
|
|
454
|
+
}>, "address" | "abi" | "args" | "functionName">>) => Promise<import("viem").EstimateContractGasReturnType>;
|
|
455
455
|
directCall: (args: readonly [readonly {
|
|
456
456
|
accountId: number;
|
|
457
457
|
data: `0x${string}`;
|
|
@@ -830,7 +830,7 @@ export declare const router: {
|
|
|
830
830
|
serializers: {
|
|
831
831
|
readonly transaction: typeof import("viem/chains").serializeTransactionOpStack;
|
|
832
832
|
};
|
|
833
|
-
}>, "address" | "
|
|
833
|
+
}>, "address" | "abi" | "args" | "functionName">>) => Promise<import("viem").EstimateContractGasReturnType>;
|
|
834
834
|
} & {
|
|
835
835
|
batchSimulate: (args: readonly [readonly {
|
|
836
836
|
account: `0x${string}`;
|
|
@@ -1212,7 +1212,7 @@ export declare const router: {
|
|
|
1212
1212
|
serializers: {
|
|
1213
1213
|
readonly transaction: typeof import("viem/chains").serializeTransactionOpStack;
|
|
1214
1214
|
};
|
|
1215
|
-
}>, "address" | "
|
|
1215
|
+
}>, "address" | "abi" | "args" | "functionName">>) => Promise<import("viem").EstimateContractGasReturnType>;
|
|
1216
1216
|
directCall: (args: readonly [readonly {
|
|
1217
1217
|
accountId: number;
|
|
1218
1218
|
data: `0x${string}`;
|
|
@@ -1591,7 +1591,7 @@ export declare const router: {
|
|
|
1591
1591
|
serializers: {
|
|
1592
1592
|
readonly transaction: typeof import("viem/chains").serializeTransactionOpStack;
|
|
1593
1593
|
};
|
|
1594
|
-
}>, "address" | "
|
|
1594
|
+
}>, "address" | "abi" | "args" | "functionName">>) => Promise<import("viem").EstimateContractGasReturnType>;
|
|
1595
1595
|
};
|
|
1596
1596
|
simulate: {
|
|
1597
1597
|
batchSimulate: <chainOverride extends import("viem").Chain | undefined = undefined, accountOverride extends import("viem").Account | import("viem").Address | undefined = undefined>(args: readonly [readonly {
|
|
@@ -1974,7 +1974,7 @@ export declare const router: {
|
|
|
1974
1974
|
serializers: {
|
|
1975
1975
|
readonly transaction: typeof import("viem/chains").serializeTransactionOpStack;
|
|
1976
1976
|
};
|
|
1977
|
-
}, chainOverride, accountOverride>, "address" | "
|
|
1977
|
+
}, chainOverride, accountOverride>, "address" | "abi" | "args" | "functionName"> | undefined) => Promise<import("viem").SimulateContractReturnType<readonly [{
|
|
1978
1978
|
readonly inputs: readonly [{
|
|
1979
1979
|
readonly components: readonly [{
|
|
1980
1980
|
readonly internalType: "Account";
|
|
@@ -2729,7 +2729,7 @@ export declare const router: {
|
|
|
2729
2729
|
serializers: {
|
|
2730
2730
|
readonly transaction: typeof import("viem/chains").serializeTransactionOpStack;
|
|
2731
2731
|
};
|
|
2732
|
-
}, chainOverride, accountOverride>, "address" | "
|
|
2732
|
+
}, chainOverride, accountOverride>, "address" | "abi" | "args" | "functionName"> | undefined) => Promise<import("viem").SimulateContractReturnType<readonly [{
|
|
2733
2733
|
readonly inputs: readonly [{
|
|
2734
2734
|
readonly components: readonly [{
|
|
2735
2735
|
readonly internalType: "Account";
|
|
@@ -3483,7 +3483,7 @@ export declare const router: {
|
|
|
3483
3483
|
serializers: {
|
|
3484
3484
|
readonly transaction: typeof import("viem/chains").serializeTransactionOpStack;
|
|
3485
3485
|
};
|
|
3486
|
-
}, undefined, chainOverride>, "address" | "
|
|
3486
|
+
}, undefined, chainOverride>, "address" | "abi" | "args" | "functionName"> extends infer T ? { [K in keyof T]: import("viem").UnionOmit<import("viem").WriteContractParameters<readonly [{
|
|
3487
3487
|
readonly inputs: readonly [{
|
|
3488
3488
|
readonly components: readonly [{
|
|
3489
3489
|
readonly internalType: "Account";
|
|
@@ -3859,7 +3859,7 @@ export declare const router: {
|
|
|
3859
3859
|
serializers: {
|
|
3860
3860
|
readonly transaction: typeof import("viem/chains").serializeTransactionOpStack;
|
|
3861
3861
|
};
|
|
3862
|
-
}, undefined, chainOverride>, "address" | "
|
|
3862
|
+
}, undefined, chainOverride>, "address" | "abi" | "args" | "functionName">[K]; } : never>(args: readonly [readonly {
|
|
3863
3863
|
account: `0x${string}`;
|
|
3864
3864
|
target: `0x${string}`;
|
|
3865
3865
|
data: `0x${string}`;
|
|
@@ -4239,7 +4239,7 @@ export declare const router: {
|
|
|
4239
4239
|
serializers: {
|
|
4240
4240
|
readonly transaction: typeof import("viem/chains").serializeTransactionOpStack;
|
|
4241
4241
|
};
|
|
4242
|
-
}, undefined, chainOverride>, "address" | "
|
|
4242
|
+
}, undefined, chainOverride>, "address" | "abi" | "args" | "functionName"> extends infer T ? { [K in keyof T]: import("viem").UnionOmit<import("viem").WriteContractParameters<readonly [{
|
|
4243
4243
|
readonly inputs: readonly [{
|
|
4244
4244
|
readonly components: readonly [{
|
|
4245
4245
|
readonly internalType: "Account";
|
|
@@ -4614,12 +4614,12 @@ export declare const router: {
|
|
|
4614
4614
|
serializers: {
|
|
4615
4615
|
readonly transaction: typeof import("viem/chains").serializeTransactionOpStack;
|
|
4616
4616
|
};
|
|
4617
|
-
}, undefined, chainOverride>, "address" | "
|
|
4617
|
+
}, undefined, chainOverride>, "address" | "abi" | "args" | "functionName">[K]; } : never>(args: readonly [readonly {
|
|
4618
4618
|
accountId: number;
|
|
4619
4619
|
data: `0x${string}`;
|
|
4620
4620
|
}[], boolean], options: options) => Promise<import("viem").WriteContractReturnType>;
|
|
4621
4621
|
};
|
|
4622
|
-
address: "
|
|
4622
|
+
address: "0xb18f37f4b37b6b4f56e15f2e9f3fe78cf5c6fe9e";
|
|
4623
4623
|
abi: readonly [{
|
|
4624
4624
|
readonly inputs: readonly [{
|
|
4625
4625
|
readonly components: readonly [{
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export * from './signing';
|
|
2
2
|
export * from './accountLib';
|
|
3
|
-
import { Hex, WalletClient } from 'viem';
|
|
3
|
+
import { Address, Hex, WalletClient } from 'viem';
|
|
4
|
+
import { AccountPosition } from '../types';
|
|
4
5
|
export declare function sendTx(walletClient: WalletClient, calldata: Hex): Promise<`0x${string}`>;
|
|
5
6
|
export declare function getRouterDirectCallData(callDataList: Hex[], requireMarginCheckCall?: boolean): Hex;
|
|
7
|
+
export declare function getUserAddressFromWalletClient(userWalletClient: WalletClient): Promise<Address>;
|
|
8
|
+
export declare function getEnteredMarkets(accountPosition: AccountPosition): Promise<readonly `0x${string}`[]>;
|
package/dist/utils/index.js
CHANGED
|
@@ -16,11 +16,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.sendTx = sendTx;
|
|
18
18
|
exports.getRouterDirectCallData = getRouterDirectCallData;
|
|
19
|
+
exports.getUserAddressFromWalletClient = getUserAddressFromWalletClient;
|
|
20
|
+
exports.getEnteredMarkets = getEnteredMarkets;
|
|
19
21
|
__exportStar(require("./signing"), exports);
|
|
20
22
|
__exportStar(require("./accountLib"), exports);
|
|
21
23
|
const viem_1 = require("viem");
|
|
22
24
|
const constants_1 = require("../constants");
|
|
23
25
|
const viemAbis_1 = require("../contracts/viemAbis");
|
|
26
|
+
const marketHub_1 = require("../entities/marketHub");
|
|
24
27
|
async function sendTx(walletClient, calldata) {
|
|
25
28
|
const [account] = await walletClient.getAddresses();
|
|
26
29
|
const txHash = await walletClient.sendTransaction({
|
|
@@ -40,4 +43,14 @@ function getRouterDirectCallData(callDataList, requireMarginCheckCall = false) {
|
|
|
40
43
|
});
|
|
41
44
|
return data;
|
|
42
45
|
}
|
|
46
|
+
async function getUserAddressFromWalletClient(userWalletClient) {
|
|
47
|
+
let userAddress = userWalletClient.account?.address;
|
|
48
|
+
if (!userAddress) {
|
|
49
|
+
[userAddress] = await userWalletClient.getAddresses();
|
|
50
|
+
}
|
|
51
|
+
return userAddress;
|
|
52
|
+
}
|
|
53
|
+
async function getEnteredMarkets(accountPosition) {
|
|
54
|
+
return marketHub_1.marketHub.read.getEnteredMarkets([accountPosition]);
|
|
55
|
+
}
|
|
43
56
|
//# sourceMappingURL=index.js.map
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AASA,wBAYC;AAED,0DAQC;AAED,wEAMC;AAED,8CAEC;AA3CD,4CAA0B;AAC1B,+CAA6B;AAE7B,+BAAsE;AACtE,4CAA8C;AAC9C,oDAAmD;AAEnD,qDAAkD;AAE3C,KAAK,UAAU,MAAM,CAAC,YAA0B,EAAE,QAAa;IACpE,MAAM,CAAC,OAAO,CAAC,GAAG,MAAM,YAAY,CAAC,YAAY,EAAE,CAAC;IACpD,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,eAAe,CAAC;QAChD,OAAO;QACP,EAAE,EAAE,0BAAc;QAClB,IAAI,EAAE,QAAQ;QAEd,KAAK,EAAE,EAAE;QACT,KAAK,EAAE,YAAY,CAAC,KAAK;KAC1B,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAgB,uBAAuB,CAAC,YAAmB,EAAE,sBAAsB,GAAG,KAAK;IACzF,MAAM,IAAI,GAAG,IAAA,yBAAkB,EAAC;QAC9B,GAAG,EAAE,qBAAU;QACf,YAAY,EAAE,YAAY;QAC1B,IAAI,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,sBAAsB,CAAC;KACnG,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC;AAEM,KAAK,UAAU,8BAA8B,CAAC,gBAA8B;IACjF,IAAI,WAAW,GAAG,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC;IACpD,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,CAAC,WAAW,CAAC,GAAG,MAAM,gBAAgB,CAAC,YAAY,EAAE,CAAC;IACxD,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC;AAEM,KAAK,UAAU,iBAAiB,CAAC,eAAgC;IACtE,OAAO,qBAAS,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC;AAC7D,CAAC"}
|
|
@@ -4,9 +4,9 @@ exports.ACTION_INPUT_NAME_MAP = void 0;
|
|
|
4
4
|
exports.signWithAgent = signWithAgent;
|
|
5
5
|
const viem_1 = require("viem");
|
|
6
6
|
const viemAbis_1 = require("../../contracts/viemAbis");
|
|
7
|
+
const entities_1 = require("../../entities");
|
|
7
8
|
const accountLib_1 = require("../accountLib");
|
|
8
9
|
const common_1 = require("./common");
|
|
9
|
-
const entities_1 = require("../../entities");
|
|
10
10
|
exports.ACTION_INPUT_NAME_MAP = {
|
|
11
11
|
placeOrders: 'orders',
|
|
12
12
|
cancelOrders: 'cancels',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../../../src/utils/signing/agent.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../../../src/utils/signing/agent.ts"],"names":[],"mappings":";;;AAkCA,sCAoDC;AAtFD,+BAAgF;AAChF,uDAA0D;AAC1D,6CAAkD;AAQlD,8CAA2C;AAC3C,qCAA2E;AAE9D,QAAA,qBAAqB,GAAG;IACnC,WAAW,EAAE,QAAQ;IACrB,YAAY,EAAE,SAAS;IACvB,gBAAgB,EAAE,WAAW;IAC7B,gBAAgB,EAAE,YAAY;CACtB,CAAC;AAgBJ,KAAK,UAAU,a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Y,EAAE,4BAAmB;gBACjC,YAAY,EAAE,gBAAgB;aAC/B;YACD,WAAW,EAAE,cAAc;YAC3B,OAAO;SACR,CAAC,CAAC;QAEH,OAAO,CAAC,IAAI,CAAC;YACX,KAAK,EAAE,MAAM,KAAK,CAAC,UAAU,EAAE;YAC/B,OAAO;YACP,SAAS;YACT,MAAM,EAAE,cAAc;SACvB,CAAC,CAAC;IACL,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -2,7 +2,7 @@ export declare const PENDLE_BOROS_ROUTER_DOMAIN: {
|
|
|
2
2
|
readonly name: "Pendle Boros Router";
|
|
3
3
|
readonly version: "1.0";
|
|
4
4
|
readonly chainId: bigint;
|
|
5
|
-
readonly verifyingContract: "
|
|
5
|
+
readonly verifyingContract: "0xb18f37f4b37b6b4f56e15f2e9f3fe78cf5c6fe9e";
|
|
6
6
|
};
|
|
7
7
|
export declare const EIP712_DOMAIN_TYPES: readonly [{
|
|
8
8
|
readonly name: "name";
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.signSetAccManagerMessage = signSetAccManagerMessage;
|
|
4
4
|
exports.signApproveAgentMessage = signApproveAgentMessage;
|
|
5
|
+
const __1 = require("..");
|
|
5
6
|
const common_1 = require("./common");
|
|
6
7
|
async function signSetAccManagerMessage(wallet, message) {
|
|
7
8
|
const [account] = await wallet.getAddresses();
|
|
@@ -21,7 +22,7 @@ async function signSetAccManagerMessage(wallet, message) {
|
|
|
21
22
|
});
|
|
22
23
|
}
|
|
23
24
|
async function signApproveAgentMessage(wallet, message) {
|
|
24
|
-
const
|
|
25
|
+
const account = await (0, __1.getUserAddressFromWalletClient)(wallet);
|
|
25
26
|
return wallet.signTypedData({
|
|
26
27
|
account,
|
|
27
28
|
domain: common_1.PENDLE_BOROS_ROUTER_DOMAIN,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sensitive.js","sourceRoot":"","sources":["../../../src/utils/signing/sensitive.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"sensitive.js","sourceRoot":"","sources":["../../../src/utils/signing/sensitive.ts"],"names":[],"mappings":";;AAKA,4DAgBC;AAED,0DAiBC;AAvCD,0BAAoD;AAEpD,qCAA2E;AAEpE,KAAK,UAAU,wBAAwB,CAAC,MAAoB,EAAE,OAA4B;IAC/F,MAAM,CAAC,OAAO,CAAC,GAAG,MAAM,MAAM,CAAC,YAAY,EAAE,CAAC;IAC9C,OAAO,MAAM,CAAC,aAAa,CAAC;QAC1B,OAAO;QACP,MAAM,EAAE,mCAA0B;QAClC,KAAK,EAAE;YACL,YAAY,EAAE,4BAAmB;YACjC,mBAAmB,EAAE;gBACnB,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;gBACpC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE;gBACvC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE;aAClC;SACF;QACD,WAAW,EAAE,qBAAqB;QAClC,OAAO;KACR,CAAC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,uBAAuB,CAAC,MAAoB,EAAE,OAA2B;IAC7F,MAAM,OAAO,GAAG,MAAM,IAAA,kCAA8B,EAAC,MAAM,CAAC,CAAC;IAC7D,OAAO,MAAM,CAAC,aAAa,CAAC;QAC1B,OAAO;QACP,MAAM,EAAE,mCAA0B;QAClC,KAAK,EAAE;YACL,YAAY,EAAE,4BAAmB;YACjC,kBAAkB,EAAE;gBAClB,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;gBACpC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;gBAClC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE;gBAClC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EA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