impermax-sdk 1.2.9 → 1.2.11
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/contracts/routers.js +4 -4
- package/lib/offchain/account/offchainAccount.d.ts +3 -1
- package/lib/offchain/account/offchainAccount.js +5 -3
- package/lib/onchain/account/lendingPool/onchainAccountBorrowable.js +1 -1
- package/lib/onchain/account/lendingPool/onchainAccountCollateral.js +1 -1
- package/lib/onchain/account/onchainAccountLendingVault.js +3 -1
- package/lib/onchain/account/onchainAccountPoolToken.js +3 -3
- package/lib/onchain/onchain.js +1 -1
- package/package.json +1 -1
|
@@ -16,9 +16,9 @@ exports.ROUTER = {
|
|
|
16
16
|
[types_1.Factory.SOL_STABLE]: '0x509f26e44F5D8814879ABB27a9eB72159FA92F53',
|
|
17
17
|
},
|
|
18
18
|
[types_1.Networks.Arbitrum]: {
|
|
19
|
-
[types_1.Factory.V2V1_1]: '
|
|
20
|
-
[types_1.Factory.V2V2]: '
|
|
21
|
-
[types_1.Factory.SOLV2]: '
|
|
19
|
+
[types_1.Factory.V2V1_1]: '0xd0543EA38f433Dd3Dc87B8e784aE715bD7154BD8',
|
|
20
|
+
[types_1.Factory.V2V2]: '0x6e6a0c7131f273c6BdC4860a7C4610A1F5978869',
|
|
21
|
+
[types_1.Factory.SOLV2]: '0x0B13BeC190E71DaCB101bC02f8f4d28A376Ff623',
|
|
22
22
|
},
|
|
23
23
|
[types_1.Networks.Avalanche]: {
|
|
24
24
|
[types_1.Factory.V2V1_2]: '0x3039C26F9126833bAca8EdBF61c761CD909F461f',
|
|
@@ -50,7 +50,7 @@ exports.DEFAULT_ROUTER = {
|
|
|
50
50
|
[types_1.Networks.Ropsten]: '0xbFf4acF789297A8507Eb7493AE18EB2C3A3A9632',
|
|
51
51
|
[types_1.Networks.Mainnet]: '0x5e169082fff23cee6766062b96051a78c543127d',
|
|
52
52
|
[types_1.Networks.Polygon]: '0x4e69Cf49FF3aF82eFe304a3C723556efB7434736',
|
|
53
|
-
[types_1.Networks.Arbitrum]: '
|
|
53
|
+
[types_1.Networks.Arbitrum]: '0x6e6a0c7131f273c6BdC4860a7C4610A1F5978869',
|
|
54
54
|
[types_1.Networks.Avalanche]: '0xaf82ee9246a608484e8567fadbef64ac1b8a87ab',
|
|
55
55
|
[types_1.Networks.Moonriver]: '0x3271cc175577465691e48196955e09d638fa05d5',
|
|
56
56
|
[types_1.Networks.Aurora]: '0xBB92270716C8c424849F17cCc12F4F24AD4064D6',
|
|
@@ -5,10 +5,12 @@ import OffchainAccountLendingVault from './offchainAccountLendingVault';
|
|
|
5
5
|
import { LendingVaultPosition, UserData } from '../offchainTypes';
|
|
6
6
|
export default class OffchainAccount {
|
|
7
7
|
private readonly offchain;
|
|
8
|
-
private readonly
|
|
8
|
+
private readonly accountAddress;
|
|
9
9
|
private lendingPools;
|
|
10
10
|
private lendingVaults;
|
|
11
11
|
constructor(offchain: Offchain, account: Address);
|
|
12
|
+
getOnchain: () => Offchain;
|
|
13
|
+
getAccountAddress: () => string;
|
|
12
14
|
private initializeLendingPool;
|
|
13
15
|
getLendingPool(factory: Factory, pair: Address): Promise<OffchainAccountLendingPool>;
|
|
14
16
|
private initializeLendingVault;
|
|
@@ -16,8 +16,10 @@ const lendingPool_1 = __importDefault(require("./lendingPool"));
|
|
|
16
16
|
const offchainAccountLendingVault_1 = __importDefault(require("./offchainAccountLendingVault"));
|
|
17
17
|
class OffchainAccount {
|
|
18
18
|
constructor(offchain, account) {
|
|
19
|
+
this.getOnchain = () => this.offchain;
|
|
20
|
+
this.getAccountAddress = () => this.accountAddress;
|
|
19
21
|
this.offchain = offchain;
|
|
20
|
-
this.
|
|
22
|
+
this.accountAddress = account;
|
|
21
23
|
this.lendingPools = {};
|
|
22
24
|
this.lendingVaults = {};
|
|
23
25
|
}
|
|
@@ -52,12 +54,12 @@ class OffchainAccount {
|
|
|
52
54
|
}
|
|
53
55
|
getUserData() {
|
|
54
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
return this.offchain.getUserData(this.
|
|
57
|
+
return this.offchain.getUserData(this.accountAddress);
|
|
56
58
|
});
|
|
57
59
|
}
|
|
58
60
|
getLendingVaultsUserData() {
|
|
59
61
|
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
-
return this.offchain.getLendingVaultsUserData(this.
|
|
62
|
+
return this.offchain.getLendingVaultsUserData(this.accountAddress);
|
|
61
63
|
});
|
|
62
64
|
}
|
|
63
65
|
getBorrowPositions() {
|
|
@@ -39,7 +39,9 @@ class OnchainAccountLendingVault extends onchainAccountPoolToken_1.default {
|
|
|
39
39
|
// OnchainInteractions
|
|
40
40
|
getMaxWithdrawable() {
|
|
41
41
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
-
|
|
42
|
+
const deposited = (yield this.getDeposited()) * this.getDust();
|
|
43
|
+
const availableCash = (yield this.poolToken.getAvailableLiquidity()) / this.getDust();
|
|
44
|
+
return Math.min(deposited, availableCash);
|
|
43
45
|
});
|
|
44
46
|
}
|
|
45
47
|
}
|
|
@@ -30,10 +30,10 @@ class OnchainAccountPoolToken {
|
|
|
30
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31
31
|
const token = yield this.poolToken.getToken();
|
|
32
32
|
if (token._address.toLowerCase() == weths_1.WETH[this.getNetwork()].toLowerCase()) {
|
|
33
|
-
return (yield this.getEth().getBalance(this.getAccountAddress())) / 1e18
|
|
33
|
+
return (yield this.getEth().getBalance(this.getAccountAddress())) / 1e18;
|
|
34
34
|
}
|
|
35
35
|
const balance = yield token.methods.balanceOf(this.getAccountAddress()).call();
|
|
36
|
-
return (yield this.poolToken.normalize(balance))
|
|
36
|
+
return (yield this.poolToken.normalize(balance));
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
getAvailableBalance() {
|
|
@@ -76,7 +76,7 @@ class OnchainAccountPoolToken {
|
|
|
76
76
|
// Max Withdrawable
|
|
77
77
|
getMaxWithdrawable() {
|
|
78
78
|
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
-
const deposited = yield this.getDeposited();
|
|
79
|
+
const deposited = (yield this.getDeposited()) * this.getDust();
|
|
80
80
|
const availableCash = (yield this.poolToken.getTotalBalance()) / this.getDust();
|
|
81
81
|
return Math.min(deposited, availableCash);
|
|
82
82
|
});
|
package/lib/onchain/onchain.js
CHANGED
|
@@ -19,7 +19,7 @@ class Onchain {
|
|
|
19
19
|
this.web3 = cfg.web3;
|
|
20
20
|
this.chainId = cfg.chainId;
|
|
21
21
|
this.uiMargin = 1.1;
|
|
22
|
-
this.dust = 1.
|
|
22
|
+
this.dust = 1.00000001;
|
|
23
23
|
this.priceInverted = cfg.priceInverted ? cfg.priceInverted : false;
|
|
24
24
|
this.contractsHelper = new onchainContractsHelper_1.default(this);
|
|
25
25
|
this.configManager = new configManager_1.default(this);
|