impermax-sdk 1.2.66 → 1.2.68

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.
Files changed (70) hide show
  1. package/lib/config/amms.js +1 -1
  2. package/lib/offchain/offchainPriceHelper.js +8 -2
  3. package/lib/offchain/query.js +247 -247
  4. package/package.json +1 -1
  5. package/lib/offchain/account/lendingPool/borrowable.d.ts +0 -14
  6. package/lib/offchain/account/lendingPool/borrowable.js +0 -73
  7. package/lib/offchain/account/lendingPool/collateral.d.ts +0 -12
  8. package/lib/offchain/account/lendingPool/collateral.js +0 -42
  9. package/lib/offchain/account/lendingVault.d.ts +0 -11
  10. package/lib/offchain/account/lendingVault.js +0 -38
  11. package/lib/offchain/account/poolToken.d.ts +0 -6
  12. package/lib/offchain/account/poolToken.js +0 -21
  13. package/lib/offchain/initializer.d.ts +0 -32
  14. package/lib/offchain/initializer.js +0 -627
  15. package/lib/offchain/lendingPool/borrowable.d.ts +0 -55
  16. package/lib/offchain/lendingPool/borrowable.js +0 -351
  17. package/lib/offchain/lendingPool/collateral.d.ts +0 -17
  18. package/lib/offchain/lendingPool/collateral.js +0 -72
  19. package/lib/offchain/lendingVault.d.ts +0 -22
  20. package/lib/offchain/lendingVault.js +0 -115
  21. package/lib/offchain/poolToken.d.ts +0 -20
  22. package/lib/offchain/poolToken.js +0 -120
  23. package/lib/offchain/priceHelper.d.ts +0 -21
  24. package/lib/offchain/priceHelper.js +0 -195
  25. package/lib/offchain/solidexHelper.d.ts +0 -16
  26. package/lib/offchain/solidexHelper.js +0 -58
  27. package/lib/offchain/types.d.ts +0 -150
  28. package/lib/offchain/types.js +0 -3
  29. package/lib/onchain/account/interactions/index.d.ts +0 -28
  30. package/lib/onchain/account/interactions/index.js +0 -158
  31. package/lib/onchain/account/interactions/lendingPool/borrowable.d.ts +0 -16
  32. package/lib/onchain/account/interactions/lendingPool/borrowable.js +0 -49
  33. package/lib/onchain/account/interactions/lendingPool/collateral.d.ts +0 -15
  34. package/lib/onchain/account/interactions/lendingPool/collateral.js +0 -33
  35. package/lib/onchain/account/interactions/lendingPool/index.d.ts +0 -41
  36. package/lib/onchain/account/interactions/lendingPool/index.js +0 -120
  37. package/lib/onchain/account/interactions/lendingVault.d.ts +0 -10
  38. package/lib/onchain/account/interactions/lendingVault.js +0 -12
  39. package/lib/onchain/account/interactions/poolToken.d.ts +0 -33
  40. package/lib/onchain/account/interactions/poolToken.js +0 -180
  41. package/lib/onchain/account/lendingPool/borrowable.d.ts +0 -29
  42. package/lib/onchain/account/lendingPool/borrowable.js +0 -135
  43. package/lib/onchain/account/lendingPool/collateral.d.ts +0 -15
  44. package/lib/onchain/account/lendingPool/collateral.js +0 -66
  45. package/lib/onchain/account/lendingVault.d.ts +0 -10
  46. package/lib/onchain/account/lendingVault.js +0 -35
  47. package/lib/onchain/account/poolToken.d.ts +0 -24
  48. package/lib/onchain/account/poolToken.js +0 -84
  49. package/lib/onchain/contractsHelper.d.ts +0 -29
  50. package/lib/onchain/contractsHelper.js +0 -52
  51. package/lib/onchain/impermaxFactory/lendingPool/borrowable.d.ts +0 -36
  52. package/lib/onchain/impermaxFactory/lendingPool/borrowable.js +0 -153
  53. package/lib/onchain/impermaxFactory/lendingPool/collateral.d.ts +0 -17
  54. package/lib/onchain/impermaxFactory/lendingPool/collateral.js +0 -59
  55. package/lib/onchain/interactions/lendingPool/borrowable.d.ts +0 -14
  56. package/lib/onchain/interactions/lendingPool/borrowable.js +0 -47
  57. package/lib/onchain/interactions/lendingPool/collateral.d.ts +0 -13
  58. package/lib/onchain/interactions/lendingPool/collateral.js +0 -31
  59. package/lib/onchain/interactions/lendingVault.d.ts +0 -8
  60. package/lib/onchain/interactions/lendingVault.js +0 -15
  61. package/lib/onchain/interactions/poolToken.d.ts +0 -31
  62. package/lib/onchain/interactions/poolToken.js +0 -181
  63. package/lib/onchain/lendingVault.d.ts +0 -17
  64. package/lib/onchain/lendingVault.js +0 -56
  65. package/lib/onchain/poolToken.d.ts +0 -32
  66. package/lib/onchain/poolToken.js +0 -121
  67. package/lib/onchain/types.d.ts +0 -45
  68. package/lib/onchain/types.js +0 -14
  69. package/lib/utils/price-from-reserves.d.ts +0 -2
  70. package/lib/utils/price-from-reserves.js +0 -19
@@ -1,181 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const ethers_1 = require("ethers");
13
- const types_1 = require("../types");
14
- const types_2 = require("../../config/types");
15
- const weths_1 = require("../../config/contracts/weths");
16
- const general_1 = require("../../config/general");
17
- const MAX_UINT256 = ethers_1.ethers.constants.MaxUint256;
18
- const EIP712DOMAIN = [
19
- { name: "name", type: "string" },
20
- { name: "version", type: "string" },
21
- { name: "chainId", type: "uint256" },
22
- { name: "verifyingContract", type: "address" },
23
- ];
24
- const PERMIT = [
25
- { name: "owner", type: "address" },
26
- { name: "spender", type: "address" },
27
- { name: "value", type: "uint256" },
28
- { name: "nonce", type: "uint256" },
29
- { name: "deadline", type: "uint256" },
30
- ];
31
- const TYPES = {
32
- EIP712Domain: EIP712DOMAIN,
33
- Permit: PERMIT,
34
- BorrowPermit: PERMIT,
35
- };
36
- class PoolToken {
37
- constructor() {
38
- // Shortcuts
39
- this.getAccountAddress = () => this.interactions.account;
40
- this.getOnchain = () => this.interactions.onchain;
41
- }
42
- send(method, onTransactionHash, value) {
43
- return this.interactions.send(method, onTransactionHash, value);
44
- }
45
- //send = this.getInteractions().send;
46
- getOwnerSpender() {
47
- return {
48
- owner: this.getAccountAddress(),
49
- spender: this.getRouterContract()._address,
50
- };
51
- }
52
- isWETH() {
53
- return __awaiter(this, void 0, void 0, function* () {
54
- const token = yield this.onchainPoolToken.getToken();
55
- return token._address.toLowerCase() == weths_1.WETH[this.getOnchain().network].toLowerCase();
56
- });
57
- }
58
- getAllowance(approvalType) {
59
- return __awaiter(this, void 0, void 0, function* () {
60
- const poolToken = yield this.onchainPoolToken.getPoolToken();
61
- const token = yield this.onchainPoolToken.getToken();
62
- if ((yield this.isWETH()) && approvalType == types_1.ApprovalType.UNDERLYING)
63
- return MAX_UINT256;
64
- const { owner, spender } = this.getOwnerSpender();
65
- const allowance = (approvalType == types_1.ApprovalType.POOL_TOKEN) ? yield poolToken.methods.allowance(owner, spender).call() :
66
- (approvalType == types_1.ApprovalType.UNDERLYING) ? yield token.methods.allowance(owner, spender).call() :
67
- (approvalType == types_1.ApprovalType.BORROW) ? yield poolToken.methods.borrowAllowance(owner, spender).call() : 0;
68
- return ethers_1.BigNumber.from(allowance);
69
- });
70
- }
71
- approve(approvalType, amount, onTransactionHash) {
72
- return __awaiter(this, void 0, void 0, function* () {
73
- const { spender } = this.getOwnerSpender();
74
- const poolToken = yield this.onchainPoolToken.getPoolToken();
75
- const token = yield this.onchainPoolToken.getToken();
76
- let method;
77
- if (approvalType == types_1.ApprovalType.POOL_TOKEN)
78
- method = poolToken.methods.approve(spender, amount);
79
- if (approvalType == types_1.ApprovalType.UNDERLYING)
80
- method = token.methods.approve(spender, amount);
81
- if (approvalType == types_1.ApprovalType.BORROW)
82
- method = poolToken.methods.borrowApprove(spender, amount);
83
- return this.send(method, onTransactionHash);
84
- });
85
- }
86
- getPermitData(approvalType, amount, deadlineArg, callBack) {
87
- return __awaiter(this, void 0, void 0, function* () {
88
- if (approvalType === types_1.ApprovalType.UNDERLYING && this.onchainPoolToken.poolTokenType != types_2.PoolTokenType.Collateral)
89
- return callBack(null);
90
- const { owner, spender } = this.getOwnerSpender();
91
- const poolToken = yield this.onchainPoolToken.getPoolToken();
92
- const token = yield this.onchainPoolToken.getToken();
93
- const contract = approvalType == types_1.ApprovalType.UNDERLYING ? token : poolToken;
94
- const nonce = yield contract.methods.nonces(owner).call();
95
- const name = yield contract.methods.name().call();
96
- const deadline = deadlineArg ? deadlineArg : general_1.DEADLINE;
97
- const data = JSON.stringify({
98
- types: TYPES,
99
- domain: {
100
- name: name,
101
- version: "1",
102
- chainId: this.getOnchain().chainId,
103
- verifyingContract: contract._address,
104
- },
105
- primaryType: approvalType == types_1.ApprovalType.BORROW ? "BorrowPermit" : "Permit",
106
- message: {
107
- owner: owner,
108
- spender: spender,
109
- value: amount.toString(),
110
- nonce: ethers_1.BigNumber.from(nonce).toHexString(),
111
- deadline: deadline.toNumber(),
112
- }
113
- });
114
- this.getOnchain().web3.currentProvider.send({
115
- method: "eth_signTypedData_v4",
116
- params: [owner, data],
117
- from: owner
118
- }, (err, data) => {
119
- if (err) {
120
- console.error(err);
121
- return callBack(null);
122
- }
123
- const signature = data.result.substring(2);
124
- const r = "0x" + signature.substring(0, 64);
125
- const s = "0x" + signature.substring(64, 128);
126
- let v = parseInt(signature.substring(128, 130), 16);
127
- if (v == 0 || v == 1)
128
- v = v + 27;
129
- //console.log(v, r, s);
130
- const permitData = ethers_1.ethers.utils.defaultAbiCoder.encode(['bool', 'uint8', 'bytes32', 'bytes32'], [false, v, r, s]);
131
- callBack({ permitData, deadline, amount });
132
- });
133
- });
134
- }
135
- getSendData(permitData) {
136
- return __awaiter(this, void 0, void 0, function* () {
137
- return {
138
- router: this.getRouterContract(),
139
- ptAddress: (yield this.onchainPoolToken.getPoolToken())._address,
140
- account: this.interactions.account,
141
- data: permitData ? permitData.permitData : '0x',
142
- deadline: permitData ? permitData.deadline : general_1.DEADLINE,
143
- };
144
- });
145
- }
146
- mintETH(amount, permitData, onTransactionHash) {
147
- return __awaiter(this, void 0, void 0, function* () {
148
- const { router, ptAddress, account, deadline } = yield this.getSendData(permitData);
149
- return this.send(router.methods.mintETH(ptAddress, account, deadline), onTransactionHash, amount);
150
- });
151
- }
152
- mint(amount, permitData, onTransactionHash) {
153
- return __awaiter(this, void 0, void 0, function* () {
154
- const { router, ptAddress, account, deadline } = yield this.getSendData(permitData);
155
- return this.send(router.methods.mint(ptAddress, amount, account, deadline), onTransactionHash);
156
- });
157
- }
158
- ;
159
- deposit(amount, permitData, onTransactionHash) {
160
- return __awaiter(this, void 0, void 0, function* () {
161
- if (yield this.isWETH()) {
162
- return this.mintETH(amount, permitData, onTransactionHash);
163
- }
164
- else {
165
- return this.mint(amount, permitData, onTransactionHash);
166
- }
167
- });
168
- }
169
- withdraw(tokens, permitData, onTransactionHash) {
170
- return __awaiter(this, void 0, void 0, function* () {
171
- const { router, ptAddress, account, data, deadline } = yield this.getSendData(permitData);
172
- if (yield this.isWETH()) {
173
- return this.send(router.methods.redeemETH(ptAddress, tokens, account, deadline, data), onTransactionHash);
174
- }
175
- else {
176
- return this.send(router.methods.redeem(ptAddress, tokens, account, deadline, data), onTransactionHash);
177
- }
178
- });
179
- }
180
- }
181
- exports.default = PoolToken;
@@ -1,17 +0,0 @@
1
- import PoolToken from "./poolToken";
2
- import { Contract } from "ethers";
3
- import { Address } from '../config/types';
4
- import OnChain from './index';
5
- export default class LendingVault extends PoolToken {
6
- router: OnChain;
7
- vaultAddress: Address;
8
- lendingVaultCache: {};
9
- constructor(router: OnChain, vaultAddress: Address);
10
- cleanCache(): void;
11
- getContractHelper: () => import("./contractsHelper").default;
12
- getPoolTokenAddress(): Promise<Address>;
13
- getOffchainPoolToken(): Promise<import("../offchain").OffchainLendingVault>;
14
- initializePoolToken(): Promise<Contract>;
15
- initializeToken(): Promise<Contract>;
16
- getAvailableLiquidity(): Promise<number>;
17
- }
@@ -1,56 +0,0 @@
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
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const poolToken_1 = __importDefault(require("./poolToken"));
16
- class LendingVault extends poolToken_1.default {
17
- constructor(router, vaultAddress) {
18
- super();
19
- this.lendingVaultCache = {};
20
- this.getContractHelper = () => this.router.contractsHelper;
21
- this.router = router;
22
- this.vaultAddress = vaultAddress;
23
- }
24
- cleanCache() {
25
- this.cache = {};
26
- this.lendingVaultCache = {};
27
- }
28
- getPoolTokenAddress() {
29
- return __awaiter(this, void 0, void 0, function* () {
30
- return this.vaultAddress;
31
- });
32
- }
33
- getOffchainPoolToken() {
34
- return __awaiter(this, void 0, void 0, function* () {
35
- return yield this.onchain.offchain.getLendingVault(this.vaultAddress);
36
- });
37
- }
38
- initializePoolToken() {
39
- return __awaiter(this, void 0, void 0, function* () {
40
- return this.getContractHelper().newLendingVault(yield this.getPoolTokenAddress());
41
- });
42
- }
43
- initializeToken() {
44
- return __awaiter(this, void 0, void 0, function* () {
45
- const poolToken = yield this.getPoolToken();
46
- return this.getContractHelper().newERC20(yield poolToken.methods.underlying().call());
47
- });
48
- }
49
- // Available Liquidity
50
- getAvailableLiquidity() {
51
- return __awaiter(this, void 0, void 0, function* () {
52
- return 0;
53
- });
54
- }
55
- }
56
- exports.default = LendingVault;
@@ -1,32 +0,0 @@
1
- import { BigNumber } from "ethers";
2
- import { Contract } from "./types";
3
- import { Address, PoolTokenType } from '../config/types';
4
- import * as offchain from '../offchain';
5
- export default abstract class PoolToken {
6
- poolTokenType: PoolTokenType;
7
- cache: {
8
- token?: Promise<Contract>;
9
- poolToken?: Promise<Contract>;
10
- exchangeRate?: Promise<number>;
11
- totalBalance?: Promise<number>;
12
- };
13
- cleanCache(): void;
14
- abstract getOffchainPoolToken(): Promise<offchain.OffchainPoolToken>;
15
- abstract getPoolTokenAddress(): Promise<Address>;
16
- abstract initializePoolToken(): Promise<Contract>;
17
- getPoolToken(): Promise<any>;
18
- abstract initializeToken(): Promise<Contract>;
19
- getToken(): Promise<any>;
20
- getTokenAddress(): Promise<any>;
21
- getDecimals(): Promise<number>;
22
- normalize(amount: number): Promise<number>;
23
- toBigNumber(amount: number): Promise<BigNumber | null>;
24
- toNumber(amount: BigNumber): Promise<number | null>;
25
- toTokens(amount: number): Promise<BigNumber | null>;
26
- fromTokens(amount: BigNumber): Promise<number | null>;
27
- private initializeTotalBalance;
28
- getTotalBalance(): Promise<number>;
29
- getTotalBalanceUSD(): Promise<number>;
30
- protected initializeExchangeRate(): Promise<number>;
31
- getExchangeRate(): Promise<number>;
32
- }
@@ -1,121 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const utils_1 = require("../utils");
13
- const ether_utils_1 = require("../utils/ether-utils");
14
- class PoolToken {
15
- constructor() {
16
- this.cache = {};
17
- }
18
- cleanCache() {
19
- this.cache = {};
20
- }
21
- getPoolToken() {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- if (!this.cache.onchainPoolToken)
24
- this.cache.poolTokens = this.initializePoolToken();
25
- return this.cache.onchainPoolToken;
26
- });
27
- }
28
- getToken() {
29
- return __awaiter(this, void 0, void 0, function* () {
30
- if (!this.cache.token)
31
- this.cache.token = this.initializeToken();
32
- return this.cache.token;
33
- });
34
- }
35
- getTokenAddress() {
36
- return __awaiter(this, void 0, void 0, function* () {
37
- return (yield this.getToken())._address;
38
- });
39
- }
40
- getDecimals() {
41
- return __awaiter(this, void 0, void 0, function* () {
42
- const offchainPoolToken = yield this.getOffchainPoolToken();
43
- return yield offchainPoolToken.getDecimals();
44
- });
45
- }
46
- // Utilities
47
- normalize(amount) {
48
- return __awaiter(this, void 0, void 0, function* () {
49
- return amount / Math.pow(10, yield this.getDecimals());
50
- });
51
- }
52
- toBigNumber(amount) {
53
- return __awaiter(this, void 0, void 0, function* () {
54
- if (!(0, utils_1.isValidNumber)(amount))
55
- return null;
56
- return (0, ether_utils_1.decimalToBalance)(amount, yield this.getDecimals());
57
- });
58
- }
59
- toNumber(amount) {
60
- return __awaiter(this, void 0, void 0, function* () {
61
- if (!amount)
62
- return null;
63
- return parseFloat(amount.toString()) / Math.pow(10, yield this.getDecimals());
64
- });
65
- }
66
- toTokens(amount) {
67
- return __awaiter(this, void 0, void 0, function* () {
68
- if (!(0, utils_1.isValidNumber)(amount))
69
- return null;
70
- const exchangeRate = yield this.getExchangeRate();
71
- return (0, ether_utils_1.decimalToBalance)(amount / exchangeRate, yield this.getDecimals());
72
- });
73
- }
74
- fromTokens(amount) {
75
- return __awaiter(this, void 0, void 0, function* () {
76
- if (!amount)
77
- return null;
78
- const exchangeRate = yield this.getExchangeRate();
79
- return parseFloat(amount.toString()) * exchangeRate / Math.pow(10, yield this.getDecimals());
80
- });
81
- }
82
- // Total balance
83
- initializeTotalBalance() {
84
- return __awaiter(this, void 0, void 0, function* () {
85
- const poolToken = yield this.getPoolToken();
86
- const amount = yield poolToken.methods.totalBalance().call();
87
- return this.normalize(amount);
88
- });
89
- }
90
- getTotalBalance() {
91
- return __awaiter(this, void 0, void 0, function* () {
92
- if (!this.cache.totalBalance)
93
- this.cache.totalBalance = this.initializeTotalBalance();
94
- return this.cache.totalBalance;
95
- });
96
- }
97
- getTotalBalanceUSD() {
98
- return __awaiter(this, void 0, void 0, function* () {
99
- const totalBalance = yield this.getTotalBalance();
100
- const offchainPoolToken = yield this.getOffchainPoolToken();
101
- const tokenPrice = yield offchainPoolToken.getTokenPriceFast();
102
- return totalBalance * tokenPrice;
103
- });
104
- }
105
- // Exchange rate
106
- initializeExchangeRate() {
107
- return __awaiter(this, void 0, void 0, function* () {
108
- const poolToken = yield this.getPoolToken();
109
- let exchangeRate = (yield poolToken.methods.exchangeRate().call()) / 1e18;
110
- return exchangeRate;
111
- });
112
- }
113
- getExchangeRate() {
114
- return __awaiter(this, void 0, void 0, function* () {
115
- if (!this.cache.exchangeRate)
116
- this.cache.exchangeRate = this.initializeExchangeRate();
117
- return this.cache.exchangeRate;
118
- });
119
- }
120
- }
121
- exports.default = PoolToken;
@@ -1,45 +0,0 @@
1
- import { BigNumber } from "ethers";
2
- import Offchain from "../offchain";
3
- import { Networks } from '../config/types';
4
- export type Contract = any;
5
- export declare enum ApprovalType {
6
- POOL_TOKEN = 0,
7
- UNDERLYING = 1,
8
- BORROW = 2
9
- }
10
- export interface PermitData {
11
- permitData: string;
12
- amount: BigNumber;
13
- deadline: BigNumber;
14
- }
15
- export interface OnchainConfig {
16
- network: Networks;
17
- offchain: Offchain;
18
- web3: any;
19
- chainId: number;
20
- priceInverted?: boolean;
21
- }
22
- export interface Changes {
23
- changeBorrowedA: number;
24
- changeBorrowedB: number;
25
- changeCollateral: number;
26
- }
27
- export declare const NO_CHANGES: {
28
- changeBorrowedA: number;
29
- changeBorrowedB: number;
30
- changeCollateral: number;
31
- };
32
- export interface Values {
33
- valueCollateral: number;
34
- valueA: number;
35
- valueB: number;
36
- }
37
- export interface AirdropData {
38
- index: number;
39
- amount: BigNumber | null;
40
- proof: Array<string>;
41
- }
42
- export interface PendingRewardUI {
43
- symbol: string;
44
- amount: number;
45
- }
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NO_CHANGES = exports.ApprovalType = void 0;
4
- var ApprovalType;
5
- (function (ApprovalType) {
6
- ApprovalType[ApprovalType["POOL_TOKEN"] = 0] = "POOL_TOKEN";
7
- ApprovalType[ApprovalType["UNDERLYING"] = 1] = "UNDERLYING";
8
- ApprovalType[ApprovalType["BORROW"] = 2] = "BORROW";
9
- })(ApprovalType = exports.ApprovalType || (exports.ApprovalType = {}));
10
- exports.NO_CHANGES = {
11
- changeBorrowedA: 0,
12
- changeBorrowedB: 0,
13
- changeCollateral: 0,
14
- };
@@ -1,2 +0,0 @@
1
- export declare function getPriceFromReservesUniswapV2(x: number, y: number, priceInverted?: boolean): number;
2
- export declare function getPriceFromReservesSolidlyStable(x: number, y: number, priceInverted?: boolean): number;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- // return X/Y price
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.getPriceFromReservesSolidlyStable = exports.getPriceFromReservesUniswapV2 = void 0;
5
- /*
6
- * X/Y price is given by dividing Y reserves by X reserves
7
- */
8
- function getPriceFromReservesUniswapV2(x, y, priceInverted = true) {
9
- const price = y / x;
10
- return !priceInverted ? price : 1 / price;
11
- }
12
- exports.getPriceFromReservesUniswapV2 = getPriceFromReservesUniswapV2;
13
- function getPriceFromReservesSolidlyStable(x, y, priceInverted = false) {
14
- const N = 3 * Math.pow(x, 2) * y + Math.pow(y, 3);
15
- const D = 3 * Math.pow(y, 2) * x + Math.pow(x, 3);
16
- const price = N / D;
17
- return !priceInverted ? price : 1 / price;
18
- }
19
- exports.getPriceFromReservesSolidlyStable = getPriceFromReservesSolidlyStable;