@curvefi/llamalend-api 1.0.21 → 1.0.22-beta.2
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/.github/workflows/publish.yml +1 -0
- package/lib/external-api.d.ts +6 -4
- package/lib/external-api.js +116 -98
- package/lib/index.d.ts +138 -41
- package/lib/index.js +80 -75
- package/lib/lendMarkets/LendMarketTemplate.d.ts +3 -1
- package/lib/lendMarkets/LendMarketTemplate.js +333 -333
- package/lib/lendMarkets/lendMarketConstructor.d.ts +2 -1
- package/lib/lendMarkets/lendMarketConstructor.js +3 -4
- package/lib/llamalend.d.ts +2 -2
- package/lib/llamalend.js +12 -20
- package/lib/mintMarkets/MintMarketTemplate.d.ts +3 -1
- package/lib/mintMarkets/MintMarketTemplate.js +204 -204
- package/lib/mintMarkets/mintMarketConstructor.d.ts +2 -1
- package/lib/mintMarkets/mintMarketConstructor.js +2 -2
- package/lib/st-crvUSD.d.ts +29 -28
- package/lib/st-crvUSD.js +237 -173
- package/lib/utils.d.ts +20 -19
- package/lib/utils.js +290 -256
- package/package.json +14 -14
- package/src/external-api.ts +25 -11
- package/src/index.ts +88 -76
- package/src/lendMarkets/LendMarketTemplate.ts +348 -346
- package/src/lendMarkets/lendMarketConstructor.ts +4 -4
- package/src/llamalend.ts +42 -58
- package/src/mintMarkets/MintMarketTemplate.ts +206 -204
- package/src/mintMarkets/mintMarketConstructor.ts +3 -2
- package/src/st-crvUSD.ts +97 -96
- package/src/utils.ts +85 -82
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { MintMarketTemplate } from "./MintMarketTemplate";
|
|
2
|
-
|
|
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
|
};
|
package/lib/st-crvUSD.d.ts
CHANGED
|
@@ -1,35 +1,36 @@
|
|
|
1
|
+
import type { Llamalend } from "./llamalend.js";
|
|
1
2
|
import { TAmount, TGas } from "./interfaces.js";
|
|
2
|
-
export declare
|
|
3
|
-
export declare
|
|
4
|
-
export declare
|
|
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
|
|
9
|
+
export declare function totalSupplyAndCrvUSDLocked(this: Llamalend): Promise<{
|
|
9
10
|
"crvUSD": string;
|
|
10
11
|
"st_crvUSD": string;
|
|
11
12
|
}>;
|
|
12
|
-
export declare
|
|
13
|
-
export declare
|
|
14
|
-
export declare
|
|
15
|
-
export declare
|
|
16
|
-
export declare
|
|
17
|
-
export declare
|
|
18
|
-
export declare
|
|
19
|
-
export declare
|
|
20
|
-
export declare
|
|
21
|
-
export declare
|
|
22
|
-
export declare
|
|
23
|
-
export declare
|
|
24
|
-
export declare
|
|
25
|
-
export declare
|
|
26
|
-
export declare
|
|
27
|
-
export declare
|
|
28
|
-
export declare
|
|
29
|
-
export declare
|
|
30
|
-
export declare
|
|
31
|
-
export declare
|
|
32
|
-
export declare
|
|
33
|
-
export declare
|
|
34
|
-
export declare
|
|
35
|
-
export declare
|
|
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
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return
|
|
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
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return {
|
|
36
|
-
|
|
37
|
-
|
|
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
|
|
42
|
-
address =
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
export
|
|
61
|
-
return
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
return (
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
|
84
|
-
address =
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
return
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
export
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
return
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
return
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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
|
|
138
|
-
address =
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
return
|
|
146
|
-
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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
|
|
165
|
-
address =
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
return
|
|
173
|
-
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
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
|
|
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
|
|
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;
|