@gearbox-protocol/sdk 3.0.0-next.5 → 3.0.0-next.50
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/contracts/IAirdropDistributor.sol +55 -0
- package/contracts/IDegenDistributor.sol +28 -0
- package/contracts/IOffchainOracle.sol +17 -0
- package/contracts/IWETHGateway.sol +33 -0
- package/contracts/IwstETHGateway.sol +24 -0
- package/contracts/index.sol +11 -3
- package/lib/apy/curveAPY.js +2 -1
- package/lib/apy/index.d.ts +2 -2
- package/lib/apy/yearnAPY.js +1 -1
- package/lib/config.d.ts +0 -1
- package/lib/config.js +1 -2
- package/lib/core/assets.d.ts +4 -4
- package/lib/core/assets.js +28 -17
- package/lib/core/creditAccount.d.ts +31 -6
- package/lib/core/creditAccount.js +101 -37
- package/lib/core/creditAccount.spec.js +693 -10
- package/lib/core/creditManager.d.ts +22 -8
- package/lib/core/creditManager.js +86 -30
- package/lib/core/events.js +14 -14
- package/lib/core/gauge.d.ts +26 -0
- package/lib/core/gauge.js +63 -0
- package/lib/core/gaugeMath.d.ts +40 -0
- package/lib/core/gaugeMath.js +108 -0
- package/lib/core/gaugeMath.spec.d.ts +1 -0
- package/lib/core/gaugeMath.spec.js +388 -0
- package/lib/core/{pool/data.d.ts → pool.d.ts} +18 -10
- package/lib/core/{pool/data.js → pool.js} +69 -24
- package/lib/core/strategy.js +2 -2
- package/lib/core/trade.d.ts +5 -23
- package/lib/core/trade.js +4 -61
- package/lib/core/transactions.d.ts +50 -3
- package/lib/core/transactions.js +136 -105
- package/lib/index.d.ts +3 -0
- package/lib/index.js +3 -0
- package/lib/parsers/abstractParser.js +1 -2
- package/lib/parsers/creditFacadeParser.d.ts +2 -1
- package/lib/parsers/creditFacadeParser.js +17 -5
- package/lib/parsers/creditFacadeParser.spec.js +2 -3
- package/lib/parsers/curveAdapterParser.js +2 -3
- package/lib/parsers/txParser.d.ts +4 -4
- package/lib/parsers/txParser.js +9 -3
- package/lib/parsers/uniV2AdapterParser.js +2 -2
- package/lib/parsers/uniV3AdapterParser.js +3 -3
- package/lib/pathfinder/core.d.ts +4 -4
- package/lib/pathfinder/pathOptions.d.ts +2 -1
- package/lib/pathfinder/pathOptions.js +20 -1
- package/lib/pathfinder/pathOptions.spec.js +2 -2
- package/lib/pathfinder/pathfinder.js +4 -3
- package/lib/pathfinder/pathfinder.spec.js +3 -1
- package/lib/payload/creditAccount.d.ts +2 -2
- package/lib/payload/gauge.d.ts +12 -0
- package/lib/payload/pool.d.ts +6 -1
- package/lib/types/IAirdropDistributor.sol/IAirdropDistributor.d.ts +124 -0
- package/lib/types/IAirdropDistributor.sol/IAirdropDistributorEvents.d.ts +73 -0
- package/lib/types/IAirdropDistributor.sol/index.d.ts +2 -0
- package/lib/types/IConvexToken.d.ts +9 -1
- package/lib/types/IConvexV1BaseRewardPoolAdapter.d.ts +17 -1
- package/lib/types/{IConvexV1BoosterAdapter.d.ts → IConvexV1BoosterAdapter.sol/IConvexV1BoosterAdapter.d.ts} +19 -4
- package/lib/types/IConvexV1BoosterAdapter.sol/IConvexV1BoosterAdapterEvents.d.ts +43 -0
- package/lib/types/IConvexV1BoosterAdapter.sol/index.d.ts +2 -0
- package/lib/types/ICreditConfiguratorV3.sol/ICreditConfiguratorV3.d.ts +716 -0
- package/lib/types/ICreditConfiguratorV3.sol/ICreditConfiguratorV3Events.d.ts +275 -0
- package/lib/types/ICreditConfiguratorV3.sol/index.d.ts +2 -0
- package/lib/types/ICreditFacadeV2.sol/ICreditFacadeV2Extended.d.ts +7 -11
- package/lib/types/ICreditFacadeV3.sol/ICreditFacadeV3.d.ts +165 -20
- package/lib/types/ICreditFacadeV3.sol/ICreditFacadeV3Events.d.ts +5 -7
- package/lib/types/ICreditFacadeV3Multicall.d.ts +35 -12
- package/lib/types/ICreditManagerV3.sol/ICreditManagerV3.d.ts +273 -39
- package/lib/types/IDataCompressorV2_10.d.ts +43 -9
- package/lib/types/IDataCompressorV3_00.d.ts +140 -10
- package/lib/types/IDegenDistributor.sol/IDegenDistributor.d.ts +96 -0
- package/lib/types/IDegenDistributor.sol/IDegenDistributorEvents.d.ts +53 -0
- package/lib/types/IDegenDistributor.sol/index.d.ts +2 -0
- package/lib/types/{draft-IERC20Permit.sol/IERC20Permit.d.ts → IERC20Permit.d.ts} +1 -1
- package/lib/types/IERC20ZapperDeposits.d.ts +117 -0
- package/lib/types/IETHZapperDeposits.d.ts +66 -0
- package/lib/types/IGasPricer.d.ts +44 -0
- package/lib/types/IGearStakingV3.sol/IGearStakingV3.d.ts +408 -0
- package/lib/types/IGearStakingV3.sol/IGearStakingV3Events.d.ts +117 -0
- package/lib/types/IGearStakingV3.sol/index.d.ts +2 -0
- package/lib/types/{ILidoV1Adapter.sol/ILidoV1Adapter.d.ts → ILidoV1Adapter.d.ts} +5 -40
- package/lib/types/ILidoV1Adapter.js +2 -0
- package/lib/types/IOffchainOracle.d.ts +58 -0
- package/lib/types/IOffchainOracle.js +2 -0
- package/lib/types/IPoolV3.sol/IPoolV3.d.ts +43 -11
- package/lib/types/IPoolV3.sol/index.d.ts +0 -1
- package/lib/types/IWETHGateway.d.ts +90 -0
- package/lib/types/IWETHGateway.js +2 -0
- package/lib/types/IZapper.d.ts +130 -0
- package/lib/types/IZapper.js +2 -0
- package/lib/types/IwstETHGateway.sol/IwstETHGateWay.d.ts +70 -0
- package/lib/types/IwstETHGateway.sol/IwstETHGateWay.js +2 -0
- package/lib/types/IwstETHGateway.sol/index.d.ts +1 -0
- package/lib/types/IwstETHGateway.sol/index.js +2 -0
- package/lib/types/factories/AddressProvider__factory.d.ts +1 -1
- package/lib/types/factories/AddressProvider__factory.js +1 -1
- package/lib/types/factories/Balances.sol/BalanceOps__factory.d.ts +1 -1
- package/lib/types/factories/Balances.sol/BalanceOps__factory.js +1 -1
- package/lib/types/factories/Claimable__factory.d.ts +1 -1
- package/lib/types/factories/Claimable__factory.js +1 -1
- package/lib/types/factories/Errors__factory.d.ts +1 -1
- package/lib/types/factories/Errors__factory.js +1 -1
- package/lib/types/factories/IAirdropDistributor.sol/IAirdropDistributorEvents__factory.d.ts +63 -0
- package/lib/types/factories/IAirdropDistributor.sol/IAirdropDistributorEvents__factory.js +88 -0
- package/lib/types/factories/IAirdropDistributor.sol/IAirdropDistributor__factory.d.ts +119 -0
- package/lib/types/factories/IAirdropDistributor.sol/IAirdropDistributor__factory.js +161 -0
- package/lib/types/factories/IAirdropDistributor.sol/index.d.ts +2 -0
- package/lib/types/factories/IAirdropDistributor.sol/index.js +10 -0
- package/lib/types/factories/IConvexToken__factory.d.ts +10 -0
- package/lib/types/factories/IConvexToken__factory.js +13 -0
- package/lib/types/factories/IConvexV1BaseRewardPoolAdapter__factory.d.ts +20 -0
- package/lib/types/factories/IConvexV1BaseRewardPoolAdapter__factory.js +26 -0
- package/lib/types/factories/IConvexV1BoosterAdapter.sol/IConvexV1BoosterAdapterEvents__factory.d.ts +23 -0
- package/lib/types/factories/IConvexV1BoosterAdapter.sol/IConvexV1BoosterAdapterEvents__factory.js +38 -0
- package/lib/types/factories/{IConvexV1BoosterAdapter__factory.d.ts → IConvexV1BoosterAdapter.sol/IConvexV1BoosterAdapter__factory.d.ts} +16 -1
- package/lib/types/factories/{IConvexV1BoosterAdapter__factory.js → IConvexV1BoosterAdapter.sol/IConvexV1BoosterAdapter__factory.js} +19 -0
- package/lib/types/factories/IConvexV1BoosterAdapter.sol/index.d.ts +2 -0
- package/lib/types/factories/IConvexV1BoosterAdapter.sol/index.js +10 -0
- package/lib/types/factories/ICreditConfiguratorV3.sol/ICreditConfiguratorV3Events__factory.d.ts +273 -0
- package/lib/types/factories/ICreditConfiguratorV3.sol/ICreditConfiguratorV3Events__factory.js +357 -0
- package/lib/types/factories/ICreditConfiguratorV3.sol/ICreditConfiguratorV3__factory.d.ts +605 -0
- package/lib/types/factories/ICreditConfiguratorV3.sol/ICreditConfiguratorV3__factory.js +785 -0
- package/lib/types/factories/ICreditConfiguratorV3.sol/index.d.ts +2 -0
- package/lib/types/factories/ICreditConfiguratorV3.sol/index.js +10 -0
- package/lib/types/factories/ICreditFacadeV2.sol/ICreditFacadeV2Extended__factory.d.ts +0 -4
- package/lib/types/factories/ICreditFacadeV2.sol/ICreditFacadeV2Extended__factory.js +0 -5
- package/lib/types/factories/ICreditFacadeV3.sol/ICreditFacadeV3Events__factory.d.ts +1 -6
- package/lib/types/factories/ICreditFacadeV3.sol/ICreditFacadeV3Events__factory.js +1 -7
- package/lib/types/factories/ICreditFacadeV3.sol/ICreditFacadeV3__factory.d.ts +144 -13
- package/lib/types/factories/ICreditFacadeV3.sol/ICreditFacadeV3__factory.js +185 -15
- package/lib/types/factories/ICreditFacadeV3Multicall__factory.d.ts +35 -5
- package/lib/types/factories/ICreditFacadeV3Multicall__factory.js +43 -5
- package/lib/types/factories/ICreditManagerV3.sol/ICreditManagerV3__factory.d.ts +199 -25
- package/lib/types/factories/ICreditManagerV3.sol/ICreditManagerV3__factory.js +252 -28
- package/lib/types/factories/IDataCompressorV2_10__factory.d.ts +110 -12
- package/lib/types/factories/IDataCompressorV2_10__factory.js +138 -14
- package/lib/types/factories/IDataCompressorV3_00__factory.d.ts +400 -16
- package/lib/types/factories/IDataCompressorV3_00__factory.js +508 -19
- package/lib/types/factories/IDegenDistributor.sol/IDegenDistributorEvents__factory.d.ts +38 -0
- package/lib/types/factories/{AaveV2_WrappedAToken.sol/IWrappedATokenEvents__factory.js → IDegenDistributor.sol/IDegenDistributorEvents__factory.js} +13 -25
- package/lib/types/factories/IDegenDistributor.sol/IDegenDistributor__factory.d.ts +84 -0
- package/lib/types/factories/{IPoolV3.sol/IPoolBase__factory.js → IDegenDistributor.sol/IDegenDistributor__factory.js} +46 -41
- package/lib/types/factories/IDegenDistributor.sol/index.d.ts +2 -0
- package/lib/types/factories/IDegenDistributor.sol/index.js +10 -0
- package/lib/types/factories/{draft-IERC20Permit.sol/IERC20Permit__factory.d.ts → IERC20Permit__factory.d.ts} +1 -1
- package/lib/types/factories/IERC20ZapperDeposits__factory.d.ts +120 -0
- package/lib/types/factories/IERC20ZapperDeposits__factory.js +165 -0
- package/lib/types/factories/IETHZapperDeposits__factory.d.ts +40 -0
- package/lib/types/factories/IETHZapperDeposits__factory.js +62 -0
- package/lib/types/factories/IGasPricer__factory.d.ts +22 -0
- package/lib/types/factories/{ILidoV1Adapter.sol/ILidoV1AdapterEvents__factory.js → IGasPricer__factory.js} +14 -8
- package/lib/types/factories/IGearStakingV3.sol/IGearStakingV3Events__factory.d.ts +113 -0
- package/lib/types/factories/IGearStakingV3.sol/IGearStakingV3Events__factory.js +152 -0
- package/lib/types/factories/IGearStakingV3.sol/IGearStakingV3__factory.d.ts +504 -0
- package/lib/types/factories/IGearStakingV3.sol/IGearStakingV3__factory.js +660 -0
- package/lib/types/factories/IGearStakingV3.sol/index.d.ts +2 -0
- package/lib/types/factories/IGearStakingV3.sol/index.js +10 -0
- package/lib/types/factories/{ILidoV1Adapter.sol/ILidoV1Adapter__factory.d.ts → ILidoV1Adapter__factory.d.ts} +1 -35
- package/lib/types/factories/{ILidoV1Adapter.sol/ILidoV1Adapter__factory.js → ILidoV1Adapter__factory.js} +0 -44
- package/lib/types/factories/IOffchainOracle__factory.d.ts +48 -0
- package/lib/types/factories/IOffchainOracle__factory.js +72 -0
- package/lib/types/factories/IPoolV3.sol/IPoolV3__factory.d.ts +62 -14
- package/lib/types/factories/IPoolV3.sol/IPoolV3__factory.js +79 -17
- package/lib/types/factories/IPoolV3.sol/index.d.ts +0 -1
- package/lib/types/factories/IPoolV3.sol/index.js +1 -3
- package/lib/types/factories/IWETHGateway__factory.d.ts +58 -0
- package/lib/types/factories/IWETHGateway__factory.js +83 -0
- package/lib/types/factories/{WERC20ZapperBase__factory.d.ts → IZapper__factory.d.ts} +57 -61
- package/lib/types/factories/{WERC20ZapperBase__factory.js → IZapper__factory.js} +65 -71
- package/lib/types/factories/{ZapperBase__factory.d.ts → IwstETHGateway.sol/IwstETHGateWay__factory.d.ts} +22 -34
- package/lib/types/factories/{ZapperBase__factory.js → IwstETHGateway.sol/IwstETHGateWay__factory.js} +22 -39
- package/lib/types/factories/IwstETHGateway.sol/index.d.ts +1 -0
- package/lib/types/factories/IwstETHGateway.sol/index.js +8 -0
- package/lib/types/factories/SafeERC20__factory.d.ts +1 -1
- package/lib/types/factories/SafeERC20__factory.js +1 -1
- package/lib/types/factories/index.d.ts +15 -13
- package/lib/types/factories/index.js +25 -25
- package/lib/types/factories/{IRouter__factory.d.ts → interfaces/IRouter__factory.d.ts} +15 -1
- package/lib/types/factories/{IRouter__factory.js → interfaces/IRouter__factory.js} +19 -0
- package/lib/types/factories/interfaces/index.d.ts +1 -0
- package/lib/types/factories/interfaces/index.js +8 -0
- package/lib/types/index.d.ts +62 -48
- package/lib/types/index.js +52 -46
- package/lib/types/{IRouter.d.ts → interfaces/IRouter.d.ts} +12 -2
- package/lib/types/interfaces/IRouter.js +2 -0
- package/lib/types/interfaces/index.d.ts +1 -0
- package/lib/types/interfaces/index.js +2 -0
- package/lib/utils/formatter.d.ts +0 -3
- package/lib/utils/formatter.js +1 -67
- package/lib/utils/math.d.ts +2 -0
- package/lib/utils/math.js +2 -0
- package/lib/utils/types.d.ts +1 -0
- package/lib/watchers/creditAccountWatcher.d.ts +3 -2
- package/lib/watchers/creditAccountWatcher.js +19 -13
- package/lib/watchers/creditAccountWatcher.spec.js +18 -18
- package/lib/watchers/creditManagerWatcher.d.ts +5 -3
- package/lib/watchers/creditManagerWatcher.js +32 -10
- package/lib/watchers/creditManagerWatcher.spec.js +12 -4
- package/package.json +10 -9
- package/contracts/IRouter.sol +0 -100
- package/lib/core/pool/index.d.ts +0 -1
- package/lib/core/pool/index.js +0 -17
- package/lib/types/AaveV2_WrappedAToken.sol/IWrappedATokenEvents.d.ts +0 -60
- package/lib/types/AaveV2_WrappedAToken.sol/WrappedAToken.d.ts +0 -332
- package/lib/types/AaveV2_WrappedAToken.sol/index.d.ts +0 -2
- package/lib/types/ERC20.d.ts +0 -198
- package/lib/types/IAToken.d.ts +0 -182
- package/lib/types/ILendingPool.d.ts +0 -140
- package/lib/types/ILidoV1Adapter.sol/ILidoV1AdapterEvents.d.ts +0 -39
- package/lib/types/ILidoV1Adapter.sol/ILidoV1AdapterExceptions.d.ts +0 -27
- package/lib/types/ILidoV1Adapter.sol/index.d.ts +0 -3
- package/lib/types/IPoolV3.sol/IPoolBase.d.ts +0 -102
- package/lib/types/WATokenZapper.d.ts +0 -134
- package/lib/types/WERC20ZapperBase.d.ts +0 -134
- package/lib/types/WETHZapper.d.ts +0 -122
- package/lib/types/WstETHZapper.d.ts +0 -134
- package/lib/types/ZapperBase.d.ts +0 -70
- package/lib/types/draft-IERC20Permit.sol/index.d.ts +0 -1
- package/lib/types/factories/AaveV2_WrappedAToken.sol/IWrappedATokenEvents__factory.d.ts +0 -48
- package/lib/types/factories/AaveV2_WrappedAToken.sol/WrappedAToken__factory.d.ts +0 -397
- package/lib/types/factories/AaveV2_WrappedAToken.sol/WrappedAToken__factory.js +0 -535
- package/lib/types/factories/AaveV2_WrappedAToken.sol/index.d.ts +0 -2
- package/lib/types/factories/AaveV2_WrappedAToken.sol/index.js +0 -10
- package/lib/types/factories/ERC20__factory.d.ts +0 -239
- package/lib/types/factories/ERC20__factory.js +0 -328
- package/lib/types/factories/IAToken__factory.d.ts +0 -198
- package/lib/types/factories/IAToken__factory.js +0 -267
- package/lib/types/factories/ILendingPool__factory.d.ts +0 -134
- package/lib/types/factories/ILendingPool__factory.js +0 -183
- package/lib/types/factories/ILidoV1Adapter.sol/ILidoV1AdapterEvents__factory.d.ts +0 -18
- package/lib/types/factories/ILidoV1Adapter.sol/ILidoV1AdapterExceptions__factory.d.ts +0 -12
- package/lib/types/factories/ILidoV1Adapter.sol/ILidoV1AdapterExceptions__factory.js +0 -24
- package/lib/types/factories/ILidoV1Adapter.sol/index.d.ts +0 -3
- package/lib/types/factories/ILidoV1Adapter.sol/index.js +0 -12
- package/lib/types/factories/IPoolV3.sol/IPoolBase__factory.d.ts +0 -80
- package/lib/types/factories/WATokenZapper__factory.d.ts +0 -161
- package/lib/types/factories/WATokenZapper__factory.js +0 -227
- package/lib/types/factories/WETHZapper__factory.d.ts +0 -138
- package/lib/types/factories/WETHZapper__factory.js +0 -198
- package/lib/types/factories/WstETHZapper__factory.d.ts +0 -161
- package/lib/types/factories/WstETHZapper__factory.js +0 -227
- package/lib/types/factories/draft-IERC20Permit.sol/index.d.ts +0 -1
- package/lib/types/factories/draft-IERC20Permit.sol/index.js +0 -8
- /package/lib/{types/AaveV2_WrappedAToken.sol/IWrappedATokenEvents.js → payload/gauge.js} +0 -0
- /package/lib/types/{AaveV2_WrappedAToken.sol/WrappedAToken.js → IAirdropDistributor.sol/IAirdropDistributor.js} +0 -0
- /package/lib/types/{AaveV2_WrappedAToken.sol/index.js → IAirdropDistributor.sol/IAirdropDistributorEvents.js} +0 -0
- /package/lib/types/{ILidoV1Adapter.sol → IAirdropDistributor.sol}/index.js +0 -0
- /package/lib/types/{IConvexV1BoosterAdapter.js → IConvexV1BoosterAdapter.sol/IConvexV1BoosterAdapter.js} +0 -0
- /package/lib/types/{ERC20.js → IConvexV1BoosterAdapter.sol/IConvexV1BoosterAdapterEvents.js} +0 -0
- /package/lib/types/{draft-IERC20Permit.sol → IConvexV1BoosterAdapter.sol}/index.js +0 -0
- /package/lib/types/{IAToken.js → ICreditConfiguratorV3.sol/ICreditConfiguratorV3.js} +0 -0
- /package/lib/types/{ILendingPool.js → ICreditConfiguratorV3.sol/ICreditConfiguratorV3Events.js} +0 -0
- /package/lib/types/{ILidoV1Adapter.sol/ILidoV1Adapter.js → ICreditConfiguratorV3.sol/index.js} +0 -0
- /package/lib/types/{ILidoV1Adapter.sol/ILidoV1AdapterEvents.js → IDegenDistributor.sol/IDegenDistributor.js} +0 -0
- /package/lib/types/{ILidoV1Adapter.sol/ILidoV1AdapterExceptions.js → IDegenDistributor.sol/IDegenDistributorEvents.js} +0 -0
- /package/lib/types/{IPoolV3.sol/IPoolBase.js → IDegenDistributor.sol/index.js} +0 -0
- /package/lib/types/{draft-IERC20Permit.sol/IERC20Permit.js → IERC20Permit.js} +0 -0
- /package/lib/types/{IRouter.js → IERC20ZapperDeposits.js} +0 -0
- /package/lib/types/{WATokenZapper.js → IETHZapperDeposits.js} +0 -0
- /package/lib/types/{WERC20ZapperBase.js → IGasPricer.js} +0 -0
- /package/lib/types/{WETHZapper.js → IGearStakingV3.sol/IGearStakingV3.js} +0 -0
- /package/lib/types/{WstETHZapper.js → IGearStakingV3.sol/IGearStakingV3Events.js} +0 -0
- /package/lib/types/{ZapperBase.js → IGearStakingV3.sol/index.js} +0 -0
- /package/lib/types/factories/{draft-IERC20Permit.sol/IERC20Permit__factory.js → IERC20Permit__factory.js} +0 -0
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const chai_1 = require("chai");
|
|
4
|
+
const gaugeMath_1 = require("./gaugeMath");
|
|
5
|
+
describe("GaugeMath vote() test", () => {
|
|
6
|
+
it("with empty state and with no changes", () => {
|
|
7
|
+
const s = { available: 0n, voteCalls: [] };
|
|
8
|
+
const v = { state: s };
|
|
9
|
+
const r = gaugeMath_1.GaugeMath.vote(v);
|
|
10
|
+
const res = { ...s, voteCalls: [] };
|
|
11
|
+
(0, chai_1.expect)(r).to.be.eql(res);
|
|
12
|
+
});
|
|
13
|
+
it("remove with no prev vote", () => {
|
|
14
|
+
const s = { available: 0n, voteCalls: [] };
|
|
15
|
+
const v = { state: s, change: { type: "remove", amount: 10n } };
|
|
16
|
+
const r = gaugeMath_1.GaugeMath.vote(v);
|
|
17
|
+
const res = { ...s, voteCalls: [] };
|
|
18
|
+
(0, chai_1.expect)(r).to.be.eql(res);
|
|
19
|
+
});
|
|
20
|
+
it("remove with prev vote - more than available", () => {
|
|
21
|
+
const s = {
|
|
22
|
+
available: 0n,
|
|
23
|
+
vote: { type: "lower", amount: 5n },
|
|
24
|
+
voteCalls: [],
|
|
25
|
+
};
|
|
26
|
+
const v = { state: s, change: { type: "remove", amount: 10n } };
|
|
27
|
+
const r = gaugeMath_1.GaugeMath.vote(v);
|
|
28
|
+
const res = {
|
|
29
|
+
available: 5n,
|
|
30
|
+
vote: { type: "lower", amount: 0n },
|
|
31
|
+
voteCalls: [{ type: "remove", amount: 5n }],
|
|
32
|
+
};
|
|
33
|
+
(0, chai_1.expect)(r).to.be.eql(res);
|
|
34
|
+
});
|
|
35
|
+
it("remove with prev vote - eq than available", () => {
|
|
36
|
+
const s = {
|
|
37
|
+
available: 0n,
|
|
38
|
+
vote: { type: "lower", amount: 5n },
|
|
39
|
+
voteCalls: [],
|
|
40
|
+
};
|
|
41
|
+
const v = { state: s, change: { type: "remove", amount: 5n } };
|
|
42
|
+
const r = gaugeMath_1.GaugeMath.vote(v);
|
|
43
|
+
const res = {
|
|
44
|
+
available: 5n,
|
|
45
|
+
vote: { type: "lower", amount: 0n },
|
|
46
|
+
voteCalls: [{ type: "remove", amount: 5n }],
|
|
47
|
+
};
|
|
48
|
+
(0, chai_1.expect)(r).to.be.eql(res);
|
|
49
|
+
});
|
|
50
|
+
it("remove with prev vote - more than available", () => {
|
|
51
|
+
const s = {
|
|
52
|
+
available: 0n,
|
|
53
|
+
vote: { type: "lower", amount: 10n },
|
|
54
|
+
voteCalls: [],
|
|
55
|
+
};
|
|
56
|
+
const v = { state: s, change: { type: "remove", amount: 5n } };
|
|
57
|
+
const r = gaugeMath_1.GaugeMath.vote(v);
|
|
58
|
+
const res = {
|
|
59
|
+
available: 5n,
|
|
60
|
+
vote: { type: "lower", amount: 5n },
|
|
61
|
+
voteCalls: [{ type: "remove", amount: 5n }],
|
|
62
|
+
};
|
|
63
|
+
(0, chai_1.expect)(r).to.be.eql(res);
|
|
64
|
+
});
|
|
65
|
+
it("add to zero", () => {
|
|
66
|
+
const s = { available: 10n, voteCalls: [] };
|
|
67
|
+
const v = { state: s, change: { type: "lower", amount: 10n } };
|
|
68
|
+
const r = gaugeMath_1.GaugeMath.vote(v);
|
|
69
|
+
const res = {
|
|
70
|
+
available: 0n,
|
|
71
|
+
vote: { type: "lower", amount: 10n },
|
|
72
|
+
voteCalls: [{ type: "lower", amount: 10n }],
|
|
73
|
+
};
|
|
74
|
+
(0, chai_1.expect)(r).to.be.eql(res);
|
|
75
|
+
});
|
|
76
|
+
it("add to same type", () => {
|
|
77
|
+
const s = {
|
|
78
|
+
available: 10n,
|
|
79
|
+
vote: { type: "lower", amount: 5n },
|
|
80
|
+
voteCalls: [],
|
|
81
|
+
};
|
|
82
|
+
const v = { state: s, change: { type: "lower", amount: 10n } };
|
|
83
|
+
const r = gaugeMath_1.GaugeMath.vote(v);
|
|
84
|
+
const res = {
|
|
85
|
+
available: 0n,
|
|
86
|
+
vote: { type: "lower", amount: 15n },
|
|
87
|
+
voteCalls: [{ type: "lower", amount: 10n }],
|
|
88
|
+
};
|
|
89
|
+
(0, chai_1.expect)(r).to.be.eql(res);
|
|
90
|
+
});
|
|
91
|
+
it("add different type", () => {
|
|
92
|
+
const s = {
|
|
93
|
+
available: 10n,
|
|
94
|
+
vote: { type: "lower", amount: 10n },
|
|
95
|
+
voteCalls: [],
|
|
96
|
+
};
|
|
97
|
+
const v = { state: s, change: { type: "raise", amount: 5n } };
|
|
98
|
+
const r = gaugeMath_1.GaugeMath.vote(v);
|
|
99
|
+
const res = {
|
|
100
|
+
available: 15n,
|
|
101
|
+
vote: { type: "raise", amount: 5n },
|
|
102
|
+
voteCalls: [
|
|
103
|
+
{ type: "remove", amount: 10n },
|
|
104
|
+
{ type: "raise", amount: 5n },
|
|
105
|
+
],
|
|
106
|
+
};
|
|
107
|
+
(0, chai_1.expect)(r).to.be.eql(res);
|
|
108
|
+
});
|
|
109
|
+
it("available can be negative after add", () => {
|
|
110
|
+
const s = {
|
|
111
|
+
available: 5n,
|
|
112
|
+
vote: { type: "lower", amount: 5n },
|
|
113
|
+
voteCalls: [],
|
|
114
|
+
};
|
|
115
|
+
const v = { state: s, change: { type: "raise", amount: 15n } };
|
|
116
|
+
const r = gaugeMath_1.GaugeMath.vote(v);
|
|
117
|
+
const res = {
|
|
118
|
+
available: -5n,
|
|
119
|
+
vote: { type: "raise", amount: 15n },
|
|
120
|
+
voteCalls: [
|
|
121
|
+
{ type: "remove", amount: 5n },
|
|
122
|
+
{ type: "raise", amount: 15n },
|
|
123
|
+
],
|
|
124
|
+
};
|
|
125
|
+
(0, chai_1.expect)(r).to.be.eql(res);
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
describe("GaugeMath revertVote() test", () => {
|
|
129
|
+
it("if no votes before & after, should return initial amount", () => {
|
|
130
|
+
const initialBalance = 21n;
|
|
131
|
+
const r = gaugeMath_1.GaugeMath.revertVote({
|
|
132
|
+
balanceAfter: initialBalance,
|
|
133
|
+
nextVoteType: "lower",
|
|
134
|
+
});
|
|
135
|
+
(0, chai_1.expect)(r).to.be.eql(initialBalance);
|
|
136
|
+
});
|
|
137
|
+
it("if no vote after and next expected type is not changed, should return initial amount", () => {
|
|
138
|
+
const initialBalance = 27n;
|
|
139
|
+
const initialVote = {
|
|
140
|
+
type: "lower",
|
|
141
|
+
amount: 99n,
|
|
142
|
+
};
|
|
143
|
+
const r = gaugeMath_1.GaugeMath.revertVote({
|
|
144
|
+
balanceAfter: initialBalance,
|
|
145
|
+
initialVote,
|
|
146
|
+
nextVoteType: "lower",
|
|
147
|
+
});
|
|
148
|
+
(0, chai_1.expect)(r).to.be.eql(initialBalance);
|
|
149
|
+
});
|
|
150
|
+
it("if no vote after and next expected type is changed, should revert initial vote", () => {
|
|
151
|
+
const initialBalance = 27n;
|
|
152
|
+
const initialVote = {
|
|
153
|
+
type: "lower",
|
|
154
|
+
amount: 99n,
|
|
155
|
+
};
|
|
156
|
+
const r = gaugeMath_1.GaugeMath.revertVote({
|
|
157
|
+
balanceAfter: initialBalance,
|
|
158
|
+
initialVote,
|
|
159
|
+
nextVoteType: "raise",
|
|
160
|
+
});
|
|
161
|
+
(0, chai_1.expect)(r).to.be.eql(initialBalance + initialVote.amount);
|
|
162
|
+
});
|
|
163
|
+
it("if no vote before, should revert vote after", () => {
|
|
164
|
+
const initialBalance = 26n;
|
|
165
|
+
const voteBy = 5n;
|
|
166
|
+
const voteAfter = {
|
|
167
|
+
available: initialBalance - voteBy,
|
|
168
|
+
vote: { type: "lower", amount: voteBy },
|
|
169
|
+
voteCalls: [{ type: "lower", amount: voteBy }],
|
|
170
|
+
};
|
|
171
|
+
const balanceAfter = voteAfter.available;
|
|
172
|
+
const r = gaugeMath_1.GaugeMath.revertVote({
|
|
173
|
+
balanceAfter,
|
|
174
|
+
nextVoteType: "lower",
|
|
175
|
+
voteAfter: voteAfter,
|
|
176
|
+
});
|
|
177
|
+
(0, chai_1.expect)(r).to.be.eql(initialBalance);
|
|
178
|
+
});
|
|
179
|
+
it("if vote before type matches expected type, should revert vote after", () => {
|
|
180
|
+
const initialBalance = 10n;
|
|
181
|
+
const voteBy = 6n;
|
|
182
|
+
const initialVote = {
|
|
183
|
+
type: "lower",
|
|
184
|
+
amount: 20n,
|
|
185
|
+
};
|
|
186
|
+
const voteAfter = {
|
|
187
|
+
available: initialBalance - voteBy,
|
|
188
|
+
vote: { type: "lower", amount: initialVote.amount + voteBy },
|
|
189
|
+
voteCalls: [{ type: "lower", amount: voteBy }],
|
|
190
|
+
};
|
|
191
|
+
const balanceAfter = voteAfter.available;
|
|
192
|
+
const r = gaugeMath_1.GaugeMath.revertVote({
|
|
193
|
+
initialVote,
|
|
194
|
+
balanceAfter,
|
|
195
|
+
nextVoteType: "lower",
|
|
196
|
+
voteAfter: voteAfter,
|
|
197
|
+
});
|
|
198
|
+
(0, chai_1.expect)(r).to.be.eql(initialBalance);
|
|
199
|
+
});
|
|
200
|
+
it("if vote before type doesn't match expected type, should revert vote before", () => {
|
|
201
|
+
const initialBalance = 10n;
|
|
202
|
+
const voteBy = 20n;
|
|
203
|
+
const initialVote = {
|
|
204
|
+
type: "raise",
|
|
205
|
+
amount: 61n,
|
|
206
|
+
};
|
|
207
|
+
const voteAfter = {
|
|
208
|
+
available: initialBalance + initialVote.amount - voteBy,
|
|
209
|
+
vote: { type: "lower", amount: voteBy },
|
|
210
|
+
voteCalls: [
|
|
211
|
+
{ type: "remove", amount: initialVote.amount },
|
|
212
|
+
{ type: "lower", amount: voteBy },
|
|
213
|
+
],
|
|
214
|
+
};
|
|
215
|
+
const r = gaugeMath_1.GaugeMath.revertVote({
|
|
216
|
+
initialVote,
|
|
217
|
+
balanceAfter: voteAfter.available,
|
|
218
|
+
nextVoteType: "lower",
|
|
219
|
+
voteAfter: voteAfter,
|
|
220
|
+
});
|
|
221
|
+
(0, chai_1.expect)(r).to.be.eql(initialBalance + initialVote.amount);
|
|
222
|
+
});
|
|
223
|
+
it("on remove, if vote before type matches expected type, should revert removal", () => {
|
|
224
|
+
const initialBalance = 100n;
|
|
225
|
+
const voteBy = 13n;
|
|
226
|
+
const initialVote = {
|
|
227
|
+
type: "lower",
|
|
228
|
+
amount: 30n,
|
|
229
|
+
};
|
|
230
|
+
const voteAfter = {
|
|
231
|
+
available: initialBalance + voteBy,
|
|
232
|
+
vote: { type: "lower", amount: initialVote.amount - voteBy },
|
|
233
|
+
voteCalls: [{ type: "remove", amount: voteBy }],
|
|
234
|
+
};
|
|
235
|
+
const r = gaugeMath_1.GaugeMath.revertVote({
|
|
236
|
+
initialVote,
|
|
237
|
+
balanceAfter: voteAfter.available,
|
|
238
|
+
nextVoteType: "lower",
|
|
239
|
+
voteAfter: voteAfter,
|
|
240
|
+
});
|
|
241
|
+
(0, chai_1.expect)(r).to.be.eql(initialBalance);
|
|
242
|
+
});
|
|
243
|
+
it("on remove, if vote before type doesn't match expected type, should revert vote before", () => {
|
|
244
|
+
const initialBalance = 100n;
|
|
245
|
+
const voteBy = 13n;
|
|
246
|
+
const initialVote = {
|
|
247
|
+
type: "raise",
|
|
248
|
+
amount: 30n,
|
|
249
|
+
};
|
|
250
|
+
const voteAfter = {
|
|
251
|
+
available: initialBalance + voteBy,
|
|
252
|
+
vote: { type: "raise", amount: initialVote.amount - voteBy },
|
|
253
|
+
voteCalls: [{ type: "remove", amount: voteBy }],
|
|
254
|
+
};
|
|
255
|
+
const r = gaugeMath_1.GaugeMath.revertVote({
|
|
256
|
+
initialVote,
|
|
257
|
+
balanceAfter: voteAfter.available,
|
|
258
|
+
nextVoteType: "lower",
|
|
259
|
+
voteAfter: voteAfter,
|
|
260
|
+
});
|
|
261
|
+
(0, chai_1.expect)(r).to.be.eql(initialBalance + initialVote.amount);
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
describe("GaugeMath getGaugeApy() test", () => {
|
|
265
|
+
it("should return null if no quota", () => {
|
|
266
|
+
const vote = { amount: 0n, type: "lower" };
|
|
267
|
+
const voteAfter = {
|
|
268
|
+
vote: { amount: 5n, type: "lower" },
|
|
269
|
+
voteCalls: [{ amount: 5n, type: "lower" }],
|
|
270
|
+
};
|
|
271
|
+
const r = gaugeMath_1.GaugeMath.getGaugeApy({
|
|
272
|
+
quota: undefined,
|
|
273
|
+
vote,
|
|
274
|
+
voteAfter,
|
|
275
|
+
});
|
|
276
|
+
(0, chai_1.expect)(r).to.be.eql(null);
|
|
277
|
+
});
|
|
278
|
+
it("should return min rate if total is zero", () => {
|
|
279
|
+
const quota = {
|
|
280
|
+
totalVotesCaSide: 0n,
|
|
281
|
+
totalVotesLpSide: 0n,
|
|
282
|
+
stakerVotesCaSide: 0n,
|
|
283
|
+
stakerVotesLpSide: 0n,
|
|
284
|
+
minRate: 12,
|
|
285
|
+
maxRate: 12345,
|
|
286
|
+
};
|
|
287
|
+
const r = gaugeMath_1.GaugeMath.getGaugeApy({
|
|
288
|
+
quota,
|
|
289
|
+
});
|
|
290
|
+
(0, chai_1.expect)(r).to.be.eql(12);
|
|
291
|
+
});
|
|
292
|
+
it("should calculate quota without votes", () => {
|
|
293
|
+
const quota = {
|
|
294
|
+
totalVotesCaSide: 100n,
|
|
295
|
+
totalVotesLpSide: 100n,
|
|
296
|
+
stakerVotesCaSide: 10n,
|
|
297
|
+
stakerVotesLpSide: 0n,
|
|
298
|
+
minRate: 0,
|
|
299
|
+
maxRate: 10000,
|
|
300
|
+
};
|
|
301
|
+
const r = gaugeMath_1.GaugeMath.getGaugeApy({
|
|
302
|
+
quota,
|
|
303
|
+
});
|
|
304
|
+
(0, chai_1.expect)(r).to.be.eql(5000);
|
|
305
|
+
});
|
|
306
|
+
it("should calculate quota with prev vote", () => {
|
|
307
|
+
const quota = {
|
|
308
|
+
totalVotesCaSide: 100n,
|
|
309
|
+
totalVotesLpSide: 100n,
|
|
310
|
+
stakerVotesCaSide: 10n,
|
|
311
|
+
stakerVotesLpSide: 0n,
|
|
312
|
+
minRate: 0,
|
|
313
|
+
maxRate: 10000,
|
|
314
|
+
};
|
|
315
|
+
const vote = { amount: 10n, type: "lower" };
|
|
316
|
+
const r = gaugeMath_1.GaugeMath.getGaugeApy({
|
|
317
|
+
quota,
|
|
318
|
+
vote,
|
|
319
|
+
});
|
|
320
|
+
(0, chai_1.expect)(r).to.be.eql(5000);
|
|
321
|
+
});
|
|
322
|
+
it("should calculate quota with same vote increase", () => {
|
|
323
|
+
const quota = {
|
|
324
|
+
totalVotesCaSide: 100n,
|
|
325
|
+
totalVotesLpSide: 100n,
|
|
326
|
+
stakerVotesCaSide: 10n,
|
|
327
|
+
stakerVotesLpSide: 0n,
|
|
328
|
+
minRate: 0,
|
|
329
|
+
maxRate: 10000,
|
|
330
|
+
};
|
|
331
|
+
const vote = { amount: 10n, type: "lower" };
|
|
332
|
+
const voteAfter = {
|
|
333
|
+
vote: { amount: 20n, type: "lower" },
|
|
334
|
+
voteCalls: [{ amount: 10n, type: "lower" }],
|
|
335
|
+
};
|
|
336
|
+
const r = gaugeMath_1.GaugeMath.getGaugeApy({
|
|
337
|
+
quota,
|
|
338
|
+
vote,
|
|
339
|
+
voteAfter,
|
|
340
|
+
});
|
|
341
|
+
(0, chai_1.expect)(r).to.be.eql(4761);
|
|
342
|
+
});
|
|
343
|
+
it("should calculate quota with different vote increase", () => {
|
|
344
|
+
const quota = {
|
|
345
|
+
totalVotesCaSide: 100n,
|
|
346
|
+
totalVotesLpSide: 100n,
|
|
347
|
+
stakerVotesCaSide: 20n,
|
|
348
|
+
stakerVotesLpSide: 0n,
|
|
349
|
+
minRate: 0,
|
|
350
|
+
maxRate: 10000,
|
|
351
|
+
};
|
|
352
|
+
const vote = { amount: 30n, type: "lower" };
|
|
353
|
+
const voteAfter = {
|
|
354
|
+
vote: { amount: 20n, type: "raise" },
|
|
355
|
+
voteCalls: [
|
|
356
|
+
{ amount: 30n, type: "remove" },
|
|
357
|
+
{ amount: 20n, type: "raise" },
|
|
358
|
+
],
|
|
359
|
+
};
|
|
360
|
+
const r = gaugeMath_1.GaugeMath.getGaugeApy({
|
|
361
|
+
quota,
|
|
362
|
+
vote,
|
|
363
|
+
voteAfter,
|
|
364
|
+
});
|
|
365
|
+
(0, chai_1.expect)(r).to.be.eql(6315);
|
|
366
|
+
});
|
|
367
|
+
it("should calculate quota with vote remove", () => {
|
|
368
|
+
const quota = {
|
|
369
|
+
totalVotesCaSide: 100n,
|
|
370
|
+
totalVotesLpSide: 100n,
|
|
371
|
+
stakerVotesCaSide: 20n,
|
|
372
|
+
stakerVotesLpSide: 0n,
|
|
373
|
+
minRate: 0,
|
|
374
|
+
maxRate: 10000,
|
|
375
|
+
};
|
|
376
|
+
const vote = { amount: 20n, type: "lower" };
|
|
377
|
+
const voteAfter = {
|
|
378
|
+
vote: { amount: 0n, type: "lower" },
|
|
379
|
+
voteCalls: [{ amount: 20n, type: "remove" }],
|
|
380
|
+
};
|
|
381
|
+
const r = gaugeMath_1.GaugeMath.getGaugeApy({
|
|
382
|
+
quota,
|
|
383
|
+
vote,
|
|
384
|
+
voteAfter,
|
|
385
|
+
});
|
|
386
|
+
(0, chai_1.expect)(r).to.be.eql(5555);
|
|
387
|
+
});
|
|
388
|
+
});
|
|
@@ -1,35 +1,43 @@
|
|
|
1
1
|
import { providers, Signer } from "ethers";
|
|
2
|
-
import { CreditManagerDebtParams, QuotaInfo } from "
|
|
3
|
-
import { ChartsPoolDataPayload, LinearModel, PoolDataPayload, UserPoolPayload } from "
|
|
4
|
-
import { IPoolService } from "
|
|
2
|
+
import { CreditManagerDebtParams, QuotaInfo } from "../payload/creditManager";
|
|
3
|
+
import { ChartsPoolDataPayload, LinearModel, PoolDataPayload, PoolZapper, UserPoolPayload } from "../payload/pool";
|
|
4
|
+
import { IPoolService, IPoolV3 } from "../types";
|
|
5
|
+
export type PoolType = "universal" | "trade" | "farm";
|
|
5
6
|
export declare class PoolData {
|
|
6
7
|
readonly address: string;
|
|
8
|
+
readonly type: PoolType;
|
|
7
9
|
readonly underlyingToken: string;
|
|
8
10
|
readonly dieselToken: string;
|
|
9
|
-
readonly isWETH: boolean;
|
|
10
|
-
readonly isWSTETH: boolean;
|
|
11
11
|
readonly isPaused: boolean;
|
|
12
12
|
readonly version: number;
|
|
13
|
+
readonly poolQuotaKeeper: string;
|
|
14
|
+
readonly gauge: string;
|
|
15
|
+
readonly name: string;
|
|
16
|
+
readonly symbol: string;
|
|
13
17
|
readonly expectedLiquidity: bigint;
|
|
14
18
|
readonly expectedLiquidityLimit: bigint;
|
|
15
19
|
readonly availableLiquidity: bigint;
|
|
16
|
-
readonly
|
|
20
|
+
readonly baseInterestIndex: bigint;
|
|
17
21
|
readonly totalBorrowed: bigint;
|
|
18
22
|
readonly totalDebtLimit: bigint;
|
|
19
|
-
readonly creditManagerDebtParams:
|
|
20
|
-
readonly quotas:
|
|
23
|
+
readonly creditManagerDebtParams: Record<string, CreditManagerDebtParams>;
|
|
24
|
+
readonly quotas: Record<string, QuotaInfo>;
|
|
25
|
+
readonly zappers: Record<string, Record<string, PoolZapper>>;
|
|
21
26
|
readonly totalAssets: bigint;
|
|
22
27
|
readonly totalSupply: bigint;
|
|
28
|
+
readonly supplyAPY7D: number | undefined;
|
|
23
29
|
readonly depositAPY: number;
|
|
24
30
|
readonly borrowAPY: number;
|
|
25
31
|
readonly interestModel: LinearModel;
|
|
26
32
|
readonly dieselRate: number;
|
|
27
33
|
readonly dieselRateRay: bigint;
|
|
28
34
|
readonly withdrawFee: number;
|
|
29
|
-
readonly
|
|
35
|
+
readonly lastBaseInterestUpdate: bigint;
|
|
30
36
|
constructor(payload: PoolDataPayload);
|
|
31
|
-
|
|
37
|
+
getPoolContractV1(signer: Signer): IPoolService;
|
|
38
|
+
getPoolContractV3(signer: Signer): IPoolV3;
|
|
32
39
|
calculateBorrowRate({ provider, expectedLiquidity, availableLiquidity, }: CalculateBorrowRateProps): Promise<import("ethers").BigNumber>;
|
|
40
|
+
static getPoolType(name: string): PoolType;
|
|
33
41
|
}
|
|
34
42
|
interface CalculateBorrowRateProps {
|
|
35
43
|
provider: providers.Provider;
|
|
@@ -2,68 +2,100 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UserPoolData = exports.ChartsPoolData = exports.PoolData = void 0;
|
|
4
4
|
const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
|
|
5
|
-
const types_1 = require("
|
|
6
|
-
const formatter_1 = require("
|
|
5
|
+
const types_1 = require("../types");
|
|
6
|
+
const formatter_1 = require("../utils/formatter");
|
|
7
7
|
class PoolData {
|
|
8
8
|
address;
|
|
9
|
+
type;
|
|
9
10
|
underlyingToken;
|
|
10
11
|
dieselToken;
|
|
11
|
-
isWETH;
|
|
12
|
-
isWSTETH;
|
|
13
12
|
isPaused;
|
|
14
13
|
version;
|
|
14
|
+
poolQuotaKeeper;
|
|
15
|
+
gauge;
|
|
16
|
+
name;
|
|
17
|
+
symbol;
|
|
15
18
|
// Information
|
|
16
19
|
expectedLiquidity;
|
|
17
20
|
expectedLiquidityLimit;
|
|
18
21
|
availableLiquidity;
|
|
19
|
-
|
|
22
|
+
baseInterestIndex;
|
|
20
23
|
totalBorrowed;
|
|
21
24
|
totalDebtLimit;
|
|
22
25
|
creditManagerDebtParams;
|
|
23
26
|
quotas;
|
|
27
|
+
zappers;
|
|
24
28
|
totalAssets;
|
|
25
29
|
totalSupply;
|
|
30
|
+
supplyAPY7D;
|
|
26
31
|
depositAPY;
|
|
27
32
|
borrowAPY;
|
|
28
33
|
interestModel;
|
|
29
34
|
dieselRate;
|
|
30
35
|
dieselRateRay;
|
|
31
36
|
withdrawFee;
|
|
32
|
-
|
|
37
|
+
lastBaseInterestUpdate;
|
|
33
38
|
constructor(payload) {
|
|
34
39
|
this.address = payload.addr.toLowerCase();
|
|
35
|
-
|
|
40
|
+
this.type = PoolData.getPoolType(payload.name || "");
|
|
36
41
|
this.underlyingToken = payload.underlying.toLowerCase();
|
|
37
42
|
this.dieselToken = payload.dieselToken.toLowerCase();
|
|
38
|
-
this.isWETH = sdk_gov_1.tokenSymbolByAddress[underlying] === "WETH";
|
|
39
|
-
this.isWSTETH = sdk_gov_1.tokenSymbolByAddress[underlying] === "wstETH";
|
|
40
43
|
this.isPaused = payload.isPaused;
|
|
41
44
|
this.version = payload.version.toNumber();
|
|
45
|
+
this.poolQuotaKeeper = payload.poolQuotaKeeper.toLowerCase();
|
|
46
|
+
this.gauge = payload.gauge.toLowerCase();
|
|
47
|
+
this.name = payload.name;
|
|
48
|
+
this.symbol = payload.symbol;
|
|
42
49
|
this.expectedLiquidity = (0, sdk_gov_1.toBigInt)(payload.expectedLiquidity);
|
|
43
50
|
this.availableLiquidity = (0, sdk_gov_1.toBigInt)(payload.availableLiquidity);
|
|
44
51
|
this.expectedLiquidityLimit =
|
|
45
52
|
this.expectedLiquidity + this.availableLiquidity;
|
|
46
|
-
this.
|
|
53
|
+
this.baseInterestIndex = (0, sdk_gov_1.toBigInt)(payload.baseInterestIndex);
|
|
47
54
|
this.totalBorrowed = (0, sdk_gov_1.toBigInt)(payload.totalBorrowed);
|
|
48
55
|
this.totalDebtLimit = (0, sdk_gov_1.toBigInt)(payload.totalDebtLimit);
|
|
49
|
-
this.creditManagerDebtParams = payload.creditManagerDebtParams.map(p =>
|
|
50
|
-
creditManager
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
56
|
+
this.creditManagerDebtParams = Object.fromEntries(payload.creditManagerDebtParams.map(p => {
|
|
57
|
+
const creditManager = p.creditManager.toLowerCase();
|
|
58
|
+
return [
|
|
59
|
+
creditManager,
|
|
60
|
+
{
|
|
61
|
+
creditManager,
|
|
62
|
+
borrowed: (0, sdk_gov_1.toBigInt)(p.borrowed),
|
|
63
|
+
limit: (0, sdk_gov_1.toBigInt)(p.limit),
|
|
64
|
+
availableToBorrow: (0, sdk_gov_1.toBigInt)(p.availableToBorrow),
|
|
65
|
+
},
|
|
66
|
+
];
|
|
54
67
|
}));
|
|
55
|
-
this.quotas = payload.quotas.map(q =>
|
|
56
|
-
token
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
68
|
+
this.quotas = Object.fromEntries(payload.quotas.map(q => {
|
|
69
|
+
const token = q.token.toLowerCase();
|
|
70
|
+
return [
|
|
71
|
+
token,
|
|
72
|
+
{
|
|
73
|
+
token,
|
|
74
|
+
rate: Number((0, sdk_gov_1.toBigInt)(q.rate) * sdk_gov_1.PERCENTAGE_DECIMALS),
|
|
75
|
+
quotaIncreaseFee: q.quotaIncreaseFee,
|
|
76
|
+
totalQuoted: (0, sdk_gov_1.toBigInt)(q.totalQuoted),
|
|
77
|
+
limit: (0, sdk_gov_1.toBigInt)(q.limit),
|
|
78
|
+
isActive: q.isActive,
|
|
79
|
+
},
|
|
80
|
+
];
|
|
62
81
|
}));
|
|
82
|
+
this.zappers = payload.zappers.reduce((acc, z) => {
|
|
83
|
+
const tokenIn = z.tokenIn.toLowerCase();
|
|
84
|
+
const tokenOut = z.tokenOut.toLowerCase();
|
|
85
|
+
const old = acc[tokenIn] || {};
|
|
86
|
+
return {
|
|
87
|
+
...acc,
|
|
88
|
+
[tokenIn]: {
|
|
89
|
+
...old,
|
|
90
|
+
[tokenOut]: { tokenIn, tokenOut, zapper: z.zapper.toLowerCase() },
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
}, {});
|
|
63
94
|
this.totalAssets = (0, sdk_gov_1.toBigInt)(payload.totalAssets);
|
|
64
95
|
this.totalSupply = (0, sdk_gov_1.toBigInt)(payload.totalSupply);
|
|
65
96
|
this.depositAPY = (0, formatter_1.rayToNumber)((0, sdk_gov_1.toBigInt)(payload.supplyRate) * sdk_gov_1.PERCENTAGE_DECIMALS);
|
|
66
97
|
this.borrowAPY = (0, formatter_1.rayToNumber)((0, sdk_gov_1.toBigInt)(payload.baseInterestRate) * sdk_gov_1.PERCENTAGE_DECIMALS);
|
|
98
|
+
this.supplyAPY7D = payload.supplyAPY7D;
|
|
67
99
|
this.interestModel = {
|
|
68
100
|
interestModel: payload.lirm.interestModel.toLowerCase(),
|
|
69
101
|
U_1: payload.lirm.U_1,
|
|
@@ -73,20 +105,33 @@ class PoolData {
|
|
|
73
105
|
R_slope2: payload.lirm.R_slope2,
|
|
74
106
|
R_slope3: payload.lirm.R_slope3,
|
|
75
107
|
version: payload?.lirm?.version?.toNumber(),
|
|
108
|
+
isBorrowingMoreU2Forbidden: payload?.lirm?.isBorrowingMoreU2Forbidden,
|
|
76
109
|
};
|
|
77
110
|
this.dieselRate = (0, formatter_1.rayToNumber)(payload.dieselRate_RAY);
|
|
78
111
|
this.dieselRateRay = (0, sdk_gov_1.toBigInt)(payload.dieselRate_RAY);
|
|
79
|
-
this.
|
|
112
|
+
this.lastBaseInterestUpdate = (0, sdk_gov_1.toBigInt)(payload.lastBaseInterestUpdate);
|
|
80
113
|
this.withdrawFee =
|
|
81
114
|
Number((0, sdk_gov_1.toBigInt)(payload.withdrawFee)) / Number(sdk_gov_1.PERCENTAGE_DECIMALS);
|
|
82
115
|
}
|
|
83
|
-
|
|
116
|
+
getPoolContractV1(signer) {
|
|
84
117
|
return types_1.IPoolService__factory.connect(this.address, signer);
|
|
85
118
|
}
|
|
119
|
+
getPoolContractV3(signer) {
|
|
120
|
+
return types_1.IPoolV3__factory.connect(this.address, signer);
|
|
121
|
+
}
|
|
86
122
|
async calculateBorrowRate({ provider, expectedLiquidity, availableLiquidity, }) {
|
|
87
123
|
const model = types_1.IInterestRateModel__factory.connect(this.interestModel.interestModel, provider);
|
|
88
124
|
return model.calcBorrowRate(expectedLiquidity, availableLiquidity);
|
|
89
125
|
}
|
|
126
|
+
static getPoolType(name) {
|
|
127
|
+
const [identity = ""] = name.split(" ") || [];
|
|
128
|
+
const lc = identity.toLowerCase();
|
|
129
|
+
if (lc === "farm")
|
|
130
|
+
return "farm";
|
|
131
|
+
if (lc === "trade")
|
|
132
|
+
return "trade";
|
|
133
|
+
return "universal";
|
|
134
|
+
}
|
|
90
135
|
}
|
|
91
136
|
exports.PoolData = PoolData;
|
|
92
137
|
class ChartsPoolData {
|
package/lib/core/strategy.js
CHANGED
package/lib/core/trade.d.ts
CHANGED
|
@@ -1,26 +1,12 @@
|
|
|
1
1
|
import { SupportedContract } from "@gearbox-protocol/sdk-gov";
|
|
2
|
-
import { Signer } from "ethers";
|
|
3
2
|
import { MultiCall, PathFinderResult, SwapOperation } from "../pathfinder/core";
|
|
4
|
-
import { ICreditFacadeV2 } from "../types";
|
|
5
3
|
import { CreditManagerData } from "./creditManager";
|
|
6
|
-
import { EVMTx } from "./eventOrTx";
|
|
7
4
|
interface Info {
|
|
8
5
|
name: string;
|
|
9
6
|
contractAddress: string;
|
|
10
7
|
creditManager: string;
|
|
11
8
|
}
|
|
12
|
-
export
|
|
13
|
-
adapter: Info;
|
|
14
|
-
tradePath: PathFinderResult;
|
|
15
|
-
creditFacade: string;
|
|
16
|
-
tokenFrom: string;
|
|
17
|
-
tokenTo: string;
|
|
18
|
-
sourceAmount: bigint;
|
|
19
|
-
expectedAmount: bigint;
|
|
20
|
-
swapType: SwapOperation;
|
|
21
|
-
swapName: TradeOperations;
|
|
22
|
-
}
|
|
23
|
-
export type TradeOperations = "farmWithdraw" | "farmDeposit" | "swap" | "unknownOperation";
|
|
9
|
+
export type TradeOperations = "farmWithdraw" | "farmDeposit" | "swap";
|
|
24
10
|
export interface GetTradesProps {
|
|
25
11
|
from: string;
|
|
26
12
|
to: string;
|
|
@@ -28,11 +14,12 @@ export interface GetTradesProps {
|
|
|
28
14
|
results: Array<PathFinderResult>;
|
|
29
15
|
creditManager: CreditManagerData;
|
|
30
16
|
currentContracts: Record<SupportedContract, string>;
|
|
17
|
+
swapType: SwapOperation;
|
|
18
|
+
swapName: TradeOperations;
|
|
31
19
|
}
|
|
32
20
|
export declare class Trade {
|
|
33
21
|
readonly helper: Info;
|
|
34
22
|
readonly tradePath: PathFinderResult;
|
|
35
|
-
readonly creditFacade: string;
|
|
36
23
|
readonly swapType: SwapOperation;
|
|
37
24
|
readonly sourceAmount: bigint;
|
|
38
25
|
readonly expectedAmount: bigint;
|
|
@@ -40,17 +27,12 @@ export declare class Trade {
|
|
|
40
27
|
readonly tokenFrom: string;
|
|
41
28
|
readonly tokenTo: string;
|
|
42
29
|
readonly operationName: TradeOperations;
|
|
43
|
-
constructor(
|
|
30
|
+
private constructor();
|
|
44
31
|
getName(): string;
|
|
45
|
-
execute(signer: Signer): Promise<EVMTx>;
|
|
46
32
|
toString(): string;
|
|
47
|
-
static getTrades({ from, to, amount, results, creditManager, currentContracts, }: GetTradesProps): Trade[];
|
|
48
|
-
static getOperationName(tokenInAddress: string, tokenOutAddress: string): TradeOperations;
|
|
33
|
+
static getTrades({ from, to, amount, results, creditManager, currentContracts, swapType, swapName, }: GetTradesProps): Trade[];
|
|
49
34
|
static getCallInfo(calls: Array<MultiCall>, creditManager: string, currentContracts: Record<SupportedContract, string>): Info[];
|
|
50
35
|
private static getContractSymbol;
|
|
51
|
-
static getTradeId(trade: Trade): string;
|
|
52
36
|
static sortTrades(trades: Array<Trade>, swapStrategy: string): Trade[];
|
|
53
|
-
static executeMulticallPath(creditFacade: string | ICreditFacadeV2, signer: Signer, calls: Array<MultiCall>): Promise<import("ethers").ContractTransaction>;
|
|
54
|
-
private static executeOnCreditFacade;
|
|
55
37
|
}
|
|
56
38
|
export {};
|