@curvefi/llamalend-api 1.0.21 → 1.0.22-beta.1

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.
@@ -1,2 +1,3 @@
1
1
  import { MintMarketTemplate } from "./MintMarketTemplate";
2
- export declare const getMintMarket: (mintMarketId: string) => MintMarketTemplate;
2
+ import type { Llamalend } from "../llamalend.js";
3
+ export declare const getMintMarket: (this: Llamalend, mintMarketId: string) => MintMarketTemplate;
@@ -1,4 +1,4 @@
1
1
  import { MintMarketTemplate } from "./MintMarketTemplate";
2
- export const getMintMarket = (mintMarketId) => {
3
- return new MintMarketTemplate(mintMarketId);
2
+ export const getMintMarket = function (mintMarketId) {
3
+ return new MintMarketTemplate(mintMarketId, this);
4
4
  };
@@ -1,35 +1,36 @@
1
+ import type { Llamalend } from "./llamalend.js";
1
2
  import { TAmount, TGas } from "./interfaces.js";
2
- export declare const convertToShares: (assets: TAmount) => Promise<string>;
3
- export declare const convertToAssets: (shares: TAmount) => Promise<string>;
4
- export declare const userBalances: (address?: string) => Promise<{
3
+ export declare function convertToShares(this: Llamalend, assets: TAmount): Promise<string>;
4
+ export declare function convertToAssets(this: Llamalend, shares: TAmount): Promise<string>;
5
+ export declare function userBalances(this: Llamalend, address?: string): Promise<{
5
6
  "crvUSD": string;
6
7
  "st_crvUSD": string;
7
8
  }>;
8
- export declare const totalSupplyAndCrvUSDLocked: () => Promise<{
9
+ export declare function totalSupplyAndCrvUSDLocked(this: Llamalend): Promise<{
9
10
  "crvUSD": string;
10
11
  "st_crvUSD": string;
11
12
  }>;
12
- export declare const maxDeposit: (address?: string) => Promise<string>;
13
- export declare const previewDeposit: (assets: TAmount) => Promise<string>;
14
- export declare const depositIsApproved: (assets: TAmount) => Promise<boolean>;
15
- export declare const depositAllowance: () => Promise<string[]>;
16
- export declare const depositApproveEstimateGas: (assets: TAmount) => Promise<TGas>;
17
- export declare const depositApprove: (assets: TAmount, isMax?: boolean) => Promise<string[]>;
18
- export declare const depositEstimateGas: (assets: TAmount) => Promise<TGas>;
19
- export declare const deposit: (assets: TAmount) => Promise<string>;
20
- export declare const maxMint: (address?: string) => Promise<string>;
21
- export declare const previewMint: (shares: TAmount) => Promise<string>;
22
- export declare const mintIsApproved: (shares: TAmount) => Promise<boolean>;
23
- export declare const mintAllowance: () => Promise<string[]>;
24
- export declare const mintApproveEstimateGas: (shares: TAmount) => Promise<TGas>;
25
- export declare const mintApprove: (shares: TAmount, isMax?: boolean) => Promise<string[]>;
26
- export declare const mintEstimateGas: (shares: TAmount) => Promise<TGas>;
27
- export declare const mint: (shares: TAmount) => Promise<string>;
28
- export declare const maxWithdraw: (address?: string) => Promise<string>;
29
- export declare const previewWithdraw: (assets: TAmount) => Promise<string>;
30
- export declare const withdrawEstimateGas: (assets: TAmount) => Promise<TGas>;
31
- export declare const withdraw: (assets: TAmount) => Promise<string>;
32
- export declare const maxRedeem: (address?: string) => Promise<string>;
33
- export declare const previewRedeem: (shares: TAmount) => Promise<string>;
34
- export declare const redeemEstimateGas: (shares: TAmount) => Promise<TGas>;
35
- export declare const redeem: (shares: TAmount) => Promise<string>;
13
+ export declare function maxDeposit(this: Llamalend, address?: string): Promise<string>;
14
+ export declare function previewDeposit(this: Llamalend, assets: TAmount): Promise<string>;
15
+ export declare function depositIsApproved(this: Llamalend, assets: TAmount): Promise<boolean>;
16
+ export declare function depositAllowance(this: Llamalend): Promise<string[]>;
17
+ export declare function depositApproveEstimateGas(this: Llamalend, assets: TAmount): Promise<TGas>;
18
+ export declare function depositApprove(this: Llamalend, assets: TAmount, isMax?: boolean): Promise<string[]>;
19
+ export declare function depositEstimateGas(this: Llamalend, assets: TAmount): Promise<TGas>;
20
+ export declare function deposit(this: Llamalend, assets: TAmount): Promise<string>;
21
+ export declare function maxMint(this: Llamalend, address?: string): Promise<string>;
22
+ export declare function previewMint(this: Llamalend, shares: TAmount): Promise<string>;
23
+ export declare function mintIsApproved(this: Llamalend, shares: TAmount): Promise<boolean>;
24
+ export declare function mintAllowance(this: Llamalend): Promise<string[]>;
25
+ export declare function mintApproveEstimateGas(this: Llamalend, shares: TAmount): Promise<TGas>;
26
+ export declare function mintApprove(this: Llamalend, shares: TAmount, isMax?: boolean): Promise<string[]>;
27
+ export declare function mintEstimateGas(this: Llamalend, shares: TAmount): Promise<TGas>;
28
+ export declare function mint(this: Llamalend, shares: TAmount): Promise<string>;
29
+ export declare function maxWithdraw(this: Llamalend, address?: string): Promise<string>;
30
+ export declare function previewWithdraw(this: Llamalend, assets: TAmount): Promise<string>;
31
+ export declare function withdrawEstimateGas(this: Llamalend, assets: TAmount): Promise<TGas>;
32
+ export declare function withdraw(this: Llamalend, assets: TAmount): Promise<string>;
33
+ export declare function maxRedeem(this: Llamalend, address?: string): Promise<string>;
34
+ export declare function previewRedeem(this: Llamalend, shares: TAmount): Promise<string>;
35
+ export declare function redeemEstimateGas(this: Llamalend, shares: TAmount): Promise<TGas>;
36
+ export declare function redeem(this: Llamalend, shares: TAmount): Promise<string>;
package/lib/st-crvUSD.js CHANGED
@@ -8,182 +8,246 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { _getAddress, _mulBy1_3, DIGas, ensureAllowance, ensureAllowanceEstimateGas, formatUnits, hasAllowance, getAllowance, parseUnits, smartNumber, getBalances, MAX_ALLOWANCE, } from "./utils.js";
11
- import { llamalend } from "./llamalend.js";
12
11
  // ---------------- UTILS ----------------
13
- export const convertToShares = (assets) => __awaiter(void 0, void 0, void 0, function* () {
14
- const _assets = parseUnits(assets);
15
- const _shares = yield llamalend.contracts[llamalend.constants.ALIASES.st_crvUSD].contract.convertToShares(_assets);
16
- return llamalend.formatUnits(_shares);
17
- });
18
- export const convertToAssets = (shares) => __awaiter(void 0, void 0, void 0, function* () {
19
- const _shares = parseUnits(shares);
20
- const _assets = yield llamalend.contracts[llamalend.constants.ALIASES.st_crvUSD].contract.convertToAssets(_shares);
21
- return llamalend.formatUnits(_assets);
22
- });
12
+ export function convertToShares(assets) {
13
+ return __awaiter(this, void 0, void 0, function* () {
14
+ const _assets = parseUnits(assets);
15
+ const _shares = yield this.contracts[this.constants.ALIASES.st_crvUSD].contract.convertToShares(_assets);
16
+ return this.formatUnits(_shares);
17
+ });
18
+ }
19
+ export function convertToAssets(shares) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ const _shares = parseUnits(shares);
22
+ const _assets = yield this.contracts[this.constants.ALIASES.st_crvUSD].contract.convertToAssets(_shares);
23
+ return this.formatUnits(_assets);
24
+ });
25
+ }
23
26
  // ---------------- BALANCES ----------------
24
- export const userBalances = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (address = llamalend.signerAddress) {
25
- const rawBalances = yield getBalances([llamalend.constants.ALIASES.crvUSD, llamalend.constants.ALIASES.st_crvUSD], address);
26
- return {
27
- "crvUSD": rawBalances[0],
28
- "st_crvUSD": rawBalances[1],
29
- };
30
- });
31
- export const totalSupplyAndCrvUSDLocked = () => __awaiter(void 0, void 0, void 0, function* () {
32
- const contract = llamalend.contracts[llamalend.constants.ALIASES.st_crvUSD].contract;
33
- const _totalSupply = yield contract.totalSupply();
34
- const _crvUSDLocked = yield contract.convertToAssets(_totalSupply);
35
- return {
36
- "crvUSD": llamalend.formatUnits(_crvUSDLocked),
37
- "st_crvUSD": llamalend.formatUnits(_totalSupply),
38
- };
39
- });
27
+ export function userBalances() {
28
+ return __awaiter(this, arguments, void 0, function* (address = "") {
29
+ address = address || this.signerAddress;
30
+ const rawBalances = yield getBalances.call(this, [this.constants.ALIASES.crvUSD, this.constants.ALIASES.st_crvUSD], address);
31
+ return {
32
+ "crvUSD": rawBalances[0],
33
+ "st_crvUSD": rawBalances[1],
34
+ };
35
+ });
36
+ }
37
+ export function totalSupplyAndCrvUSDLocked() {
38
+ return __awaiter(this, void 0, void 0, function* () {
39
+ const contract = this.contracts[this.constants.ALIASES.st_crvUSD].contract;
40
+ const _totalSupply = yield contract.totalSupply();
41
+ const _crvUSDLocked = yield contract.convertToAssets(_totalSupply);
42
+ return {
43
+ "crvUSD": this.formatUnits(_crvUSDLocked),
44
+ "st_crvUSD": this.formatUnits(_totalSupply),
45
+ };
46
+ });
47
+ }
40
48
  // ---------------- DEPOSIT ----------------
41
- export const maxDeposit = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (address = "") {
42
- address = _getAddress(address);
43
- const _assets = yield llamalend.contracts[llamalend.constants.ALIASES.crvUSD].contract.balanceOf(address);
44
- return formatUnits(_assets);
45
- });
46
- export const previewDeposit = (assets) => __awaiter(void 0, void 0, void 0, function* () {
47
- const _assets = parseUnits(assets);
48
- const _shares = yield llamalend.contracts[llamalend.constants.ALIASES.st_crvUSD].contract.previewDeposit(_assets);
49
- return llamalend.formatUnits(_shares);
50
- });
51
- export const depositIsApproved = (assets) => __awaiter(void 0, void 0, void 0, function* () {
52
- return yield hasAllowance([llamalend.constants.ALIASES.crvUSD], [assets], llamalend.signerAddress, llamalend.constants.ALIASES.st_crvUSD);
53
- });
54
- export const depositAllowance = () => __awaiter(void 0, void 0, void 0, function* () {
55
- return yield getAllowance([llamalend.constants.ALIASES.crvUSD], llamalend.signerAddress, llamalend.constants.ALIASES.st_crvUSD);
56
- });
57
- export const depositApproveEstimateGas = (assets) => __awaiter(void 0, void 0, void 0, function* () {
58
- return yield ensureAllowanceEstimateGas([llamalend.constants.ALIASES.crvUSD], [assets], llamalend.constants.ALIASES.st_crvUSD);
59
- });
60
- export const depositApprove = (assets_1, ...args_1) => __awaiter(void 0, [assets_1, ...args_1], void 0, function* (assets, isMax = true) {
61
- return yield ensureAllowance([llamalend.constants.ALIASES.crvUSD], [assets], llamalend.constants.ALIASES.st_crvUSD, isMax);
62
- });
63
- const _deposit = (assets_1, ...args_1) => __awaiter(void 0, [assets_1, ...args_1], void 0, function* (assets, estimateGas = false) {
64
- const _assets = parseUnits(assets);
65
- const contract = llamalend.contracts[llamalend.constants.ALIASES.st_crvUSD].contract;
66
- const gas = yield contract.deposit.estimateGas(_assets, llamalend.signerAddress, Object.assign({}, llamalend.constantOptions));
67
- if (estimateGas)
68
- return smartNumber(gas);
69
- yield llamalend.updateFeeData();
70
- const gasLimit = _mulBy1_3(DIGas(gas));
71
- return (yield contract.deposit(_assets, llamalend.signerAddress, Object.assign(Object.assign({}, llamalend.options), { gasLimit }))).hash;
72
- });
73
- export const depositEstimateGas = (assets) => __awaiter(void 0, void 0, void 0, function* () {
74
- if (!(yield depositIsApproved(assets)))
75
- throw Error("Approval is needed for gas estimation");
76
- return yield _deposit(assets, true);
77
- });
78
- export const deposit = (assets) => __awaiter(void 0, void 0, void 0, function* () {
79
- yield depositApprove(assets);
80
- return yield _deposit(assets, false);
81
- });
49
+ export function maxDeposit() {
50
+ return __awaiter(this, arguments, void 0, function* (address = "") {
51
+ address = _getAddress.call(this, address);
52
+ const _assets = yield this.contracts[this.constants.ALIASES.crvUSD].contract.balanceOf(address);
53
+ return formatUnits(_assets);
54
+ });
55
+ }
56
+ export function previewDeposit(assets) {
57
+ return __awaiter(this, void 0, void 0, function* () {
58
+ const _assets = parseUnits(assets);
59
+ const _shares = yield this.contracts[this.constants.ALIASES.st_crvUSD].contract.previewDeposit(_assets);
60
+ return this.formatUnits(_shares);
61
+ });
62
+ }
63
+ export function depositIsApproved(assets) {
64
+ return __awaiter(this, void 0, void 0, function* () {
65
+ return yield hasAllowance.call(this, [this.constants.ALIASES.crvUSD], [assets], this.signerAddress, this.constants.ALIASES.st_crvUSD);
66
+ });
67
+ }
68
+ export function depositAllowance() {
69
+ return __awaiter(this, void 0, void 0, function* () {
70
+ return yield getAllowance.call(this, [this.constants.ALIASES.crvUSD], this.signerAddress, this.constants.ALIASES.st_crvUSD);
71
+ });
72
+ }
73
+ export function depositApproveEstimateGas(assets) {
74
+ return __awaiter(this, void 0, void 0, function* () {
75
+ return yield ensureAllowanceEstimateGas.call(this, [this.constants.ALIASES.crvUSD], [assets], this.constants.ALIASES.st_crvUSD);
76
+ });
77
+ }
78
+ export function depositApprove(assets_1) {
79
+ return __awaiter(this, arguments, void 0, function* (assets, isMax = true) {
80
+ return yield ensureAllowance.call(this, [this.constants.ALIASES.crvUSD], [assets], this.constants.ALIASES.st_crvUSD, isMax);
81
+ });
82
+ }
83
+ function _deposit(assets_1) {
84
+ return __awaiter(this, arguments, void 0, function* (assets, estimateGas = false) {
85
+ const _assets = parseUnits(assets);
86
+ const contract = this.contracts[this.constants.ALIASES.st_crvUSD].contract;
87
+ const gas = yield contract.deposit.estimateGas(_assets, this.signerAddress, Object.assign({}, this.constantOptions));
88
+ if (estimateGas)
89
+ return smartNumber(gas);
90
+ yield this.updateFeeData();
91
+ const gasLimit = _mulBy1_3(DIGas(gas));
92
+ return (yield contract.deposit(_assets, this.signerAddress, Object.assign(Object.assign({}, this.options), { gasLimit }))).hash;
93
+ });
94
+ }
95
+ export function depositEstimateGas(assets) {
96
+ return __awaiter(this, void 0, void 0, function* () {
97
+ if (!(yield depositIsApproved.call(this, assets)))
98
+ throw Error("Approval is needed for gas estimation");
99
+ return yield _deposit.call(this, assets, true);
100
+ });
101
+ }
102
+ export function deposit(assets) {
103
+ return __awaiter(this, void 0, void 0, function* () {
104
+ yield depositApprove.call(this, assets);
105
+ return yield _deposit.call(this, assets, false);
106
+ });
107
+ }
82
108
  // ---------------- MINT ----------------
83
- export const maxMint = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (address = "") {
84
- address = _getAddress(address);
85
- const _assetBalance = yield llamalend.contracts[llamalend.constants.ALIASES.crvUSD].contract.balanceOf(address);
86
- const _shares = yield llamalend.contracts[llamalend.constants.ALIASES.st_crvUSD].contract.convertToShares(_assetBalance);
87
- return formatUnits(_shares);
88
- });
89
- export const previewMint = (shares) => __awaiter(void 0, void 0, void 0, function* () {
90
- const _shares = parseUnits(shares);
91
- const _assets = yield llamalend.contracts[llamalend.constants.ALIASES.st_crvUSD].contract.previewMint(_shares);
92
- return formatUnits(_assets);
93
- });
94
- export const mintIsApproved = (shares) => __awaiter(void 0, void 0, void 0, function* () {
95
- const assets = yield previewMint(shares);
96
- return yield hasAllowance([llamalend.constants.ALIASES.crvUSD], [assets], llamalend.signerAddress, llamalend.constants.ALIASES.st_crvUSD);
97
- });
98
- export const mintAllowance = () => __awaiter(void 0, void 0, void 0, function* () {
99
- const assets = yield getAllowance([llamalend.constants.ALIASES.crvUSD], llamalend.signerAddress, llamalend.constants.ALIASES.st_crvUSD);
100
- try {
101
- return [yield convertToShares(assets[0])];
102
- }
103
- catch (e) {
104
- if (parseUnits(assets[0]) === MAX_ALLOWANCE)
105
- return [llamalend.formatUnits(MAX_ALLOWANCE)];
106
- throw e;
107
- }
108
- });
109
- export const mintApproveEstimateGas = (shares) => __awaiter(void 0, void 0, void 0, function* () {
110
- const assets = yield previewMint(shares);
111
- return yield ensureAllowanceEstimateGas([llamalend.constants.ALIASES.crvUSD], [assets], llamalend.constants.ALIASES.st_crvUSD);
112
- });
113
- export const mintApprove = (shares_1, ...args_1) => __awaiter(void 0, [shares_1, ...args_1], void 0, function* (shares, isMax = true) {
114
- const assets = yield previewMint(shares);
115
- return yield ensureAllowance([llamalend.constants.ALIASES.crvUSD], [assets], llamalend.constants.ALIASES.st_crvUSD, isMax);
116
- });
117
- const _mint = (shares_1, ...args_1) => __awaiter(void 0, [shares_1, ...args_1], void 0, function* (shares, estimateGas = false) {
118
- const _shares = parseUnits(shares);
119
- const contract = llamalend.contracts[llamalend.constants.ALIASES.st_crvUSD].contract;
120
- const gas = yield contract.mint.estimateGas(_shares, llamalend.signerAddress, Object.assign({}, llamalend.constantOptions));
121
- if (estimateGas)
122
- return smartNumber(gas);
123
- yield llamalend.updateFeeData();
124
- const gasLimit = _mulBy1_3(DIGas(gas));
125
- return (yield contract.mint(_shares, llamalend.signerAddress, Object.assign(Object.assign({}, llamalend.options), { gasLimit }))).hash;
126
- });
127
- export const mintEstimateGas = (shares) => __awaiter(void 0, void 0, void 0, function* () {
128
- if (!(yield mintIsApproved(shares)))
129
- throw Error("Approval is needed for gas estimation");
130
- return yield _mint(shares, true);
131
- });
132
- export const mint = (shares) => __awaiter(void 0, void 0, void 0, function* () {
133
- yield mintApprove(shares);
134
- return yield _mint(shares, false);
135
- });
109
+ export function maxMint() {
110
+ return __awaiter(this, arguments, void 0, function* (address = "") {
111
+ address = _getAddress.call(this, address);
112
+ const _assetBalance = yield this.contracts[this.constants.ALIASES.crvUSD].contract.balanceOf(address);
113
+ const _shares = yield this.contracts[this.constants.ALIASES.st_crvUSD].contract.convertToShares(_assetBalance);
114
+ return formatUnits(_shares);
115
+ });
116
+ }
117
+ export function previewMint(shares) {
118
+ return __awaiter(this, void 0, void 0, function* () {
119
+ const _shares = parseUnits(shares);
120
+ const _assets = yield this.contracts[this.constants.ALIASES.st_crvUSD].contract.previewMint(_shares);
121
+ return formatUnits(_assets);
122
+ });
123
+ }
124
+ export function mintIsApproved(shares) {
125
+ return __awaiter(this, void 0, void 0, function* () {
126
+ const assets = yield previewMint.call(this, shares);
127
+ return yield hasAllowance.call(this, [this.constants.ALIASES.crvUSD], [assets], this.signerAddress, this.constants.ALIASES.st_crvUSD);
128
+ });
129
+ }
130
+ export function mintAllowance() {
131
+ return __awaiter(this, void 0, void 0, function* () {
132
+ const assets = yield getAllowance.call(this, [this.constants.ALIASES.crvUSD], this.signerAddress, this.constants.ALIASES.st_crvUSD);
133
+ try {
134
+ return [yield convertToShares.call(this, assets[0])];
135
+ }
136
+ catch (e) {
137
+ if (parseUnits(assets[0]) === MAX_ALLOWANCE)
138
+ return [this.formatUnits(MAX_ALLOWANCE)];
139
+ throw e;
140
+ }
141
+ });
142
+ }
143
+ export function mintApproveEstimateGas(shares) {
144
+ return __awaiter(this, void 0, void 0, function* () {
145
+ const assets = yield previewMint.call(this, shares);
146
+ return yield ensureAllowanceEstimateGas.call(this, [this.constants.ALIASES.crvUSD], [assets], this.constants.ALIASES.st_crvUSD);
147
+ });
148
+ }
149
+ export function mintApprove(shares_1) {
150
+ return __awaiter(this, arguments, void 0, function* (shares, isMax = true) {
151
+ const assets = yield previewMint.call(this, shares);
152
+ return yield ensureAllowance.call(this, [this.constants.ALIASES.crvUSD], [assets], this.constants.ALIASES.st_crvUSD, isMax);
153
+ });
154
+ }
155
+ function _mint(shares_1) {
156
+ return __awaiter(this, arguments, void 0, function* (shares, estimateGas = false) {
157
+ const _shares = parseUnits(shares);
158
+ const contract = this.contracts[this.constants.ALIASES.st_crvUSD].contract;
159
+ const gas = yield contract.mint.estimateGas(_shares, this.signerAddress, Object.assign({}, this.constantOptions));
160
+ if (estimateGas)
161
+ return smartNumber(gas);
162
+ yield this.updateFeeData();
163
+ const gasLimit = _mulBy1_3(DIGas(gas));
164
+ return (yield contract.mint(_shares, this.signerAddress, Object.assign(Object.assign({}, this.options), { gasLimit }))).hash;
165
+ });
166
+ }
167
+ export function mintEstimateGas(shares) {
168
+ return __awaiter(this, void 0, void 0, function* () {
169
+ if (!(yield mintIsApproved.call(this, shares)))
170
+ throw Error("Approval is needed for gas estimation");
171
+ return yield _mint.call(this, shares, true);
172
+ });
173
+ }
174
+ export function mint(shares) {
175
+ return __awaiter(this, void 0, void 0, function* () {
176
+ yield mintApprove.call(this, shares);
177
+ return yield _mint.call(this, shares, false);
178
+ });
179
+ }
136
180
  // ---------------- WITHDRAW ----------------
137
- export const maxWithdraw = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (address = "") {
138
- address = _getAddress(address);
139
- const _assets = yield llamalend.contracts[llamalend.constants.ALIASES.st_crvUSD].contract.maxWithdraw(address);
140
- return formatUnits(_assets);
141
- });
142
- export const previewWithdraw = (assets) => __awaiter(void 0, void 0, void 0, function* () {
143
- const _assets = parseUnits(assets);
144
- const _shares = yield llamalend.contracts[llamalend.constants.ALIASES.st_crvUSD].contract.previewWithdraw(_assets);
145
- return formatUnits(_shares);
146
- });
147
- const _withdraw = (assets_1, ...args_1) => __awaiter(void 0, [assets_1, ...args_1], void 0, function* (assets, estimateGas = false) {
148
- const _assets = parseUnits(assets);
149
- const contract = llamalend.contracts[llamalend.constants.ALIASES.st_crvUSD].contract;
150
- const gas = yield contract.withdraw.estimateGas(_assets, llamalend.signerAddress, llamalend.signerAddress, Object.assign({}, llamalend.constantOptions));
151
- if (estimateGas)
152
- return smartNumber(gas);
153
- yield llamalend.updateFeeData();
154
- const gasLimit = _mulBy1_3(DIGas(gas));
155
- return (yield contract.withdraw(_assets, llamalend.signerAddress, llamalend.signerAddress, Object.assign(Object.assign({}, llamalend.options), { gasLimit }))).hash;
156
- });
157
- export const withdrawEstimateGas = (assets) => __awaiter(void 0, void 0, void 0, function* () {
158
- return yield _withdraw(assets, true);
159
- });
160
- export const withdraw = (assets) => __awaiter(void 0, void 0, void 0, function* () {
161
- return yield _withdraw(assets, false);
162
- });
181
+ export function maxWithdraw() {
182
+ return __awaiter(this, arguments, void 0, function* (address = "") {
183
+ address = _getAddress.call(this, address);
184
+ const _assets = yield this.contracts[this.constants.ALIASES.st_crvUSD].contract.maxWithdraw(address);
185
+ return formatUnits(_assets);
186
+ });
187
+ }
188
+ export function previewWithdraw(assets) {
189
+ return __awaiter(this, void 0, void 0, function* () {
190
+ const _assets = parseUnits(assets);
191
+ const _shares = yield this.contracts[this.constants.ALIASES.st_crvUSD].contract.previewWithdraw(_assets);
192
+ return formatUnits(_shares);
193
+ });
194
+ }
195
+ function _withdraw(assets_1) {
196
+ return __awaiter(this, arguments, void 0, function* (assets, estimateGas = false) {
197
+ const _assets = parseUnits(assets);
198
+ const contract = this.contracts[this.constants.ALIASES.st_crvUSD].contract;
199
+ const gas = yield contract.withdraw.estimateGas(_assets, this.signerAddress, this.signerAddress, Object.assign({}, this.constantOptions));
200
+ if (estimateGas)
201
+ return smartNumber(gas);
202
+ yield this.updateFeeData();
203
+ const gasLimit = _mulBy1_3(DIGas(gas));
204
+ return (yield contract.withdraw(_assets, this.signerAddress, this.signerAddress, Object.assign(Object.assign({}, this.options), { gasLimit }))).hash;
205
+ });
206
+ }
207
+ export function withdrawEstimateGas(assets) {
208
+ return __awaiter(this, void 0, void 0, function* () {
209
+ return yield _withdraw.call(this, assets, true);
210
+ });
211
+ }
212
+ export function withdraw(assets) {
213
+ return __awaiter(this, void 0, void 0, function* () {
214
+ return yield _withdraw.call(this, assets, false);
215
+ });
216
+ }
163
217
  // ---------------- REDEEM ----------------
164
- export const maxRedeem = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (address = "") {
165
- address = _getAddress(address);
166
- const _shares = yield llamalend.contracts[llamalend.constants.ALIASES.st_crvUSD].contract.maxRedeem(address);
167
- return formatUnits(_shares);
168
- });
169
- export const previewRedeem = (shares) => __awaiter(void 0, void 0, void 0, function* () {
170
- const _shares = parseUnits(shares, 18);
171
- const _assets = yield llamalend.contracts[llamalend.constants.ALIASES.st_crvUSD].contract.previewRedeem(_shares);
172
- return formatUnits(_assets);
173
- });
174
- const _redeem = (shares_1, ...args_1) => __awaiter(void 0, [shares_1, ...args_1], void 0, function* (shares, estimateGas = false) {
175
- const _shares = parseUnits(shares, 18);
176
- const contract = llamalend.contracts[llamalend.constants.ALIASES.st_crvUSD].contract;
177
- const gas = yield contract.redeem.estimateGas(_shares, llamalend.signerAddress, llamalend.signerAddress, Object.assign({}, llamalend.constantOptions));
178
- if (estimateGas)
179
- return smartNumber(gas);
180
- yield llamalend.updateFeeData();
181
- const gasLimit = _mulBy1_3(DIGas(gas));
182
- return (yield contract.redeem(_shares, llamalend.signerAddress, llamalend.signerAddress, Object.assign(Object.assign({}, llamalend.options), { gasLimit }))).hash;
183
- });
184
- export const redeemEstimateGas = (shares) => __awaiter(void 0, void 0, void 0, function* () {
185
- return yield _redeem(shares, true);
186
- });
187
- export const redeem = (shares) => __awaiter(void 0, void 0, void 0, function* () {
188
- return yield _redeem(shares, false);
189
- });
218
+ export function maxRedeem() {
219
+ return __awaiter(this, arguments, void 0, function* (address = "") {
220
+ address = _getAddress.call(this, address);
221
+ const _shares = yield this.contracts[this.constants.ALIASES.st_crvUSD].contract.maxRedeem(address);
222
+ return formatUnits(_shares);
223
+ });
224
+ }
225
+ export function previewRedeem(shares) {
226
+ return __awaiter(this, void 0, void 0, function* () {
227
+ const _shares = parseUnits(shares, 18);
228
+ const _assets = yield this.contracts[this.constants.ALIASES.st_crvUSD].contract.previewRedeem(_shares);
229
+ return formatUnits(_assets);
230
+ });
231
+ }
232
+ function _redeem(shares_1) {
233
+ return __awaiter(this, arguments, void 0, function* (shares, estimateGas = false) {
234
+ const _shares = parseUnits(shares, 18);
235
+ const contract = this.contracts[this.constants.ALIASES.st_crvUSD].contract;
236
+ const gas = yield contract.redeem.estimateGas(_shares, this.signerAddress, this.signerAddress, Object.assign({}, this.constantOptions));
237
+ if (estimateGas)
238
+ return smartNumber(gas);
239
+ yield this.updateFeeData();
240
+ const gasLimit = _mulBy1_3(DIGas(gas));
241
+ return (yield contract.redeem(_shares, this.signerAddress, this.signerAddress, Object.assign(Object.assign({}, this.options), { gasLimit }))).hash;
242
+ });
243
+ }
244
+ export function redeemEstimateGas(shares) {
245
+ return __awaiter(this, void 0, void 0, function* () {
246
+ return yield _redeem.call(this, shares, true);
247
+ });
248
+ }
249
+ export function redeem(shares) {
250
+ return __awaiter(this, void 0, void 0, function* () {
251
+ return yield _redeem.call(this, shares, false);
252
+ });
253
+ }
package/lib/utils.d.ts CHANGED
@@ -2,6 +2,7 @@ import { BigNumberish, Numeric } from "ethers";
2
2
  import { Call } from "@curvefi/ethcall";
3
3
  import BigNumber from 'bignumber.js';
4
4
  import { ICurveContract, TGas } from "./interfaces.js";
5
+ import type { Llamalend } from "./llamalend.js";
5
6
  import memoize from "memoizee";
6
7
  export declare const MAX_ALLOWANCE: bigint;
7
8
  export declare const MAX_ACTIVE_BAND: bigint;
@@ -23,26 +24,26 @@ export declare const smartNumber: (abstractNumber: bigint | bigint[]) => number
23
24
  export declare const DIGas: (gas: bigint | Array<bigint>) => bigint;
24
25
  export declare const getGasFromArray: (gas: number[]) => number | number[];
25
26
  export declare const gasSum: (gas: number[], currentGas: number | number[]) => number[];
26
- export declare const _getAddress: (address: string) => string;
27
+ export declare const _getAddress: (this: Llamalend, address: string) => string;
27
28
  export declare const handleMultiCallResponse: (callsMap: string[], response: any[]) => Record<string, any>;
28
- export declare const _getCoinAddressesNoCheck: (...coins: string[] | string[][]) => string[];
29
- export declare const _getCoinAddresses: (coins: string[]) => string[];
30
- export declare const _getCoinDecimals: (coinAddresses: string[]) => number[];
31
- export declare const _getBalances: (coinAddresses: string[], address?: string) => Promise<bigint[]>;
32
- export declare const getBalances: (coins: string[], address?: string) => Promise<string[]>;
33
- export declare const _getAllowance: ((coins: string[], address: string, spender: string) => Promise<bigint[]>) & memoize.Memoized<(coins: string[], address: string, spender: string) => Promise<bigint[]>>;
34
- export declare const getAllowance: (coins: string[], address: string, spender: string) => Promise<string[]>;
35
- export declare const hasAllowance: (coins: string[], amounts: (number | string)[], address: string, spender: string) => Promise<boolean>;
36
- export declare const _ensureAllowance: (coins: string[], _amounts: bigint[], spender: string, isMax?: boolean) => Promise<string[]>;
37
- export declare const ensureAllowanceEstimateGas: (coins: string[], amounts: (number | string)[], spender: string, isMax?: boolean) => Promise<TGas>;
38
- export declare const ensureAllowance: (coins: string[], amounts: (number | string)[], spender: string, isMax?: boolean) => Promise<string[]>;
39
- export declare const _getUsdRate: (assetId: string) => Promise<number>;
40
- export declare const getUsdRate: (coin: string) => Promise<number>;
41
- export declare const getBaseFeeByLastBlock: () => Promise<number>;
42
- export declare const getGasPriceFromL1: () => Promise<number>;
43
- export declare const getGasPriceFromL2: () => Promise<number>;
44
- export declare const getGasInfoForL2: () => Promise<Record<string, number>>;
45
- export declare const totalSupply: () => Promise<{
29
+ export declare const _getCoinAddressesNoCheck: (this: Llamalend, ...coins: string[] | string[][]) => string[];
30
+ export declare const _getCoinAddresses: (this: Llamalend, coins: string[]) => string[];
31
+ export declare const _getCoinDecimals: (this: Llamalend, coinAddresses: string[]) => number[];
32
+ export declare const _getBalances: (this: Llamalend, coinAddresses: string[], address?: string) => Promise<bigint[]>;
33
+ export declare const getBalances: (this: Llamalend, coins: string[], address?: string) => Promise<string[]>;
34
+ export declare function _getAllowance(this: Llamalend, coins: string[], address: string, spender: string): Promise<bigint[]>;
35
+ export declare const getAllowance: (this: Llamalend, coins: string[], address: string, spender: string) => Promise<string[]>;
36
+ export declare const hasAllowance: (this: Llamalend, coins: string[], amounts: (number | string)[], address: string, spender: string) => Promise<boolean>;
37
+ export declare const _ensureAllowance: (this: Llamalend, coins: string[], _amounts: bigint[], spender: string, isMax?: boolean) => Promise<string[]>;
38
+ export declare const ensureAllowanceEstimateGas: (this: Llamalend, coins: string[], amounts: (number | string)[], spender: string, isMax?: boolean) => Promise<TGas>;
39
+ export declare const ensureAllowance: (this: Llamalend, coins: string[], amounts: (number | string)[], spender: string, isMax?: boolean) => Promise<string[]>;
40
+ export declare const _getUsdRate: (this: Llamalend, assetId: string) => Promise<number>;
41
+ export declare const getUsdRate: (this: Llamalend, coin: string) => Promise<number>;
42
+ export declare const getBaseFeeByLastBlock: (this: Llamalend) => Promise<number>;
43
+ export declare const getGasPriceFromL1: (this: Llamalend) => Promise<number>;
44
+ export declare function getGasPriceFromL2(this: Llamalend): Promise<number>;
45
+ export declare const getGasInfoForL2: (this: Llamalend) => Promise<Record<string, number>>;
46
+ export declare const totalSupply: (this: Llamalend) => Promise<{
46
47
  total: string;
47
48
  minted: string;
48
49
  pegKeepersDebt: string;