@curvefi/api 2.13.1 → 2.15.0
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/README.md +22 -0
- package/lib/boosting.d.ts +3 -0
- package/lib/boosting.js +61 -2
- package/lib/constants/abis/fee_distributor.json +483 -0
- package/lib/constants/abis/fee_distributor_view.json +483 -0
- package/lib/constants/abis/wsteth/swap.json +865 -0
- package/lib/constants/aliases.js +10 -0
- package/lib/constants/coins/arbitrum.js +1 -0
- package/lib/constants/coins/optimism.js +1 -0
- package/lib/constants/pools/arbitrum.js +25 -0
- package/lib/constants/pools/optimism.js +26 -0
- package/lib/curve.js +2 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +3 -0
- package/lib/pools/mixins/depositBalancedAmountsMixins.js +33 -23
- package/lib/pools/mixins/withdrawBonusMixins.js +1 -1
- package/package.json +1 -1
package/lib/constants/aliases.js
CHANGED
|
@@ -6,6 +6,7 @@ exports.ALIASES_ETHEREUM = (0, utils_1.lowerCaseValues)({
|
|
|
6
6
|
"crv": "0xD533a949740bb3306d119CC777fa900bA034cd52",
|
|
7
7
|
"minter": "0xd061D61a4d941c39E5453435B6345Dc261C2fcE0",
|
|
8
8
|
"voting_escrow": "0x5f3b5DfEb7B28CDbD7FAba78963EE202a494e2A2",
|
|
9
|
+
"fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
|
|
9
10
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
10
11
|
"address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
|
|
11
12
|
"router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
|
|
@@ -18,6 +19,7 @@ exports.ALIASES_POLYGON = (0, utils_1.lowerCaseValues)({
|
|
|
18
19
|
"crv": "0x172370d5cd63279efa6d502dab29171933a610af",
|
|
19
20
|
"minter": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
|
|
20
21
|
"voting_escrow": "0x5f3b5DfEb7B28CDbD7FAba78963EE202a494e2A2",
|
|
22
|
+
"fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
|
|
21
23
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
22
24
|
"address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
|
|
23
25
|
"router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
|
|
@@ -30,6 +32,7 @@ exports.ALIASES_FANTOM = (0, utils_1.lowerCaseValues)({
|
|
|
30
32
|
"crv": "0x1E4F97b9f9F913c46F1632781732927B9019C68b",
|
|
31
33
|
"minter": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
|
|
32
34
|
"voting_escrow": "0x5f3b5DfEb7B28CDbD7FAba78963EE202a494e2A2",
|
|
35
|
+
"fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
|
|
33
36
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
34
37
|
"address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
|
|
35
38
|
"router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
|
|
@@ -42,6 +45,7 @@ exports.ALIASES_AVALANCHE = (0, utils_1.lowerCaseValues)({
|
|
|
42
45
|
"crv": "0x47536F17F4fF30e64A96a7555826b8f9e66ec468",
|
|
43
46
|
"minter": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
|
|
44
47
|
"voting_escrow": "0x5f3b5DfEb7B28CDbD7FAba78963EE202a494e2A2",
|
|
48
|
+
"fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
|
|
45
49
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
46
50
|
"address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
|
|
47
51
|
"router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
|
|
@@ -54,6 +58,7 @@ exports.ALIASES_ARBITRUM = (0, utils_1.lowerCaseValues)({
|
|
|
54
58
|
"crv": "0x11cDb42B0EB46D95f990BeDD4695A6e3fA034978",
|
|
55
59
|
"minter": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
|
|
56
60
|
"voting_escrow": "0x5f3b5DfEb7B28CDbD7FAba78963EE202a494e2A2",
|
|
61
|
+
"fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
|
|
57
62
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
58
63
|
"address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
|
|
59
64
|
"router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
|
|
@@ -66,6 +71,7 @@ exports.ALIASES_OPTIMISM = (0, utils_1.lowerCaseValues)({
|
|
|
66
71
|
"crv": "0x0994206dfE8De6Ec6920FF4D779B0d950605Fb53",
|
|
67
72
|
"minter": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
|
|
68
73
|
"voting_escrow": "0x5f3b5DfEb7B28CDbD7FAba78963EE202a494e2A2",
|
|
74
|
+
"fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
|
|
69
75
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
70
76
|
"address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
|
|
71
77
|
"router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
|
|
@@ -78,6 +84,7 @@ exports.ALIASES_XDAI = (0, utils_1.lowerCaseValues)({
|
|
|
78
84
|
"crv": "0x712b3d230f3c1c19db860d80619288b1f0bdd0bd",
|
|
79
85
|
"minter": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
|
|
80
86
|
"voting_escrow": "0x5f3b5DfEb7B28CDbD7FAba78963EE202a494e2A2",
|
|
87
|
+
"fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
|
|
81
88
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
82
89
|
"address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
|
|
83
90
|
"router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
|
|
@@ -90,6 +97,7 @@ exports.ALIASES_MOONBEAM = (0, utils_1.lowerCaseValues)({
|
|
|
90
97
|
"crv": "0x7C598c96D02398d89FbCb9d41Eab3DF0C16F227D",
|
|
91
98
|
"minter": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
|
|
92
99
|
"voting_escrow": "0x5f3b5DfEb7B28CDbD7FAba78963EE202a494e2A2",
|
|
100
|
+
"fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
|
|
93
101
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
94
102
|
"address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
|
|
95
103
|
"router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
|
|
@@ -102,6 +110,7 @@ exports.ALIASES_AURORA = (0, utils_1.lowerCaseValues)({
|
|
|
102
110
|
"crv": "0x64D5BaF5ac030e2b7c435aDD967f787ae94D0205",
|
|
103
111
|
"minter": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
|
|
104
112
|
"voting_escrow": "0x5f3b5DfEb7B28CDbD7FAba78963EE202a494e2A2",
|
|
113
|
+
"fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
|
|
105
114
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
106
115
|
"address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
|
|
107
116
|
"router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
|
|
@@ -114,6 +123,7 @@ exports.ALIASES_KAVA = (0, utils_1.lowerCaseValues)({
|
|
|
114
123
|
"crv": "0x64D5BaF5ac030e2b7c435aDD967f787ae94D0205",
|
|
115
124
|
"minter": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
|
|
116
125
|
"voting_escrow": "0x5f3b5DfEb7B28CDbD7FAba78963EE202a494e2A2",
|
|
126
|
+
"fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
|
|
117
127
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
118
128
|
"address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
|
|
119
129
|
"router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
|
|
@@ -16,6 +16,7 @@ exports.COINS_ARBITRUM = (0, utils_1.lowerCaseValues)({
|
|
|
16
16
|
// --- ETH ---
|
|
17
17
|
"eth": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
|
|
18
18
|
"weth": "0x82af49447d8a07e3bd95bd0d56f35241523fbab1",
|
|
19
|
+
"wsteth": "0x5979D7b546E38E414F7E9822514be443A4800529",
|
|
19
20
|
});
|
|
20
21
|
exports.cTokensArbitrum = []; //.map((a) => a.toLowerCase());
|
|
21
22
|
exports.yTokensArbitrum = []; //.map((a) => a.toLowerCase());
|
|
@@ -14,6 +14,7 @@ exports.COINS_OPTIMISM = (0, utils_1.lowerCaseValues)({
|
|
|
14
14
|
'eth': '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
|
|
15
15
|
'weth': '0x4200000000000000000000000000000000000006',
|
|
16
16
|
'seth': '0xe405de8f52ba7559f9df3c368500b6e6ae6cee49',
|
|
17
|
+
'wsteth': '0x1f32b1c2345538c0c6f582fcb022739c4a194ebb',
|
|
17
18
|
});
|
|
18
19
|
exports.cTokensOptimism = []; //.map((a) => a.toLowerCase());
|
|
19
20
|
exports.yTokensOptimism = []; //.map((a) => a.toLowerCase());
|
|
@@ -12,6 +12,7 @@ var swap_json_3 = __importDefault(require("../abis/eursusd2/swap.json"));
|
|
|
12
12
|
var zap_json_1 = __importDefault(require("../abis/eursusd2/zap.json"));
|
|
13
13
|
var swap_json_4 = __importDefault(require("../abis/ren-arbitrum/swap.json"));
|
|
14
14
|
var gauge_child_json_1 = __importDefault(require("../abis/gauge_child.json"));
|
|
15
|
+
var swap_json_5 = __importDefault(require("../abis/wsteth/swap.json"));
|
|
15
16
|
exports.POOLS_DATA_ARBITRUM = (0, utils_1.lowerCasePoolDataAddresses)({
|
|
16
17
|
'2pool': {
|
|
17
18
|
name: "2pool",
|
|
@@ -122,4 +123,28 @@ exports.POOLS_DATA_ARBITRUM = (0, utils_1.lowerCasePoolDataAddresses)({
|
|
|
122
123
|
gauge_abi: gauge_child_json_1.default,
|
|
123
124
|
deposit_abi: zap_json_1.default,
|
|
124
125
|
},
|
|
126
|
+
wsteth: {
|
|
127
|
+
name: "wsteth",
|
|
128
|
+
full_name: "wsteth",
|
|
129
|
+
symbol: "wsteth",
|
|
130
|
+
reference_asset: 'ETH',
|
|
131
|
+
is_plain: true,
|
|
132
|
+
swap_address: '0x6eB2dc694eB516B16Dc9FBc678C60052BbdD7d80',
|
|
133
|
+
token_address: '0xDbcD16e622c95AcB2650b38eC799f76BFC557a0b',
|
|
134
|
+
gauge_address: '0x098EF55011B6B8c99845128114A9D9159777d697',
|
|
135
|
+
underlying_coins: ['ETH', 'wstETH'],
|
|
136
|
+
wrapped_coins: ['ETH', 'wstETH'],
|
|
137
|
+
underlying_coin_addresses: [
|
|
138
|
+
'0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
|
|
139
|
+
'0x5979D7b546E38E414F7E9822514be443A4800529',
|
|
140
|
+
],
|
|
141
|
+
wrapped_coin_addresses: [
|
|
142
|
+
'0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
|
|
143
|
+
'0x5979D7b546E38E414F7E9822514be443A4800529',
|
|
144
|
+
],
|
|
145
|
+
underlying_decimals: [18, 18],
|
|
146
|
+
wrapped_decimals: [18, 18],
|
|
147
|
+
swap_abi: swap_json_5.default,
|
|
148
|
+
gauge_abi: gauge_child_json_1.default,
|
|
149
|
+
},
|
|
125
150
|
});
|
|
@@ -5,7 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.POOLS_DATA_OPTIMISM = void 0;
|
|
7
7
|
var swap_json_1 = __importDefault(require("../abis/3pool-optimism/swap.json"));
|
|
8
|
+
var swap_json_2 = __importDefault(require("../abis/wsteth/swap.json"));
|
|
8
9
|
var gauge_rewards_only_json_1 = __importDefault(require("../abis/gauge_rewards_only.json"));
|
|
10
|
+
var gauge_child_json_1 = __importDefault(require("../abis/gauge_child.json"));
|
|
9
11
|
var utils_1 = require("../utils");
|
|
10
12
|
exports.POOLS_DATA_OPTIMISM = (0, utils_1.lowerCasePoolDataAddresses)({
|
|
11
13
|
'3pool': {
|
|
@@ -34,4 +36,28 @@ exports.POOLS_DATA_OPTIMISM = (0, utils_1.lowerCasePoolDataAddresses)({
|
|
|
34
36
|
swap_abi: swap_json_1.default,
|
|
35
37
|
gauge_abi: gauge_rewards_only_json_1.default,
|
|
36
38
|
},
|
|
39
|
+
wsteth: {
|
|
40
|
+
name: "wsteth",
|
|
41
|
+
full_name: "wsteth",
|
|
42
|
+
symbol: "wsteth",
|
|
43
|
+
reference_asset: 'ETH',
|
|
44
|
+
is_plain: true,
|
|
45
|
+
swap_address: '0xB90B9B1F91a01Ea22A182CD84C1E22222e39B415',
|
|
46
|
+
token_address: '0xEfDE221f306152971D8e9f181bFe998447975810',
|
|
47
|
+
gauge_address: '0xD53cCBfED6577d8dc82987e766e75E3cb73a8563',
|
|
48
|
+
underlying_coins: ['ETH', 'wstETH'],
|
|
49
|
+
wrapped_coins: ['ETH', 'wstETH'],
|
|
50
|
+
underlying_coin_addresses: [
|
|
51
|
+
'0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
|
|
52
|
+
'0x1f32b1c2345538c0c6f582fcb022739c4a194ebb',
|
|
53
|
+
],
|
|
54
|
+
wrapped_coin_addresses: [
|
|
55
|
+
'0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
|
|
56
|
+
'0x1f32b1c2345538c0c6f582fcb022739c4a194ebb',
|
|
57
|
+
],
|
|
58
|
+
underlying_decimals: [18, 18],
|
|
59
|
+
wrapped_decimals: [18, 18],
|
|
60
|
+
swap_abi: swap_json_2.default,
|
|
61
|
+
gauge_abi: gauge_child_json_1.default,
|
|
62
|
+
},
|
|
37
63
|
});
|
package/lib/curve.js
CHANGED
|
@@ -71,6 +71,7 @@ var yERC20_json_1 = __importDefault(require("./constants/abis/yERC20.json"));
|
|
|
71
71
|
var minter_json_1 = __importDefault(require("./constants/abis/minter.json"));
|
|
72
72
|
var minter_child_json_1 = __importDefault(require("./constants/abis/minter_child.json"));
|
|
73
73
|
var votingescrow_json_1 = __importDefault(require("./constants/abis/votingescrow.json"));
|
|
74
|
+
var fee_distributor_json_1 = __importDefault(require("./constants/abis/fee_distributor.json"));
|
|
74
75
|
var address_provider_json_1 = __importDefault(require("./constants/abis/address_provider.json"));
|
|
75
76
|
var gaugecontroller_json_1 = __importDefault(require("./constants/abis/gaugecontroller.json"));
|
|
76
77
|
var router_json_1 = __importDefault(require("./constants/abis/router.json"));
|
|
@@ -504,6 +505,7 @@ var Curve = /** @class */ (function () {
|
|
|
504
505
|
contract: new ethers_1.Contract(this.constants.ALIASES.voting_escrow, votingescrow_json_1.default, this.signer || this.provider),
|
|
505
506
|
multicallContract: new ethcall_1.Contract(this.constants.ALIASES.voting_escrow, votingescrow_json_1.default),
|
|
506
507
|
};
|
|
508
|
+
this.setContract(this.constants.ALIASES.fee_distributor, fee_distributor_json_1.default);
|
|
507
509
|
this.contracts[this.constants.ALIASES.address_provider] = {
|
|
508
510
|
contract: new ethers_1.Contract(this.constants.ALIASES.address_provider, address_provider_json_1.default, this.signer || this.provider),
|
|
509
511
|
multicallContract: new ethcall_1.Contract(this.constants.ALIASES.address_provider, address_provider_json_1.default),
|
package/lib/index.d.ts
CHANGED
|
@@ -61,12 +61,15 @@ declare const curve: {
|
|
|
61
61
|
increaseAmount: (amount: string | number) => Promise<string>;
|
|
62
62
|
increaseUnlockTime: (days: number) => Promise<string>;
|
|
63
63
|
withdrawLockedCrv: () => Promise<string>;
|
|
64
|
+
claimableFees: (address?: string) => Promise<string>;
|
|
65
|
+
claimFees: (address?: string) => Promise<string>;
|
|
64
66
|
estimateGas: {
|
|
65
67
|
approve: (amount: string | number) => Promise<number>;
|
|
66
68
|
createLock: (amount: string | number, days: number) => Promise<number>;
|
|
67
69
|
increaseAmount: (amount: string | number) => Promise<number>;
|
|
68
70
|
increaseUnlockTime: (days: number) => Promise<number>;
|
|
69
71
|
withdrawLockedCrv: () => Promise<number>;
|
|
72
|
+
claimFees: (address?: string) => Promise<number>;
|
|
70
73
|
};
|
|
71
74
|
};
|
|
72
75
|
router: {
|
package/lib/index.js
CHANGED
|
@@ -121,12 +121,15 @@ var curve = {
|
|
|
121
121
|
increaseAmount: boosting_1.increaseAmount,
|
|
122
122
|
increaseUnlockTime: boosting_1.increaseUnlockTime,
|
|
123
123
|
withdrawLockedCrv: boosting_1.withdrawLockedCrv,
|
|
124
|
+
claimableFees: boosting_1.claimableFees,
|
|
125
|
+
claimFees: boosting_1.claimFees,
|
|
124
126
|
estimateGas: {
|
|
125
127
|
approve: boosting_1.approveEstimateGas,
|
|
126
128
|
createLock: boosting_1.createLockEstimateGas,
|
|
127
129
|
increaseAmount: boosting_1.increaseAmountEstimateGas,
|
|
128
130
|
increaseUnlockTime: boosting_1.increaseUnlockTimeEstimateGas,
|
|
129
131
|
withdrawLockedCrv: boosting_1.withdrawLockedCrvEstimateGas,
|
|
132
|
+
claimFees: boosting_1.claimFeesEstimateGas,
|
|
130
133
|
},
|
|
131
134
|
},
|
|
132
135
|
router: {
|
|
@@ -35,36 +35,44 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
38
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
42
|
exports.depositWrappedBalancedAmountsCryptoMixin = exports.depositWrappedBalancedAmountsMixin = exports.depositBalancedAmountsCryptoMixin = exports.depositBalancedAmountsMixin = void 0;
|
|
43
|
+
var bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
44
|
+
var utils_1 = require("../../utils");
|
|
40
45
|
function _depositBalancedAmounts(poolBalances, walletBalances, decimals) {
|
|
41
|
-
var
|
|
42
|
-
var
|
|
46
|
+
var poolBalancesBN = poolBalances.map(utils_1.BN);
|
|
47
|
+
var walletBalancesBN = walletBalances.map(utils_1.BN);
|
|
48
|
+
var poolTotalLiquidityBN = poolBalancesBN.reduce(function (a, b) { return a.plus(b); });
|
|
49
|
+
var poolBalancesRatiosBN = poolBalancesBN.map(function (b) { return b.div(poolTotalLiquidityBN); });
|
|
43
50
|
// Cross factors for each wallet balance used as reference to see the
|
|
44
51
|
// max that can be used according to the lowest relative wallet balance
|
|
45
|
-
var
|
|
46
|
-
var
|
|
52
|
+
var balancedAmountsForEachScenarioBN = walletBalancesBN.map(function (_, i) { return (walletBalancesBN.map(function (_, j) { return (poolBalancesRatiosBN[j].times(walletBalancesBN[i]).div(poolBalancesRatiosBN[i])); })); });
|
|
53
|
+
var firstCoinBalanceForEachScenarioBN = balancedAmountsForEachScenarioBN.map(function (_a) {
|
|
47
54
|
var a = _a[0];
|
|
48
55
|
return a;
|
|
49
56
|
});
|
|
50
|
-
var
|
|
51
|
-
return
|
|
57
|
+
var scenarioWithLowestBalancesBN = firstCoinBalanceForEachScenarioBN.map(String).indexOf(bignumber_js_1.default.min.apply(bignumber_js_1.default, firstCoinBalanceForEachScenarioBN).toString());
|
|
58
|
+
return balancedAmountsForEachScenarioBN[scenarioWithLowestBalancesBN].map(function (a, i) { return a.toFixed(decimals[i]); });
|
|
52
59
|
}
|
|
53
60
|
// @ts-ignore
|
|
54
61
|
exports.depositBalancedAmountsMixin = {
|
|
55
62
|
depositBalancedAmounts: function () {
|
|
56
63
|
return __awaiter(this, void 0, void 0, function () {
|
|
57
|
-
var poolBalances, walletBalances, _a, _b;
|
|
64
|
+
var poolBalances, walletBalances, _a, _b, balancedAmountsBN;
|
|
58
65
|
return __generator(this, function (_c) {
|
|
59
66
|
switch (_c.label) {
|
|
60
67
|
case 0: return [4 /*yield*/, this.stats.underlyingBalances()];
|
|
61
68
|
case 1:
|
|
62
|
-
poolBalances =
|
|
69
|
+
poolBalances = _c.sent();
|
|
63
70
|
_b = (_a = Object).values;
|
|
64
71
|
return [4 /*yield*/, this.walletUnderlyingCoinBalances()];
|
|
65
72
|
case 2:
|
|
66
|
-
walletBalances = _b.apply(_a, [_c.sent()])
|
|
67
|
-
|
|
73
|
+
walletBalances = _b.apply(_a, [_c.sent()]);
|
|
74
|
+
balancedAmountsBN = (_depositBalancedAmounts(poolBalances, walletBalances, this.underlyingDecimals));
|
|
75
|
+
return [2 /*return*/, balancedAmountsBN.map(function (b, i) { return bignumber_js_1.default.min((0, utils_1.BN)(b), (0, utils_1.BN)(walletBalances[i])).toString(); })];
|
|
68
76
|
}
|
|
69
77
|
});
|
|
70
78
|
});
|
|
@@ -75,23 +83,23 @@ exports.depositBalancedAmountsCryptoMixin = {
|
|
|
75
83
|
depositBalancedAmounts: function () {
|
|
76
84
|
return __awaiter(this, void 0, void 0, function () {
|
|
77
85
|
var poolBalances, walletBalances, _a, _b, prices, poolBalancesUSD, walletBalancesUSD, balancedAmountsUSD;
|
|
86
|
+
var _this = this;
|
|
78
87
|
return __generator(this, function (_c) {
|
|
79
88
|
switch (_c.label) {
|
|
80
89
|
case 0: return [4 /*yield*/, this.stats.underlyingBalances()];
|
|
81
90
|
case 1:
|
|
82
|
-
poolBalances =
|
|
91
|
+
poolBalances = _c.sent();
|
|
83
92
|
_b = (_a = Object).values;
|
|
84
93
|
return [4 /*yield*/, this.walletUnderlyingCoinBalances()];
|
|
85
94
|
case 2:
|
|
86
|
-
walletBalances = _b.apply(_a, [_c.sent()])
|
|
95
|
+
walletBalances = _b.apply(_a, [_c.sent()]);
|
|
87
96
|
return [4 /*yield*/, this._underlyingPrices()];
|
|
88
97
|
case 3:
|
|
89
98
|
prices = _c.sent();
|
|
90
|
-
poolBalancesUSD = poolBalances.map(function (b, i) { return b
|
|
91
|
-
walletBalancesUSD = walletBalances.map(function (b, i) { return b
|
|
99
|
+
poolBalancesUSD = poolBalances.map(function (b, i) { return (0, utils_1.BN)(b).times(prices[i]).toString(); });
|
|
100
|
+
walletBalancesUSD = walletBalances.map(function (b, i) { return (0, utils_1.BN)(b).times(prices[i]).toString(); });
|
|
92
101
|
balancedAmountsUSD = _depositBalancedAmounts(poolBalancesUSD, walletBalancesUSD, this.underlyingDecimals);
|
|
93
|
-
|
|
94
|
-
return [2 /*return*/, balancedAmountsUSD.map(function (b, i) { return String(Math.min(Number(b) / prices[i], poolBalances[i])); })];
|
|
102
|
+
return [2 /*return*/, balancedAmountsUSD.map(function (b, i) { return bignumber_js_1.default.min((0, utils_1.BN)((0, utils_1.BN)(b).div(prices[i]).toFixed(_this.underlyingDecimals[i])), (0, utils_1.BN)(walletBalances[i])).toString(); })];
|
|
95
103
|
}
|
|
96
104
|
});
|
|
97
105
|
});
|
|
@@ -101,17 +109,18 @@ exports.depositBalancedAmountsCryptoMixin = {
|
|
|
101
109
|
exports.depositWrappedBalancedAmountsMixin = {
|
|
102
110
|
depositWrappedBalancedAmounts: function () {
|
|
103
111
|
return __awaiter(this, void 0, void 0, function () {
|
|
104
|
-
var poolBalances, walletBalances, _a, _b;
|
|
112
|
+
var poolBalances, walletBalances, _a, _b, balancedAmountsBN;
|
|
105
113
|
return __generator(this, function (_c) {
|
|
106
114
|
switch (_c.label) {
|
|
107
115
|
case 0: return [4 /*yield*/, this.stats.wrappedBalances()];
|
|
108
116
|
case 1:
|
|
109
|
-
poolBalances =
|
|
117
|
+
poolBalances = _c.sent();
|
|
110
118
|
_b = (_a = Object).values;
|
|
111
119
|
return [4 /*yield*/, this.walletWrappedCoinBalances()];
|
|
112
120
|
case 2:
|
|
113
|
-
walletBalances = _b.apply(_a, [_c.sent()])
|
|
114
|
-
|
|
121
|
+
walletBalances = _b.apply(_a, [_c.sent()]);
|
|
122
|
+
balancedAmountsBN = (_depositBalancedAmounts(poolBalances, walletBalances, this.underlyingDecimals));
|
|
123
|
+
return [2 /*return*/, balancedAmountsBN.map(function (b, i) { return bignumber_js_1.default.min((0, utils_1.BN)(b), (0, utils_1.BN)(walletBalances[i])).toString(); })];
|
|
115
124
|
}
|
|
116
125
|
});
|
|
117
126
|
});
|
|
@@ -122,6 +131,7 @@ exports.depositWrappedBalancedAmountsCryptoMixin = {
|
|
|
122
131
|
depositWrappedBalancedAmounts: function () {
|
|
123
132
|
return __awaiter(this, void 0, void 0, function () {
|
|
124
133
|
var poolBalances, walletBalances, _a, _b, prices, poolBalancesUSD, walletBalancesUSD, balancedAmountsUSD;
|
|
134
|
+
var _this = this;
|
|
125
135
|
return __generator(this, function (_c) {
|
|
126
136
|
switch (_c.label) {
|
|
127
137
|
case 0: return [4 /*yield*/, this.stats.wrappedBalances()];
|
|
@@ -134,10 +144,10 @@ exports.depositWrappedBalancedAmountsCryptoMixin = {
|
|
|
134
144
|
return [4 /*yield*/, this._wrappedPrices()];
|
|
135
145
|
case 3:
|
|
136
146
|
prices = _c.sent();
|
|
137
|
-
poolBalancesUSD = poolBalances.map(function (b, i) { return b
|
|
138
|
-
walletBalancesUSD = walletBalances.map(function (b, i) { return b
|
|
147
|
+
poolBalancesUSD = poolBalances.map(function (b, i) { return (0, utils_1.BN)(b).times(prices[i]).toString(); });
|
|
148
|
+
walletBalancesUSD = walletBalances.map(function (b, i) { return (0, utils_1.BN)(b).times(prices[i]).toString(); });
|
|
139
149
|
balancedAmountsUSD = _depositBalancedAmounts(poolBalancesUSD, walletBalancesUSD, this.wrappedDecimals);
|
|
140
|
-
return [2 /*return*/, balancedAmountsUSD.map(function (b, i) { return
|
|
150
|
+
return [2 /*return*/, balancedAmountsUSD.map(function (b, i) { return bignumber_js_1.default.min((0, utils_1.BN)((0, utils_1.BN)(b).div(prices[i]).toFixed(_this.wrappedDecimals[i])), (0, utils_1.BN)(walletBalances[i])).toString(); })];
|
|
141
151
|
}
|
|
142
152
|
});
|
|
143
153
|
});
|
|
@@ -197,7 +197,7 @@ exports.withdrawOneCoinWrappedCryptoBonusMixin = {
|
|
|
197
197
|
_e.label = 2;
|
|
198
198
|
case 2: return [4 /*yield*/, this._wrappedPrices()];
|
|
199
199
|
case 3:
|
|
200
|
-
prices = (_e.sent()).map(function (p, i) { return i ===
|
|
200
|
+
prices = (_e.sent()).map(function (p, i, arr) { return i === arr.length - 1 ? p * vp : p; });
|
|
201
201
|
coinPrice = prices[this._getCoinIdx(coin)];
|
|
202
202
|
_d = Number;
|
|
203
203
|
return [4 /*yield*/, this.withdrawOneCoinWrappedExpected(lpTokenAmount, coin)];
|