impermax-sdk 1.1.50 → 1.1.52
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 +3 -1
- package/lib/config/amms.js +6 -0
- package/lib/config/farms.d.ts +2 -0
- package/lib/config/farms.js +3 -0
- package/lib/config/subgraphs.d.ts +1 -0
- package/lib/config/subgraphs.js +2 -1
- package/lib/config/types.d.ts +3 -0
- package/lib/offchain/account/offchainAccountLendingVault.d.ts +1 -0
- package/lib/offchain/account/offchainAccountLendingVault.js +1 -0
- package/lib/offchain/configManager/index.d.ts +4 -0
- package/lib/offchain/configManager/index.js +10 -0
- package/lib/offchain/configManager/offchainConfigManager.d.ts +27 -0
- package/lib/offchain/configManager/offchainConfigManager.js +78 -0
- package/lib/offchain/configManager/offchainConfigManagerInitializer.d.ts +8 -0
- package/lib/offchain/configManager/offchainConfigManagerInitializer.js +86 -0
- package/lib/offchain/configManager/offchainProposal.d.ts +9 -0
- package/lib/offchain/configManager/offchainProposal.js +12 -0
- package/lib/offchain/index.d.ts +3 -1
- package/lib/offchain/index.js +5 -1
- package/lib/offchain/offchain.d.ts +4 -1
- package/lib/offchain/offchain.js +5 -0
- package/lib/offchain/offchainPriceHelper.js +6 -1
- package/lib/offchain/offchainTypes.d.ts +28 -0
- package/lib/offchain/query.d.ts +2 -0
- package/lib/offchain/query.js +36 -1
- package/lib/onchain/interactions/onchainInteractionsLendingVault.d.ts +4 -4
- package/lib/onchain/interactions/onchainInteractionsLendingVault.js +1 -1
- package/package.json +5 -3
package/lib/config/amms.d.ts
CHANGED
|
@@ -29,12 +29,14 @@ export declare enum Amms {
|
|
|
29
29
|
velocore = "velocore",
|
|
30
30
|
draculafi = "draculafi",
|
|
31
31
|
vesync = "vesync",
|
|
32
|
-
solunea = "solunea"
|
|
32
|
+
solunea = "solunea",
|
|
33
|
+
pearl = "pearl"
|
|
33
34
|
}
|
|
34
35
|
export declare const hrAmms: {
|
|
35
36
|
uniswap: string;
|
|
36
37
|
quickswap: string;
|
|
37
38
|
satin: string;
|
|
39
|
+
pearl: string;
|
|
38
40
|
sushiswap: string;
|
|
39
41
|
swapr: string;
|
|
40
42
|
swapfish: string;
|
package/lib/config/amms.js
CHANGED
|
@@ -34,11 +34,13 @@ var Amms;
|
|
|
34
34
|
Amms["draculafi"] = "draculafi";
|
|
35
35
|
Amms["vesync"] = "vesync";
|
|
36
36
|
Amms["solunea"] = "solunea";
|
|
37
|
+
Amms["pearl"] = "pearl";
|
|
37
38
|
})(Amms = exports.Amms || (exports.Amms = {}));
|
|
38
39
|
exports.hrAmms = {
|
|
39
40
|
[Amms.uniswap]: 'Uniswap',
|
|
40
41
|
[Amms.quickswap]: 'QuickSwap',
|
|
41
42
|
[Amms.satin]: 'Satin',
|
|
43
|
+
[Amms.pearl]: 'Pearl',
|
|
42
44
|
[Amms.sushiswap]: 'SushiSwap',
|
|
43
45
|
[Amms.swapr]: 'Swapr',
|
|
44
46
|
[Amms.swapfish]: 'SwapFish',
|
|
@@ -77,6 +79,7 @@ exports.AMM_FACTORY = {
|
|
|
77
79
|
[types_1.Networks.Polygon]: {
|
|
78
80
|
[Amms.quickswap]: '0x5757371414417b8C6CAad45bAeF941aBc7d3Ab32',
|
|
79
81
|
[Amms.satin]: '0xCaF3Fb1b03F1D71A110167327f5106bE82beE209',
|
|
82
|
+
[Amms.pearl]: '0xb07c75e3db03eb69f047b92274019912014ba78e',
|
|
80
83
|
[Amms.sushiswap]: '0xc35dadb65012ec5796536bd9864ed8773abc74c4',
|
|
81
84
|
[Amms.tetuswap]: '0x684d8c187be836171a1Af8D533e4724893031828',
|
|
82
85
|
},
|
|
@@ -144,6 +147,7 @@ exports.AMM_SUBGRAPH_URLS = {
|
|
|
144
147
|
[types_1.Networks.Polygon]: {
|
|
145
148
|
[Amms.quickswap]: 'https://api.thegraph.com/subgraphs/name/sameepsi/quickswap06',
|
|
146
149
|
//[Amms.satin]: "",
|
|
150
|
+
//[Amms.pearl]: "",
|
|
147
151
|
[Amms.sushiswap]: 'https://api.thegraph.com/subgraphs/name/sushiswap/matic-exchange',
|
|
148
152
|
[Amms.tetuswap]: 'https://api.thegraph.com/subgraphs/name/tetu-io/tetu-swap',
|
|
149
153
|
},
|
|
@@ -195,6 +199,7 @@ exports.ADD_LIQUIDITY_URLS = {
|
|
|
195
199
|
[types_1.Networks.Polygon]: {
|
|
196
200
|
[Amms.quickswap]: 'https://quickswap.exchange/#/add/',
|
|
197
201
|
[Amms.satin]: 'https://satin.exchange/liquidity/',
|
|
202
|
+
[Amms.pearl]: 'https://www.pearl.exchange/liquidity/manage/',
|
|
198
203
|
[Amms.sushiswap]: 'https://app.sushi.com/legacy/add/',
|
|
199
204
|
[Amms.tetuswap]: 'https://swap.tetu.io/#/add/',
|
|
200
205
|
},
|
|
@@ -253,6 +258,7 @@ exports.AMM_LP_FEE = {
|
|
|
253
258
|
[types_1.Networks.Polygon]: {
|
|
254
259
|
[Amms.quickswap]: 0.0025,
|
|
255
260
|
[Amms.satin]: 0,
|
|
261
|
+
[Amms.pearl]: 0,
|
|
256
262
|
[Amms.sushiswap]: 0.0025,
|
|
257
263
|
[Amms.tetuswap]: 0,
|
|
258
264
|
},
|
package/lib/config/farms.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare enum Farms {
|
|
|
4
4
|
quickswap = "quickswap",
|
|
5
5
|
quickswapDual = "quickswapDual",
|
|
6
6
|
satin = "satin",
|
|
7
|
+
pearl = "pearl",
|
|
7
8
|
sushiswap = "sushiswap",
|
|
8
9
|
arbinyan = "arbinyan",
|
|
9
10
|
swapr = "swapr",
|
|
@@ -43,6 +44,7 @@ export declare const hrFarms: {
|
|
|
43
44
|
quickswap: string;
|
|
44
45
|
quickswapDual: string;
|
|
45
46
|
satin: string;
|
|
47
|
+
pearl: string;
|
|
46
48
|
sushiswap: string;
|
|
47
49
|
arbinyan: string;
|
|
48
50
|
swapr: string;
|
package/lib/config/farms.js
CHANGED
|
@@ -8,6 +8,7 @@ var Farms;
|
|
|
8
8
|
Farms["quickswap"] = "quickswap";
|
|
9
9
|
Farms["quickswapDual"] = "quickswapDual";
|
|
10
10
|
Farms["satin"] = "satin";
|
|
11
|
+
Farms["pearl"] = "pearl";
|
|
11
12
|
Farms["sushiswap"] = "sushiswap";
|
|
12
13
|
Farms["arbinyan"] = "arbinyan";
|
|
13
14
|
Farms["swapr"] = "swapr";
|
|
@@ -47,6 +48,7 @@ exports.hrFarms = {
|
|
|
47
48
|
[Farms.quickswap]: 'QuickSwap',
|
|
48
49
|
[Farms.quickswapDual]: 'QuickSwap',
|
|
49
50
|
[Farms.satin]: 'Satin',
|
|
51
|
+
[Farms.pearl]: 'Pearl',
|
|
50
52
|
[Farms.sushiswap]: 'SushiSwap',
|
|
51
53
|
[Farms.arbinyan]: 'ArbyNYAN',
|
|
52
54
|
[Farms.swapr]: 'Swapr',
|
|
@@ -89,6 +91,7 @@ exports.STAKED_LP_FACTORY = {
|
|
|
89
91
|
[Farms.quickswap]: '0x846019FB6f136fC98b80e527C3d34F39D16a38c4',
|
|
90
92
|
[Farms.quickswapDual]: '0xC4505Cc6125d61E2A352ce5cf2129f2fb19259a8',
|
|
91
93
|
[Farms.satin]: '0xCaF3Fb1b03F1D71A110167327f5106bE82beE209',
|
|
94
|
+
[Farms.pearl]: '0xb07c75e3db03eb69f047b92274019912014ba78e',
|
|
92
95
|
[Farms.sushiswap]: '0xcb30A66e72Ed90D1b34f78fc0655895FC28bB6CF',
|
|
93
96
|
[Farms.tetuswap]: '0x8E45622663Bb01dc285B4F51Eb8F9FE4fa7b5899',
|
|
94
97
|
},
|
|
@@ -4,3 +4,4 @@ export declare const IMPERMAX_CHEF_SUBGRAPH_URL: NetworkIndex<string>;
|
|
|
4
4
|
export declare const LENDING_VAULT_SUBGRAPH_URL: NetworkIndex<string>;
|
|
5
5
|
export declare const BLOCKS_SUBGRAPH_URL: NetworkIndex<string>;
|
|
6
6
|
export declare const XIMX_SUBGRAPH_URL = "https://api.thegraph.com/subgraphs/name/impermax-finance/imx-staking";
|
|
7
|
+
export declare const CONFIG_MANAGER_SUBGRAPH_RUL = "https://api.studio.thegraph.com/query/50523/prova1/version/latest";
|
package/lib/config/subgraphs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.XIMX_SUBGRAPH_URL = exports.BLOCKS_SUBGRAPH_URL = exports.LENDING_VAULT_SUBGRAPH_URL = exports.IMPERMAX_CHEF_SUBGRAPH_URL = exports.IMPERMAX_SUBGRAPH_URL = void 0;
|
|
3
|
+
exports.CONFIG_MANAGER_SUBGRAPH_RUL = 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
5
|
exports.IMPERMAX_SUBGRAPH_URL = {
|
|
6
6
|
[types_1.Networks.Ropsten]: {
|
|
@@ -96,3 +96,4 @@ exports.BLOCKS_SUBGRAPH_URL = {
|
|
|
96
96
|
[types_1.Networks.Sxnetwork]: '',
|
|
97
97
|
};
|
|
98
98
|
exports.XIMX_SUBGRAPH_URL = "https://api.thegraph.com/subgraphs/name/impermax-finance/imx-staking";
|
|
99
|
+
exports.CONFIG_MANAGER_SUBGRAPH_RUL = "https://api.studio.thegraph.com/query/50523/prova1/version/latest";
|
package/lib/config/types.d.ts
CHANGED
|
@@ -38,6 +38,9 @@ export type FactoryIndex<Type> = {
|
|
|
38
38
|
export type AddressIndex<Type> = {
|
|
39
39
|
[key in Address]: Type;
|
|
40
40
|
};
|
|
41
|
+
export type NumberIndex<Type> = {
|
|
42
|
+
[key in number]: Type;
|
|
43
|
+
};
|
|
41
44
|
export type NetworkFactoryIndex<Type> = NetworkIndex<FactoryIndex<Type>>;
|
|
42
45
|
export type LendingPoolIndex<Type> = FactoryIndex<AddressIndex<Type>>;
|
|
43
46
|
export type AmmIndex = {
|
|
@@ -6,6 +6,7 @@ export default class OffchainAccountLendingVault extends OffchainAccountPoolToke
|
|
|
6
6
|
private readonly account;
|
|
7
7
|
protected readonly poolToken: OffchainLendingVault;
|
|
8
8
|
constructor(account: OffchainAccount, lendingVault: OffchainLendingVault);
|
|
9
|
+
getAccount: () => OffchainAccount;
|
|
9
10
|
private getVaultAddress;
|
|
10
11
|
getLendingVaultPosition(): Promise<LendingVaultPosition | undefined>;
|
|
11
12
|
getAmount(): Promise<number>;
|
|
@@ -16,6 +16,7 @@ const offchainAccountPoolToken_1 = __importDefault(require("./offchainAccountPoo
|
|
|
16
16
|
class OffchainAccountLendingVault extends offchainAccountPoolToken_1.default {
|
|
17
17
|
constructor(account, lendingVault) {
|
|
18
18
|
super();
|
|
19
|
+
this.getAccount = () => this.account;
|
|
19
20
|
this.getVaultAddress = () => this.poolToken.getVaultAddress();
|
|
20
21
|
this.account = account;
|
|
21
22
|
this.poolToken = lendingVault;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.OffchainProposal = void 0;
|
|
7
|
+
const offchainProposal_1 = __importDefault(require("./offchainProposal"));
|
|
8
|
+
exports.OffchainProposal = offchainProposal_1.default;
|
|
9
|
+
const offchainConfigManager_1 = __importDefault(require("./offchainConfigManager"));
|
|
10
|
+
exports.default = offchainConfigManager_1.default;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import Offchain from '../index';
|
|
2
|
+
import OffchainProposal from './offchainProposal';
|
|
3
|
+
import { NumberIndex } from '../../config/types';
|
|
4
|
+
import { ProposalData, ProposalMetadata } from '../offchainTypes';
|
|
5
|
+
import * as initializer from './offchainConfigManagerInitializer';
|
|
6
|
+
export default class OffchainConfigManager {
|
|
7
|
+
private readonly offchain;
|
|
8
|
+
protected proposals: NumberIndex<OffchainProposal>;
|
|
9
|
+
protected proposalsMetadata: Promise<ProposalMetadata[]> | null;
|
|
10
|
+
protected metadataParameters: {
|
|
11
|
+
rangeBegin: number;
|
|
12
|
+
rangeEnd: number;
|
|
13
|
+
descending: boolean;
|
|
14
|
+
};
|
|
15
|
+
protected proposalsData: NumberIndex<Promise<ProposalData> | null>;
|
|
16
|
+
constructor(offchain: Offchain);
|
|
17
|
+
cleanCache(): void;
|
|
18
|
+
getOffchain: () => Offchain;
|
|
19
|
+
getLatestProposals(rangeBegin?: number, rangeEnd?: number): Promise<ProposalMetadata[]>;
|
|
20
|
+
getProposal(proposalId: number): Promise<OffchainProposal>;
|
|
21
|
+
protected fetchProposalsMetadata: typeof initializer.fetchProposalsMetadata;
|
|
22
|
+
protected initializeProposalsMetadata: typeof initializer.initializeProposalsMetadata;
|
|
23
|
+
getProposalsMetadata: typeof initializer.getProposalsMetadata;
|
|
24
|
+
protected fetchProposalData: typeof initializer.fetchProposalData;
|
|
25
|
+
protected initializeProposalData: typeof initializer.initializeProposalData;
|
|
26
|
+
getProposalData: typeof initializer.getProposalData;
|
|
27
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
const offchainProposal_1 = __importDefault(require("./offchainProposal"));
|
|
39
|
+
const initializer = __importStar(require("./offchainConfigManagerInitializer"));
|
|
40
|
+
class OffchainConfigManager {
|
|
41
|
+
constructor(offchain) {
|
|
42
|
+
this.proposals = {};
|
|
43
|
+
this.metadataParameters = {
|
|
44
|
+
rangeBegin: 0,
|
|
45
|
+
rangeEnd: 0,
|
|
46
|
+
descending: true
|
|
47
|
+
};
|
|
48
|
+
this.proposalsData = {};
|
|
49
|
+
this.getOffchain = () => this.offchain;
|
|
50
|
+
// Fetchers
|
|
51
|
+
this.fetchProposalsMetadata = initializer.fetchProposalsMetadata;
|
|
52
|
+
this.initializeProposalsMetadata = initializer.initializeProposalsMetadata;
|
|
53
|
+
this.getProposalsMetadata = initializer.getProposalsMetadata;
|
|
54
|
+
this.fetchProposalData = initializer.fetchProposalData;
|
|
55
|
+
this.initializeProposalData = initializer.initializeProposalData;
|
|
56
|
+
this.getProposalData = initializer.getProposalData;
|
|
57
|
+
this.offchain = offchain;
|
|
58
|
+
}
|
|
59
|
+
cleanCache() {
|
|
60
|
+
this.proposalsMetadata = null;
|
|
61
|
+
this.proposals = {};
|
|
62
|
+
this.proposalsData = {};
|
|
63
|
+
}
|
|
64
|
+
getLatestProposals(rangeBegin = 0, rangeEnd = 25) {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
return this.getProposalsMetadata(rangeBegin, rangeEnd, true);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
getProposal(proposalId) {
|
|
70
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
yield this.getProposalData(proposalId); // make sure the proposal data is initialized
|
|
72
|
+
if (!this.proposals[proposalId])
|
|
73
|
+
this.proposals[proposalId] = new offchainProposal_1.default(this, proposalId);
|
|
74
|
+
return this.proposals[proposalId];
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.default = OffchainConfigManager;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ProposalData, ProposalMetadata } from '../offchainTypes';
|
|
2
|
+
import OffchainConfigManager from './offchainConfigManager';
|
|
3
|
+
export declare function fetchProposalsMetadata(this: OffchainConfigManager, rangeBegin: any, rangeEnd: any, descending: any): Promise<ProposalMetadata[]>;
|
|
4
|
+
export declare function fetchProposalData(this: OffchainConfigManager, id: number): Promise<ProposalData>;
|
|
5
|
+
export declare function initializeProposalsMetadata(this: OffchainConfigManager, rangeBegin: any, rangeEnd: any, descending: any): Promise<ProposalMetadata[]>;
|
|
6
|
+
export declare function getProposalsMetadata(this: OffchainConfigManager, rangeBegin: any, rangeEnd: any, descending: any): Promise<ProposalMetadata[]>;
|
|
7
|
+
export declare function initializeProposalData(this: OffchainConfigManager, id: number): Promise<ProposalData>;
|
|
8
|
+
export declare function getProposalData(this: OffchainConfigManager, id: number): Promise<ProposalData>;
|
|
@@ -0,0 +1,86 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.getProposalData = exports.initializeProposalData = exports.getProposalsMetadata = exports.initializeProposalsMetadata = exports.fetchProposalData = exports.fetchProposalsMetadata = void 0;
|
|
36
|
+
const subgraphs_1 = require("../../config/subgraphs");
|
|
37
|
+
const query = __importStar(require("../query"));
|
|
38
|
+
function fetchProposalsMetadata(rangeBegin, rangeEnd, descending) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
const subgraph = subgraphs_1.CONFIG_MANAGER_SUBGRAPH_RUL;
|
|
41
|
+
const result = yield this.getOffchain().apolloFetcher(subgraph, query.proposalsMetaQuery(rangeBegin, rangeEnd, descending));
|
|
42
|
+
return result.data.proposals;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
exports.fetchProposalsMetadata = fetchProposalsMetadata;
|
|
46
|
+
function fetchProposalData(id) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
const subgraph = subgraphs_1.CONFIG_MANAGER_SUBGRAPH_RUL;
|
|
49
|
+
const result = yield this.getOffchain().apolloFetcher(subgraph, query.proposalQuery(id));
|
|
50
|
+
return result.data.proposal;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
exports.fetchProposalData = fetchProposalData;
|
|
54
|
+
function initializeProposalsMetadata(rangeBegin, rangeEnd, descending) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
return this.fetchProposalsMetadata(rangeBegin, rangeEnd, descending);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
exports.initializeProposalsMetadata = initializeProposalsMetadata;
|
|
60
|
+
function getProposalsMetadata(rangeBegin, rangeEnd, descending) {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
if (!this.proposalsMetadata ||
|
|
63
|
+
this.metadataParameters.rangeBegin != rangeBegin ||
|
|
64
|
+
this.metadataParameters.rangeEnd != rangeEnd ||
|
|
65
|
+
this.metadataParameters.descending != descending) {
|
|
66
|
+
this.proposalsMetadata = this.initializeProposalsMetadata(rangeBegin, rangeEnd, descending);
|
|
67
|
+
this.metadataParameters = { rangeBegin, rangeEnd, descending };
|
|
68
|
+
}
|
|
69
|
+
return this.proposalsMetadata;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
exports.getProposalsMetadata = getProposalsMetadata;
|
|
73
|
+
function initializeProposalData(id) {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
return this.fetchProposalData(id);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
exports.initializeProposalData = initializeProposalData;
|
|
79
|
+
function getProposalData(id) {
|
|
80
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
if (!this.proposalsData[id])
|
|
82
|
+
this.proposalsData[id] = this.initializeProposalData(id);
|
|
83
|
+
return this.proposalsData[id];
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
exports.getProposalData = getProposalData;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import OffchainConfigManager from './offchainConfigManager';
|
|
2
|
+
export default class OffchainProposal {
|
|
3
|
+
private readonly configManager;
|
|
4
|
+
private readonly proposalId;
|
|
5
|
+
constructor(configManager: OffchainConfigManager, proposalId: number);
|
|
6
|
+
getConfigManager: () => OffchainConfigManager;
|
|
7
|
+
getProposalId: () => number;
|
|
8
|
+
getOffchain: () => import("..").default;
|
|
9
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class OffchainProposal {
|
|
4
|
+
constructor(configManager, proposalId) {
|
|
5
|
+
this.getConfigManager = () => this.configManager;
|
|
6
|
+
this.getProposalId = () => this.proposalId;
|
|
7
|
+
this.getOffchain = () => this.configManager.getOffchain();
|
|
8
|
+
this.configManager = configManager;
|
|
9
|
+
this.proposalId = proposalId;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.default = OffchainProposal;
|
package/lib/offchain/index.d.ts
CHANGED
|
@@ -4,8 +4,10 @@ import OffchainPriceHelper from "./offchainPriceHelper";
|
|
|
4
4
|
import OffchainSolidexHelper from "./offchainSolidexHelper";
|
|
5
5
|
import OffchainAccount from "./account";
|
|
6
6
|
import * as account from "./account";
|
|
7
|
+
import * as configManager from "./configManager";
|
|
7
8
|
import OffchainLendingVault from './offchainLendingVault';
|
|
8
9
|
import OffchainPoolToken from "./offchainPoolToken";
|
|
9
10
|
import Offchain from './offchain';
|
|
10
|
-
|
|
11
|
+
import OffchainConfigManager from "./configManager";
|
|
12
|
+
export { account, lendingPool, configManager, OffchainAccount, OffchainLendingPool, OffchainConfigManager, OffchainPoolToken, OffchainLendingVault, OffchainSolidexHelper, OffchainPriceHelper, };
|
|
11
13
|
export default Offchain;
|
package/lib/offchain/index.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.OffchainPriceHelper = exports.OffchainSolidexHelper = exports.OffchainLendingVault = exports.OffchainPoolToken = exports.OffchainLendingPool = exports.OffchainAccount = exports.lendingPool = exports.account = void 0;
|
|
29
|
+
exports.OffchainPriceHelper = exports.OffchainSolidexHelper = exports.OffchainLendingVault = exports.OffchainPoolToken = exports.OffchainConfigManager = exports.OffchainLendingPool = exports.OffchainAccount = exports.configManager = exports.lendingPool = exports.account = void 0;
|
|
30
30
|
const lendingPool_1 = __importDefault(require("./lendingPool"));
|
|
31
31
|
exports.OffchainLendingPool = lendingPool_1.default;
|
|
32
32
|
const lendingPool = __importStar(require("./lendingPool"));
|
|
@@ -39,9 +39,13 @@ const account_1 = __importDefault(require("./account"));
|
|
|
39
39
|
exports.OffchainAccount = account_1.default;
|
|
40
40
|
const account = __importStar(require("./account"));
|
|
41
41
|
exports.account = account;
|
|
42
|
+
const configManager = __importStar(require("./configManager"));
|
|
43
|
+
exports.configManager = configManager;
|
|
42
44
|
const offchainLendingVault_1 = __importDefault(require("./offchainLendingVault"));
|
|
43
45
|
exports.OffchainLendingVault = offchainLendingVault_1.default;
|
|
44
46
|
const offchainPoolToken_1 = __importDefault(require("./offchainPoolToken"));
|
|
45
47
|
exports.OffchainPoolToken = offchainPoolToken_1.default;
|
|
46
48
|
const offchain_1 = __importDefault(require("./offchain"));
|
|
49
|
+
const configManager_1 = __importDefault(require("./configManager"));
|
|
50
|
+
exports.OffchainConfigManager = configManager_1.default;
|
|
47
51
|
exports.default = offchain_1.default;
|
|
@@ -6,6 +6,7 @@ import OffchainAccount from "./account";
|
|
|
6
6
|
import { Address, AddressIndex, Factory, FactoryIndex, LendingPoolIndex, Networks } from '../config/types';
|
|
7
7
|
import { LendingPoolData, LendingVaultData, LendingVaultPosition, TvlData, UserData, XimxData } from './offchainTypes';
|
|
8
8
|
import OffchainLendingVault from './offchainLendingVault';
|
|
9
|
+
import OffchainConfigManager from './configManager';
|
|
9
10
|
export interface OffchainCfg {
|
|
10
11
|
network: Networks;
|
|
11
12
|
chainId: number;
|
|
@@ -20,6 +21,7 @@ export default class Offchain {
|
|
|
20
21
|
protected accounts: AddressIndex<OffchainAccount>;
|
|
21
22
|
protected priceHelper: OffchainPriceHelper;
|
|
22
23
|
protected solidexHelper: OffchainSolidexHelper;
|
|
24
|
+
protected configManager: OffchainConfigManager;
|
|
23
25
|
protected lendingPoolsData: Promise<LendingPoolIndex<LendingPoolData>> | null;
|
|
24
26
|
protected usersData: {
|
|
25
27
|
[key in Address]?: Promise<FactoryIndex<UserData> | null>;
|
|
@@ -37,6 +39,7 @@ export default class Offchain {
|
|
|
37
39
|
getAccount(accountAddress: Address): OffchainAccount;
|
|
38
40
|
getPriceHelper: () => OffchainPriceHelper;
|
|
39
41
|
getSolidexHelper: () => OffchainSolidexHelper;
|
|
42
|
+
getConfigManager: () => OffchainConfigManager;
|
|
40
43
|
/**
|
|
41
44
|
* TODO
|
|
42
45
|
* Potrei organizzare in:
|
|
@@ -46,7 +49,7 @@ export default class Offchain {
|
|
|
46
49
|
* - ximxData
|
|
47
50
|
* - lendingVaultData
|
|
48
51
|
*/
|
|
49
|
-
|
|
52
|
+
apolloFetcher: typeof initializer.apolloFetcher;
|
|
50
53
|
protected fetchLendingPools: typeof initializer.fetchLendingPools;
|
|
51
54
|
protected fetchLendingPoolsPast: typeof initializer.fetchLendingPoolsPast;
|
|
52
55
|
protected fetchPastVolume: typeof initializer.fetchPastVolume;
|
package/lib/offchain/offchain.js
CHANGED
|
@@ -40,10 +40,12 @@ const offchainPriceHelper_1 = __importDefault(require("./offchainPriceHelper"));
|
|
|
40
40
|
const offchainSolidexHelper_1 = __importDefault(require("./offchainSolidexHelper"));
|
|
41
41
|
const account_1 = __importDefault(require("./account"));
|
|
42
42
|
const offchainLendingVault_1 = __importDefault(require("./offchainLendingVault"));
|
|
43
|
+
const configManager_1 = __importDefault(require("./configManager"));
|
|
43
44
|
class Offchain {
|
|
44
45
|
constructor(cfg) {
|
|
45
46
|
this.getPriceHelper = () => this.priceHelper;
|
|
46
47
|
this.getSolidexHelper = () => this.solidexHelper;
|
|
48
|
+
this.getConfigManager = () => this.configManager;
|
|
47
49
|
/**
|
|
48
50
|
* TODO
|
|
49
51
|
* Potrei organizzare in:
|
|
@@ -84,6 +86,7 @@ class Offchain {
|
|
|
84
86
|
this.whitelistedPairs = cfg.whitelistedPairs ? cfg.whitelistedPairs : {};
|
|
85
87
|
this.priceHelper = new offchainPriceHelper_1.default(this);
|
|
86
88
|
this.solidexHelper = new offchainSolidexHelper_1.default(this);
|
|
89
|
+
this.configManager = new configManager_1.default(this);
|
|
87
90
|
this.accounts = {};
|
|
88
91
|
this.usersData = {};
|
|
89
92
|
this.lendingVaultsUsersData = {};
|
|
@@ -91,11 +94,13 @@ class Offchain {
|
|
|
91
94
|
cleanCache() {
|
|
92
95
|
this.lendingPoolsData = null;
|
|
93
96
|
this.usersData = {};
|
|
97
|
+
this.lendingVaultsData = null;
|
|
94
98
|
this.lendingVaultsUsersData = {};
|
|
95
99
|
this.tvlData = null;
|
|
96
100
|
this.ximxData = null;
|
|
97
101
|
this.priceHelper.cleanCache();
|
|
98
102
|
this.solidexHelper.cleanCache();
|
|
103
|
+
this.configManager.cleanCache();
|
|
99
104
|
}
|
|
100
105
|
getLendingPool(factory, pairAddress) {
|
|
101
106
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -12,6 +12,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
const debank_ids_1 = require("../config/debank-ids");
|
|
13
13
|
// coingecko has priority over debank for initialized tokens
|
|
14
14
|
const coingecko_ids = {
|
|
15
|
+
//Polygon
|
|
16
|
+
"0x40379a439d4f6795b6fc9aa5687db461677a2dba": "real-usd",
|
|
17
|
+
"0x00e8c0e92eb3ad88189e7125ec8825edc03ab265": "wrapped-usdr",
|
|
18
|
+
"0x49e6a20f1bbdfeec2a8222e052000bbb14ee6007": "tangible",
|
|
19
|
+
"0x7238390d5f6f64e67c3211c343a410e2a3dec142": "pearl",
|
|
15
20
|
// Arbitrum
|
|
16
21
|
"0xb348b87b23d5977e2948e6f36ca07e1ec94d7328": "swapfish",
|
|
17
22
|
"0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f": "wrapped-bitcoin",
|
|
@@ -182,7 +187,7 @@ class OffchainPriceHelper {
|
|
|
182
187
|
return 0.05;
|
|
183
188
|
}
|
|
184
189
|
if (tokenAddress.toLowerCase() === '0x160e07e42adbc1fce92d505b579bcd8a3fbea77d') { // fix for FANG
|
|
185
|
-
return 0.
|
|
190
|
+
return 0.1;
|
|
186
191
|
}
|
|
187
192
|
if (tokenAddress.toLowerCase() === '0x1c28edf9e0d66f3124f141a3cf3ef1217f7019c4') { // fix for SLNA
|
|
188
193
|
return 0.00045;
|
|
@@ -171,3 +171,31 @@ export interface LendingVaultPosition {
|
|
|
171
171
|
id: Address;
|
|
172
172
|
};
|
|
173
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* Config manager
|
|
176
|
+
*/
|
|
177
|
+
export interface PairConfig {
|
|
178
|
+
factory: string;
|
|
179
|
+
pair: string;
|
|
180
|
+
safetyMarginSqrt: number;
|
|
181
|
+
liquidationIncentive: number;
|
|
182
|
+
liquidationFee: number;
|
|
183
|
+
reserveFactor0: number;
|
|
184
|
+
kinkUtilizationRate0: number;
|
|
185
|
+
adjustSpeed0: number;
|
|
186
|
+
borrowTracker0: string;
|
|
187
|
+
reserveFactor1: number;
|
|
188
|
+
kinkUtilizationRate1: number;
|
|
189
|
+
adjustSpeed1: number;
|
|
190
|
+
borrowTracker1: string;
|
|
191
|
+
whiteListState: number;
|
|
192
|
+
}
|
|
193
|
+
export interface ProposalData {
|
|
194
|
+
id: number;
|
|
195
|
+
state: string;
|
|
196
|
+
pairConfigs: PairConfig[];
|
|
197
|
+
}
|
|
198
|
+
export interface ProposalMetadata {
|
|
199
|
+
id: number;
|
|
200
|
+
state: string;
|
|
201
|
+
}
|
package/lib/offchain/query.d.ts
CHANGED
|
@@ -10,3 +10,5 @@ export declare function userQuery(account: Address): import("graphql").DocumentN
|
|
|
10
10
|
export declare function ximxQuery(): import("graphql").DocumentNode;
|
|
11
11
|
export declare function lendingVaultsQuery(addressesFilter: Address[]): import("graphql").DocumentNode;
|
|
12
12
|
export declare function lendingVaultsUserQuery(account: Address): import("graphql").DocumentNode;
|
|
13
|
+
export declare function proposalsMetaQuery(rangeBegin: any, rangeEnd: any, descending: any): import("graphql").DocumentNode;
|
|
14
|
+
export declare function proposalQuery(id: number): import("graphql").DocumentNode;
|
package/lib/offchain/query.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.lendingVaultsUserQuery = exports.lendingVaultsQuery = exports.ximxQuery = exports.userQuery = exports.tvlQuery = exports.currentVolumeAndReservesQuery = exports.pastVolumeQuery = exports.impermaxChefQuery = exports.lendingPoolsPastQuery = exports.lendingPoolsQuery = exports.blockQuery = void 0;
|
|
6
|
+
exports.proposalQuery = exports.proposalsMetaQuery = exports.lendingVaultsUserQuery = exports.lendingVaultsQuery = exports.ximxQuery = exports.userQuery = exports.tvlQuery = exports.currentVolumeAndReservesQuery = exports.pastVolumeQuery = exports.impermaxChefQuery = exports.lendingPoolsPastQuery = exports.lendingPoolsQuery = exports.blockQuery = void 0;
|
|
7
7
|
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
8
8
|
const factories_1 = require("../config/factories");
|
|
9
9
|
function blockQuery(timestamp) {
|
|
@@ -269,3 +269,38 @@ function lendingVaultsUserQuery(account) {
|
|
|
269
269
|
}`;
|
|
270
270
|
}
|
|
271
271
|
exports.lendingVaultsUserQuery = lendingVaultsUserQuery;
|
|
272
|
+
function proposalsMetaQuery(rangeBegin, rangeEnd, descending) {
|
|
273
|
+
// TODO USE PARAMETERS
|
|
274
|
+
return (0, graphql_tag_1.default) `{
|
|
275
|
+
proposals(first:${rangeEnd - rangeBegin}) {
|
|
276
|
+
id
|
|
277
|
+
state
|
|
278
|
+
}
|
|
279
|
+
}`;
|
|
280
|
+
}
|
|
281
|
+
exports.proposalsMetaQuery = proposalsMetaQuery;
|
|
282
|
+
function proposalQuery(id) {
|
|
283
|
+
return (0, graphql_tag_1.default) `{
|
|
284
|
+
proposal(id:${id}) {
|
|
285
|
+
id
|
|
286
|
+
state
|
|
287
|
+
pairConfigs(first:1000) {
|
|
288
|
+
factory
|
|
289
|
+
pair
|
|
290
|
+
safetyMarginSqrt
|
|
291
|
+
liquidationIncentive
|
|
292
|
+
liquidationFee
|
|
293
|
+
reserveFactor0
|
|
294
|
+
reserveFactor1
|
|
295
|
+
kinkUtilizationRate0
|
|
296
|
+
kinkUtilizationRate1
|
|
297
|
+
adjustSpeed0
|
|
298
|
+
adjustSpeed1
|
|
299
|
+
borrowTracker0
|
|
300
|
+
borrowTracker1
|
|
301
|
+
whiteListState
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}`;
|
|
305
|
+
}
|
|
306
|
+
exports.proposalQuery = proposalQuery;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import OnchainInteractions from "./index";
|
|
2
|
-
import * as onchain from '../index';
|
|
3
2
|
import OnchainInteractionsPoolToken from './onchainInteractionsPoolToken';
|
|
4
3
|
import OnchainAccountLendingVault from '../account/onchainAccountLendingVault';
|
|
4
|
+
import OnchainLendingVault from '../onchainLendingVault';
|
|
5
5
|
export default class OnchainInteractionsLendingVault extends OnchainInteractionsPoolToken {
|
|
6
6
|
private readonly interactions;
|
|
7
|
-
protected poolToken:
|
|
8
|
-
constructor(interactions: OnchainInteractions, lendingVault:
|
|
9
|
-
getVaultAddress: () => string;
|
|
7
|
+
protected poolToken: OnchainLendingVault;
|
|
8
|
+
constructor(interactions: OnchainInteractions, lendingVault: OnchainLendingVault);
|
|
10
9
|
getInteractions: () => OnchainInteractions;
|
|
10
|
+
getVaultAddress: () => string;
|
|
11
11
|
getAccountPoolToken(): OnchainAccountLendingVault;
|
|
12
12
|
getAccountLendingVault: () => OnchainAccountLendingVault;
|
|
13
13
|
getRouterContract: () => any;
|
|
@@ -7,8 +7,8 @@ const onchainInteractionsPoolToken_1 = __importDefault(require("./onchainInterac
|
|
|
7
7
|
class OnchainInteractionsLendingVault extends onchainInteractionsPoolToken_1.default {
|
|
8
8
|
constructor(interactions, lendingVault) {
|
|
9
9
|
super();
|
|
10
|
-
this.getVaultAddress = () => this.poolToken.getVaultAddress();
|
|
11
10
|
this.getInteractions = () => this.interactions;
|
|
11
|
+
this.getVaultAddress = () => this.poolToken.getVaultAddress();
|
|
12
12
|
this.getAccountLendingVault = this.getAccountPoolToken;
|
|
13
13
|
this.getRouterContract = () => this.interactions.getDefaultRouterContract();
|
|
14
14
|
this.interactions = interactions;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "impermax-sdk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.52",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"module": "./lib/index.js",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"lib/"
|
|
9
9
|
],
|
|
10
10
|
"scripts": {
|
|
11
|
-
"test": "
|
|
11
|
+
"test": "mocha",
|
|
12
12
|
"tsc": "tsc -p tsconfig.json",
|
|
13
13
|
"prepublishOnly": "npm run tsc"
|
|
14
14
|
},
|
|
@@ -22,8 +22,10 @@
|
|
|
22
22
|
"apollo-cache-inmemory": "^1.6.6",
|
|
23
23
|
"apollo-client": "^2.6.10",
|
|
24
24
|
"apollo-link-http": "^1.5.17",
|
|
25
|
+
"chai": "^4.3.8",
|
|
25
26
|
"ethers": "^5.0.26",
|
|
26
27
|
"graphql": "^15.4.0",
|
|
27
|
-
"graphql-tag": "^2.11.0"
|
|
28
|
+
"graphql-tag": "^2.11.0",
|
|
29
|
+
"mocha": "^10.2.0"
|
|
28
30
|
}
|
|
29
31
|
}
|