impermax-sdk 1.2.133 → 1.2.135
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/amms.d.ts +2 -0
- package/lib/config/amms.js +5 -0
- package/lib/config/contracts/impermax-factories.js +1 -0
- package/lib/config/contracts/routers.js +1 -0
- package/lib/config/farms.d.ts +3 -1
- package/lib/config/farms.js +3 -0
- package/lib/config/subgraphs.js +112 -37
- package/lib/offchain/account/lendingPool/offchainAccountBorrowable.js +29 -48
- package/lib/offchain/account/lendingPool/offchainAccountCollateral.js +12 -25
- package/lib/offchain/account/lendingPool/offchainAccountLendingPool.js +24 -37
- package/lib/offchain/account/offchainAccount.js +67 -98
- package/lib/offchain/account/offchainAccountLendingVault.js +26 -43
- package/lib/offchain/account/offchainAccountPoolToken.js +4 -15
- package/lib/offchain/configManager/offchainConfigManager.js +7 -20
- package/lib/offchain/configManager/offchainConfigManagerInitializer.js +23 -40
- package/lib/offchain/configManager/offchainPairConfig.js +25 -48
- package/lib/offchain/configManager/offchainProposal.js +15 -32
- package/lib/offchain/lendingPool/offchainBorrowable.js +270 -358
- package/lib/offchain/lendingPool/offchainCollateral.js +23 -49
- package/lib/offchain/lendingPool/offchainLendingPool.js +120 -169
- package/lib/offchain/offchain.js +81 -118
- package/lib/offchain/offchainAPRHelper.js +185 -233
- package/lib/offchain/offchainEndpointManager.js +40 -50
- package/lib/offchain/offchainInitializer.js +594 -661
- package/lib/offchain/offchainLendingVault.js +41 -78
- package/lib/offchain/offchainPoolToken.js +55 -88
- package/lib/offchain/offchainPriceHelper.js +187 -211
- package/lib/offchain/offchainSolidexHelper.js +30 -43
- package/lib/offchain/queries/apis/thegraph/index.js +1 -2
- package/lib/offchain/queries/index.js +4 -1
- package/lib/onchain/account/lendingPool/onchainAccountBorrowable.js +85 -116
- package/lib/onchain/account/lendingPool/onchainAccountCollateral.js +36 -61
- package/lib/onchain/account/lendingPool/onchainAccountLendingPool.js +182 -221
- package/lib/onchain/account/onchainAccount.js +80 -111
- package/lib/onchain/account/onchainAccountLendingVault.js +6 -19
- package/lib/onchain/account/onchainAccountPoolToken.js +37 -60
- package/lib/onchain/configManager/onchainPairConfig.js +28 -51
- package/lib/onchain/configManager/onchainProposal.js +16 -31
- package/lib/onchain/impermaxFactory/lendingPool/onchainBorrowable.js +75 -119
- package/lib/onchain/impermaxFactory/lendingPool/onchainCollateral.js +12 -34
- package/lib/onchain/impermaxFactory/lendingPool/onchainLendingPool.js +224 -299
- package/lib/onchain/interactions/lendingPool/onchainInteractionsBorrowable.js +16 -29
- package/lib/onchain/interactions/lendingPool/onchainInteractionsCollateral.js +5 -18
- package/lib/onchain/interactions/lendingPool/onchainInteractionsLendingPool.js +69 -90
- package/lib/onchain/interactions/onchainInteractions.js +51 -70
- package/lib/onchain/interactions/onchainInteractionsConfigManager.js +9 -24
- package/lib/onchain/interactions/onchainInteractionsPoolToken.js +100 -129
- package/lib/onchain/onchainLendingVault.js +18 -39
- package/lib/onchain/onchainPoolToken.js +68 -107
- package/lib/utils/ether-utils.js +1 -1
- package/lib/utils/lliquidity-math.js +4 -4
- package/package.json +1 -1
package/lib/config/amms.d.ts
CHANGED
|
@@ -48,6 +48,7 @@ export declare enum Amms {
|
|
|
48
48
|
equalizerStable = "equalizerStable",
|
|
49
49
|
wigoswap = "wigoswap",
|
|
50
50
|
velodrome = "velodrome",
|
|
51
|
+
velodromeStable = "velodromeStable",
|
|
51
52
|
alien = "alien",
|
|
52
53
|
shadow = "shadow",
|
|
53
54
|
nile = "nile",
|
|
@@ -103,6 +104,7 @@ export declare const hrAmms: {
|
|
|
103
104
|
equalizerStable: string;
|
|
104
105
|
wigoswap: string;
|
|
105
106
|
velodrome: string;
|
|
107
|
+
velodromeStable: string;
|
|
106
108
|
alien: string;
|
|
107
109
|
shadow: string;
|
|
108
110
|
nile: string;
|
package/lib/config/amms.js
CHANGED
|
@@ -52,6 +52,7 @@ var Amms;
|
|
|
52
52
|
Amms["equalizerStable"] = "equalizerStable";
|
|
53
53
|
Amms["wigoswap"] = "wigoswap";
|
|
54
54
|
Amms["velodrome"] = "velodrome";
|
|
55
|
+
Amms["velodromeStable"] = "velodromeStable";
|
|
55
56
|
Amms["alien"] = "alien";
|
|
56
57
|
Amms["shadow"] = "shadow";
|
|
57
58
|
Amms["nile"] = "nile";
|
|
@@ -107,6 +108,7 @@ exports.hrAmms = {
|
|
|
107
108
|
[Amms.equalizerStable]: 'Equalizer',
|
|
108
109
|
[Amms.wigoswap]: 'Wigoswap',
|
|
109
110
|
[Amms.velodrome]: 'Velodrome',
|
|
111
|
+
[Amms.velodromeStable]: 'Velodrome Stable',
|
|
110
112
|
[Amms.alien]: 'AlienBase',
|
|
111
113
|
[Amms.shadow]: 'Shadow',
|
|
112
114
|
[Amms.nile]: 'Nile',
|
|
@@ -198,6 +200,7 @@ exports.AMM_FACTORY = {
|
|
|
198
200
|
},
|
|
199
201
|
[types_1.Networks.Optimism]: {
|
|
200
202
|
[Amms.velodrome]: '0xF1046053aa5682b4F9a81b5481394DA16BE5FF5a',
|
|
203
|
+
[Amms.velodromeStable]: '0xF1046053aa5682b4F9a81b5481394DA16BE5FF5a',
|
|
201
204
|
},
|
|
202
205
|
[types_1.Networks.Real]: {
|
|
203
206
|
[Amms.pearl]: '0x2B965fDf04f9e9bEEf1659464Ef3A0094A68D923',
|
|
@@ -368,6 +371,7 @@ exports.ADD_LIQUIDITY_URLS = {
|
|
|
368
371
|
},
|
|
369
372
|
[types_1.Networks.Optimism]: {
|
|
370
373
|
[Amms.velodrome]: 'https://velodrome.finance/deposit/',
|
|
374
|
+
[Amms.velodromeStable]: 'https://velodrome.finance/deposit/',
|
|
371
375
|
},
|
|
372
376
|
[types_1.Networks.Real]: {
|
|
373
377
|
[Amms.pearlStable]: 'https://www.pearl.exchange/supply-liquidity/v2/',
|
|
@@ -464,6 +468,7 @@ exports.AMM_LP_FEE = {
|
|
|
464
468
|
},
|
|
465
469
|
[types_1.Networks.Optimism]: {
|
|
466
470
|
[Amms.velodrome]: 0,
|
|
471
|
+
[Amms.velodromeStable]: 0,
|
|
467
472
|
},
|
|
468
473
|
[types_1.Networks.Real]: {
|
|
469
474
|
[Amms.pearlStable]: 0,
|
|
@@ -65,6 +65,7 @@ exports.IMPERMAX_FACTORY = {
|
|
|
65
65
|
},
|
|
66
66
|
[types_1.Networks.Optimism]: {
|
|
67
67
|
[types_1.Factory.SOLV2]: '0xa058Ba91958cD30D44c7B0Cf58A369876Fb70B05',
|
|
68
|
+
[types_1.Factory.SOL_STABLE]: '0x48168439ca4ef9e95975e3e2488bfcbd8fb1a80c',
|
|
68
69
|
},
|
|
69
70
|
[types_1.Networks.Sonic]: {
|
|
70
71
|
[types_1.Factory.SOLV2]: '0x26fca5916c20D252feEF7A58E39886d3d3112b91',
|
|
@@ -62,6 +62,7 @@ exports.ROUTER = {
|
|
|
62
62
|
},
|
|
63
63
|
[types_1.Networks.Optimism]: {
|
|
64
64
|
[types_1.Factory.SOLV2]: '0xb5657FA5ba87CaD11b9150c319069625d423aaD4',
|
|
65
|
+
[types_1.Factory.SOL_STABLE]: '0x6C21983B79d97d7789872CDC08dC90E0153B776a',
|
|
65
66
|
},
|
|
66
67
|
[types_1.Networks.Mantle]: {
|
|
67
68
|
[types_1.Factory.V2V2]: '0xF4A9dda025e65945E7A3F873D6146A12c8110A19'
|
package/lib/config/farms.d.ts
CHANGED
|
@@ -53,7 +53,8 @@ export declare enum Farms {
|
|
|
53
53
|
nileStable = "nileStable",
|
|
54
54
|
equalizerStable = "equalizerStable",
|
|
55
55
|
velodrome = "velodrome",
|
|
56
|
-
alien = "alien"
|
|
56
|
+
alien = "alien",
|
|
57
|
+
velodromeStable = "velodromeStable"
|
|
57
58
|
}
|
|
58
59
|
export declare const hrFarms: {
|
|
59
60
|
quickswapOld: string;
|
|
@@ -107,6 +108,7 @@ export declare const hrFarms: {
|
|
|
107
108
|
nileStable: string;
|
|
108
109
|
equalizerStable: string;
|
|
109
110
|
velodrome: string;
|
|
111
|
+
velodromeStable: string;
|
|
110
112
|
alien: string;
|
|
111
113
|
};
|
|
112
114
|
export type FarmIndex = {
|
package/lib/config/farms.js
CHANGED
|
@@ -58,6 +58,7 @@ var Farms;
|
|
|
58
58
|
Farms["equalizerStable"] = "equalizerStable";
|
|
59
59
|
Farms["velodrome"] = "velodrome";
|
|
60
60
|
Farms["alien"] = "alien";
|
|
61
|
+
Farms["velodromeStable"] = "velodromeStable";
|
|
61
62
|
})(Farms = exports.Farms || (exports.Farms = {}));
|
|
62
63
|
exports.hrFarms = {
|
|
63
64
|
[Farms.quickswapOld]: 'QuickSwap',
|
|
@@ -111,6 +112,7 @@ exports.hrFarms = {
|
|
|
111
112
|
[Farms.nileStable]: 'Nile Stable',
|
|
112
113
|
[Farms.equalizerStable]: 'Equalizer Stable',
|
|
113
114
|
[Farms.velodrome]: 'Velodrome',
|
|
115
|
+
[Farms.velodromeStable]: 'Velodrome Stable',
|
|
114
116
|
[Farms.alien]: 'AlienBase',
|
|
115
117
|
};
|
|
116
118
|
exports.STAKED_LP_FACTORY = {
|
|
@@ -198,6 +200,7 @@ exports.STAKED_LP_FACTORY = {
|
|
|
198
200
|
},
|
|
199
201
|
[types_1.Networks.Optimism]: {
|
|
200
202
|
[Farms.velodrome]: '0x47183bB55AD0F891887E099Cec3570d3C667cD00',
|
|
203
|
+
[Farms.velodromeStable]: '0xaea67e5ccc89d69cbabbe9d7811c3c6b36407055',
|
|
201
204
|
},
|
|
202
205
|
[types_1.Networks.Real]: {
|
|
203
206
|
[Farms.pearl]: '0x2B965fDf04f9e9bEEf1659464Ef3A0094A68D923',
|
package/lib/config/subgraphs.js
CHANGED
|
@@ -2,97 +2,172 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WHITELIST_SUBGRAPH_URL = exports.CONFIG_MANAGER_SUBGRAPH_URL = exports.XIMX_SUBGRAPH_URL = exports.BLOCKS_SUBGRAPH_URL = exports.LENDING_VAULT_SUBGRAPH_URL = exports.IMPERMAX_CHEF_SUBGRAPH_URL = exports.IMPERMAX_SUBGRAPH_URL = void 0;
|
|
4
4
|
const types_1 = require("./types");
|
|
5
|
+
// @ts-ignore
|
|
5
6
|
exports.IMPERMAX_SUBGRAPH_URL = {
|
|
6
7
|
[types_1.Networks.Ropsten]: {},
|
|
7
8
|
[types_1.Networks.Mainnet]: {
|
|
8
|
-
[types_1.Factory.V2V1]: [
|
|
9
|
+
[types_1.Factory.V2V1]: [
|
|
10
|
+
"https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/Dn5WZv53V1K8LrKqqYn29hhuhpwfuFfmsrsTqMgFjrD3",
|
|
11
|
+
],
|
|
9
12
|
},
|
|
10
13
|
[types_1.Networks.Polygon]: {
|
|
11
|
-
[types_1.Factory.V2V1_1]: [
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
[types_1.Factory.V2V1_1]: [
|
|
15
|
+
"https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/F3BfecWo2by5QKrwhkXwuXjyLZnQqJ1wqoejwe67KuyG",
|
|
16
|
+
// Temp fix
|
|
17
|
+
//"https://polygon-factory-production.up.railway.app/"
|
|
18
|
+
],
|
|
19
|
+
[types_1.Factory.V2V2]: [
|
|
20
|
+
"https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/5JbuAaWwyRm78yWpRCJJS217hXXft59g9MbsjTTZnYQa",
|
|
21
|
+
// Temp fix
|
|
22
|
+
//"https://polygon-factory-production.up.railway.app/"
|
|
23
|
+
],
|
|
24
|
+
[types_1.Factory.SOLV2]: [
|
|
25
|
+
"https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/Giwg5N4SCehmUzNwXtAQZnZvUuTjcp7cr3nzUZosRDFU",
|
|
26
|
+
"https://polygon-factory-production.up.railway.app/"
|
|
27
|
+
],
|
|
28
|
+
[types_1.Factory.SOL_STABLE]: [
|
|
29
|
+
"https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/EWckMdMiZeDSGHxq2V8gZBDF549Xjr9iKkPvisqckF11",
|
|
30
|
+
"https://polygon-factory-production.up.railway.app/"
|
|
31
|
+
],
|
|
15
32
|
},
|
|
16
33
|
[types_1.Networks.Arbitrum]: {
|
|
17
|
-
[types_1.Factory.V2V1_1]: [
|
|
18
|
-
|
|
19
|
-
|
|
34
|
+
[types_1.Factory.V2V1_1]: [
|
|
35
|
+
"https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/3PMyaq269mDMwhJ7E285RYD1r43x996b6xZmJSCGvtkm",
|
|
36
|
+
// Temp fix for arbitrum v1 subgraph
|
|
37
|
+
//"https://arbitrum-factory-production.up.railway.app/"
|
|
38
|
+
],
|
|
39
|
+
[types_1.Factory.V2V2]: [
|
|
40
|
+
"https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/BkMRb8mR5zgCbjFSgau6s27pnANhR6k64RGVKUbWaZdY",
|
|
41
|
+
// Temp fix for arbitrum v2 subgraph
|
|
42
|
+
//"https://arbitrum-factory-production.up.railway.app/"
|
|
43
|
+
],
|
|
44
|
+
[types_1.Factory.SOLV2]: [
|
|
45
|
+
"https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/AdLbcSfG6JnpZ7RDdHNHq3bJ21waGnRi7AJ5x3YFGYFo",
|
|
46
|
+
"https://arbitrum-factory-production.up.railway.app/"
|
|
47
|
+
],
|
|
20
48
|
},
|
|
21
49
|
[types_1.Networks.Avalanche]: {
|
|
22
|
-
[types_1.Factory.V2V1_2]: [
|
|
23
|
-
|
|
24
|
-
|
|
50
|
+
[types_1.Factory.V2V1_2]: [
|
|
51
|
+
"https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/HXhHppWXhFqgLfdmTahFj2x7F5Xq8BwADxGY3nbCUAwr",
|
|
52
|
+
// Temp fix
|
|
53
|
+
//"https://avalanche-factory-production.up.railway.app/"
|
|
54
|
+
],
|
|
55
|
+
[types_1.Factory.V2V2]: [
|
|
56
|
+
"https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/8Gz5ZGyRkSA7WBrSteeyez39AgZQsoEbtXe8GtHD7JMQ",
|
|
57
|
+
// Temp fix
|
|
58
|
+
//"https://avalanche-factory-production.up.railway.app/"
|
|
59
|
+
],
|
|
60
|
+
[types_1.Factory.SOLV2]: [
|
|
61
|
+
"https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/78e6cZp11r2coLx8YYo5y4AqzEhQXYT6sw3Bg5Tiy5XU",
|
|
62
|
+
"https://avalanche-factory-production.up.railway.app/"
|
|
63
|
+
],
|
|
25
64
|
},
|
|
26
65
|
[types_1.Networks.Mantle]: {
|
|
27
|
-
[types_1.Factory.V2V2]: [
|
|
66
|
+
[types_1.Factory.V2V2]: [
|
|
67
|
+
"https://subgraph-api.mantle.xyz/subgraphs/name/impermax-finance/impermax-mantle-v2",
|
|
68
|
+
],
|
|
28
69
|
},
|
|
29
70
|
[types_1.Networks.Moonriver]: {
|
|
30
|
-
|
|
71
|
+
//[Factory.V2V1_2]: [
|
|
72
|
+
// "https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/6NqkDBwiybbB3BjErF6QGGYJCqzyhVFKpNYHQTN2j8Jn",
|
|
73
|
+
//],
|
|
31
74
|
},
|
|
32
75
|
[types_1.Networks.Aurora]: {},
|
|
33
76
|
[types_1.Networks.Cronos]: {},
|
|
34
77
|
[types_1.Networks.Fantom]: {
|
|
35
|
-
[types_1.Factory.SOLV1_2]: [
|
|
36
|
-
|
|
37
|
-
|
|
78
|
+
[types_1.Factory.SOLV1_2]: [
|
|
79
|
+
"https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/8vssJypWas5oenzsjjQq1yLqMe7FRt2evcqZdzCNEWt7",
|
|
80
|
+
],
|
|
81
|
+
[types_1.Factory.SOLV2]: [
|
|
82
|
+
"https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/DJ2bTPinDji7Kwev3WjyfxRo487tJHiEEMEo8kmTMT8F",
|
|
83
|
+
],
|
|
84
|
+
[types_1.Factory.V2V2]: [
|
|
85
|
+
"https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/DPk9E2c9fLKF8N6rN3jcyvSrEq4VEgjdeeJcnaEKAngG",
|
|
86
|
+
],
|
|
38
87
|
},
|
|
39
88
|
[types_1.Networks.Canto]: {
|
|
40
|
-
|
|
89
|
+
//[Factory.SOLV2]: [
|
|
90
|
+
// "https://api.impermax.finance/subgraphs/name/impermax-finance/impermax-canto-solv2",
|
|
91
|
+
//],
|
|
41
92
|
},
|
|
42
93
|
[types_1.Networks.ZksyncEra]: {
|
|
43
|
-
[types_1.Factory.SOLV2]: [
|
|
94
|
+
[types_1.Factory.SOLV2]: [
|
|
95
|
+
"https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/8YSS88X8ChDw1QvuAMtxjezSXNiYer9k9d3Uu8XFLHzX",
|
|
96
|
+
"https://zksync-factory-production.up.railway.app/"
|
|
97
|
+
],
|
|
44
98
|
},
|
|
45
99
|
[types_1.Networks.Harmony]: {},
|
|
46
100
|
[types_1.Networks.Moonbeam]: {},
|
|
47
101
|
[types_1.Networks.Sxnetwork]: {},
|
|
48
102
|
[types_1.Networks.Blast]: {
|
|
49
|
-
[types_1.Factory.SOLV2]: [
|
|
50
|
-
|
|
51
|
-
|
|
103
|
+
[types_1.Factory.SOLV2]: [
|
|
104
|
+
"https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/4FDikpVjE2XnDJ5QcpQ1YJXWcUDiAgE7x8ErtsHh33UB",
|
|
105
|
+
"https://blast-factory-production.up.railway.app/"
|
|
106
|
+
],
|
|
107
|
+
[types_1.Factory.V2V2]: [
|
|
108
|
+
"https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/6xkrXFPJ4wqh9cy9ayP19WGr2wZVSMP3FniMjcW2LUG4",
|
|
109
|
+
"https://blast-factory-production.up.railway.app/"
|
|
110
|
+
],
|
|
52
111
|
},
|
|
53
112
|
[types_1.Networks.Base]: {
|
|
54
113
|
[types_1.Factory.SOLV2]: [
|
|
55
|
-
|
|
56
|
-
|
|
114
|
+
"https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/deployments/id/QmfMs5GpdHtaDjUy4YceRhJJdQa4Po2YypLYfxw1z5JEK7",
|
|
115
|
+
"https://base-factory-production.up.railway.app/",
|
|
57
116
|
],
|
|
58
117
|
[types_1.Factory.SOL_STABLE]: [
|
|
59
|
-
|
|
60
|
-
|
|
118
|
+
"https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/9wN7xinUXf8RP8dbwpkzSmCNQKfz31FDpvPEvTQyT8SL",
|
|
119
|
+
"https://base-factory-production.up.railway.app/",
|
|
61
120
|
],
|
|
62
121
|
[types_1.Factory.V2V2]: [
|
|
63
|
-
|
|
64
|
-
|
|
122
|
+
"https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/deployments/id/QmQsSqSSm2gvj9LxYxmHapJV5eMjuV1JdKuWirgyJe8zn5",
|
|
123
|
+
"https://base-factory-production.up.railway.app/",
|
|
65
124
|
],
|
|
66
125
|
},
|
|
67
126
|
[types_1.Networks.Scroll]: {
|
|
68
|
-
[types_1.Factory.SOLV2]: [
|
|
69
|
-
|
|
127
|
+
[types_1.Factory.SOLV2]: [
|
|
128
|
+
"https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/9HL6kLRt3AbQsprTvk7KZdaHunJ5GGsLdYWd27nNfCFC",
|
|
129
|
+
"https://scroll-factory-production.up.railway.app/"
|
|
130
|
+
],
|
|
131
|
+
[types_1.Factory.SOL_STABLE]: [
|
|
132
|
+
"https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/C42ymmkDArE1T5wdYKwao6mntqNSjP2E34TeGusiF3sk",
|
|
133
|
+
"https://scroll-factory-production.up.railway.app/"
|
|
134
|
+
],
|
|
70
135
|
},
|
|
71
136
|
[types_1.Networks.Optimism]: {
|
|
72
137
|
[types_1.Factory.SOLV2]: [
|
|
73
|
-
|
|
74
|
-
|
|
138
|
+
"https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/74C2pMzH3wNKf38PNheGZfSiY4FzmJoKiGtHLYa7oD2s",
|
|
139
|
+
"https://optimism-factory-production.up.railway.app/",
|
|
140
|
+
],
|
|
141
|
+
[types_1.Factory.SOL_STABLE]: [
|
|
142
|
+
"https://optimism-factory-production.up.railway.app/",
|
|
75
143
|
]
|
|
76
144
|
},
|
|
77
145
|
[types_1.Networks.Real]: {
|
|
78
|
-
|
|
79
|
-
|
|
146
|
+
//[Factory.SOL_STABLE]: [
|
|
147
|
+
// "https://api.goldsky.com/api/public/project_cm2d5q4l4w31601vz4swb3vmi/subgraphs/impermax-finance/impermax-real-v2-stable/gn",
|
|
148
|
+
//],
|
|
149
|
+
//[Factory.SOLV2]: [
|
|
150
|
+
// "https://api.goldsky.com/api/public/project_cm2rhb30ot9wu01to8c9h9e37/subgraphs/impermax-real-solv2/3.0/gn",
|
|
151
|
+
//],
|
|
80
152
|
},
|
|
81
153
|
[types_1.Networks.Sonic]: {
|
|
82
154
|
[types_1.Factory.SOLV2]: [
|
|
83
155
|
'https://sonic-factory-production.up.railway.app/',
|
|
84
|
-
'https://gateway.thegraph.com/api/
|
|
156
|
+
'https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/HK9BA4oFp1xaoQW7YVP4m2nbxX7q2bQCZWNPKBtudtZR'
|
|
85
157
|
],
|
|
86
158
|
[types_1.Factory.SOL_STABLE]: [
|
|
87
|
-
'https://
|
|
159
|
+
'https://sonic-factory-production.up.railway.app/',
|
|
160
|
+
'https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/61ZJXkM5uRGntP1HZkmH4iaKRzsf1BBhQdZYi9euLkpM'
|
|
88
161
|
]
|
|
89
162
|
},
|
|
90
163
|
[types_1.Networks.Linea]: {
|
|
91
164
|
[types_1.Factory.SOLV2]: [
|
|
92
|
-
'https://gateway.thegraph.com/api/
|
|
165
|
+
'https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/AyFSeFRAtUm4aY3cb1zTJqoMjcgSNrRipucuSxkEZ1v9',
|
|
166
|
+
'https://linea-factory-production.up.railway.app/'
|
|
93
167
|
],
|
|
94
168
|
[types_1.Factory.SOL_STABLE]: [
|
|
95
|
-
'https://gateway.thegraph.com/api/
|
|
169
|
+
'https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/subgraphs/id/Ah5k6hzS9YicNHWuA4Uts9MQQQGbPLDtwD8tYjKaX8Ls',
|
|
170
|
+
'https://linea-factory-production.up.railway.app/'
|
|
96
171
|
]
|
|
97
172
|
}
|
|
98
173
|
};
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -22,50 +13,40 @@ class OffchainAccountBorrowable extends offchainAccountPoolToken_1.default {
|
|
|
22
13
|
this.poolTokenType = poolTokenType;
|
|
23
14
|
this.poolToken = lendingPool.getLendingPool().getPoolToken(poolTokenType);
|
|
24
15
|
}
|
|
25
|
-
getSupplyPosition() {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return lendingPoolPosition.supplyPositions[this.poolTokenType];
|
|
31
|
-
});
|
|
16
|
+
async getSupplyPosition() {
|
|
17
|
+
const lendingPoolPosition = await this.lendingPool.getLendingPoolPosition();
|
|
18
|
+
if (!lendingPoolPosition)
|
|
19
|
+
return undefined;
|
|
20
|
+
return lendingPoolPosition.supplyPositions[this.poolTokenType];
|
|
32
21
|
}
|
|
33
22
|
// TODO update to support real time exchange rate
|
|
34
|
-
getAmount() {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return supplyBalance * exchangeRate;
|
|
42
|
-
});
|
|
23
|
+
async getAmount() {
|
|
24
|
+
const supplyPosition = await this.getSupplyPosition();
|
|
25
|
+
if (!supplyPosition)
|
|
26
|
+
return 0;
|
|
27
|
+
const exchangeRate = await this.poolToken.getExchangeRate();
|
|
28
|
+
const supplyBalance = parseFloat(supplyPosition.balance);
|
|
29
|
+
return supplyBalance * exchangeRate;
|
|
43
30
|
}
|
|
44
|
-
getBorrowPosition() {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return lendingPoolPosition.borrowPositions[this.poolTokenType];
|
|
50
|
-
});
|
|
31
|
+
async getBorrowPosition() {
|
|
32
|
+
const lendingPoolPosition = await this.lendingPool.getLendingPoolPosition();
|
|
33
|
+
if (!lendingPoolPosition)
|
|
34
|
+
return undefined;
|
|
35
|
+
return lendingPoolPosition.borrowPositions[this.poolTokenType];
|
|
51
36
|
}
|
|
52
|
-
getBorrowedAmount() {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return borrowBalance * borrowIndex / userBorrowIndex;
|
|
61
|
-
});
|
|
37
|
+
async getBorrowedAmount() {
|
|
38
|
+
const borrowPosition = await this.getBorrowPosition();
|
|
39
|
+
const borrowIndex = await this.poolToken.getBorrowIndex();
|
|
40
|
+
if (!borrowPosition)
|
|
41
|
+
return 0;
|
|
42
|
+
const borrowBalance = parseFloat(borrowPosition.borrowBalance);
|
|
43
|
+
const userBorrowIndex = parseFloat(borrowPosition.borrowIndex);
|
|
44
|
+
return borrowBalance * borrowIndex / userBorrowIndex;
|
|
62
45
|
}
|
|
63
|
-
getBorrowedValue() {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return borrowedAmount * tokenPrice;
|
|
68
|
-
});
|
|
46
|
+
async getBorrowedValue() {
|
|
47
|
+
const tokenPrice = await this.poolToken.getTokenPriceAccurate();
|
|
48
|
+
const borrowedAmount = await this.getBorrowedAmount();
|
|
49
|
+
return borrowedAmount * tokenPrice;
|
|
69
50
|
}
|
|
70
51
|
}
|
|
71
52
|
exports.default = OffchainAccountBorrowable;
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -21,23 +12,19 @@ class OffchainAccountCollateral extends offchainAccountPoolToken_1.default {
|
|
|
21
12
|
this.lendingPool = lendingPool;
|
|
22
13
|
this.poolToken = lendingPool.getLendingPool().getCollateral();
|
|
23
14
|
}
|
|
24
|
-
getCollateralPosition() {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return lendingPoolPosition.collateralPosition;
|
|
30
|
-
});
|
|
15
|
+
async getCollateralPosition() {
|
|
16
|
+
const lendingPoolPosition = await this.lendingPool.getLendingPoolPosition();
|
|
17
|
+
if (!lendingPoolPosition)
|
|
18
|
+
return undefined;
|
|
19
|
+
return lendingPoolPosition.collateralPosition;
|
|
31
20
|
}
|
|
32
|
-
getAmount() {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return collateralBalance * exchangeRate;
|
|
40
|
-
});
|
|
21
|
+
async getAmount() {
|
|
22
|
+
const collateralPosition = await this.getCollateralPosition();
|
|
23
|
+
if (!collateralPosition)
|
|
24
|
+
return 0;
|
|
25
|
+
const exchangeRate = await this.poolToken.getExchangeRate();
|
|
26
|
+
const collateralBalance = parseFloat(collateralPosition.balance);
|
|
27
|
+
return collateralBalance * exchangeRate;
|
|
41
28
|
}
|
|
42
29
|
}
|
|
43
30
|
exports.default = OffchainAccountCollateral;
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -34,35 +25,31 @@ class OffchainAccountLendingPool {
|
|
|
34
25
|
getPoolToken(poolTokenType) {
|
|
35
26
|
return this.poolTokens[poolTokenType];
|
|
36
27
|
}
|
|
37
|
-
getLendingPoolPosition() {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
supplyPositions:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
borrowPositions:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
};
|
|
57
|
-
});
|
|
28
|
+
async getLendingPoolPosition() {
|
|
29
|
+
const userData = await this.account.getUserData();
|
|
30
|
+
if (!userData)
|
|
31
|
+
return undefined;
|
|
32
|
+
const userDataOfFactory = userData[this.lendingPool.getFactory()];
|
|
33
|
+
const pairAddress = this.lendingPool.getPairAddress();
|
|
34
|
+
const supplyPositions = userDataOfFactory.supplyPositions[pairAddress];
|
|
35
|
+
const borrowPositions = userDataOfFactory.borrowPositions[pairAddress];
|
|
36
|
+
return {
|
|
37
|
+
collateralPosition: userDataOfFactory.collateralPositions[pairAddress],
|
|
38
|
+
supplyPositions: {
|
|
39
|
+
[types_1.PoolTokenType.BorrowableA]: supplyPositions ? supplyPositions[types_1.PoolTokenType.BorrowableA] : undefined,
|
|
40
|
+
[types_1.PoolTokenType.BorrowableB]: supplyPositions ? supplyPositions[types_1.PoolTokenType.BorrowableB] : undefined,
|
|
41
|
+
},
|
|
42
|
+
borrowPositions: {
|
|
43
|
+
[types_1.PoolTokenType.BorrowableA]: borrowPositions ? borrowPositions[types_1.PoolTokenType.BorrowableA] : undefined,
|
|
44
|
+
[types_1.PoolTokenType.BorrowableB]: borrowPositions ? borrowPositions[types_1.PoolTokenType.BorrowableB] : undefined,
|
|
45
|
+
},
|
|
46
|
+
};
|
|
58
47
|
}
|
|
59
|
-
getBorrowerEquityValue() {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return collateralValue - borrowedValueA - borrowedValueB;
|
|
65
|
-
});
|
|
48
|
+
async getBorrowerEquityValue() {
|
|
49
|
+
const collateralValue = await this.getCollateral().getValue();
|
|
50
|
+
const borrowedValueA = await this.getBorrowableA().getBorrowedValue();
|
|
51
|
+
const borrowedValueB = await this.getBorrowableB().getBorrowedValue();
|
|
52
|
+
return collateralValue - borrowedValueA - borrowedValueB;
|
|
66
53
|
}
|
|
67
54
|
}
|
|
68
55
|
exports.default = OffchainAccountLendingPool;
|