impermax-sdk 2.1.93 → 2.1.95
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/lib/config/subgraphs.js +9 -9
- package/lib/offchain/offchainInitializer.js +4 -0
- package/lib/offchain/queries/apis/ponder/index.js +2 -0
- package/lib/onchain/interactions/lendingPool/nftlp/onchainInteractionsNftlpUniswapV3.js +2 -4
- package/lib/onchain/interactions/onchainInteractionsPoolToken.d.ts +12 -11
- package/lib/onchain/interactions/onchainInteractionsPoolToken.js +25 -22
- package/package.json +1 -1
package/lib/config/subgraphs.js
CHANGED
|
@@ -223,21 +223,21 @@ exports.IMPERMAX_CHEF_SUBGRAPH_URL = {
|
|
|
223
223
|
};
|
|
224
224
|
exports.BLOCKS_SUBGRAPH_URL = {
|
|
225
225
|
[types_1.Networks.Ropsten]: "",
|
|
226
|
-
[types_1.Networks.Mainnet]: "
|
|
227
|
-
[types_1.Networks.Polygon]: "
|
|
228
|
-
[types_1.Networks.Arbitrum]: "
|
|
229
|
-
[types_1.Networks.Avalanche]: "
|
|
230
|
-
[types_1.Networks.Moonriver]: "
|
|
226
|
+
[types_1.Networks.Mainnet]: "",
|
|
227
|
+
[types_1.Networks.Polygon]: "",
|
|
228
|
+
[types_1.Networks.Arbitrum]: "",
|
|
229
|
+
[types_1.Networks.Avalanche]: "",
|
|
230
|
+
[types_1.Networks.Moonriver]: "",
|
|
231
231
|
[types_1.Networks.Aurora]: "",
|
|
232
232
|
[types_1.Networks.Cronos]: "",
|
|
233
|
-
[types_1.Networks.Fantom]: "
|
|
234
|
-
[types_1.Networks.Canto]: "
|
|
235
|
-
[types_1.Networks.ZksyncEra]: "
|
|
233
|
+
[types_1.Networks.Fantom]: "",
|
|
234
|
+
[types_1.Networks.Canto]: "",
|
|
235
|
+
[types_1.Networks.ZksyncEra]: "",
|
|
236
236
|
[types_1.Networks.Blast]: "",
|
|
237
237
|
[types_1.Networks.Harmony]: "",
|
|
238
238
|
[types_1.Networks.Moonbeam]: "",
|
|
239
239
|
[types_1.Networks.Sxnetwork]: "",
|
|
240
|
-
[types_1.Networks.Base]: "
|
|
240
|
+
[types_1.Networks.Base]: "",
|
|
241
241
|
[types_1.Networks.Mantle]: "",
|
|
242
242
|
[types_1.Networks.Scroll]: "",
|
|
243
243
|
[types_1.Networks.Real]: "",
|
|
@@ -577,6 +577,8 @@ function fetchUserData(account) {
|
|
|
577
577
|
const subgraphs = subgraphs_1.IMPERMAX_SUBGRAPH_URL[this.network][factory];
|
|
578
578
|
// We pass network + factory to get the actual factory address in case we use multiple factories in 1 api
|
|
579
579
|
const result = yield this.endpointManager.fetch(subgraphs, this.network, (queryBuilder) => queryBuilder.userQuery(account, this.network, factory));
|
|
580
|
+
if (!result)
|
|
581
|
+
continue;
|
|
580
582
|
const user = result.data.user;
|
|
581
583
|
if (!user)
|
|
582
584
|
continue;
|
|
@@ -799,6 +801,8 @@ function fetchVaultsUserData(account) {
|
|
|
799
801
|
if (!subgraphs || subgraphs.length === 0)
|
|
800
802
|
continue;
|
|
801
803
|
const result = results[i++];
|
|
804
|
+
if (!result)
|
|
805
|
+
continue;
|
|
802
806
|
const user = result.data.user;
|
|
803
807
|
if (user && user.positions) {
|
|
804
808
|
userVaultData[vaultType] = user.positions.map((position) => (Object.assign(Object.assign({}, position), { vaultType })));
|
|
@@ -240,6 +240,8 @@ class PonderQueryBuilder {
|
|
|
240
240
|
supplyPositions(limit:1000, where: { factoryId: "${impermax_factories_1.IMPERMAX_FACTORY[network][factory]}"}) {
|
|
241
241
|
items {
|
|
242
242
|
balance
|
|
243
|
+
cumulativeEarnings
|
|
244
|
+
lastExchangeRate
|
|
243
245
|
borrowable {
|
|
244
246
|
underlying {
|
|
245
247
|
id
|
|
@@ -117,7 +117,7 @@ class OnchainInteractionsNftlpUniswapV3 extends onchainInteractionsNftlp_1.defau
|
|
|
117
117
|
// Mint
|
|
118
118
|
if (depositADelta > 0 || depositBDelta > 0) {
|
|
119
119
|
console.log("depositADelta, depositBDelta", depositADelta, depositBDelta);
|
|
120
|
-
console.log((_a = (yield borrowableA.toBigNumber(depositADelta))) === null || _a === void 0 ? void 0 : _a.toString(), (_b = (yield
|
|
120
|
+
console.log((_a = (yield borrowableA.toBigNumber(depositADelta))) === null || _a === void 0 ? void 0 : _a.toString(), (_b = (yield borrowableB.toBigNumber(depositBDelta))) === null || _b === void 0 ? void 0 : _b.toString(), (_c = (yield borrowableA.toBigNumber(depositADelta / this.getUiMargin()))) === null || _c === void 0 ? void 0 : _c.toString(), (_d = (yield borrowableB.toBigNumber(depositBDelta / this.getUiMargin()))) === null || _d === void 0 ? void 0 : _d.toString());
|
|
121
121
|
actions.push(yield actionsGetter.methods.getMintUniV3Action(yield borrowableA.toBigNumber(depositADelta), yield borrowableB.toBigNumber(depositBDelta), yield borrowableA.toBigNumber(depositADelta / this.getUiMargin()), yield borrowableB.toBigNumber(depositBDelta / this.getUiMargin())).call());
|
|
122
122
|
if (isEthA) {
|
|
123
123
|
ethValue += depositADelta;
|
|
@@ -205,9 +205,7 @@ class OnchainInteractionsNftlpUniswapV3 extends onchainInteractionsNftlp_1.defau
|
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
207
|
if (ethValue > 0 || doWithdrawEth) {
|
|
208
|
-
|
|
209
|
-
// this.getAccountAddress()
|
|
210
|
-
//).call());
|
|
208
|
+
actions.push(yield actionsGetter.methods.getWithdrawEthAction(this.getAccountAddress()).call());
|
|
211
209
|
}
|
|
212
210
|
return {
|
|
213
211
|
actions,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BigNumber } from "ethers";
|
|
2
2
|
import { Contract, Permit, Permits } from "../onchainTypes";
|
|
3
3
|
import OnchainInteractions from './index';
|
|
4
4
|
import OnchainPoolToken from '../onchainPoolToken';
|
|
5
5
|
import OnchainAccountPoolToken from '../account/onchainAccountPoolToken';
|
|
6
|
+
import { Extension, Factory } from "../../config/types";
|
|
6
7
|
export default abstract class OnchainInteractionsPoolToken {
|
|
7
8
|
protected poolToken: OnchainPoolToken;
|
|
8
9
|
getPoolToken: () => OnchainPoolToken;
|
|
@@ -13,20 +14,20 @@ export default abstract class OnchainInteractionsPoolToken {
|
|
|
13
14
|
protected getOnchain: () => import("..").default;
|
|
14
15
|
protected getPermitHelper: () => import("../onchainPermitHelper").default;
|
|
15
16
|
protected send(method: any, onTransactionHash: Function, value?: BigNumber): Promise<any>;
|
|
16
|
-
getOwnerSpender(): {
|
|
17
|
+
getOwnerSpender(factory?: Factory, extension?: Extension): {
|
|
17
18
|
owner: string;
|
|
18
19
|
spender: any;
|
|
19
20
|
};
|
|
20
21
|
isWETH(): Promise<boolean>;
|
|
21
|
-
getPoolTokenAllowance(): Promise<
|
|
22
|
-
getUnderlyingAllowance(): Promise<
|
|
23
|
-
getPermit2Allowance(): Promise<
|
|
24
|
-
approvePoolToken(amount: BigNumber, onTransactionHash: Function): Promise<any>;
|
|
25
|
-
permitPoolToken(amount: BigNumber): Promise<Permit>;
|
|
26
|
-
approveUnderlying(amount: BigNumber, onTransactionHash: Function): Promise<any>;
|
|
27
|
-
approvePermit2(amount: BigNumber, onTransactionHash: Function): Promise<any>;
|
|
28
|
-
permitUnderlying(amount: BigNumber): Promise<Permit>;
|
|
29
|
-
permit2Underlying(amount: BigNumber): Promise<Permit>;
|
|
22
|
+
getPoolTokenAllowance(factory?: undefined, extension?: undefined): Promise<BigNumber>;
|
|
23
|
+
getUnderlyingAllowance(factory?: undefined, extension?: undefined): Promise<BigNumber>;
|
|
24
|
+
getPermit2Allowance(factory?: undefined, extension?: undefined): Promise<BigNumber>;
|
|
25
|
+
approvePoolToken(amount: BigNumber, onTransactionHash: Function, factory?: undefined, extension?: undefined): Promise<any>;
|
|
26
|
+
permitPoolToken(amount: BigNumber, factory?: undefined, extension?: undefined): Promise<Permit>;
|
|
27
|
+
approveUnderlying(amount: BigNumber, onTransactionHash: Function, factory?: undefined, extension?: undefined): Promise<any>;
|
|
28
|
+
approvePermit2(amount: BigNumber, onTransactionHash: Function, factory?: undefined, extension?: undefined): Promise<any>;
|
|
29
|
+
permitUnderlying(amount: BigNumber, factory?: undefined, extension?: undefined): Promise<Permit>;
|
|
30
|
+
permit2Underlying(amount: BigNumber, factory?: undefined, extension?: undefined): Promise<Permit>;
|
|
30
31
|
protected getSendData(permits: Permits): Promise<{
|
|
31
32
|
router: any;
|
|
32
33
|
ptAddress: any;
|
|
@@ -12,6 +12,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
const ethers_1 = require("ethers");
|
|
13
13
|
const weths_1 = require("../../config/contracts/weths");
|
|
14
14
|
const general_1 = require("../../config/general");
|
|
15
|
+
const types_1 = require("../../config/types");
|
|
16
|
+
const routers_1 = require("../../config/contracts/routers");
|
|
15
17
|
const MAX_UINT256 = ethers_1.ethers.constants.MaxUint256;
|
|
16
18
|
const EIP712DOMAIN = [
|
|
17
19
|
{ name: "name", type: "string" },
|
|
@@ -43,11 +45,12 @@ class OnchainInteractionsPoolToken {
|
|
|
43
45
|
return this.getInteractions().send(method, onTransactionHash, value);
|
|
44
46
|
}
|
|
45
47
|
//send = this.getInteractions().send;
|
|
46
|
-
getOwnerSpender() {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
getOwnerSpender(factory, extension) {
|
|
49
|
+
const owner = this.getAccountAddress();
|
|
50
|
+
const network = this.getOnchain().network;
|
|
51
|
+
const spender = factory == types_1.Factory.V3 && extension ? routers_1.ROUTER_V3[network][extension]
|
|
52
|
+
: factory ? routers_1.ROUTER[network][factory] : this.getPoolTokenRouter()._address;
|
|
53
|
+
return { owner, spender };
|
|
51
54
|
}
|
|
52
55
|
isWETH() {
|
|
53
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -55,64 +58,64 @@ class OnchainInteractionsPoolToken {
|
|
|
55
58
|
return token._address.toLowerCase() == weths_1.WETH[this.getOnchain().network].toLowerCase();
|
|
56
59
|
});
|
|
57
60
|
}
|
|
58
|
-
getPoolTokenAllowance() {
|
|
61
|
+
getPoolTokenAllowance(factory = undefined, extension = undefined) {
|
|
59
62
|
return __awaiter(this, void 0, void 0, function* () {
|
|
60
63
|
const poolToken = yield this.poolToken.getPoolToken();
|
|
61
|
-
const { owner, spender } = this.getOwnerSpender();
|
|
64
|
+
const { owner, spender } = this.getOwnerSpender(factory, extension);
|
|
62
65
|
const allowance = yield poolToken.methods.allowance(owner, spender).call();
|
|
63
66
|
return ethers_1.BigNumber.from(allowance);
|
|
64
67
|
});
|
|
65
68
|
}
|
|
66
|
-
getUnderlyingAllowance() {
|
|
69
|
+
getUnderlyingAllowance(factory = undefined, extension = undefined) {
|
|
67
70
|
return __awaiter(this, void 0, void 0, function* () {
|
|
68
71
|
if (yield this.isWETH())
|
|
69
72
|
return MAX_UINT256;
|
|
70
73
|
const token = yield this.poolToken.getToken();
|
|
71
|
-
const { owner, spender } = this.getOwnerSpender();
|
|
74
|
+
const { owner, spender } = this.getOwnerSpender(factory, extension);
|
|
72
75
|
const allowance = yield token.methods.allowance(owner, spender).call();
|
|
73
76
|
return ethers_1.BigNumber.from(allowance);
|
|
74
77
|
});
|
|
75
78
|
}
|
|
76
|
-
getPermit2Allowance() {
|
|
79
|
+
getPermit2Allowance(factory = undefined, extension = undefined) {
|
|
77
80
|
return __awaiter(this, void 0, void 0, function* () {
|
|
78
81
|
if (yield this.isWETH())
|
|
79
82
|
return MAX_UINT256;
|
|
80
83
|
const token = yield this.poolToken.getToken();
|
|
81
|
-
const { owner } = this.getOwnerSpender();
|
|
84
|
+
const { owner } = this.getOwnerSpender(factory, extension);
|
|
82
85
|
const allowance = yield token.methods.allowance(owner, general_1.PERMIT2_ADDRESS).call();
|
|
83
86
|
return ethers_1.BigNumber.from(allowance);
|
|
84
87
|
});
|
|
85
88
|
}
|
|
86
|
-
approvePoolToken(amount, onTransactionHash) {
|
|
89
|
+
approvePoolToken(amount, onTransactionHash, factory = undefined, extension = undefined) {
|
|
87
90
|
return __awaiter(this, void 0, void 0, function* () {
|
|
88
|
-
const { spender } = this.getOwnerSpender();
|
|
91
|
+
const { spender } = this.getOwnerSpender(factory, extension);
|
|
89
92
|
const poolToken = yield this.poolToken.getPoolToken();
|
|
90
93
|
return this.send(poolToken.methods.approve(spender, amount), onTransactionHash);
|
|
91
94
|
});
|
|
92
95
|
}
|
|
93
|
-
permitPoolToken(amount) {
|
|
96
|
+
permitPoolToken(amount, factory = undefined, extension = undefined) {
|
|
94
97
|
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
-
const { owner, spender } = this.getOwnerSpender();
|
|
98
|
+
const { owner, spender } = this.getOwnerSpender(factory, extension);
|
|
96
99
|
const poolToken = yield this.poolToken.getPoolToken();
|
|
97
100
|
return this.getPermitHelper().getTokenPermit(poolToken, owner, spender, amount);
|
|
98
101
|
});
|
|
99
102
|
}
|
|
100
|
-
approveUnderlying(amount, onTransactionHash) {
|
|
103
|
+
approveUnderlying(amount, onTransactionHash, factory = undefined, extension = undefined) {
|
|
101
104
|
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
-
const { spender } = this.getOwnerSpender();
|
|
105
|
+
const { spender } = this.getOwnerSpender(factory, extension);
|
|
103
106
|
const token = yield this.poolToken.getToken();
|
|
104
107
|
return this.send(token.methods.approve(spender, amount), onTransactionHash);
|
|
105
108
|
});
|
|
106
109
|
}
|
|
107
|
-
approvePermit2(amount, onTransactionHash) {
|
|
110
|
+
approvePermit2(amount, onTransactionHash, factory = undefined, extension = undefined) {
|
|
108
111
|
return __awaiter(this, void 0, void 0, function* () {
|
|
109
112
|
const token = yield this.poolToken.getToken();
|
|
110
113
|
return this.send(token.methods.approve(general_1.PERMIT2_ADDRESS, amount), onTransactionHash);
|
|
111
114
|
});
|
|
112
115
|
}
|
|
113
|
-
permitUnderlying(amount) {
|
|
116
|
+
permitUnderlying(amount, factory = undefined, extension = undefined) {
|
|
114
117
|
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
-
const { owner, spender } = this.getOwnerSpender();
|
|
118
|
+
const { owner, spender } = this.getOwnerSpender(factory, extension);
|
|
116
119
|
const token = yield this.poolToken.getToken();
|
|
117
120
|
// experimental feature: check if the token supports permit by getting the DOMAIN_SEPARATOR
|
|
118
121
|
const domain = yield token.methods.DOMAIN_SEPARATOR().call();
|
|
@@ -124,9 +127,9 @@ class OnchainInteractionsPoolToken {
|
|
|
124
127
|
return this.getPermitHelper().getTokenPermit(token, owner, spender, amount, version);
|
|
125
128
|
});
|
|
126
129
|
}
|
|
127
|
-
permit2Underlying(amount) {
|
|
130
|
+
permit2Underlying(amount, factory = undefined, extension = undefined) {
|
|
128
131
|
return __awaiter(this, void 0, void 0, function* () {
|
|
129
|
-
const { owner, spender } = this.getOwnerSpender();
|
|
132
|
+
const { owner, spender } = this.getOwnerSpender(factory, extension);
|
|
130
133
|
const token = yield this.poolToken.getToken();
|
|
131
134
|
return this.getPermitHelper().getPermit2Single(token, owner, spender, amount);
|
|
132
135
|
});
|