@gearbox-protocol/sdk 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.idea/gearbox-sdk.iml +12 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/.prettierrc +10 -0
- package/README.md +4 -0
- package/lib/config.d.ts +1 -0
- package/lib/config.js +4 -0
- package/lib/core/constants.d.ts +17 -0
- package/lib/core/constants.js +36 -0
- package/lib/core/contracts.d.ts +64 -0
- package/lib/core/contracts.js +104 -0
- package/lib/core/contractsRegister.d.ts +2 -0
- package/lib/core/contractsRegister.js +43 -0
- package/lib/core/creditAccount.d.ts +35 -0
- package/lib/core/creditAccount.js +98 -0
- package/lib/core/creditCard.d.ts +13 -0
- package/lib/core/creditCard.js +2 -0
- package/lib/core/creditManager.d.ts +37 -0
- package/lib/core/creditManager.js +118 -0
- package/lib/core/creditOperation.d.ts +9 -0
- package/lib/core/creditOperation.js +2 -0
- package/lib/core/creditSession.d.ts +26 -0
- package/lib/core/creditSession.js +44 -0
- package/lib/core/errors.d.ts +26 -0
- package/lib/core/errors.js +74 -0
- package/lib/core/event.d.ts +42 -0
- package/lib/core/event.js +2 -0
- package/lib/core/eventOrTx.d.ts +36 -0
- package/lib/core/eventOrTx.js +97 -0
- package/lib/core/events.d.ts +369 -0
- package/lib/core/events.js +730 -0
- package/lib/core/history.d.ts +42 -0
- package/lib/core/history.js +2 -0
- package/lib/core/operations.d.ts +22 -0
- package/lib/core/operations.js +20 -0
- package/lib/core/oracles.d.ts +6 -0
- package/lib/core/oracles.js +2 -0
- package/lib/core/pool.d.ts +28 -0
- package/lib/core/pool.js +32 -0
- package/lib/core/swap.d.ts +4 -0
- package/lib/core/swap.js +8 -0
- package/lib/core/token.d.ts +3 -0
- package/lib/core/token.js +229 -0
- package/lib/core/tokenData.d.ts +28 -0
- package/lib/core/tokenData.js +58 -0
- package/lib/core/tokenDistributor.d.ts +12 -0
- package/lib/core/tokenDistributor.js +9 -0
- package/lib/core/trade.d.ts +35 -0
- package/lib/core/trade.js +62 -0
- package/lib/core/transactions.d.ts +127 -0
- package/lib/core/transactions.js +306 -0
- package/lib/index.d.ts +33 -0
- package/lib/index.js +47 -0
- package/lib/payload/creditAccount.d.ts +26 -0
- package/lib/payload/creditAccount.js +2 -0
- package/lib/payload/creditManager.d.ts +43 -0
- package/lib/payload/creditManager.js +2 -0
- package/lib/payload/creditSession.d.ts +23 -0
- package/lib/payload/creditSession.js +2 -0
- package/lib/payload/graphPayload.d.ts +9 -0
- package/lib/payload/graphPayload.js +2 -0
- package/lib/payload/pool.d.ts +17 -0
- package/lib/payload/pool.js +3 -0
- package/lib/payload/token.d.ts +5 -0
- package/lib/payload/token.js +2 -0
- package/lib/types/ACL.d.ts +491 -0
- package/lib/types/ACLTrait.d.ts +148 -0
- package/lib/types/ACLTraitTest.d.ts +209 -0
- package/lib/types/AbstractAccountMiner.d.ts +143 -0
- package/lib/types/AccountFactory.d.ts +716 -0
- package/lib/types/AccountMinerAuction.d.ts +391 -0
- package/lib/types/AccountMinerMock.d.ts +241 -0
- package/lib/types/AccountMinerNonReceivableTest.d.ts +127 -0
- package/lib/types/AccountMinerOwnFunds.d.ts +218 -0
- package/lib/types/AccountMining.d.ts +222 -0
- package/lib/types/AdaptersDeployer.d.ts +262 -0
- package/lib/types/AddressProvider.d.ts +912 -0
- package/lib/types/AggregatorV3Interface.d.ts +234 -0
- package/lib/types/ChainlinkPriceFeedMock.d.ts +215 -0
- package/lib/types/ContractsRegister.d.ts +398 -0
- package/lib/types/CoreDeployer.d.ts +394 -0
- package/lib/types/CreditAccount.d.ts +443 -0
- package/lib/types/CreditFilter.d.ts +1609 -0
- package/lib/types/CreditFilterMock.d.ts +1687 -0
- package/lib/types/CreditManager.d.ts +1285 -0
- package/lib/types/CreditManagerMockForFilter.d.ts +605 -0
- package/lib/types/CreditManagerMockForPoolTest.d.ts +204 -0
- package/lib/types/CurveMock.d.ts +298 -0
- package/lib/types/CurveV1Adapter.d.ts +349 -0
- package/lib/types/DataCompressor.d.ts +1331 -0
- package/lib/types/Deployer.d.ts +224 -0
- package/lib/types/DieselToken.d.ts +567 -0
- package/lib/types/ERC165.d.ts +116 -0
- package/lib/types/ERC20.d.ts +411 -0
- package/lib/types/ERC20BlockingMock.d.ts +568 -0
- package/lib/types/ERC721.d.ts +625 -0
- package/lib/types/Errors.d.ts +1854 -0
- package/lib/types/ExecutorMock.d.ts +140 -0
- package/lib/types/FlashLoanAttacker.d.ts +170 -0
- package/lib/types/FuzzHarness.d.ts +124 -0
- package/lib/types/GearBeta.d.ts +745 -0
- package/lib/types/GearToken.d.ts +888 -0
- package/lib/types/GenesisDeployer.d.ts +282 -0
- package/lib/types/IAccountFactory.d.ts +317 -0
- package/lib/types/IAccountMiner.d.ts +124 -0
- package/lib/types/IAppAddressProvider.d.ts +198 -0
- package/lib/types/IAppCreditManager.d.ts +408 -0
- package/lib/types/IAppERC20.d.ts +309 -0
- package/lib/types/IAppPoolService.d.ts +166 -0
- package/lib/types/ICreditAccount.d.ts +430 -0
- package/lib/types/ICreditAccountData.d.ts +347 -0
- package/lib/types/ICreditFilter.d.ts +1162 -0
- package/lib/types/ICreditManager.d.ts +971 -0
- package/lib/types/ICurvePool.d.ts +298 -0
- package/lib/types/IDataCompressor.d.ts +1231 -0
- package/lib/types/IERC165.d.ts +116 -0
- package/lib/types/IERC20.d.ts +294 -0
- package/lib/types/IERC721.d.ts +472 -0
- package/lib/types/IERC721Enumerable.d.ts +564 -0
- package/lib/types/IERC721Metadata.d.ts +523 -0
- package/lib/types/IERC721Receiver.d.ts +132 -0
- package/lib/types/IGearToken.d.ts +527 -0
- package/lib/types/IInterestRateModel.d.ts +121 -0
- package/lib/types/IMerkleDistributor.d.ts +190 -0
- package/lib/types/IPoolService.d.ts +772 -0
- package/lib/types/IPriceOracle.d.ts +211 -0
- package/lib/types/IQuoter.d.ts +269 -0
- package/lib/types/ISwapRouter.d.ts +404 -0
- package/lib/types/IUniswapV2Migrator.d.ts +134 -0
- package/lib/types/IUniswapV2Router01.d.ts +1119 -0
- package/lib/types/IUniswapV2Router02.d.ts +1432 -0
- package/lib/types/IUniswapV3SwapCallback.d.ts +127 -0
- package/lib/types/IWETH.d.ts +169 -0
- package/lib/types/IWETHGateway.d.ts +335 -0
- package/lib/types/IYVault.d.ts +558 -0
- package/lib/types/LeveragedActions.d.ts +772 -0
- package/lib/types/LinearInterestRateModel.d.ts +279 -0
- package/lib/types/MockPoolService.d.ts +1271 -0
- package/lib/types/Multicall2.d.ts +449 -0
- package/lib/types/Ownable.d.ts +169 -0
- package/lib/types/PathFinder.d.ts +379 -0
- package/lib/types/Pausable.d.ts +105 -0
- package/lib/types/PercentageMathTest.d.ts +154 -0
- package/lib/types/PoolDeployer.d.ts +282 -0
- package/lib/types/PoolService.d.ts +1174 -0
- package/lib/types/PriceOracle.d.ts +387 -0
- package/lib/types/Proxy.d.ts +78 -0
- package/lib/types/StepVesting.d.ts +411 -0
- package/lib/types/TestPoolService.d.ts +1294 -0
- package/lib/types/TokenDistributor.d.ts +640 -0
- package/lib/types/TokenFeeMock.d.ts +544 -0
- package/lib/types/TokenMock.d.ts +531 -0
- package/lib/types/TreasuryMock.d.ts +86 -0
- package/lib/types/UniswapRouterMock.d.ts +1520 -0
- package/lib/types/UniswapV2Adapter.d.ts +1463 -0
- package/lib/types/UniswapV3Adapter.d.ts +455 -0
- package/lib/types/VestingDeployer.d.ts +247 -0
- package/lib/types/WETHGateway.d.ts +376 -0
- package/lib/types/WETHMock.d.ts +433 -0
- package/lib/types/WadRayMathTest.d.ts +316 -0
- package/lib/types/YearnAdapter.d.ts +609 -0
- package/lib/types/YearnMock.d.ts +795 -0
- package/lib/types/YearnPriceFeed.d.ts +399 -0
- package/lib/types/commons.d.ts +16 -0
- package/lib/types/commons.js +5 -0
- package/lib/types/factories/ACLTraitTest__factory.d.ts +52 -0
- package/lib/types/factories/ACLTraitTest__factory.js +138 -0
- package/lib/types/factories/ACLTrait__factory.d.ts +31 -0
- package/lib/types/factories/ACLTrait__factory.js +75 -0
- package/lib/types/factories/ACL__factory.d.ts +45 -0
- package/lib/types/factories/ACL__factory.js +317 -0
- package/lib/types/factories/AbstractAccountMiner__factory.d.ts +30 -0
- package/lib/types/factories/AbstractAccountMiner__factory.js +61 -0
- package/lib/types/factories/AccountFactory__factory.d.ts +72 -0
- package/lib/types/factories/AccountFactory__factory.js +508 -0
- package/lib/types/factories/AccountMinerAuction__factory.js +304 -0
- package/lib/types/factories/AccountMinerMock__factory.js +196 -0
- package/lib/types/factories/AccountMinerNonReceivableTest__factory.js +84 -0
- package/lib/types/factories/AccountMinerOwnFunds__factory.js +181 -0
- package/lib/types/factories/AccountMining__factory.d.ts +56 -0
- package/lib/types/factories/AccountMining__factory.js +192 -0
- package/lib/types/factories/AdaptersDeployer__factory.d.ts +85 -0
- package/lib/types/factories/AdaptersDeployer__factory.js +202 -0
- package/lib/types/factories/AddressProvider__factory.d.ts +52 -0
- package/lib/types/factories/AddressProvider__factory.js +582 -0
- package/lib/types/factories/AggregatorV3Interface__factory.d.ts +22 -0
- package/lib/types/factories/AggregatorV3Interface__factory.js +133 -0
- package/lib/types/factories/ChainlinkPriceFeedMock__factory.d.ts +42 -0
- package/lib/types/factories/ChainlinkPriceFeedMock__factory.js +193 -0
- package/lib/types/factories/ContractsRegister__factory.d.ts +56 -0
- package/lib/types/factories/ContractsRegister__factory.js +310 -0
- package/lib/types/factories/CoreDeployer__factory.js +331 -0
- package/lib/types/factories/CreditAccount__factory.d.ts +32 -0
- package/lib/types/factories/CreditAccount__factory.js +262 -0
- package/lib/types/factories/CreditFilterMock__factory.d.ts +56 -0
- package/lib/types/factories/CreditFilterMock__factory.js +1083 -0
- package/lib/types/factories/CreditFilter__factory.d.ts +56 -0
- package/lib/types/factories/CreditFilter__factory.js +1047 -0
- package/lib/types/factories/CreditManagerMockForFilter__factory.d.ts +38 -0
- package/lib/types/factories/CreditManagerMockForFilter__factory.js +324 -0
- package/lib/types/factories/CreditManagerMockForPoolTest__factory.d.ts +48 -0
- package/lib/types/factories/CreditManagerMockForPoolTest__factory.js +131 -0
- package/lib/types/factories/CreditManager__factory.d.ts +77 -0
- package/lib/types/factories/CreditManager__factory.js +1030 -0
- package/lib/types/factories/CurveMock__factory.d.ts +42 -0
- package/lib/types/factories/CurveMock__factory.js +210 -0
- package/lib/types/factories/CurveV1Adapter__factory.d.ts +42 -0
- package/lib/types/factories/CurveV1Adapter__factory.js +254 -0
- package/lib/types/factories/DataCompressor__factory.d.ts +71 -0
- package/lib/types/factories/DataCompressor__factory.js +944 -0
- package/lib/types/factories/Deployer__factory.js +248 -0
- package/lib/types/factories/DieselToken__factory.d.ts +56 -0
- package/lib/types/factories/DieselToken__factory.js +432 -0
- package/lib/types/factories/ERC165__factory.d.ts +22 -0
- package/lib/types/factories/ERC165__factory.js +41 -0
- package/lib/types/factories/ERC20BlockingMock__factory.d.ts +56 -0
- package/lib/types/factories/ERC20BlockingMock__factory.js +429 -0
- package/lib/types/factories/ERC20__factory.d.ts +56 -0
- package/lib/types/factories/ERC20__factory.js +339 -0
- package/lib/types/factories/ERC721__factory.d.ts +56 -0
- package/lib/types/factories/ERC721__factory.js +468 -0
- package/lib/types/factories/Errors__factory.d.ts +28 -0
- package/lib/types/factories/Errors__factory.js +1015 -0
- package/lib/types/factories/ExecutorMock__factory.d.ts +38 -0
- package/lib/types/factories/ExecutorMock__factory.js +103 -0
- package/lib/types/factories/FlashLoanAttacker__factory.d.ts +48 -0
- package/lib/types/factories/FlashLoanAttacker__factory.js +117 -0
- package/lib/types/factories/FuzzHarness__factory.d.ts +38 -0
- package/lib/types/factories/FuzzHarness__factory.js +92 -0
- package/lib/types/factories/GearBeta__factory.d.ts +52 -0
- package/lib/types/factories/GearBeta__factory.js +527 -0
- package/lib/types/factories/GearToken__factory.d.ts +56 -0
- package/lib/types/factories/GearToken__factory.js +708 -0
- package/lib/types/factories/GenesisDeployer__factory.d.ts +108 -0
- package/lib/types/factories/GenesisDeployer__factory.js +231 -0
- package/lib/types/factories/IAccountFactory__factory.d.ts +35 -0
- package/lib/types/factories/IAccountFactory__factory.js +226 -0
- package/lib/types/factories/IAccountMiner__factory.d.ts +28 -0
- package/lib/types/factories/IAccountMiner__factory.js +48 -0
- package/lib/types/factories/IAppAddressProvider__factory.d.ts +18 -0
- package/lib/types/factories/IAppAddressProvider__factory.js +100 -0
- package/lib/types/factories/IAppCreditManager__factory.d.ts +42 -0
- package/lib/types/factories/IAppCreditManager__factory.js +204 -0
- package/lib/types/factories/IAppERC20__factory.d.ts +22 -0
- package/lib/types/factories/IAppERC20__factory.js +194 -0
- package/lib/types/factories/IAppPoolService__factory.d.ts +22 -0
- package/lib/types/factories/IAppPoolService__factory.js +69 -0
- package/lib/types/factories/ICreditAccountData__factory.d.ts +35 -0
- package/lib/types/factories/ICreditAccountData__factory.js +216 -0
- package/lib/types/factories/ICreditAccount__factory.d.ts +22 -0
- package/lib/types/factories/ICreditAccount__factory.js +218 -0
- package/lib/types/factories/ICreditFilter__factory.d.ts +35 -0
- package/lib/types/factories/ICreditFilter__factory.js +700 -0
- package/lib/types/factories/ICreditManager__factory.d.ts +56 -0
- package/lib/types/factories/ICreditManager__factory.js +720 -0
- package/lib/types/factories/ICurvePool__factory.d.ts +22 -0
- package/lib/types/factories/ICurvePool__factory.js +168 -0
- package/lib/types/factories/IDataCompressor__factory.d.ts +51 -0
- package/lib/types/factories/IDataCompressor__factory.js +826 -0
- package/lib/types/factories/IERC165__factory.d.ts +22 -0
- package/lib/types/factories/IERC165__factory.js +41 -0
- package/lib/types/factories/IERC20__factory.d.ts +35 -0
- package/lib/types/factories/IERC20__factory.js +205 -0
- package/lib/types/factories/IERC721Enumerable__factory.d.ts +35 -0
- package/lib/types/factories/IERC721Enumerable__factory.js +363 -0
- package/lib/types/factories/IERC721Metadata__factory.d.ts +35 -0
- package/lib/types/factories/IERC721Metadata__factory.js +352 -0
- package/lib/types/factories/IERC721Receiver__factory.d.ts +22 -0
- package/lib/types/factories/IERC721Receiver__factory.js +56 -0
- package/lib/types/factories/IERC721__factory.d.ts +35 -0
- package/lib/types/factories/IERC721__factory.js +307 -0
- package/lib/types/factories/IGearToken__factory.d.ts +35 -0
- package/lib/types/factories/IGearToken__factory.js +342 -0
- package/lib/types/factories/IInterestRateModel__factory.d.ts +22 -0
- package/lib/types/factories/IInterestRateModel__factory.js +46 -0
- package/lib/types/factories/IMerkleDistributor__factory.d.ts +35 -0
- package/lib/types/factories/IMerkleDistributor__factory.js +109 -0
- package/lib/types/factories/IPoolService__factory.d.ts +35 -0
- package/lib/types/factories/IPoolService__factory.js +580 -0
- package/lib/types/factories/IPriceOracle__factory.d.ts +35 -0
- package/lib/types/factories/IPriceOracle__factory.js +112 -0
- package/lib/types/factories/IQuoter__factory.d.ts +22 -0
- package/lib/types/factories/IQuoter__factory.js +148 -0
- package/lib/types/factories/ISwapRouter__factory.d.ts +27 -0
- package/lib/types/factories/ISwapRouter__factory.js +236 -0
- package/lib/types/factories/IUniswapV2Migrator__factory.d.ts +18 -0
- package/lib/types/factories/IUniswapV2Migrator__factory.js +55 -0
- package/lib/types/factories/IUniswapV2Router01__factory.d.ts +22 -0
- package/lib/types/factories/IUniswapV2Router01__factory.js +771 -0
- package/lib/types/factories/IUniswapV2Router02__factory.d.ts +22 -0
- package/lib/types/factories/IUniswapV2Router02__factory.js +973 -0
- package/lib/types/factories/IUniswapV3SwapCallback__factory.d.ts +18 -0
- package/lib/types/factories/IUniswapV3SwapCallback__factory.js +45 -0
- package/lib/types/factories/IWETHGateway__factory.d.ts +18 -0
- package/lib/types/factories/IWETHGateway__factory.js +150 -0
- package/lib/types/factories/IWETH__factory.d.ts +22 -0
- package/lib/types/factories/IWETH__factory.js +66 -0
- package/lib/types/factories/IYVault__factory.d.ts +35 -0
- package/lib/types/factories/IYVault__factory.js +411 -0
- package/lib/types/factories/LeveragedActions__factory.d.ts +84 -0
- package/lib/types/factories/LeveragedActions__factory.js +569 -0
- package/lib/types/factories/LinearInterestRateModel__factory.d.ts +42 -0
- package/lib/types/factories/LinearInterestRateModel__factory.js +209 -0
- package/lib/types/factories/MockPoolService__factory.d.ts +56 -0
- package/lib/types/factories/MockPoolService__factory.js +889 -0
- package/lib/types/factories/Multicall2__factory.d.ts +52 -0
- package/lib/types/factories/Multicall2__factory.js +364 -0
- package/lib/types/factories/Ownable__factory.d.ts +42 -0
- package/lib/types/factories/Ownable__factory.js +74 -0
- package/lib/types/factories/PathFinder__factory.d.ts +61 -0
- package/lib/types/factories/PathFinder__factory.js +302 -0
- package/lib/types/factories/Pausable__factory.d.ts +31 -0
- package/lib/types/factories/Pausable__factory.js +61 -0
- package/lib/types/factories/PercentageMathTest__factory.d.ts +32 -0
- package/lib/types/factories/PercentageMathTest__factory.js +101 -0
- package/lib/types/factories/PoolDeployer__factory.d.ts +113 -0
- package/lib/types/factories/PoolDeployer__factory.js +257 -0
- package/lib/types/factories/PoolService__factory.d.ts +56 -0
- package/lib/types/factories/PoolService__factory.js +873 -0
- package/lib/types/factories/PriceOracle__factory.d.ts +56 -0
- package/lib/types/factories/PriceOracle__factory.js +290 -0
- package/lib/types/factories/Proxy__factory.d.ts +13 -0
- package/lib/types/factories/Proxy__factory.js +30 -0
- package/lib/types/factories/StepVesting__factory.d.ts +52 -0
- package/lib/types/factories/StepVesting__factory.js +296 -0
- package/lib/types/factories/TestPoolService__factory.d.ts +56 -0
- package/lib/types/factories/TestPoolService__factory.js +932 -0
- package/lib/types/factories/TokenDistributor__factory.d.ts +82 -0
- package/lib/types/factories/TokenDistributor__factory.js +481 -0
- package/lib/types/factories/TokenFeeMock__factory.d.ts +56 -0
- package/lib/types/factories/TokenFeeMock__factory.js +427 -0
- package/lib/types/factories/TokenMock__factory.d.ts +56 -0
- package/lib/types/factories/TokenMock__factory.js +409 -0
- package/lib/types/factories/TreasuryMock__factory.d.ts +35 -0
- package/lib/types/factories/TreasuryMock__factory.js +70 -0
- package/lib/types/factories/UniswapRouterMock__factory.d.ts +32 -0
- package/lib/types/factories/UniswapRouterMock__factory.js +1046 -0
- package/lib/types/factories/UniswapV2Adapter__factory.d.ts +42 -0
- package/lib/types/factories/UniswapV2Adapter__factory.js +1059 -0
- package/lib/types/factories/UniswapV3Adapter__factory.d.ts +47 -0
- package/lib/types/factories/UniswapV3Adapter__factory.js +322 -0
- package/lib/types/factories/VestingDeployer__factory.js +216 -0
- package/lib/types/factories/WETHGateway__factory.d.ts +70 -0
- package/lib/types/factories/WETHGateway__factory.js +241 -0
- package/lib/types/factories/WETHMock__factory.d.ts +52 -0
- package/lib/types/factories/WETHMock__factory.js +355 -0
- package/lib/types/factories/WadRayMathTest__factory.d.ts +32 -0
- package/lib/types/factories/WadRayMathTest__factory.js +239 -0
- package/lib/types/factories/YearnAdapter__factory.d.ts +56 -0
- package/lib/types/factories/YearnAdapter__factory.js +497 -0
- package/lib/types/factories/YearnMock__factory.d.ts +56 -0
- package/lib/types/factories/YearnMock__factory.js +598 -0
- package/lib/types/factories/YearnPriceFeed__factory.d.ts +56 -0
- package/lib/types/factories/YearnPriceFeed__factory.js +350 -0
- package/lib/types/hardhat.d.ts +343 -0
- package/lib/types/index.d.ts +152 -0
- package/lib/types/index.js +156 -0
- package/lib/utils/events.d.ts +2 -0
- package/lib/utils/events.js +13 -0
- package/lib/utils/formatter.d.ts +13 -0
- package/lib/utils/formatter.js +125 -0
- package/lib/utils/loading.d.ts +1 -0
- package/lib/utils/loading.js +17 -0
- package/lib/utils/math.d.ts +6 -0
- package/lib/utils/math.js +44 -0
- package/lib/utils/multicall.d.ts +15 -0
- package/lib/utils/multicall.js +84 -0
- package/lib/utils/repeater.d.ts +1 -0
- package/lib/utils/repeater.js +72 -0
- package/lib/utils/validate.d.ts +1 -0
- package/lib/utils/validate.js +13 -0
- package/package.json +27 -0
- package/src/abi/adapters/YearnV2.sol/YearnAdapter.dbg.json +4 -0
- package/src/abi/adapters/YearnV2.sol/YearnAdapter.json +455 -0
- package/src/abi/core/ACL.sol/ACL.dbg.json +4 -0
- package/src/abi/core/ACL.sol/ACL.json +262 -0
- package/src/abi/core/ACLTrait.sol/ACLTrait.dbg.json +4 -0
- package/src/abi/core/ACLTrait.sol/ACLTrait.json +64 -0
- package/src/abi/core/AccountMining.sol/AccountMining.dbg.json +4 -0
- package/src/abi/core/AccountMining.sol/AccountMining.json +150 -0
- package/src/abi/core/AddressProvider.sol/AddressProvider.dbg.json +4 -0
- package/src/abi/core/AddressProvider.sol/AddressProvider.json +496 -0
- package/src/abi/core/ContractsRegister.sol/ContractsRegister.dbg.json +4 -0
- package/src/abi/core/ContractsRegister.sol/ContractsRegister.json +255 -0
- package/src/abi/credit/LeverageActions.sol/LeveragedActions.dbg.json +4 -0
- package/src/abi/credit/LeverageActions.sol/LeveragedActions.json +514 -0
- package/src/abi/deployer/AdaptersDeployer.sol/AdaptersDeployer.dbg.json +4 -0
- package/src/abi/deployer/AdaptersDeployer.sol/AdaptersDeployer.json +160 -0
- package/src/abi/deployer/GenesisDeployer.sol/GenesisDeployer.dbg.json +4 -0
- package/src/abi/deployer/GenesisDeployer.sol/GenesisDeployer.json +189 -0
- package/src/abi/deployer/PoolDeployer.sol/PoolDeployer.dbg.json +4 -0
- package/src/abi/deployer/PoolDeployer.sol/PoolDeployer.json +215 -0
- package/src/abi/fuzzing/FuzzHarness.sol/FuzzHarness.dbg.json +4 -0
- package/src/abi/fuzzing/FuzzHarness.sol/FuzzHarness.json +50 -0
- package/src/abi/integrations/yearn/IYVault.sol/IYVault.dbg.json +4 -0
- package/src/abi/integrations/yearn/IYVault.sol/IYVault.json +400 -0
- package/src/abi/interfaces/IGearToken.sol/IGearToken.dbg.json +4 -0
- package/src/abi/interfaces/IGearToken.sol/IGearToken.json +331 -0
- package/src/abi/interfaces/IMerkleDistributor.sol/IMerkleDistributor.dbg.json +4 -0
- package/src/abi/interfaces/IMerkleDistributor.sol/IMerkleDistributor.json +98 -0
- package/src/abi/mocks/core/ACLTraitTest.sol/ACLTraitTest.dbg.json +4 -0
- package/src/abi/mocks/core/ACLTraitTest.sol/ACLTraitTest.json +96 -0
- package/src/abi/mocks/credit/ExecutorMock.sol/ExecutorMock.dbg.json +4 -0
- package/src/abi/mocks/credit/ExecutorMock.sol/ExecutorMock.json +61 -0
- package/src/abi/mocks/integrations/CurveMock.sol/CurveMock.dbg.json +4 -0
- package/src/abi/mocks/integrations/CurveMock.sol/CurveMock.json +168 -0
- package/src/abi/mocks/integrations/YearnMock.sol/YearnMock.dbg.json +4 -0
- package/src/abi/mocks/integrations/YearnMock.sol/YearnMock.json +556 -0
- package/src/abi/mocks/oracles/ChainlinkPriceFeedMock.sol/ChainlinkPriceFeedMock.dbg.json +4 -0
- package/src/abi/mocks/oracles/ChainlinkPriceFeedMock.sol/ChainlinkPriceFeedMock.json +151 -0
- package/src/abi/mocks/pool/CreditManagerMockForPoolTest.sol/CreditManagerMockForPoolTest.dbg.json +4 -0
- package/src/abi/mocks/pool/CreditManagerMockForPoolTest.sol/CreditManagerMockForPoolTest.json +89 -0
- package/src/abi/mocks/tokens/ERC20Blocking.sol/ERC20BlockingMock.dbg.json +4 -0
- package/src/abi/mocks/tokens/ERC20Blocking.sol/ERC20BlockingMock.json +387 -0
- package/src/abi/mocks/tokens/ERC20Fee.sol/TokenFeeMock.dbg.json +4 -0
- package/src/abi/mocks/tokens/ERC20Fee.sol/TokenFeeMock.json +385 -0
- package/src/abi/oracles/YearnPriceFeed.sol/YearnPriceFeed.dbg.json +4 -0
- package/src/abi/oracles/YearnPriceFeed.sol/YearnPriceFeed.json +321 -0
- package/src/abi/support/PathFinder.sol/PathFinder.dbg.json +4 -0
- package/src/abi/support/PathFinder.sol/PathFinder.json +189 -0
- package/src/abi/tokens/GearNFT.sol/GearBeta.dbg.json +4 -0
- package/src/abi/tokens/GearNFT.sol/GearBeta.json +485 -0
- package/src/abi/tokens/TokenDistributor.sol/TokenDistributor.dbg.json +4 -0
- package/src/abi/tokens/TokenDistributor.sol/TokenDistributor.json +439 -0
- package/src/abi/tokens/Vesting.sol/StepVesting.dbg.json +4 -0
- package/src/abi/tokens/Vesting.sol/StepVesting.json +254 -0
- package/src/config.ts +1 -0
- package/src/core/constants.ts +44 -0
- package/src/core/contracts.ts +151 -0
- package/src/core/contractsRegister.ts +51 -0
- package/src/core/creditAccount.ts +105 -0
- package/src/core/creditCard.ts +15 -0
- package/src/core/creditManager.ts +171 -0
- package/src/core/creditOperation.ts +9 -0
- package/src/core/creditSession.ts +67 -0
- package/src/core/errors.ts +45 -0
- package/src/core/eventOrTx.ts +94 -0
- package/src/core/events.ts +1167 -0
- package/src/core/history.ts +55 -0
- package/src/core/operations.ts +35 -0
- package/src/core/oracles.ts +7 -0
- package/src/core/pool.ts +60 -0
- package/src/core/swap.ts +4 -0
- package/src/core/token.ts +275 -0
- package/src/core/tokenData.ts +84 -0
- package/src/core/tokenDistributor.ts +14 -0
- package/src/core/trade.ts +83 -0
- package/src/core/transactions.ts +407 -0
- package/src/index.ts +42 -0
- package/src/payload/creditAccount.ts +29 -0
- package/src/payload/creditManager.ts +46 -0
- package/src/payload/creditSession.ts +24 -0
- package/src/payload/graphPayload.ts +10 -0
- package/src/payload/pool.ts +20 -0
- package/src/payload/token.ts +5 -0
- package/src/types/ACL.d.ts +491 -0
- package/src/types/ACLTrait.d.ts +148 -0
- package/src/types/ACLTraitTest.d.ts +209 -0
- package/src/types/AccountFactory.d.ts +716 -0
- package/src/types/AccountMining.d.ts +222 -0
- package/src/types/AddressProvider.d.ts +912 -0
- package/src/types/AggregatorV3Interface.d.ts +234 -0
- package/src/types/ChainlinkPriceFeedMock.d.ts +215 -0
- package/src/types/ContractsRegister.d.ts +398 -0
- package/src/types/CreditAccount.d.ts +443 -0
- package/src/types/CreditFilter.d.ts +1609 -0
- package/src/types/CreditFilterMock.d.ts +1687 -0
- package/src/types/CreditManager.d.ts +1285 -0
- package/src/types/CreditManagerMockForFilter.d.ts +605 -0
- package/src/types/CreditManagerMockForPoolTest.d.ts +204 -0
- package/src/types/CurveMock.d.ts +298 -0
- package/src/types/CurveV1Adapter.d.ts +349 -0
- package/src/types/DataCompressor.d.ts +1331 -0
- package/src/types/DieselToken.d.ts +567 -0
- package/src/types/ERC165.d.ts +116 -0
- package/src/types/ERC20.d.ts +411 -0
- package/src/types/ERC20BlockingMock.d.ts +568 -0
- package/src/types/ERC721.d.ts +625 -0
- package/src/types/Errors.d.ts +1854 -0
- package/src/types/ExecutorMock.d.ts +140 -0
- package/src/types/FlashLoanAttacker.d.ts +170 -0
- package/src/types/FuzzHarness.d.ts +124 -0
- package/src/types/GearBeta.d.ts +745 -0
- package/src/types/GearToken.d.ts +888 -0
- package/src/types/IAccountFactory.d.ts +317 -0
- package/src/types/IAccountMiner.d.ts +124 -0
- package/src/types/IAppAddressProvider.d.ts +198 -0
- package/src/types/IAppCreditManager.d.ts +408 -0
- package/src/types/IAppERC20.d.ts +309 -0
- package/src/types/IAppPoolService.d.ts +166 -0
- package/src/types/ICreditAccount.d.ts +430 -0
- package/src/types/ICreditFilter.d.ts +1162 -0
- package/src/types/ICreditManager.d.ts +971 -0
- package/src/types/ICurvePool.d.ts +298 -0
- package/src/types/IDataCompressor.d.ts +1231 -0
- package/src/types/IERC165.d.ts +116 -0
- package/src/types/IERC20.d.ts +294 -0
- package/src/types/IERC721.d.ts +472 -0
- package/src/types/IERC721Enumerable.d.ts +564 -0
- package/src/types/IERC721Metadata.d.ts +523 -0
- package/src/types/IERC721Receiver.d.ts +132 -0
- package/src/types/IGearToken.d.ts +527 -0
- package/src/types/IInterestRateModel.d.ts +121 -0
- package/src/types/IMerkleDistributor.d.ts +190 -0
- package/src/types/IPoolService.d.ts +772 -0
- package/src/types/IPriceOracle.d.ts +211 -0
- package/src/types/IQuoter.d.ts +269 -0
- package/src/types/ISwapRouter.d.ts +404 -0
- package/src/types/IUniswapV2Migrator.d.ts +134 -0
- package/src/types/IUniswapV2Router01.d.ts +1119 -0
- package/src/types/IUniswapV2Router02.d.ts +1432 -0
- package/src/types/IUniswapV3SwapCallback.d.ts +127 -0
- package/src/types/IWETH.d.ts +169 -0
- package/src/types/IWETHGateway.d.ts +335 -0
- package/src/types/IYVault.d.ts +558 -0
- package/src/types/LeveragedActions.d.ts +772 -0
- package/src/types/LinearInterestRateModel.d.ts +279 -0
- package/src/types/MockPoolService.d.ts +1271 -0
- package/src/types/Multicall2.d.ts +449 -0
- package/src/types/Ownable.d.ts +169 -0
- package/src/types/PathFinder.d.ts +379 -0
- package/src/types/Pausable.d.ts +105 -0
- package/src/types/PercentageMathTest.d.ts +154 -0
- package/src/types/PoolService.d.ts +1174 -0
- package/src/types/PriceOracle.d.ts +387 -0
- package/src/types/StepVesting.d.ts +411 -0
- package/src/types/TestPoolService.d.ts +1294 -0
- package/src/types/TokenDistributor.d.ts +640 -0
- package/src/types/TokenFeeMock.d.ts +544 -0
- package/src/types/TokenMock.d.ts +531 -0
- package/src/types/TreasuryMock.d.ts +86 -0
- package/src/types/UniswapRouterMock.d.ts +1520 -0
- package/src/types/UniswapV2Adapter.d.ts +1463 -0
- package/src/types/UniswapV3Adapter.d.ts +455 -0
- package/src/types/WETHGateway.d.ts +376 -0
- package/src/types/WETHMock.d.ts +433 -0
- package/src/types/WadRayMathTest.d.ts +316 -0
- package/src/types/YearnAdapter.d.ts +609 -0
- package/src/types/YearnMock.d.ts +795 -0
- package/src/types/YearnPriceFeed.d.ts +399 -0
- package/src/types/commons.d.ts +16 -0
- package/src/types/commons.js +5 -0
- package/src/types/commons.ts +37 -0
- package/src/types/factories/ACLTraitTest__factory.ts +137 -0
- package/src/types/factories/ACLTrait__factory.ts +76 -0
- package/src/types/factories/ACL__factory.ts +308 -0
- package/src/types/factories/AccountFactory__factory.ts +510 -0
- package/src/types/factories/AccountMining__factory.ts +214 -0
- package/src/types/factories/AddressProvider__factory.ts +579 -0
- package/src/types/factories/AggregatorV3Interface__factory.ts +141 -0
- package/src/types/factories/ChainlinkPriceFeedMock__factory.ts +209 -0
- package/src/types/factories/ContractsRegister__factory.ts +312 -0
- package/src/types/factories/CreditAccount__factory.ts +256 -0
- package/src/types/factories/CreditFilterMock__factory.ts +1092 -0
- package/src/types/factories/CreditFilter__factory.ts +1053 -0
- package/src/types/factories/CreditManagerMockForFilter__factory.ts +325 -0
- package/src/types/factories/CreditManagerMockForPoolTest__factory.ts +137 -0
- package/src/types/factories/CreditManager__factory.ts +1063 -0
- package/src/types/factories/CurveMock__factory.ts +206 -0
- package/src/types/factories/CurveV1Adapter__factory.ts +263 -0
- package/src/types/factories/DataCompressor__factory.ts +946 -0
- package/src/types/factories/DieselToken__factory.ts +449 -0
- package/src/types/factories/ERC165__factory.ts +39 -0
- package/src/types/factories/ERC20BlockingMock__factory.ts +434 -0
- package/src/types/factories/ERC20__factory.ts +334 -0
- package/src/types/factories/ERC721__factory.ts +463 -0
- package/src/types/factories/Errors__factory.ts +1006 -0
- package/src/types/factories/ExecutorMock__factory.ts +97 -0
- package/src/types/factories/FlashLoanAttacker__factory.ts +119 -0
- package/src/types/factories/FuzzHarness__factory.ts +94 -0
- package/src/types/factories/GearBeta__factory.ts +521 -0
- package/src/types/factories/GearToken__factory.ts +704 -0
- package/src/types/factories/IAccountFactory__factory.ts +230 -0
- package/src/types/factories/IAccountMiner__factory.ts +49 -0
- package/src/types/factories/IAppAddressProvider__factory.ts +104 -0
- package/src/types/factories/IAppCreditManager__factory.ts +208 -0
- package/src/types/factories/IAppERC20__factory.ts +195 -0
- package/src/types/factories/IAppPoolService__factory.ts +73 -0
- package/src/types/factories/ICreditAccount__factory.ts +222 -0
- package/src/types/factories/ICreditFilter__factory.ts +701 -0
- package/src/types/factories/ICreditManager__factory.ts +724 -0
- package/src/types/factories/ICurvePool__factory.ts +169 -0
- package/src/types/factories/IDataCompressor__factory.ts +830 -0
- package/src/types/factories/IERC165__factory.ts +42 -0
- package/src/types/factories/IERC20__factory.ts +203 -0
- package/src/types/factories/IERC721Enumerable__factory.ts +367 -0
- package/src/types/factories/IERC721Metadata__factory.ts +356 -0
- package/src/types/factories/IERC721Receiver__factory.ts +60 -0
- package/src/types/factories/IERC721__factory.ts +308 -0
- package/src/types/factories/IGearToken__factory.ts +343 -0
- package/src/types/factories/IInterestRateModel__factory.ts +50 -0
- package/src/types/factories/IMerkleDistributor__factory.ts +113 -0
- package/src/types/factories/IPoolService__factory.ts +581 -0
- package/src/types/factories/IPriceOracle__factory.ts +113 -0
- package/src/types/factories/IQuoter__factory.ts +149 -0
- package/src/types/factories/ISwapRouter__factory.ts +237 -0
- package/src/types/factories/IUniswapV2Migrator__factory.ts +59 -0
- package/src/types/factories/IUniswapV2Router01__factory.ts +775 -0
- package/src/types/factories/IUniswapV2Router02__factory.ts +977 -0
- package/src/types/factories/IUniswapV3SwapCallback__factory.ts +53 -0
- package/src/types/factories/IWETHGateway__factory.ts +151 -0
- package/src/types/factories/IWETH__factory.ts +64 -0
- package/src/types/factories/IYVault__factory.ts +412 -0
- package/src/types/factories/LeveragedActions__factory.ts +571 -0
- package/src/types/factories/LinearInterestRateModel__factory.ts +237 -0
- package/src/types/factories/MockPoolService__factory.ts +891 -0
- package/src/types/factories/Multicall2__factory.ts +358 -0
- package/src/types/factories/Ownable__factory.ts +75 -0
- package/src/types/factories/PathFinder__factory.ts +301 -0
- package/src/types/factories/Pausable__factory.ts +62 -0
- package/src/types/factories/PercentageMathTest__factory.ts +98 -0
- package/src/types/factories/PoolService__factory.ts +898 -0
- package/src/types/factories/PriceOracle__factory.ts +289 -0
- package/src/types/factories/StepVesting__factory.ts +290 -0
- package/src/types/factories/TestPoolService__factory.ts +960 -0
- package/src/types/factories/TokenDistributor__factory.ts +483 -0
- package/src/types/factories/TokenFeeMock__factory.ts +439 -0
- package/src/types/factories/TokenMock__factory.ts +407 -0
- package/src/types/factories/TreasuryMock__factory.ts +64 -0
- package/src/types/factories/UniswapRouterMock__factory.ts +1043 -0
- package/src/types/factories/UniswapV2Adapter__factory.ts +1064 -0
- package/src/types/factories/UniswapV3Adapter__factory.ts +327 -0
- package/src/types/factories/WETHGateway__factory.ts +240 -0
- package/src/types/factories/WETHMock__factory.ts +349 -0
- package/src/types/factories/WadRayMathTest__factory.ts +236 -0
- package/src/types/factories/YearnAdapter__factory.ts +499 -0
- package/src/types/factories/YearnMock__factory.ts +594 -0
- package/src/types/factories/YearnPriceFeed__factory.ts +378 -0
- package/src/types/hardhat.d.ts +343 -0
- package/src/types/index.d.ts +174 -0
- package/src/types/index.js +178 -0
- package/src/types/index.ts +156 -0
- package/src/utils/events.ts +10 -0
- package/src/utils/formatter.ts +138 -0
- package/src/utils/loading.ts +9 -0
- package/src/utils/math.ts +42 -0
- package/src/utils/multicall.ts +54 -0
- package/src/utils/repeater.ts +18 -0
- package/src/utils/validate.ts +8 -0
- package/tsconfig.json +62 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="WEB_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager">
|
|
4
|
+
<content url="file://$MODULE_DIR$">
|
|
5
|
+
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
|
6
|
+
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
|
7
|
+
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
|
8
|
+
</content>
|
|
9
|
+
<orderEntry type="inheritedJdk" />
|
|
10
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
11
|
+
</component>
|
|
12
|
+
</module>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/gearbox-sdk.iml" filepath="$PROJECT_DIR$/.idea/gearbox-sdk.iml" />
|
|
6
|
+
</modules>
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
package/.idea/vcs.xml
ADDED
package/.prettierrc
ADDED
package/README.md
ADDED
package/lib/config.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const STATIC_TOKEN = "https://static.gearbox.fi/tokens/";
|
package/lib/config.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BigNumber } from "ethers";
|
|
2
|
+
export declare const MAX_INT: BigNumber;
|
|
3
|
+
export declare const MAINNET_NETWORK = 1;
|
|
4
|
+
export declare const KOVAN_NETWORK = 42;
|
|
5
|
+
export declare const LOCAL_NETWORK = 1337;
|
|
6
|
+
export declare type NetworkType = "Mainnet" | "Kovan";
|
|
7
|
+
export declare const getNetworkType: (chainId: number) => NetworkType;
|
|
8
|
+
export declare const RAY: BigNumber;
|
|
9
|
+
export declare const halfRAY: BigNumber;
|
|
10
|
+
export declare const WAD: BigNumber;
|
|
11
|
+
export declare const SECONDS_PER_YEAR: number;
|
|
12
|
+
export declare const PERCENTAGE_FACTOR = 10000;
|
|
13
|
+
export declare const LIQUIDATION_DISCOUNTED_SUM = 9500;
|
|
14
|
+
export declare const UNDERLYING_TOKEN_LIQUIDATION_THRESHOLD = 9300;
|
|
15
|
+
export declare const timeRanges: Record<string, number>;
|
|
16
|
+
export declare const LEVERAGE_DECIMALS = 100;
|
|
17
|
+
export declare const ADDRESS_0x0 = "0x0000000000000000000000000000000000000000";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ADDRESS_0x0 = exports.LEVERAGE_DECIMALS = exports.timeRanges = exports.UNDERLYING_TOKEN_LIQUIDATION_THRESHOLD = exports.LIQUIDATION_DISCOUNTED_SUM = exports.PERCENTAGE_FACTOR = exports.SECONDS_PER_YEAR = exports.WAD = exports.halfRAY = exports.RAY = exports.getNetworkType = exports.LOCAL_NETWORK = exports.KOVAN_NETWORK = exports.MAINNET_NETWORK = exports.MAX_INT = void 0;
|
|
4
|
+
var ethers_1 = require("ethers");
|
|
5
|
+
exports.MAX_INT = ethers_1.BigNumber.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
|
6
|
+
exports.MAINNET_NETWORK = 1;
|
|
7
|
+
exports.KOVAN_NETWORK = 42;
|
|
8
|
+
exports.LOCAL_NETWORK = 1337;
|
|
9
|
+
var getNetworkType = function (chainId) {
|
|
10
|
+
switch (chainId) {
|
|
11
|
+
case exports.MAINNET_NETWORK:
|
|
12
|
+
case exports.LOCAL_NETWORK:
|
|
13
|
+
return "Mainnet";
|
|
14
|
+
case exports.KOVAN_NETWORK:
|
|
15
|
+
return "Kovan";
|
|
16
|
+
default:
|
|
17
|
+
throw new Error("unknown network");
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
exports.getNetworkType = getNetworkType;
|
|
21
|
+
exports.RAY = ethers_1.BigNumber.from(10).pow(27);
|
|
22
|
+
exports.halfRAY = exports.RAY.div(2);
|
|
23
|
+
exports.WAD = ethers_1.BigNumber.from(10).pow(18);
|
|
24
|
+
exports.SECONDS_PER_YEAR = 365 * 24 * 3600;
|
|
25
|
+
exports.PERCENTAGE_FACTOR = 1e4;
|
|
26
|
+
exports.LIQUIDATION_DISCOUNTED_SUM = 9500;
|
|
27
|
+
exports.UNDERLYING_TOKEN_LIQUIDATION_THRESHOLD = 9300;
|
|
28
|
+
exports.timeRanges = {
|
|
29
|
+
// "1H": 3600,
|
|
30
|
+
"1D": 3600 * 24,
|
|
31
|
+
"1W": 3600 * 24 * 7,
|
|
32
|
+
"1M": 3600 * 24 * 30,
|
|
33
|
+
"1Y": 3600 * 24 * 365,
|
|
34
|
+
};
|
|
35
|
+
exports.LEVERAGE_DECIMALS = 100;
|
|
36
|
+
exports.ADDRESS_0x0 = "0x0000000000000000000000000000000000000000";
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export declare const UNISWAP_V2_ROUTER = "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D";
|
|
2
|
+
export declare const UNISWAP_V3_ROUTER = "0xE592427A0AEce92De3Edee1F18E0157C05861564";
|
|
3
|
+
export declare const UNISWAP_V3_QUOTER = "0xb27308f9f90d607463bb33ea1bebb41c27ce5ab6";
|
|
4
|
+
export declare const CURVE_3POOL_ADDRESS = "0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7";
|
|
5
|
+
export declare const CURVE_STETH_ADDRESS = "0xDC24316b9AE028F1497c275EB9192a3Ea0f67022";
|
|
6
|
+
export declare const CURVE_STETH_GATEWAY_ADDRESS = "";
|
|
7
|
+
export declare const CURVE_FRAX_ADDRESS = "0xd632f22692FaC7611d2AA1C0D552930D43CAEd3B";
|
|
8
|
+
export declare const CURVE_LUSD_ADDRESS = "0x5a6a4d54456819380173272a5e8e9b9904bdf41b";
|
|
9
|
+
export declare const CURVE_SUSD_ADDRESS = "0x5a6a4d54456819380173272a5e8e9b9904bdf41b";
|
|
10
|
+
export declare const CURVE_GUSD_ADDRESS = "0x5a6a4d54456819380173272a5e8e9b9904bdf41b";
|
|
11
|
+
export declare const YEARN_DAI_ADDRESS = "0xdA816459F1AB5631232FE5e97a05BBBb94970c95";
|
|
12
|
+
export declare const YEARN_USDC_ADDRESS = "0xa354F35829Ae975e850e23e9615b11Da1B3dC4DE";
|
|
13
|
+
export declare const YEARN_WETH_ADDRESS = "0xa258C4606Ca8206D8aA700cE2143D7db854D168c";
|
|
14
|
+
export declare const YEARN_WBTC_ADDRESS = "0xA696a63cc78DfFa1a63E9E50587C197387FF6C7E";
|
|
15
|
+
export declare const YEARN_CURVE_FRAX_ADDRESS = "0xB4AdA607B9d6b2c9Ee07A275e9616B84AC560139";
|
|
16
|
+
export declare const YEARN_CURVE_STETH_ADDRESS = "0xdCD90C7f6324cfa40d7169ef80b12031770B4325";
|
|
17
|
+
export declare const YEARN_DAI_KOVAN_MOCK = "0xe5267045739E4d6FcA15BB4a79190012F146893b";
|
|
18
|
+
export declare const YEARN_USDC_KOVAN_MOCK = "0x980E4d8A22105c2a2fA2252B7685F32fc7564512";
|
|
19
|
+
export declare const SUSHISWAP_MAINNET = "0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F";
|
|
20
|
+
export declare const SUSHISWAP_KOVAN = "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506";
|
|
21
|
+
export declare const CONVEX_BOOSTER_ADDRESS = "0xF403C135812408BFbE8713b5A23a04b3D48AAE31";
|
|
22
|
+
export declare const CONVEX_3POOL_REWARD_POOL_ADDRESS = "0x689440f2Ff927E1f24c72F1087E1FAF471eCe1c8";
|
|
23
|
+
export declare const CONVEX_FRAX3CRV_REWARD_POOL_ADDRESS = "0xB900EF131301B307dB5eFcbed9DBb50A3e209B2e";
|
|
24
|
+
export declare const CONVEX_CLAIM_ZAP_ADDRESS = "0x92Cf9E5e4D1Dfbf7dA0d2BB3e884a68416a65070";
|
|
25
|
+
export declare const LIDO_STETH_ADDRESS = "0xae7ab96520de3a18e5e111b5eaab095312d7fe84";
|
|
26
|
+
export declare enum AdapterInterface {
|
|
27
|
+
NO_SWAP = 0,
|
|
28
|
+
UNISWAP_V2 = 1,
|
|
29
|
+
UNISWAP_V3 = 2,
|
|
30
|
+
CURVE_V1_2ASSETS = 3,
|
|
31
|
+
CURVE_V1_3ASSETS = 4,
|
|
32
|
+
CURVE_V1_4ASSETS = 5,
|
|
33
|
+
CURVE_V1_STETH = 6,
|
|
34
|
+
YEARN_V2 = 7,
|
|
35
|
+
CONVEX_V1_BASE_REWARD_POOL = 8,
|
|
36
|
+
CONVEX_V1_BOOSTER = 9,
|
|
37
|
+
CONVEX_V1_CLAIM_ZAP = 10,
|
|
38
|
+
LIDO_V1 = 11
|
|
39
|
+
}
|
|
40
|
+
export declare type AdapterParams = {
|
|
41
|
+
name: string;
|
|
42
|
+
type: AdapterInterface.UNISWAP_V2;
|
|
43
|
+
icon: string;
|
|
44
|
+
} | {
|
|
45
|
+
name: string;
|
|
46
|
+
type: AdapterInterface.UNISWAP_V3;
|
|
47
|
+
quoter: string;
|
|
48
|
+
icon: string;
|
|
49
|
+
} | {
|
|
50
|
+
name: string;
|
|
51
|
+
type: AdapterInterface.CURVE_V1_2ASSETS;
|
|
52
|
+
nCoins: number;
|
|
53
|
+
icon: string;
|
|
54
|
+
} | {
|
|
55
|
+
name: string;
|
|
56
|
+
type: AdapterInterface.CURVE_V1_3ASSETS;
|
|
57
|
+
nCoins: number;
|
|
58
|
+
icon: string;
|
|
59
|
+
} | {
|
|
60
|
+
name: string;
|
|
61
|
+
type: AdapterInterface.YEARN_V2;
|
|
62
|
+
icon: string;
|
|
63
|
+
};
|
|
64
|
+
export declare const knownContracts: Record<string, AdapterParams>;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* SPDX-License-Identifier: BSL-1.1
|
|
4
|
+
* Gearbox. Generalized leverage protocol, which allows to take leverage and then use it across other DeFi protocols and platforms in a composable way.
|
|
5
|
+
* (c) Gearbox.fi, 2021
|
|
6
|
+
*/
|
|
7
|
+
var _a;
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.knownContracts = exports.AdapterInterface = exports.LIDO_STETH_ADDRESS = exports.CONVEX_CLAIM_ZAP_ADDRESS = exports.CONVEX_FRAX3CRV_REWARD_POOL_ADDRESS = exports.CONVEX_3POOL_REWARD_POOL_ADDRESS = exports.CONVEX_BOOSTER_ADDRESS = exports.SUSHISWAP_KOVAN = exports.SUSHISWAP_MAINNET = exports.YEARN_USDC_KOVAN_MOCK = exports.YEARN_DAI_KOVAN_MOCK = exports.YEARN_CURVE_STETH_ADDRESS = exports.YEARN_CURVE_FRAX_ADDRESS = exports.YEARN_WBTC_ADDRESS = exports.YEARN_WETH_ADDRESS = exports.YEARN_USDC_ADDRESS = exports.YEARN_DAI_ADDRESS = exports.CURVE_GUSD_ADDRESS = exports.CURVE_SUSD_ADDRESS = exports.CURVE_LUSD_ADDRESS = exports.CURVE_FRAX_ADDRESS = exports.CURVE_STETH_GATEWAY_ADDRESS = exports.CURVE_STETH_ADDRESS = exports.CURVE_3POOL_ADDRESS = exports.UNISWAP_V3_QUOTER = exports.UNISWAP_V3_ROUTER = exports.UNISWAP_V2_ROUTER = void 0;
|
|
10
|
+
exports.UNISWAP_V2_ROUTER = "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D";
|
|
11
|
+
exports.UNISWAP_V3_ROUTER = "0xE592427A0AEce92De3Edee1F18E0157C05861564";
|
|
12
|
+
exports.UNISWAP_V3_QUOTER = "0xb27308f9f90d607463bb33ea1bebb41c27ce5ab6";
|
|
13
|
+
exports.CURVE_3POOL_ADDRESS = "0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7";
|
|
14
|
+
exports.CURVE_STETH_ADDRESS = "0xDC24316b9AE028F1497c275EB9192a3Ea0f67022";
|
|
15
|
+
exports.CURVE_STETH_GATEWAY_ADDRESS = "";
|
|
16
|
+
exports.CURVE_FRAX_ADDRESS = "0xd632f22692FaC7611d2AA1C0D552930D43CAEd3B";
|
|
17
|
+
exports.CURVE_LUSD_ADDRESS = "0x5a6a4d54456819380173272a5e8e9b9904bdf41b";
|
|
18
|
+
exports.CURVE_SUSD_ADDRESS = "0x5a6a4d54456819380173272a5e8e9b9904bdf41b";
|
|
19
|
+
exports.CURVE_GUSD_ADDRESS = "0x5a6a4d54456819380173272a5e8e9b9904bdf41b";
|
|
20
|
+
exports.YEARN_DAI_ADDRESS = "0xdA816459F1AB5631232FE5e97a05BBBb94970c95";
|
|
21
|
+
exports.YEARN_USDC_ADDRESS = "0xa354F35829Ae975e850e23e9615b11Da1B3dC4DE";
|
|
22
|
+
exports.YEARN_WETH_ADDRESS = "0xa258C4606Ca8206D8aA700cE2143D7db854D168c";
|
|
23
|
+
exports.YEARN_WBTC_ADDRESS = "0xA696a63cc78DfFa1a63E9E50587C197387FF6C7E";
|
|
24
|
+
exports.YEARN_CURVE_FRAX_ADDRESS = "0xB4AdA607B9d6b2c9Ee07A275e9616B84AC560139";
|
|
25
|
+
exports.YEARN_CURVE_STETH_ADDRESS = "0xdCD90C7f6324cfa40d7169ef80b12031770B4325";
|
|
26
|
+
exports.YEARN_DAI_KOVAN_MOCK = "0xe5267045739E4d6FcA15BB4a79190012F146893b";
|
|
27
|
+
exports.YEARN_USDC_KOVAN_MOCK = "0x980E4d8A22105c2a2fA2252B7685F32fc7564512";
|
|
28
|
+
exports.SUSHISWAP_MAINNET = "0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F";
|
|
29
|
+
exports.SUSHISWAP_KOVAN = "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506";
|
|
30
|
+
exports.CONVEX_BOOSTER_ADDRESS = "0xF403C135812408BFbE8713b5A23a04b3D48AAE31";
|
|
31
|
+
exports.CONVEX_3POOL_REWARD_POOL_ADDRESS = "0x689440f2Ff927E1f24c72F1087E1FAF471eCe1c8";
|
|
32
|
+
exports.CONVEX_FRAX3CRV_REWARD_POOL_ADDRESS = "0xB900EF131301B307dB5eFcbed9DBb50A3e209B2e";
|
|
33
|
+
exports.CONVEX_CLAIM_ZAP_ADDRESS = "0x92Cf9E5e4D1Dfbf7dA0d2BB3e884a68416a65070";
|
|
34
|
+
exports.LIDO_STETH_ADDRESS = "0xae7ab96520de3a18e5e111b5eaab095312d7fe84";
|
|
35
|
+
var AdapterInterface;
|
|
36
|
+
(function (AdapterInterface) {
|
|
37
|
+
AdapterInterface[AdapterInterface["NO_SWAP"] = 0] = "NO_SWAP";
|
|
38
|
+
AdapterInterface[AdapterInterface["UNISWAP_V2"] = 1] = "UNISWAP_V2";
|
|
39
|
+
AdapterInterface[AdapterInterface["UNISWAP_V3"] = 2] = "UNISWAP_V3";
|
|
40
|
+
AdapterInterface[AdapterInterface["CURVE_V1_2ASSETS"] = 3] = "CURVE_V1_2ASSETS";
|
|
41
|
+
AdapterInterface[AdapterInterface["CURVE_V1_3ASSETS"] = 4] = "CURVE_V1_3ASSETS";
|
|
42
|
+
AdapterInterface[AdapterInterface["CURVE_V1_4ASSETS"] = 5] = "CURVE_V1_4ASSETS";
|
|
43
|
+
AdapterInterface[AdapterInterface["CURVE_V1_STETH"] = 6] = "CURVE_V1_STETH";
|
|
44
|
+
AdapterInterface[AdapterInterface["YEARN_V2"] = 7] = "YEARN_V2";
|
|
45
|
+
AdapterInterface[AdapterInterface["CONVEX_V1_BASE_REWARD_POOL"] = 8] = "CONVEX_V1_BASE_REWARD_POOL";
|
|
46
|
+
AdapterInterface[AdapterInterface["CONVEX_V1_BOOSTER"] = 9] = "CONVEX_V1_BOOSTER";
|
|
47
|
+
AdapterInterface[AdapterInterface["CONVEX_V1_CLAIM_ZAP"] = 10] = "CONVEX_V1_CLAIM_ZAP";
|
|
48
|
+
AdapterInterface[AdapterInterface["LIDO_V1"] = 11] = "LIDO_V1"; // 11 - 2048
|
|
49
|
+
})(AdapterInterface = exports.AdapterInterface || (exports.AdapterInterface = {}));
|
|
50
|
+
exports.knownContracts = (_a = {},
|
|
51
|
+
_a[exports.UNISWAP_V2_ROUTER] = {
|
|
52
|
+
name: "UniswapV2",
|
|
53
|
+
type: AdapterInterface.UNISWAP_V2,
|
|
54
|
+
icon: "/protocols/uniswap.png"
|
|
55
|
+
},
|
|
56
|
+
_a[exports.UNISWAP_V3_ROUTER] = {
|
|
57
|
+
name: "UniswapV3",
|
|
58
|
+
quoter: exports.UNISWAP_V3_QUOTER,
|
|
59
|
+
type: AdapterInterface.UNISWAP_V3,
|
|
60
|
+
icon: "/protocols/uniswap.png"
|
|
61
|
+
},
|
|
62
|
+
_a[exports.SUSHISWAP_MAINNET] = {
|
|
63
|
+
name: "Sushiswap",
|
|
64
|
+
type: AdapterInterface.UNISWAP_V2,
|
|
65
|
+
icon: "/protocols/sushi.svg"
|
|
66
|
+
},
|
|
67
|
+
_a[exports.CURVE_3POOL_ADDRESS] = {
|
|
68
|
+
name: "Curve 3pool",
|
|
69
|
+
type: AdapterInterface.CURVE_V1_3ASSETS,
|
|
70
|
+
nCoins: 3,
|
|
71
|
+
icon: "/protocols/curve.svg"
|
|
72
|
+
},
|
|
73
|
+
_a[exports.CURVE_STETH_ADDRESS] = {
|
|
74
|
+
name: "Curve stETH",
|
|
75
|
+
type: AdapterInterface.CURVE_V1_2ASSETS,
|
|
76
|
+
nCoins: 2,
|
|
77
|
+
icon: "/protocols/curve.svg"
|
|
78
|
+
},
|
|
79
|
+
_a[exports.YEARN_DAI_ADDRESS] = {
|
|
80
|
+
name: "Yearn DAI",
|
|
81
|
+
type: AdapterInterface.YEARN_V2,
|
|
82
|
+
icon: "/protocols/yearn.svg"
|
|
83
|
+
},
|
|
84
|
+
_a[exports.YEARN_DAI_KOVAN_MOCK] = {
|
|
85
|
+
name: "Yearn DAI",
|
|
86
|
+
type: AdapterInterface.YEARN_V2,
|
|
87
|
+
icon: "/protocols/yearn.svg"
|
|
88
|
+
},
|
|
89
|
+
_a[exports.YEARN_USDC_ADDRESS] = {
|
|
90
|
+
name: "Yearn USDC",
|
|
91
|
+
type: AdapterInterface.YEARN_V2,
|
|
92
|
+
icon: "/protocols/yearn.svg"
|
|
93
|
+
},
|
|
94
|
+
_a[exports.YEARN_USDC_KOVAN_MOCK] = {
|
|
95
|
+
name: "Yearn USDC",
|
|
96
|
+
type: AdapterInterface.YEARN_V2,
|
|
97
|
+
icon: "/protocols/yearn.svg"
|
|
98
|
+
},
|
|
99
|
+
_a[exports.SUSHISWAP_KOVAN] = {
|
|
100
|
+
name: "Sushiswap",
|
|
101
|
+
type: AdapterInterface.UNISWAP_V2,
|
|
102
|
+
icon: "/protocols/sushi.svg"
|
|
103
|
+
},
|
|
104
|
+
_a);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.getContractName = exports.deployedContracts = void 0;
|
|
5
|
+
var contracts_1 = require("./contracts");
|
|
6
|
+
exports.deployedContracts = (_a = {
|
|
7
|
+
// MAINNET
|
|
8
|
+
"0x24946bCbBd028D5ABb62ad9B635EB1b1a67AF668": "DAI",
|
|
9
|
+
"0x777E23A2AcB2fCbB35f6ccF98272d03C722Ba6EB": "DAI",
|
|
10
|
+
"0x86130bDD69143D8a4E5fc50bf4323D48049E98E4": "USDC",
|
|
11
|
+
"0x2664cc24CBAd28749B3Dd6fC97A6B402484De527": "USDC",
|
|
12
|
+
"0xB03670c20F87f2169A7c4eBE35746007e9575901": "WETH",
|
|
13
|
+
"0x968f9a68a98819E2e6Bb910466e191A7b6cf02F0": "WETH",
|
|
14
|
+
"0xB2A015c71c17bCAC6af36645DEad8c572bA08A08": "WBTC",
|
|
15
|
+
"0xC38478B0A4bAFE964C3526EEFF534d70E1E09017": "WBTC"
|
|
16
|
+
},
|
|
17
|
+
_a[contracts_1.UNISWAP_V2_ROUTER] = "Uniswap V2",
|
|
18
|
+
_a[contracts_1.UNISWAP_V3_ROUTER] = "Uniswap V3",
|
|
19
|
+
_a[contracts_1.CURVE_3POOL_ADDRESS] = "Curve 3Pool",
|
|
20
|
+
_a[contracts_1.SUSHISWAP_MAINNET] = "Sushiswap",
|
|
21
|
+
_a[contracts_1.YEARN_DAI_ADDRESS] = "Yearn DAI",
|
|
22
|
+
_a[contracts_1.YEARN_USDC_ADDRESS] = "Yearn USDC",
|
|
23
|
+
// KOVAN
|
|
24
|
+
_a["0xc40B71BCcb749D91923654571f715Bf1FC464E66"] = "DAI",
|
|
25
|
+
_a["0x1b0c9312FB74d08e57F49Ee5e4601a1846dc2207"] = "USDC",
|
|
26
|
+
_a["0x4b20dD834B8898caC2c1B2C94163f14FA866AadC"] = "WETH",
|
|
27
|
+
_a["0x2c52bc97485bcb3BeA763Fb5793eF15BA388D140"] = "WBTC",
|
|
28
|
+
_a["0xe04b4db67127d1930D36f16B51653120C4285708"] = "WBTC",
|
|
29
|
+
_a["0x600073357c29d169aAF3E543A4519749830553F1"] = "WETH",
|
|
30
|
+
_a["0xdBAd1361d9A03B81Be8D3a54Ef0dc9e39a1bA5b3"] = "USDC",
|
|
31
|
+
_a["0x50d1fA47b0D88BA0D108148B8481b4A762eFB99e"] = "DAI",
|
|
32
|
+
_a[contracts_1.YEARN_DAI_KOVAN_MOCK] = "Yearn DAI",
|
|
33
|
+
_a[contracts_1.YEARN_USDC_KOVAN_MOCK] = "Yearn USDC",
|
|
34
|
+
_a[contracts_1.SUSHISWAP_KOVAN] = "Sushiswap",
|
|
35
|
+
_a);
|
|
36
|
+
function getContractName(address) {
|
|
37
|
+
Object.entries(exports.deployedContracts).forEach(function (_a) {
|
|
38
|
+
var addr = _a[0], name = _a[1];
|
|
39
|
+
exports.deployedContracts[addr.toLowerCase()] = name;
|
|
40
|
+
});
|
|
41
|
+
return exports.deployedContracts[address.toLowerCase()] || address;
|
|
42
|
+
}
|
|
43
|
+
exports.getContractName = getContractName;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { BigNumber } from "ethers";
|
|
2
|
+
import { CreditAccountDataExtendedPayload, CreditAccountDataPayload } from "../payload/creditAccount";
|
|
3
|
+
import { TokenData } from "./tokenData";
|
|
4
|
+
export declare type Balance = {
|
|
5
|
+
address: string;
|
|
6
|
+
balance: BigNumber;
|
|
7
|
+
};
|
|
8
|
+
export declare class CreditAccountData {
|
|
9
|
+
readonly id: string;
|
|
10
|
+
readonly addr: string;
|
|
11
|
+
readonly borrower: string;
|
|
12
|
+
readonly inUse: boolean;
|
|
13
|
+
readonly creditManager: string;
|
|
14
|
+
readonly underlyingToken: string;
|
|
15
|
+
borrowedAmountPlusInterest: BigNumber;
|
|
16
|
+
totalValue: BigNumber;
|
|
17
|
+
healthFactor: number;
|
|
18
|
+
borrowRate: number;
|
|
19
|
+
readonly allowedTokens: Array<string>;
|
|
20
|
+
readonly allTokens: Array<string>;
|
|
21
|
+
balances: Record<string, BigNumber>;
|
|
22
|
+
allBalances: Record<string, BigNumber>;
|
|
23
|
+
isDeleting: boolean;
|
|
24
|
+
constructor(payload: CreditAccountDataPayload);
|
|
25
|
+
balancesSorted(prices: Record<string, number>, tokens: Record<string, TokenData>): Array<Balance>;
|
|
26
|
+
}
|
|
27
|
+
export declare class CreditAccountDataExtended extends CreditAccountData {
|
|
28
|
+
readonly repayAmount: BigNumber;
|
|
29
|
+
readonly liquidationAmount: BigNumber;
|
|
30
|
+
readonly borrowedAmount: BigNumber;
|
|
31
|
+
readonly canBeClosed: boolean;
|
|
32
|
+
readonly cumulativeIndexAtOpen: BigNumber;
|
|
33
|
+
readonly since: number;
|
|
34
|
+
constructor(payload: CreditAccountDataExtendedPayload);
|
|
35
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.CreditAccountDataExtended = exports.CreditAccountData = void 0;
|
|
19
|
+
var ethers_1 = require("ethers");
|
|
20
|
+
var constants_1 = require("./constants");
|
|
21
|
+
var CreditAccountData = /** @class */ (function () {
|
|
22
|
+
function CreditAccountData(payload) {
|
|
23
|
+
var _this = this;
|
|
24
|
+
this.allowedTokens = [];
|
|
25
|
+
this.allTokens = [];
|
|
26
|
+
this.balances = {};
|
|
27
|
+
this.allBalances = {};
|
|
28
|
+
this.id = payload.creditManager;
|
|
29
|
+
this.addr = payload.addr;
|
|
30
|
+
this.borrower = payload.borrower;
|
|
31
|
+
this.inUse = payload.inUse;
|
|
32
|
+
this.creditManager = payload.creditManager;
|
|
33
|
+
this.underlyingToken = payload.underlyingToken;
|
|
34
|
+
this.borrowedAmountPlusInterest = ethers_1.BigNumber.from(payload.borrowedAmountPlusInterest);
|
|
35
|
+
this.totalValue = ethers_1.BigNumber.from(payload.totalValue);
|
|
36
|
+
this.healthFactor =
|
|
37
|
+
ethers_1.BigNumber.from(payload.healthFactor).toNumber() / constants_1.PERCENTAGE_FACTOR;
|
|
38
|
+
this.borrowRate =
|
|
39
|
+
ethers_1.BigNumber.from(payload.borrowRate)
|
|
40
|
+
.mul(constants_1.PERCENTAGE_FACTOR)
|
|
41
|
+
.mul(100)
|
|
42
|
+
.div(constants_1.RAY)
|
|
43
|
+
.toNumber() / constants_1.PERCENTAGE_FACTOR;
|
|
44
|
+
(payload.balances || []).forEach(function (b) {
|
|
45
|
+
if (b.isAllowed) {
|
|
46
|
+
_this.balances[b.token] = ethers_1.BigNumber.from(b.balance);
|
|
47
|
+
_this.allowedTokens.push(b.token);
|
|
48
|
+
}
|
|
49
|
+
_this.allBalances[b.token] = ethers_1.BigNumber.from(b.balance);
|
|
50
|
+
_this.allTokens.push(b.token);
|
|
51
|
+
});
|
|
52
|
+
this.isDeleting = false;
|
|
53
|
+
}
|
|
54
|
+
CreditAccountData.prototype.balancesSorted = function (prices, tokens) {
|
|
55
|
+
var priceCalc = function (addr, amount) {
|
|
56
|
+
var _a;
|
|
57
|
+
return amount
|
|
58
|
+
.mul(Math.floor(1000 * prices[addr.toLowerCase() || ""] || 0))
|
|
59
|
+
.div(ethers_1.BigNumber.from(10).pow(((_a = tokens[addr]) === null || _a === void 0 ? void 0 : _a.decimals) || 18));
|
|
60
|
+
};
|
|
61
|
+
var tokensAbcComparator = function (t1, t2) {
|
|
62
|
+
return ((t1 === null || t1 === void 0 ? void 0 : t1.symbol) || "") > ((t2 === null || t2 === void 0 ? void 0 : t2.symbol) || "") ? 1 : -1;
|
|
63
|
+
};
|
|
64
|
+
return tokens
|
|
65
|
+
? Object.entries(this.balances || [])
|
|
66
|
+
.sort(function (_a, _b) {
|
|
67
|
+
var addr1 = _a[0], amount1 = _a[1];
|
|
68
|
+
var addr2 = _b[0], amount2 = _b[1];
|
|
69
|
+
return priceCalc(addr1, amount1).eq(priceCalc(addr2, amount2))
|
|
70
|
+
? tokensAbcComparator(tokens[addr1], tokens[addr2])
|
|
71
|
+
: priceCalc(addr1, amount1).gt(priceCalc(addr2, amount2))
|
|
72
|
+
? -1
|
|
73
|
+
: 1;
|
|
74
|
+
})
|
|
75
|
+
.map(function (_a) {
|
|
76
|
+
var address = _a[0], balance = _a[1];
|
|
77
|
+
return ({ address: address, balance: balance });
|
|
78
|
+
})
|
|
79
|
+
: [];
|
|
80
|
+
};
|
|
81
|
+
return CreditAccountData;
|
|
82
|
+
}());
|
|
83
|
+
exports.CreditAccountData = CreditAccountData;
|
|
84
|
+
var CreditAccountDataExtended = /** @class */ (function (_super) {
|
|
85
|
+
__extends(CreditAccountDataExtended, _super);
|
|
86
|
+
function CreditAccountDataExtended(payload) {
|
|
87
|
+
var _this = _super.call(this, payload) || this;
|
|
88
|
+
_this.borrowedAmount = ethers_1.BigNumber.from(payload.borrowedAmount);
|
|
89
|
+
_this.cumulativeIndexAtOpen = ethers_1.BigNumber.from(payload.cumulativeIndexAtOpen);
|
|
90
|
+
_this.repayAmount = ethers_1.BigNumber.from(payload.repayAmount);
|
|
91
|
+
_this.liquidationAmount = ethers_1.BigNumber.from(payload.liquidationAmount);
|
|
92
|
+
_this.canBeClosed = payload.canBeClosed || false;
|
|
93
|
+
_this.since = ethers_1.BigNumber.from(payload.since).toNumber();
|
|
94
|
+
return _this;
|
|
95
|
+
}
|
|
96
|
+
return CreditAccountDataExtended;
|
|
97
|
+
}(CreditAccountData));
|
|
98
|
+
exports.CreditAccountDataExtended = CreditAccountDataExtended;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface CardCustomisation {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
background: string;
|
|
5
|
+
}
|
|
6
|
+
export interface CardBackground {
|
|
7
|
+
id: string;
|
|
8
|
+
background: string;
|
|
9
|
+
}
|
|
10
|
+
export interface CardCollection {
|
|
11
|
+
id: string;
|
|
12
|
+
backgrounds: Array<CardBackground>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { BigNumber, ethers, Signer } from "ethers";
|
|
2
|
+
import { IAppCreditManager } from "../types";
|
|
3
|
+
import { CreditManagerDataPayload, CreditManagerStatPayload } from "../payload/creditManager";
|
|
4
|
+
export declare class CreditManagerData {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly address: string;
|
|
7
|
+
readonly underlyingToken: string;
|
|
8
|
+
readonly isWETH: boolean;
|
|
9
|
+
readonly canBorrow: boolean;
|
|
10
|
+
readonly borrowRate: number;
|
|
11
|
+
readonly minAmount: BigNumber;
|
|
12
|
+
readonly maxAmount: BigNumber;
|
|
13
|
+
readonly maxLeverageFactor: number;
|
|
14
|
+
readonly availableLiquidity: BigNumber;
|
|
15
|
+
readonly allowedTokens: Array<string>;
|
|
16
|
+
readonly adapters: Record<string, string>;
|
|
17
|
+
constructor(payload: CreditManagerDataPayload);
|
|
18
|
+
validateOpenAccount(balance: BigNumber, decimals: number, amount_BN: BigNumber, leverage: number): string | null;
|
|
19
|
+
getContractETH(signer: Signer | ethers.providers.Provider): IAppCreditManager;
|
|
20
|
+
}
|
|
21
|
+
export declare function calcMaxIncreaseBorrow(healthFactor: number, borrowAmountPlusInterest: BigNumber, maxLeverageFactor: number): BigNumber;
|
|
22
|
+
export declare function calcHealthFactorAfterIncreasingBorrow(healthFactor: number | undefined, borrowAmountPlusInterest: BigNumber | undefined, additional: BigNumber): number;
|
|
23
|
+
export declare function calcHealthFactorAfterAddingCollateral(healthFactor: number | undefined, borrowAmountPlusInterest: BigNumber | undefined, additionalCollateral: BigNumber): number;
|
|
24
|
+
export declare class CreditManagerStat extends CreditManagerData {
|
|
25
|
+
readonly uniqueUsers: number;
|
|
26
|
+
readonly openedAccountsCount: number;
|
|
27
|
+
readonly totalOpenedAccounts: number;
|
|
28
|
+
readonly totalClosedAccounts: number;
|
|
29
|
+
readonly totalRepaidAccounts: number;
|
|
30
|
+
readonly totalLiquidatedAccounts: number;
|
|
31
|
+
readonly totalBorrowed: BigNumber;
|
|
32
|
+
readonly cumulativeBorrowed: BigNumber;
|
|
33
|
+
readonly totalRepaid: BigNumber;
|
|
34
|
+
readonly totalProfit: BigNumber;
|
|
35
|
+
readonly totalLosses: BigNumber;
|
|
36
|
+
constructor(payload: CreditManagerStatPayload);
|
|
37
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.CreditManagerStat = exports.calcHealthFactorAfterAddingCollateral = exports.calcHealthFactorAfterIncreasingBorrow = exports.calcMaxIncreaseBorrow = exports.CreditManagerData = void 0;
|
|
19
|
+
var ethers_1 = require("ethers");
|
|
20
|
+
var types_1 = require("../types");
|
|
21
|
+
var formatter_1 = require("../utils/formatter");
|
|
22
|
+
var constants_1 = require("./constants");
|
|
23
|
+
var CreditManagerData = /** @class */ (function () {
|
|
24
|
+
function CreditManagerData(payload) {
|
|
25
|
+
var _this = this;
|
|
26
|
+
var _a;
|
|
27
|
+
this.adapters = {};
|
|
28
|
+
this.id = payload.addr;
|
|
29
|
+
this.address = payload.addr;
|
|
30
|
+
this.underlyingToken = payload.underlyingToken || "";
|
|
31
|
+
this.isWETH = payload.isWETH || false;
|
|
32
|
+
this.canBorrow = payload.canBorrow || false;
|
|
33
|
+
this.borrowRate =
|
|
34
|
+
ethers_1.BigNumber.from(payload.borrowRate || 0)
|
|
35
|
+
.mul(constants_1.PERCENTAGE_FACTOR)
|
|
36
|
+
.mul(100)
|
|
37
|
+
.div(constants_1.RAY)
|
|
38
|
+
.toNumber() / constants_1.PERCENTAGE_FACTOR;
|
|
39
|
+
this.minAmount = ethers_1.BigNumber.from(payload.minAmount || 0);
|
|
40
|
+
this.maxAmount = ethers_1.BigNumber.from(payload.maxAmount || 0);
|
|
41
|
+
this.maxLeverageFactor = ethers_1.BigNumber.from(payload.maxLeverageFactor || 0).toNumber();
|
|
42
|
+
this.availableLiquidity = ethers_1.BigNumber.from(payload.availableLiquidity || 0);
|
|
43
|
+
this.allowedTokens = payload.allowedTokens || [];
|
|
44
|
+
(_a = payload.adapters) === null || _a === void 0 ? void 0 : _a.forEach(function (a) {
|
|
45
|
+
_this.adapters[a.allowedContract] = a.adapter;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
CreditManagerData.prototype.validateOpenAccount = function (balance, decimals, amount_BN, leverage) {
|
|
49
|
+
if (balance.lt(amount_BN))
|
|
50
|
+
return "Insufficient funds";
|
|
51
|
+
if (amount_BN.lt(this.minAmount))
|
|
52
|
+
return "Amount is less than minimal (".concat((0, formatter_1.formatBN)(this.minAmount, decimals), ")");
|
|
53
|
+
if (amount_BN.gt(this.maxAmount))
|
|
54
|
+
return "Amount is greater than maximum (".concat((0, formatter_1.formatBN)(this.maxAmount, decimals), ")");
|
|
55
|
+
if (leverage > this.maxLeverageFactor)
|
|
56
|
+
return "Leverage is bigger than max";
|
|
57
|
+
if (amount_BN.mul(leverage).div(100).gt(this.availableLiquidity))
|
|
58
|
+
return "Insufficient liquidity in the pool";
|
|
59
|
+
return null;
|
|
60
|
+
};
|
|
61
|
+
CreditManagerData.prototype.getContractETH = function (signer) {
|
|
62
|
+
return types_1.IAppCreditManager__factory.connect(this.address, signer);
|
|
63
|
+
};
|
|
64
|
+
return CreditManagerData;
|
|
65
|
+
}());
|
|
66
|
+
exports.CreditManagerData = CreditManagerData;
|
|
67
|
+
function calcMaxIncreaseBorrow(healthFactor, borrowAmountPlusInterest, maxLeverageFactor) {
|
|
68
|
+
var healthFactorPercentage = Math.floor(healthFactor * constants_1.PERCENTAGE_FACTOR);
|
|
69
|
+
var minHealthFactor = Math.floor((constants_1.UNDERLYING_TOKEN_LIQUIDATION_THRESHOLD * (maxLeverageFactor + 100)) /
|
|
70
|
+
maxLeverageFactor);
|
|
71
|
+
var result = borrowAmountPlusInterest
|
|
72
|
+
.mul(healthFactorPercentage - minHealthFactor)
|
|
73
|
+
.div(minHealthFactor - constants_1.UNDERLYING_TOKEN_LIQUIDATION_THRESHOLD);
|
|
74
|
+
return result.isNegative() ? ethers_1.BigNumber.from(0) : result;
|
|
75
|
+
}
|
|
76
|
+
exports.calcMaxIncreaseBorrow = calcMaxIncreaseBorrow;
|
|
77
|
+
function calcHealthFactorAfterIncreasingBorrow(healthFactor, borrowAmountPlusInterest, additional) {
|
|
78
|
+
if (!healthFactor || !borrowAmountPlusInterest)
|
|
79
|
+
return 0;
|
|
80
|
+
var healthFactorPercentage = Math.floor(healthFactor * constants_1.PERCENTAGE_FACTOR);
|
|
81
|
+
return (borrowAmountPlusInterest
|
|
82
|
+
.mul(healthFactorPercentage)
|
|
83
|
+
.add(additional.mul(constants_1.UNDERLYING_TOKEN_LIQUIDATION_THRESHOLD))
|
|
84
|
+
.div(borrowAmountPlusInterest.add(additional))
|
|
85
|
+
.toNumber() / constants_1.PERCENTAGE_FACTOR);
|
|
86
|
+
}
|
|
87
|
+
exports.calcHealthFactorAfterIncreasingBorrow = calcHealthFactorAfterIncreasingBorrow;
|
|
88
|
+
function calcHealthFactorAfterAddingCollateral(healthFactor, borrowAmountPlusInterest, additionalCollateral) {
|
|
89
|
+
if (!healthFactor || !borrowAmountPlusInterest)
|
|
90
|
+
return 0;
|
|
91
|
+
var healthFactorPercentage = Math.floor(healthFactor * constants_1.PERCENTAGE_FACTOR);
|
|
92
|
+
return (borrowAmountPlusInterest
|
|
93
|
+
.mul(healthFactorPercentage)
|
|
94
|
+
.add(additionalCollateral.mul(constants_1.UNDERLYING_TOKEN_LIQUIDATION_THRESHOLD))
|
|
95
|
+
.div(borrowAmountPlusInterest)
|
|
96
|
+
.toNumber() / constants_1.PERCENTAGE_FACTOR);
|
|
97
|
+
}
|
|
98
|
+
exports.calcHealthFactorAfterAddingCollateral = calcHealthFactorAfterAddingCollateral;
|
|
99
|
+
var CreditManagerStat = /** @class */ (function (_super) {
|
|
100
|
+
__extends(CreditManagerStat, _super);
|
|
101
|
+
function CreditManagerStat(payload) {
|
|
102
|
+
var _this = _super.call(this, payload) || this;
|
|
103
|
+
_this.uniqueUsers = payload.uniqueUsers;
|
|
104
|
+
_this.openedAccountsCount = payload.openedAccountsCount || 0;
|
|
105
|
+
_this.totalOpenedAccounts = payload.totalOpenedAccounts || 0;
|
|
106
|
+
_this.totalClosedAccounts = payload.totalClosedAccounts || 0;
|
|
107
|
+
_this.totalRepaidAccounts = payload.totalRepaidAccounts || 0;
|
|
108
|
+
_this.totalLiquidatedAccounts = payload.totalLiquidatedAccounts || 0;
|
|
109
|
+
_this.totalBorrowed = ethers_1.BigNumber.from(payload.totalBorrowed || 0);
|
|
110
|
+
_this.cumulativeBorrowed = ethers_1.BigNumber.from(payload.cumulativeBorrowed || 0);
|
|
111
|
+
_this.totalRepaid = ethers_1.BigNumber.from(payload.totalRepaid || 0);
|
|
112
|
+
_this.totalProfit = ethers_1.BigNumber.from(payload.totalProfit || 0);
|
|
113
|
+
_this.totalLosses = ethers_1.BigNumber.from(payload.totalLosses || 0);
|
|
114
|
+
return _this;
|
|
115
|
+
}
|
|
116
|
+
return CreditManagerStat;
|
|
117
|
+
}(CreditManagerData));
|
|
118
|
+
exports.CreditManagerStat = CreditManagerStat;
|