diff --git a/src/apps/polygon/ethereum/polygon.balance-fetcher.ts b/src/apps/polygon/ethereum/polygon.balance-fetcher.ts index 181219ddd..9247f3751 100644 --- a/src/apps/polygon/ethereum/polygon.balance-fetcher.ts +++ b/src/apps/polygon/ethereum/polygon.balance-fetcher.ts @@ -14,7 +14,7 @@ import { POLYGON_DEFINITION } from '../polygon.definition'; import { PolygonStakingContractPositionDataProps } from './polygon.staking.contract-position-fetcher'; -type Eth2DepositsResponse = { +type DelegatedMaticResponse = { delegators: { validatorId: string; delegatedAmount: string; @@ -39,7 +39,7 @@ export class EthereumPolygonBalanceFetcher implements BalanceFetcher { constructor(@Inject(APP_TOOLKIT) private readonly appToolkit: IAppToolkit) {} async getDelegatedBalances(address: string) { - const data = await this.appToolkit.helpers.theGraphHelper.gqlFetchAll({ + const data = await this.appToolkit.helpers.theGraphHelper.gqlFetchAll({ endpoint: GQL_ENDPOINT, query: DELEGATED_MATIC_QUERY, dataToSearch: 'delegators', diff --git a/src/apps/sushiswap-kashi/arbitrum/sushiswap-kashi.balance-fetcher.ts b/src/apps/sushiswap-kashi/arbitrum/sushiswap-kashi.balance-fetcher.ts new file mode 100644 index 000000000..c7958ac24 --- /dev/null +++ b/src/apps/sushiswap-kashi/arbitrum/sushiswap-kashi.balance-fetcher.ts @@ -0,0 +1,34 @@ +import { Inject } from '@nestjs/common'; + +import { Register } from '~app-toolkit/decorators'; +import { presentBalanceFetcherResponse } from '~app-toolkit/helpers/presentation/balance-fetcher-response.present'; +import { BalanceFetcher } from '~balance/balance-fetcher.interface'; +import { Network } from '~types/network.interface'; + +import { SushiSwapKashiLendingBalanceHelper } from '../helpers/sushiswap-kashi.lending.balance-helper'; +import { SUSHISWAP_KASHI_DEFINITION } from '../sushiswap-kashi.definition'; + +const appId = SUSHISWAP_KASHI_DEFINITION.id; +const network = Network.ARBITRUM_MAINNET; + +@Register.BalanceFetcher(appId, network) +export class ArbitrumSushiswapKashiBalanceFetcher implements BalanceFetcher { + constructor( + @Inject(SushiSwapKashiLendingBalanceHelper) + private readonly sushiSwapKashiLendingBalanceHelper: SushiSwapKashiLendingBalanceHelper, + ) {} + + async getBalances(address: string) { + const balances = await this.sushiSwapKashiLendingBalanceHelper.getBalances({ + network, + address, + }); + + return presentBalanceFetcherResponse([ + { + label: 'Lending', + assets: balances, + }, + ]); + } +} diff --git a/src/apps/sushiswap-kashi/arbitrum/sushiswap-kashi.lending.token-fetcher.ts b/src/apps/sushiswap-kashi/arbitrum/sushiswap-kashi.lending.token-fetcher.ts new file mode 100644 index 000000000..de6d650df --- /dev/null +++ b/src/apps/sushiswap-kashi/arbitrum/sushiswap-kashi.lending.token-fetcher.ts @@ -0,0 +1,29 @@ +import { Inject } from '@nestjs/common'; + +import { Register } from '~app-toolkit/decorators'; +import { PositionFetcher } from '~position/position-fetcher.interface'; +import { AppTokenPosition } from '~position/position.interface'; +import { Network } from '~types/network.interface'; + +import { SushiswapKashiLendingTokenHelper } from '../helpers/sushiswap-kashi.lending.token-helper'; +import { SUSHISWAP_KASHI_DEFINITION } from '../sushiswap-kashi.definition'; + +const appId = SUSHISWAP_KASHI_DEFINITION.id; +const groupId = SUSHISWAP_KASHI_DEFINITION.groups.lending.id; +const network = Network.ARBITRUM_MAINNET; + +@Register.TokenPositionFetcher({ appId, groupId, network }) +export class ArbitrumSushiswapKashiLendingTokenFetcher implements PositionFetcher { + constructor( + @Inject(SushiswapKashiLendingTokenHelper) private readonly lendingTokenHelper: SushiswapKashiLendingTokenHelper, + ) {} + + getPositions() { + return this.lendingTokenHelper.getTokens({ + network, + subgraphUrl: 'https://api.thegraph.com/subgraphs/name/sushiswap/arbitrum-bentobox', + subgraphVersion: 1, + first: 1000, + }); + } +} diff --git a/src/apps/sushiswap-kashi/binance-smart-chain/sushiswap-kashi.balance-fetcher.ts b/src/apps/sushiswap-kashi/binance-smart-chain/sushiswap-kashi.balance-fetcher.ts new file mode 100644 index 000000000..4bf64c021 --- /dev/null +++ b/src/apps/sushiswap-kashi/binance-smart-chain/sushiswap-kashi.balance-fetcher.ts @@ -0,0 +1,34 @@ +import { Inject } from '@nestjs/common'; + +import { Register } from '~app-toolkit/decorators'; +import { presentBalanceFetcherResponse } from '~app-toolkit/helpers/presentation/balance-fetcher-response.present'; +import { BalanceFetcher } from '~balance/balance-fetcher.interface'; +import { Network } from '~types/network.interface'; + +import { SushiSwapKashiLendingBalanceHelper } from '../helpers/sushiswap-kashi.lending.balance-helper'; +import { SUSHISWAP_KASHI_DEFINITION } from '../sushiswap-kashi.definition'; + +const appId = SUSHISWAP_KASHI_DEFINITION.id; +const network = Network.BINANCE_SMART_CHAIN_MAINNET; + +@Register.BalanceFetcher(appId, network) +export class BinanceSmartChainSushiswapKashiBalanceFetcher implements BalanceFetcher { + constructor( + @Inject(SushiSwapKashiLendingBalanceHelper) + private readonly sushiSwapKashiLendingBalanceHelper: SushiSwapKashiLendingBalanceHelper, + ) {} + + async getBalances(address: string) { + const balances = await this.sushiSwapKashiLendingBalanceHelper.getBalances({ + network, + address, + }); + + return presentBalanceFetcherResponse([ + { + label: 'Lending', + assets: balances, + }, + ]); + } +} diff --git a/src/apps/sushiswap-kashi/binance-smart-chain/sushiswap-kashi.lending.token-fetcher.ts b/src/apps/sushiswap-kashi/binance-smart-chain/sushiswap-kashi.lending.token-fetcher.ts new file mode 100644 index 000000000..e3442ee53 --- /dev/null +++ b/src/apps/sushiswap-kashi/binance-smart-chain/sushiswap-kashi.lending.token-fetcher.ts @@ -0,0 +1,29 @@ +import { Inject } from '@nestjs/common'; + +import { Register } from '~app-toolkit/decorators'; +import { PositionFetcher } from '~position/position-fetcher.interface'; +import { AppTokenPosition } from '~position/position.interface'; +import { Network } from '~types/network.interface'; + +import { SushiswapKashiLendingTokenHelper } from '../helpers/sushiswap-kashi.lending.token-helper'; +import { SUSHISWAP_KASHI_DEFINITION } from '../sushiswap-kashi.definition'; + +const appId = SUSHISWAP_KASHI_DEFINITION.id; +const groupId = SUSHISWAP_KASHI_DEFINITION.groups.lending.id; +const network = Network.BINANCE_SMART_CHAIN_MAINNET; + +@Register.TokenPositionFetcher({ appId, groupId, network }) +export class BinanceSmartChainSushiswapKashiLendingTokenFetcher implements PositionFetcher { + constructor( + @Inject(SushiswapKashiLendingTokenHelper) private readonly lendingTokenHelper: SushiswapKashiLendingTokenHelper, + ) {} + + getPositions() { + return this.lendingTokenHelper.getTokens({ + network, + subgraphUrl: 'https://api.thegraph.com/subgraphs/name/sushiswap/bsc-bentobox', + subgraphVersion: 1, + first: 1000, + }); + } +} diff --git a/src/apps/sushiswap-kashi/contracts/abis/sushiswap-kashi-lending-token.json b/src/apps/sushiswap-kashi/contracts/abis/sushiswap-kashi-lending-token.json new file mode 100644 index 000000000..49099f588 --- /dev/null +++ b/src/apps/sushiswap-kashi/contracts/abis/sushiswap-kashi-lending-token.json @@ -0,0 +1,508 @@ +[ + { + "inputs": [{ "internalType": "contract IBentoBoxV1", "name": "bentoBox_", "type": "address" }], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "_owner", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "_spender", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "_value", "type": "uint256" } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "uint256", "name": "accruedAmount", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "feeFraction", "type": "uint256" }, + { "indexed": false, "internalType": "uint64", "name": "rate", "type": "uint64" }, + { "indexed": false, "internalType": "uint256", "name": "utilization", "type": "uint256" } + ], + "name": "LogAccrue", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "from", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "to", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "share", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "fraction", "type": "uint256" } + ], + "name": "LogAddAsset", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "from", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "to", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "share", "type": "uint256" } + ], + "name": "LogAddCollateral", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "from", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "to", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "feeAmount", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "part", "type": "uint256" } + ], + "name": "LogBorrow", + "type": "event" + }, + { + "anonymous": false, + "inputs": [{ "indexed": false, "internalType": "uint256", "name": "rate", "type": "uint256" }], + "name": "LogExchangeRate", + "type": "event" + }, + { + "anonymous": false, + "inputs": [{ "indexed": true, "internalType": "address", "name": "newFeeTo", "type": "address" }], + "name": "LogFeeTo", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "from", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "to", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "share", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "fraction", "type": "uint256" } + ], + "name": "LogRemoveAsset", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "from", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "to", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "share", "type": "uint256" } + ], + "name": "LogRemoveCollateral", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "from", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "to", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "part", "type": "uint256" } + ], + "name": "LogRepay", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "feeTo", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "feesEarnedFraction", "type": "uint256" } + ], + "name": "LogWithdrawFees", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "previousOwner", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "newOwner", "type": "address" } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "_from", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "_to", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "_value", "type": "uint256" } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [], + "name": "DOMAIN_SEPARATOR", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { "inputs": [], "name": "accrue", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [], + "name": "accrueInfo", + "outputs": [ + { "internalType": "uint64", "name": "interestPerSecond", "type": "uint64" }, + { "internalType": "uint64", "name": "lastAccrued", "type": "uint64" }, + { "internalType": "uint128", "name": "feesEarnedFraction", "type": "uint128" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "bool", "name": "skim", "type": "bool" }, + { "internalType": "uint256", "name": "share", "type": "uint256" } + ], + "name": "addAsset", + "outputs": [{ "internalType": "uint256", "name": "fraction", "type": "uint256" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "bool", "name": "skim", "type": "bool" }, + { "internalType": "uint256", "name": "share", "type": "uint256" } + ], + "name": "addCollateral", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "", "type": "address" }, + { "internalType": "address", "name": "", "type": "address" } + ], + "name": "allowance", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "spender", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "approve", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "asset", + "outputs": [{ "internalType": "contract IERC20", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "balanceOf", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "bentoBox", + "outputs": [{ "internalType": "contract IBentoBoxV1", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "borrow", + "outputs": [ + { "internalType": "uint256", "name": "part", "type": "uint256" }, + { "internalType": "uint256", "name": "share", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { "inputs": [], "name": "claimOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [], + "name": "collateral", + "outputs": [{ "internalType": "contract IERC20", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint8[]", "name": "actions", "type": "uint8[]" }, + { "internalType": "uint256[]", "name": "values", "type": "uint256[]" }, + { "internalType": "bytes[]", "name": "datas", "type": "bytes[]" } + ], + "name": "cook", + "outputs": [ + { "internalType": "uint256", "name": "value1", "type": "uint256" }, + { "internalType": "uint256", "name": "value2", "type": "uint256" } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "exchangeRate", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "feeTo", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "bytes", "name": "data", "type": "bytes" }], + "name": "init", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address[]", "name": "users", "type": "address[]" }, + { "internalType": "uint256[]", "name": "maxBorrowParts", "type": "uint256[]" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "contract ISwapper", "name": "swapper", "type": "address" }, + { "internalType": "bool", "name": "open", "type": "bool" } + ], + "name": "liquidate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "masterContract", + "outputs": [{ "internalType": "contract KashiPairMediumRiskV1", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "nonces", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "oracle", + "outputs": [{ "internalType": "contract IOracle", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "oracleData", + "outputs": [{ "internalType": "bytes", "name": "", "type": "bytes" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "owner_", "type": "address" }, + { "internalType": "address", "name": "spender", "type": "address" }, + { "internalType": "uint256", "name": "value", "type": "uint256" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" }, + { "internalType": "uint8", "name": "v", "type": "uint8" }, + { "internalType": "bytes32", "name": "r", "type": "bytes32" }, + { "internalType": "bytes32", "name": "s", "type": "bytes32" } + ], + "name": "permit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "fraction", "type": "uint256" } + ], + "name": "removeAsset", + "outputs": [{ "internalType": "uint256", "name": "share", "type": "uint256" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "share", "type": "uint256" } + ], + "name": "removeCollateral", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "bool", "name": "skim", "type": "bool" }, + { "internalType": "uint256", "name": "part", "type": "uint256" } + ], + "name": "repay", + "outputs": [{ "internalType": "uint256", "name": "amount", "type": "uint256" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "newFeeTo", "type": "address" }], + "name": "setFeeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "contract ISwapper", "name": "swapper", "type": "address" }, + { "internalType": "bool", "name": "enable", "type": "bool" } + ], + "name": "setSwapper", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "contract ISwapper", "name": "", "type": "address" }], + "name": "swappers", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalAsset", + "outputs": [ + { "internalType": "uint128", "name": "elastic", "type": "uint128" }, + { "internalType": "uint128", "name": "base", "type": "uint128" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalBorrow", + "outputs": [ + { "internalType": "uint128", "name": "elastic", "type": "uint128" }, + { "internalType": "uint128", "name": "base", "type": "uint128" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalCollateralShare", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "transfer", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "from", "type": "address" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "transferFrom", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "newOwner", "type": "address" }, + { "internalType": "bool", "name": "direct", "type": "bool" }, + { "internalType": "bool", "name": "renounce", "type": "bool" } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "updateExchangeRate", + "outputs": [ + { "internalType": "bool", "name": "updated", "type": "bool" }, + { "internalType": "uint256", "name": "rate", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "userBorrowPart", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "userCollateralShare", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { "inputs": [], "name": "withdrawFees", "outputs": [], "stateMutability": "nonpayable", "type": "function" } +] diff --git a/src/apps/sushiswap-kashi/contracts/ethers/SushiswapKashiLendingToken.ts b/src/apps/sushiswap-kashi/contracts/ethers/SushiswapKashiLendingToken.ts new file mode 100644 index 000000000..4ed4d35ca --- /dev/null +++ b/src/apps/sushiswap-kashi/contracts/ethers/SushiswapKashiLendingToken.ts @@ -0,0 +1,1272 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumber, + BigNumberish, + BytesLike, + CallOverrides, + ContractTransaction, + Overrides, + PayableOverrides, + PopulatedTransaction, + Signer, + utils, +} from 'ethers'; +import type { FunctionFragment, Result, EventFragment } from '@ethersproject/abi'; +import type { Listener, Provider } from '@ethersproject/providers'; +import type { TypedEventFilter, TypedEvent, TypedListener, OnEvent } from './common'; + +export interface SushiswapKashiLendingTokenInterface extends utils.Interface { + functions: { + 'DOMAIN_SEPARATOR()': FunctionFragment; + 'accrue()': FunctionFragment; + 'accrueInfo()': FunctionFragment; + 'addAsset(address,bool,uint256)': FunctionFragment; + 'addCollateral(address,bool,uint256)': FunctionFragment; + 'allowance(address,address)': FunctionFragment; + 'approve(address,uint256)': FunctionFragment; + 'asset()': FunctionFragment; + 'balanceOf(address)': FunctionFragment; + 'bentoBox()': FunctionFragment; + 'borrow(address,uint256)': FunctionFragment; + 'claimOwnership()': FunctionFragment; + 'collateral()': FunctionFragment; + 'cook(uint8[],uint256[],bytes[])': FunctionFragment; + 'decimals()': FunctionFragment; + 'exchangeRate()': FunctionFragment; + 'feeTo()': FunctionFragment; + 'init(bytes)': FunctionFragment; + 'liquidate(address[],uint256[],address,address,bool)': FunctionFragment; + 'masterContract()': FunctionFragment; + 'name()': FunctionFragment; + 'nonces(address)': FunctionFragment; + 'oracle()': FunctionFragment; + 'oracleData()': FunctionFragment; + 'owner()': FunctionFragment; + 'pendingOwner()': FunctionFragment; + 'permit(address,address,uint256,uint256,uint8,bytes32,bytes32)': FunctionFragment; + 'removeAsset(address,uint256)': FunctionFragment; + 'removeCollateral(address,uint256)': FunctionFragment; + 'repay(address,bool,uint256)': FunctionFragment; + 'setFeeTo(address)': FunctionFragment; + 'setSwapper(address,bool)': FunctionFragment; + 'swappers(address)': FunctionFragment; + 'symbol()': FunctionFragment; + 'totalAsset()': FunctionFragment; + 'totalBorrow()': FunctionFragment; + 'totalCollateralShare()': FunctionFragment; + 'totalSupply()': FunctionFragment; + 'transfer(address,uint256)': FunctionFragment; + 'transferFrom(address,address,uint256)': FunctionFragment; + 'transferOwnership(address,bool,bool)': FunctionFragment; + 'updateExchangeRate()': FunctionFragment; + 'userBorrowPart(address)': FunctionFragment; + 'userCollateralShare(address)': FunctionFragment; + 'withdrawFees()': FunctionFragment; + }; + + getFunction( + nameOrSignatureOrTopic: + | 'DOMAIN_SEPARATOR' + | 'accrue' + | 'accrueInfo' + | 'addAsset' + | 'addCollateral' + | 'allowance' + | 'approve' + | 'asset' + | 'balanceOf' + | 'bentoBox' + | 'borrow' + | 'claimOwnership' + | 'collateral' + | 'cook' + | 'decimals' + | 'exchangeRate' + | 'feeTo' + | 'init' + | 'liquidate' + | 'masterContract' + | 'name' + | 'nonces' + | 'oracle' + | 'oracleData' + | 'owner' + | 'pendingOwner' + | 'permit' + | 'removeAsset' + | 'removeCollateral' + | 'repay' + | 'setFeeTo' + | 'setSwapper' + | 'swappers' + | 'symbol' + | 'totalAsset' + | 'totalBorrow' + | 'totalCollateralShare' + | 'totalSupply' + | 'transfer' + | 'transferFrom' + | 'transferOwnership' + | 'updateExchangeRate' + | 'userBorrowPart' + | 'userCollateralShare' + | 'withdrawFees', + ): FunctionFragment; + + encodeFunctionData(functionFragment: 'DOMAIN_SEPARATOR', values?: undefined): string; + encodeFunctionData(functionFragment: 'accrue', values?: undefined): string; + encodeFunctionData(functionFragment: 'accrueInfo', values?: undefined): string; + encodeFunctionData(functionFragment: 'addAsset', values: [string, boolean, BigNumberish]): string; + encodeFunctionData(functionFragment: 'addCollateral', values: [string, boolean, BigNumberish]): string; + encodeFunctionData(functionFragment: 'allowance', values: [string, string]): string; + encodeFunctionData(functionFragment: 'approve', values: [string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'asset', values?: undefined): string; + encodeFunctionData(functionFragment: 'balanceOf', values: [string]): string; + encodeFunctionData(functionFragment: 'bentoBox', values?: undefined): string; + encodeFunctionData(functionFragment: 'borrow', values: [string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'claimOwnership', values?: undefined): string; + encodeFunctionData(functionFragment: 'collateral', values?: undefined): string; + encodeFunctionData(functionFragment: 'cook', values: [BigNumberish[], BigNumberish[], BytesLike[]]): string; + encodeFunctionData(functionFragment: 'decimals', values?: undefined): string; + encodeFunctionData(functionFragment: 'exchangeRate', values?: undefined): string; + encodeFunctionData(functionFragment: 'feeTo', values?: undefined): string; + encodeFunctionData(functionFragment: 'init', values: [BytesLike]): string; + encodeFunctionData( + functionFragment: 'liquidate', + values: [string[], BigNumberish[], string, string, boolean], + ): string; + encodeFunctionData(functionFragment: 'masterContract', values?: undefined): string; + encodeFunctionData(functionFragment: 'name', values?: undefined): string; + encodeFunctionData(functionFragment: 'nonces', values: [string]): string; + encodeFunctionData(functionFragment: 'oracle', values?: undefined): string; + encodeFunctionData(functionFragment: 'oracleData', values?: undefined): string; + encodeFunctionData(functionFragment: 'owner', values?: undefined): string; + encodeFunctionData(functionFragment: 'pendingOwner', values?: undefined): string; + encodeFunctionData( + functionFragment: 'permit', + values: [string, string, BigNumberish, BigNumberish, BigNumberish, BytesLike, BytesLike], + ): string; + encodeFunctionData(functionFragment: 'removeAsset', values: [string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'removeCollateral', values: [string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'repay', values: [string, boolean, BigNumberish]): string; + encodeFunctionData(functionFragment: 'setFeeTo', values: [string]): string; + encodeFunctionData(functionFragment: 'setSwapper', values: [string, boolean]): string; + encodeFunctionData(functionFragment: 'swappers', values: [string]): string; + encodeFunctionData(functionFragment: 'symbol', values?: undefined): string; + encodeFunctionData(functionFragment: 'totalAsset', values?: undefined): string; + encodeFunctionData(functionFragment: 'totalBorrow', values?: undefined): string; + encodeFunctionData(functionFragment: 'totalCollateralShare', values?: undefined): string; + encodeFunctionData(functionFragment: 'totalSupply', values?: undefined): string; + encodeFunctionData(functionFragment: 'transfer', values: [string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'transferFrom', values: [string, string, BigNumberish]): string; + encodeFunctionData(functionFragment: 'transferOwnership', values: [string, boolean, boolean]): string; + encodeFunctionData(functionFragment: 'updateExchangeRate', values?: undefined): string; + encodeFunctionData(functionFragment: 'userBorrowPart', values: [string]): string; + encodeFunctionData(functionFragment: 'userCollateralShare', values: [string]): string; + encodeFunctionData(functionFragment: 'withdrawFees', values?: undefined): string; + + decodeFunctionResult(functionFragment: 'DOMAIN_SEPARATOR', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'accrue', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'accrueInfo', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'addAsset', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'addCollateral', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'allowance', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'approve', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'asset', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'balanceOf', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'bentoBox', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'borrow', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'claimOwnership', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'collateral', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'cook', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'decimals', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'exchangeRate', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'feeTo', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'init', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'liquidate', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'masterContract', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'name', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'nonces', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'oracle', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'oracleData', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'owner', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'pendingOwner', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'permit', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'removeAsset', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'removeCollateral', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'repay', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'setFeeTo', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'setSwapper', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'swappers', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'symbol', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'totalAsset', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'totalBorrow', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'totalCollateralShare', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'totalSupply', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'transfer', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'transferFrom', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'transferOwnership', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'updateExchangeRate', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'userBorrowPart', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'userCollateralShare', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'withdrawFees', data: BytesLike): Result; + + events: { + 'Approval(address,address,uint256)': EventFragment; + 'LogAccrue(uint256,uint256,uint64,uint256)': EventFragment; + 'LogAddAsset(address,address,uint256,uint256)': EventFragment; + 'LogAddCollateral(address,address,uint256)': EventFragment; + 'LogBorrow(address,address,uint256,uint256,uint256)': EventFragment; + 'LogExchangeRate(uint256)': EventFragment; + 'LogFeeTo(address)': EventFragment; + 'LogRemoveAsset(address,address,uint256,uint256)': EventFragment; + 'LogRemoveCollateral(address,address,uint256)': EventFragment; + 'LogRepay(address,address,uint256,uint256)': EventFragment; + 'LogWithdrawFees(address,uint256)': EventFragment; + 'OwnershipTransferred(address,address)': EventFragment; + 'Transfer(address,address,uint256)': EventFragment; + }; + + getEvent(nameOrSignatureOrTopic: 'Approval'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'LogAccrue'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'LogAddAsset'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'LogAddCollateral'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'LogBorrow'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'LogExchangeRate'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'LogFeeTo'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'LogRemoveAsset'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'LogRemoveCollateral'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'LogRepay'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'LogWithdrawFees'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'OwnershipTransferred'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'Transfer'): EventFragment; +} + +export interface ApprovalEventObject { + _owner: string; + _spender: string; + _value: BigNumber; +} +export type ApprovalEvent = TypedEvent<[string, string, BigNumber], ApprovalEventObject>; + +export type ApprovalEventFilter = TypedEventFilter; + +export interface LogAccrueEventObject { + accruedAmount: BigNumber; + feeFraction: BigNumber; + rate: BigNumber; + utilization: BigNumber; +} +export type LogAccrueEvent = TypedEvent<[BigNumber, BigNumber, BigNumber, BigNumber], LogAccrueEventObject>; + +export type LogAccrueEventFilter = TypedEventFilter; + +export interface LogAddAssetEventObject { + from: string; + to: string; + share: BigNumber; + fraction: BigNumber; +} +export type LogAddAssetEvent = TypedEvent<[string, string, BigNumber, BigNumber], LogAddAssetEventObject>; + +export type LogAddAssetEventFilter = TypedEventFilter; + +export interface LogAddCollateralEventObject { + from: string; + to: string; + share: BigNumber; +} +export type LogAddCollateralEvent = TypedEvent<[string, string, BigNumber], LogAddCollateralEventObject>; + +export type LogAddCollateralEventFilter = TypedEventFilter; + +export interface LogBorrowEventObject { + from: string; + to: string; + amount: BigNumber; + feeAmount: BigNumber; + part: BigNumber; +} +export type LogBorrowEvent = TypedEvent<[string, string, BigNumber, BigNumber, BigNumber], LogBorrowEventObject>; + +export type LogBorrowEventFilter = TypedEventFilter; + +export interface LogExchangeRateEventObject { + rate: BigNumber; +} +export type LogExchangeRateEvent = TypedEvent<[BigNumber], LogExchangeRateEventObject>; + +export type LogExchangeRateEventFilter = TypedEventFilter; + +export interface LogFeeToEventObject { + newFeeTo: string; +} +export type LogFeeToEvent = TypedEvent<[string], LogFeeToEventObject>; + +export type LogFeeToEventFilter = TypedEventFilter; + +export interface LogRemoveAssetEventObject { + from: string; + to: string; + share: BigNumber; + fraction: BigNumber; +} +export type LogRemoveAssetEvent = TypedEvent<[string, string, BigNumber, BigNumber], LogRemoveAssetEventObject>; + +export type LogRemoveAssetEventFilter = TypedEventFilter; + +export interface LogRemoveCollateralEventObject { + from: string; + to: string; + share: BigNumber; +} +export type LogRemoveCollateralEvent = TypedEvent<[string, string, BigNumber], LogRemoveCollateralEventObject>; + +export type LogRemoveCollateralEventFilter = TypedEventFilter; + +export interface LogRepayEventObject { + from: string; + to: string; + amount: BigNumber; + part: BigNumber; +} +export type LogRepayEvent = TypedEvent<[string, string, BigNumber, BigNumber], LogRepayEventObject>; + +export type LogRepayEventFilter = TypedEventFilter; + +export interface LogWithdrawFeesEventObject { + feeTo: string; + feesEarnedFraction: BigNumber; +} +export type LogWithdrawFeesEvent = TypedEvent<[string, BigNumber], LogWithdrawFeesEventObject>; + +export type LogWithdrawFeesEventFilter = TypedEventFilter; + +export interface OwnershipTransferredEventObject { + previousOwner: string; + newOwner: string; +} +export type OwnershipTransferredEvent = TypedEvent<[string, string], OwnershipTransferredEventObject>; + +export type OwnershipTransferredEventFilter = TypedEventFilter; + +export interface TransferEventObject { + _from: string; + _to: string; + _value: BigNumber; +} +export type TransferEvent = TypedEvent<[string, string, BigNumber], TransferEventObject>; + +export type TransferEventFilter = TypedEventFilter; + +export interface SushiswapKashiLendingToken extends BaseContract { + connect(signerOrProvider: Signer | Provider | string): this; + attach(addressOrName: string): this; + deployed(): Promise; + + interface: SushiswapKashiLendingTokenInterface; + + queryFilter( + event: TypedEventFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined, + ): Promise>; + + listeners(eventFilter?: TypedEventFilter): Array>; + listeners(eventName?: string): Array; + removeAllListeners(eventFilter: TypedEventFilter): this; + removeAllListeners(eventName?: string): this; + off: OnEvent; + on: OnEvent; + once: OnEvent; + removeListener: OnEvent; + + functions: { + DOMAIN_SEPARATOR(overrides?: CallOverrides): Promise<[string]>; + + accrue(overrides?: Overrides & { from?: string | Promise }): Promise; + + accrueInfo(overrides?: CallOverrides): Promise< + [BigNumber, BigNumber, BigNumber] & { + interestPerSecond: BigNumber; + lastAccrued: BigNumber; + feesEarnedFraction: BigNumber; + } + >; + + addAsset( + to: string, + skim: boolean, + share: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + addCollateral( + to: string, + skim: boolean, + share: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + allowance(arg0: string, arg1: string, overrides?: CallOverrides): Promise<[BigNumber]>; + + approve( + spender: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + asset(overrides?: CallOverrides): Promise<[string]>; + + balanceOf(arg0: string, overrides?: CallOverrides): Promise<[BigNumber]>; + + bentoBox(overrides?: CallOverrides): Promise<[string]>; + + borrow( + to: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + claimOwnership(overrides?: Overrides & { from?: string | Promise }): Promise; + + collateral(overrides?: CallOverrides): Promise<[string]>; + + cook( + actions: BigNumberish[], + values: BigNumberish[], + datas: BytesLike[], + overrides?: PayableOverrides & { from?: string | Promise }, + ): Promise; + + decimals(overrides?: CallOverrides): Promise<[number]>; + + exchangeRate(overrides?: CallOverrides): Promise<[BigNumber]>; + + feeTo(overrides?: CallOverrides): Promise<[string]>; + + init( + data: BytesLike, + overrides?: PayableOverrides & { from?: string | Promise }, + ): Promise; + + liquidate( + users: string[], + maxBorrowParts: BigNumberish[], + to: string, + swapper: string, + open: boolean, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + masterContract(overrides?: CallOverrides): Promise<[string]>; + + name(overrides?: CallOverrides): Promise<[string]>; + + nonces(arg0: string, overrides?: CallOverrides): Promise<[BigNumber]>; + + oracle(overrides?: CallOverrides): Promise<[string]>; + + oracleData(overrides?: CallOverrides): Promise<[string]>; + + owner(overrides?: CallOverrides): Promise<[string]>; + + pendingOwner(overrides?: CallOverrides): Promise<[string]>; + + permit( + owner_: string, + spender: string, + value: BigNumberish, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + removeAsset( + to: string, + fraction: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + removeCollateral( + to: string, + share: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + repay( + to: string, + skim: boolean, + part: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + setFeeTo( + newFeeTo: string, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + setSwapper( + swapper: string, + enable: boolean, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + swappers(arg0: string, overrides?: CallOverrides): Promise<[boolean]>; + + symbol(overrides?: CallOverrides): Promise<[string]>; + + totalAsset(overrides?: CallOverrides): Promise<[BigNumber, BigNumber] & { elastic: BigNumber; base: BigNumber }>; + + totalBorrow(overrides?: CallOverrides): Promise<[BigNumber, BigNumber] & { elastic: BigNumber; base: BigNumber }>; + + totalCollateralShare(overrides?: CallOverrides): Promise<[BigNumber]>; + + totalSupply(overrides?: CallOverrides): Promise<[BigNumber]>; + + transfer( + to: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + transferFrom( + from: string, + to: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + transferOwnership( + newOwner: string, + direct: boolean, + renounce: boolean, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + updateExchangeRate(overrides?: Overrides & { from?: string | Promise }): Promise; + + userBorrowPart(arg0: string, overrides?: CallOverrides): Promise<[BigNumber]>; + + userCollateralShare(arg0: string, overrides?: CallOverrides): Promise<[BigNumber]>; + + withdrawFees(overrides?: Overrides & { from?: string | Promise }): Promise; + }; + + DOMAIN_SEPARATOR(overrides?: CallOverrides): Promise; + + accrue(overrides?: Overrides & { from?: string | Promise }): Promise; + + accrueInfo(overrides?: CallOverrides): Promise< + [BigNumber, BigNumber, BigNumber] & { + interestPerSecond: BigNumber; + lastAccrued: BigNumber; + feesEarnedFraction: BigNumber; + } + >; + + addAsset( + to: string, + skim: boolean, + share: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + addCollateral( + to: string, + skim: boolean, + share: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + allowance(arg0: string, arg1: string, overrides?: CallOverrides): Promise; + + approve( + spender: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + asset(overrides?: CallOverrides): Promise; + + balanceOf(arg0: string, overrides?: CallOverrides): Promise; + + bentoBox(overrides?: CallOverrides): Promise; + + borrow( + to: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + claimOwnership(overrides?: Overrides & { from?: string | Promise }): Promise; + + collateral(overrides?: CallOverrides): Promise; + + cook( + actions: BigNumberish[], + values: BigNumberish[], + datas: BytesLike[], + overrides?: PayableOverrides & { from?: string | Promise }, + ): Promise; + + decimals(overrides?: CallOverrides): Promise; + + exchangeRate(overrides?: CallOverrides): Promise; + + feeTo(overrides?: CallOverrides): Promise; + + init( + data: BytesLike, + overrides?: PayableOverrides & { from?: string | Promise }, + ): Promise; + + liquidate( + users: string[], + maxBorrowParts: BigNumberish[], + to: string, + swapper: string, + open: boolean, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + masterContract(overrides?: CallOverrides): Promise; + + name(overrides?: CallOverrides): Promise; + + nonces(arg0: string, overrides?: CallOverrides): Promise; + + oracle(overrides?: CallOverrides): Promise; + + oracleData(overrides?: CallOverrides): Promise; + + owner(overrides?: CallOverrides): Promise; + + pendingOwner(overrides?: CallOverrides): Promise; + + permit( + owner_: string, + spender: string, + value: BigNumberish, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + removeAsset( + to: string, + fraction: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + removeCollateral( + to: string, + share: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + repay( + to: string, + skim: boolean, + part: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + setFeeTo(newFeeTo: string, overrides?: Overrides & { from?: string | Promise }): Promise; + + setSwapper( + swapper: string, + enable: boolean, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + swappers(arg0: string, overrides?: CallOverrides): Promise; + + symbol(overrides?: CallOverrides): Promise; + + totalAsset(overrides?: CallOverrides): Promise<[BigNumber, BigNumber] & { elastic: BigNumber; base: BigNumber }>; + + totalBorrow(overrides?: CallOverrides): Promise<[BigNumber, BigNumber] & { elastic: BigNumber; base: BigNumber }>; + + totalCollateralShare(overrides?: CallOverrides): Promise; + + totalSupply(overrides?: CallOverrides): Promise; + + transfer( + to: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + transferFrom( + from: string, + to: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + transferOwnership( + newOwner: string, + direct: boolean, + renounce: boolean, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + updateExchangeRate(overrides?: Overrides & { from?: string | Promise }): Promise; + + userBorrowPart(arg0: string, overrides?: CallOverrides): Promise; + + userCollateralShare(arg0: string, overrides?: CallOverrides): Promise; + + withdrawFees(overrides?: Overrides & { from?: string | Promise }): Promise; + + callStatic: { + DOMAIN_SEPARATOR(overrides?: CallOverrides): Promise; + + accrue(overrides?: CallOverrides): Promise; + + accrueInfo(overrides?: CallOverrides): Promise< + [BigNumber, BigNumber, BigNumber] & { + interestPerSecond: BigNumber; + lastAccrued: BigNumber; + feesEarnedFraction: BigNumber; + } + >; + + addAsset(to: string, skim: boolean, share: BigNumberish, overrides?: CallOverrides): Promise; + + addCollateral(to: string, skim: boolean, share: BigNumberish, overrides?: CallOverrides): Promise; + + allowance(arg0: string, arg1: string, overrides?: CallOverrides): Promise; + + approve(spender: string, amount: BigNumberish, overrides?: CallOverrides): Promise; + + asset(overrides?: CallOverrides): Promise; + + balanceOf(arg0: string, overrides?: CallOverrides): Promise; + + bentoBox(overrides?: CallOverrides): Promise; + + borrow( + to: string, + amount: BigNumberish, + overrides?: CallOverrides, + ): Promise<[BigNumber, BigNumber] & { part: BigNumber; share: BigNumber }>; + + claimOwnership(overrides?: CallOverrides): Promise; + + collateral(overrides?: CallOverrides): Promise; + + cook( + actions: BigNumberish[], + values: BigNumberish[], + datas: BytesLike[], + overrides?: CallOverrides, + ): Promise<[BigNumber, BigNumber] & { value1: BigNumber; value2: BigNumber }>; + + decimals(overrides?: CallOverrides): Promise; + + exchangeRate(overrides?: CallOverrides): Promise; + + feeTo(overrides?: CallOverrides): Promise; + + init(data: BytesLike, overrides?: CallOverrides): Promise; + + liquidate( + users: string[], + maxBorrowParts: BigNumberish[], + to: string, + swapper: string, + open: boolean, + overrides?: CallOverrides, + ): Promise; + + masterContract(overrides?: CallOverrides): Promise; + + name(overrides?: CallOverrides): Promise; + + nonces(arg0: string, overrides?: CallOverrides): Promise; + + oracle(overrides?: CallOverrides): Promise; + + oracleData(overrides?: CallOverrides): Promise; + + owner(overrides?: CallOverrides): Promise; + + pendingOwner(overrides?: CallOverrides): Promise; + + permit( + owner_: string, + spender: string, + value: BigNumberish, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: CallOverrides, + ): Promise; + + removeAsset(to: string, fraction: BigNumberish, overrides?: CallOverrides): Promise; + + removeCollateral(to: string, share: BigNumberish, overrides?: CallOverrides): Promise; + + repay(to: string, skim: boolean, part: BigNumberish, overrides?: CallOverrides): Promise; + + setFeeTo(newFeeTo: string, overrides?: CallOverrides): Promise; + + setSwapper(swapper: string, enable: boolean, overrides?: CallOverrides): Promise; + + swappers(arg0: string, overrides?: CallOverrides): Promise; + + symbol(overrides?: CallOverrides): Promise; + + totalAsset(overrides?: CallOverrides): Promise<[BigNumber, BigNumber] & { elastic: BigNumber; base: BigNumber }>; + + totalBorrow(overrides?: CallOverrides): Promise<[BigNumber, BigNumber] & { elastic: BigNumber; base: BigNumber }>; + + totalCollateralShare(overrides?: CallOverrides): Promise; + + totalSupply(overrides?: CallOverrides): Promise; + + transfer(to: string, amount: BigNumberish, overrides?: CallOverrides): Promise; + + transferFrom(from: string, to: string, amount: BigNumberish, overrides?: CallOverrides): Promise; + + transferOwnership(newOwner: string, direct: boolean, renounce: boolean, overrides?: CallOverrides): Promise; + + updateExchangeRate( + overrides?: CallOverrides, + ): Promise<[boolean, BigNumber] & { updated: boolean; rate: BigNumber }>; + + userBorrowPart(arg0: string, overrides?: CallOverrides): Promise; + + userCollateralShare(arg0: string, overrides?: CallOverrides): Promise; + + withdrawFees(overrides?: CallOverrides): Promise; + }; + + filters: { + 'Approval(address,address,uint256)'( + _owner?: string | null, + _spender?: string | null, + _value?: null, + ): ApprovalEventFilter; + Approval(_owner?: string | null, _spender?: string | null, _value?: null): ApprovalEventFilter; + + 'LogAccrue(uint256,uint256,uint64,uint256)'( + accruedAmount?: null, + feeFraction?: null, + rate?: null, + utilization?: null, + ): LogAccrueEventFilter; + LogAccrue(accruedAmount?: null, feeFraction?: null, rate?: null, utilization?: null): LogAccrueEventFilter; + + 'LogAddAsset(address,address,uint256,uint256)'( + from?: string | null, + to?: string | null, + share?: null, + fraction?: null, + ): LogAddAssetEventFilter; + LogAddAsset(from?: string | null, to?: string | null, share?: null, fraction?: null): LogAddAssetEventFilter; + + 'LogAddCollateral(address,address,uint256)'( + from?: string | null, + to?: string | null, + share?: null, + ): LogAddCollateralEventFilter; + LogAddCollateral(from?: string | null, to?: string | null, share?: null): LogAddCollateralEventFilter; + + 'LogBorrow(address,address,uint256,uint256,uint256)'( + from?: string | null, + to?: string | null, + amount?: null, + feeAmount?: null, + part?: null, + ): LogBorrowEventFilter; + LogBorrow( + from?: string | null, + to?: string | null, + amount?: null, + feeAmount?: null, + part?: null, + ): LogBorrowEventFilter; + + 'LogExchangeRate(uint256)'(rate?: null): LogExchangeRateEventFilter; + LogExchangeRate(rate?: null): LogExchangeRateEventFilter; + + 'LogFeeTo(address)'(newFeeTo?: string | null): LogFeeToEventFilter; + LogFeeTo(newFeeTo?: string | null): LogFeeToEventFilter; + + 'LogRemoveAsset(address,address,uint256,uint256)'( + from?: string | null, + to?: string | null, + share?: null, + fraction?: null, + ): LogRemoveAssetEventFilter; + LogRemoveAsset(from?: string | null, to?: string | null, share?: null, fraction?: null): LogRemoveAssetEventFilter; + + 'LogRemoveCollateral(address,address,uint256)'( + from?: string | null, + to?: string | null, + share?: null, + ): LogRemoveCollateralEventFilter; + LogRemoveCollateral(from?: string | null, to?: string | null, share?: null): LogRemoveCollateralEventFilter; + + 'LogRepay(address,address,uint256,uint256)'( + from?: string | null, + to?: string | null, + amount?: null, + part?: null, + ): LogRepayEventFilter; + LogRepay(from?: string | null, to?: string | null, amount?: null, part?: null): LogRepayEventFilter; + + 'LogWithdrawFees(address,uint256)'(feeTo?: string | null, feesEarnedFraction?: null): LogWithdrawFeesEventFilter; + LogWithdrawFees(feeTo?: string | null, feesEarnedFraction?: null): LogWithdrawFeesEventFilter; + + 'OwnershipTransferred(address,address)'( + previousOwner?: string | null, + newOwner?: string | null, + ): OwnershipTransferredEventFilter; + OwnershipTransferred(previousOwner?: string | null, newOwner?: string | null): OwnershipTransferredEventFilter; + + 'Transfer(address,address,uint256)'(_from?: string | null, _to?: string | null, _value?: null): TransferEventFilter; + Transfer(_from?: string | null, _to?: string | null, _value?: null): TransferEventFilter; + }; + + estimateGas: { + DOMAIN_SEPARATOR(overrides?: CallOverrides): Promise; + + accrue(overrides?: Overrides & { from?: string | Promise }): Promise; + + accrueInfo(overrides?: CallOverrides): Promise; + + addAsset( + to: string, + skim: boolean, + share: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + addCollateral( + to: string, + skim: boolean, + share: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + allowance(arg0: string, arg1: string, overrides?: CallOverrides): Promise; + + approve( + spender: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + asset(overrides?: CallOverrides): Promise; + + balanceOf(arg0: string, overrides?: CallOverrides): Promise; + + bentoBox(overrides?: CallOverrides): Promise; + + borrow( + to: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + claimOwnership(overrides?: Overrides & { from?: string | Promise }): Promise; + + collateral(overrides?: CallOverrides): Promise; + + cook( + actions: BigNumberish[], + values: BigNumberish[], + datas: BytesLike[], + overrides?: PayableOverrides & { from?: string | Promise }, + ): Promise; + + decimals(overrides?: CallOverrides): Promise; + + exchangeRate(overrides?: CallOverrides): Promise; + + feeTo(overrides?: CallOverrides): Promise; + + init(data: BytesLike, overrides?: PayableOverrides & { from?: string | Promise }): Promise; + + liquidate( + users: string[], + maxBorrowParts: BigNumberish[], + to: string, + swapper: string, + open: boolean, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + masterContract(overrides?: CallOverrides): Promise; + + name(overrides?: CallOverrides): Promise; + + nonces(arg0: string, overrides?: CallOverrides): Promise; + + oracle(overrides?: CallOverrides): Promise; + + oracleData(overrides?: CallOverrides): Promise; + + owner(overrides?: CallOverrides): Promise; + + pendingOwner(overrides?: CallOverrides): Promise; + + permit( + owner_: string, + spender: string, + value: BigNumberish, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + removeAsset( + to: string, + fraction: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + removeCollateral( + to: string, + share: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + repay( + to: string, + skim: boolean, + part: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + setFeeTo(newFeeTo: string, overrides?: Overrides & { from?: string | Promise }): Promise; + + setSwapper( + swapper: string, + enable: boolean, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + swappers(arg0: string, overrides?: CallOverrides): Promise; + + symbol(overrides?: CallOverrides): Promise; + + totalAsset(overrides?: CallOverrides): Promise; + + totalBorrow(overrides?: CallOverrides): Promise; + + totalCollateralShare(overrides?: CallOverrides): Promise; + + totalSupply(overrides?: CallOverrides): Promise; + + transfer( + to: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + transferFrom( + from: string, + to: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + transferOwnership( + newOwner: string, + direct: boolean, + renounce: boolean, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + updateExchangeRate(overrides?: Overrides & { from?: string | Promise }): Promise; + + userBorrowPart(arg0: string, overrides?: CallOverrides): Promise; + + userCollateralShare(arg0: string, overrides?: CallOverrides): Promise; + + withdrawFees(overrides?: Overrides & { from?: string | Promise }): Promise; + }; + + populateTransaction: { + DOMAIN_SEPARATOR(overrides?: CallOverrides): Promise; + + accrue(overrides?: Overrides & { from?: string | Promise }): Promise; + + accrueInfo(overrides?: CallOverrides): Promise; + + addAsset( + to: string, + skim: boolean, + share: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + addCollateral( + to: string, + skim: boolean, + share: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + allowance(arg0: string, arg1: string, overrides?: CallOverrides): Promise; + + approve( + spender: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + asset(overrides?: CallOverrides): Promise; + + balanceOf(arg0: string, overrides?: CallOverrides): Promise; + + bentoBox(overrides?: CallOverrides): Promise; + + borrow( + to: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + claimOwnership(overrides?: Overrides & { from?: string | Promise }): Promise; + + collateral(overrides?: CallOverrides): Promise; + + cook( + actions: BigNumberish[], + values: BigNumberish[], + datas: BytesLike[], + overrides?: PayableOverrides & { from?: string | Promise }, + ): Promise; + + decimals(overrides?: CallOverrides): Promise; + + exchangeRate(overrides?: CallOverrides): Promise; + + feeTo(overrides?: CallOverrides): Promise; + + init( + data: BytesLike, + overrides?: PayableOverrides & { from?: string | Promise }, + ): Promise; + + liquidate( + users: string[], + maxBorrowParts: BigNumberish[], + to: string, + swapper: string, + open: boolean, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + masterContract(overrides?: CallOverrides): Promise; + + name(overrides?: CallOverrides): Promise; + + nonces(arg0: string, overrides?: CallOverrides): Promise; + + oracle(overrides?: CallOverrides): Promise; + + oracleData(overrides?: CallOverrides): Promise; + + owner(overrides?: CallOverrides): Promise; + + pendingOwner(overrides?: CallOverrides): Promise; + + permit( + owner_: string, + spender: string, + value: BigNumberish, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + removeAsset( + to: string, + fraction: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + removeCollateral( + to: string, + share: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + repay( + to: string, + skim: boolean, + part: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + setFeeTo( + newFeeTo: string, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + setSwapper( + swapper: string, + enable: boolean, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + swappers(arg0: string, overrides?: CallOverrides): Promise; + + symbol(overrides?: CallOverrides): Promise; + + totalAsset(overrides?: CallOverrides): Promise; + + totalBorrow(overrides?: CallOverrides): Promise; + + totalCollateralShare(overrides?: CallOverrides): Promise; + + totalSupply(overrides?: CallOverrides): Promise; + + transfer( + to: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + transferFrom( + from: string, + to: string, + amount: BigNumberish, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + transferOwnership( + newOwner: string, + direct: boolean, + renounce: boolean, + overrides?: Overrides & { from?: string | Promise }, + ): Promise; + + updateExchangeRate(overrides?: Overrides & { from?: string | Promise }): Promise; + + userBorrowPart(arg0: string, overrides?: CallOverrides): Promise; + + userCollateralShare(arg0: string, overrides?: CallOverrides): Promise; + + withdrawFees(overrides?: Overrides & { from?: string | Promise }): Promise; + }; +} diff --git a/src/apps/sushiswap-kashi/contracts/ethers/common.ts b/src/apps/sushiswap-kashi/contracts/ethers/common.ts new file mode 100644 index 000000000..6cfb10425 --- /dev/null +++ b/src/apps/sushiswap-kashi/contracts/ethers/common.ts @@ -0,0 +1,30 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { Listener } from '@ethersproject/providers'; +import type { Event, EventFilter } from 'ethers'; + +export interface TypedEvent = any, TArgsObject = any> extends Event { + args: TArgsArray & TArgsObject; +} + +export interface TypedEventFilter<_TEvent extends TypedEvent> extends EventFilter {} + +export interface TypedListener { + (...listenerArg: [...__TypechainArgsArray, TEvent]): void; +} + +type __TypechainArgsArray = T extends TypedEvent ? U : never; + +export interface OnEvent { + (eventFilter: TypedEventFilter, listener: TypedListener): TRes; + (eventName: string, listener: Listener): TRes; +} + +export type MinEthersFactory = { + deploy(...a: ARGS[]): Promise; +}; + +export type GetContractTypeFromFactory = F extends MinEthersFactory ? C : never; + +export type GetARGsTypeFromFactory = F extends MinEthersFactory ? Parameters : never; diff --git a/src/apps/sushiswap-kashi/contracts/ethers/factories/SushiswapKashiLendingToken__factory.ts b/src/apps/sushiswap-kashi/contracts/ethers/factories/SushiswapKashiLendingToken__factory.ts new file mode 100644 index 000000000..2c5d1bd62 --- /dev/null +++ b/src/apps/sushiswap-kashi/contracts/ethers/factories/SushiswapKashiLendingToken__factory.ts @@ -0,0 +1,1187 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Signer, utils } from 'ethers'; +import type { Provider } from '@ethersproject/providers'; +import type { SushiswapKashiLendingToken, SushiswapKashiLendingTokenInterface } from '../SushiswapKashiLendingToken'; + +const _abi = [ + { + inputs: [ + { + internalType: 'contract IBentoBoxV1', + name: 'bentoBox_', + type: 'address', + }, + ], + stateMutability: 'nonpayable', + type: 'constructor', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: '_owner', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: '_spender', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: '_value', + type: 'uint256', + }, + ], + name: 'Approval', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'uint256', + name: 'accruedAmount', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'feeFraction', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint64', + name: 'rate', + type: 'uint64', + }, + { + indexed: false, + internalType: 'uint256', + name: 'utilization', + type: 'uint256', + }, + ], + name: 'LogAccrue', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'from', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'to', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'share', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'fraction', + type: 'uint256', + }, + ], + name: 'LogAddAsset', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'from', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'to', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'share', + type: 'uint256', + }, + ], + name: 'LogAddCollateral', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'from', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'to', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'feeAmount', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'part', + type: 'uint256', + }, + ], + name: 'LogBorrow', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'uint256', + name: 'rate', + type: 'uint256', + }, + ], + name: 'LogExchangeRate', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'newFeeTo', + type: 'address', + }, + ], + name: 'LogFeeTo', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'from', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'to', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'share', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'fraction', + type: 'uint256', + }, + ], + name: 'LogRemoveAsset', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'from', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'to', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'share', + type: 'uint256', + }, + ], + name: 'LogRemoveCollateral', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'from', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'to', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'part', + type: 'uint256', + }, + ], + name: 'LogRepay', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'feeTo', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'feesEarnedFraction', + type: 'uint256', + }, + ], + name: 'LogWithdrawFees', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'previousOwner', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'newOwner', + type: 'address', + }, + ], + name: 'OwnershipTransferred', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: '_from', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: '_to', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: '_value', + type: 'uint256', + }, + ], + name: 'Transfer', + type: 'event', + }, + { + inputs: [], + name: 'DOMAIN_SEPARATOR', + outputs: [ + { + internalType: 'bytes32', + name: '', + type: 'bytes32', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'accrue', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'accrueInfo', + outputs: [ + { + internalType: 'uint64', + name: 'interestPerSecond', + type: 'uint64', + }, + { + internalType: 'uint64', + name: 'lastAccrued', + type: 'uint64', + }, + { + internalType: 'uint128', + name: 'feesEarnedFraction', + type: 'uint128', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'bool', + name: 'skim', + type: 'bool', + }, + { + internalType: 'uint256', + name: 'share', + type: 'uint256', + }, + ], + name: 'addAsset', + outputs: [ + { + internalType: 'uint256', + name: 'fraction', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'bool', + name: 'skim', + type: 'bool', + }, + { + internalType: 'uint256', + name: 'share', + type: 'uint256', + }, + ], + name: 'addCollateral', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + name: 'allowance', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'spender', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'approve', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'asset', + outputs: [ + { + internalType: 'contract IERC20', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + name: 'balanceOf', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'bentoBox', + outputs: [ + { + internalType: 'contract IBentoBoxV1', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'borrow', + outputs: [ + { + internalType: 'uint256', + name: 'part', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'share', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'claimOwnership', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'collateral', + outputs: [ + { + internalType: 'contract IERC20', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint8[]', + name: 'actions', + type: 'uint8[]', + }, + { + internalType: 'uint256[]', + name: 'values', + type: 'uint256[]', + }, + { + internalType: 'bytes[]', + name: 'datas', + type: 'bytes[]', + }, + ], + name: 'cook', + outputs: [ + { + internalType: 'uint256', + name: 'value1', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'value2', + type: 'uint256', + }, + ], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [], + name: 'decimals', + outputs: [ + { + internalType: 'uint8', + name: '', + type: 'uint8', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'exchangeRate', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'feeTo', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'bytes', + name: 'data', + type: 'bytes', + }, + ], + name: 'init', + outputs: [], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address[]', + name: 'users', + type: 'address[]', + }, + { + internalType: 'uint256[]', + name: 'maxBorrowParts', + type: 'uint256[]', + }, + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'contract ISwapper', + name: 'swapper', + type: 'address', + }, + { + internalType: 'bool', + name: 'open', + type: 'bool', + }, + ], + name: 'liquidate', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'masterContract', + outputs: [ + { + internalType: 'contract KashiPairMediumRiskV1', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'name', + outputs: [ + { + internalType: 'string', + name: '', + type: 'string', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + name: 'nonces', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'oracle', + outputs: [ + { + internalType: 'contract IOracle', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'oracleData', + outputs: [ + { + internalType: 'bytes', + name: '', + type: 'bytes', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'owner', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'pendingOwner', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'owner_', + type: 'address', + }, + { + internalType: 'address', + name: 'spender', + type: 'address', + }, + { + internalType: 'uint256', + name: 'value', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'deadline', + type: 'uint256', + }, + { + internalType: 'uint8', + name: 'v', + type: 'uint8', + }, + { + internalType: 'bytes32', + name: 'r', + type: 'bytes32', + }, + { + internalType: 'bytes32', + name: 's', + type: 'bytes32', + }, + ], + name: 'permit', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'uint256', + name: 'fraction', + type: 'uint256', + }, + ], + name: 'removeAsset', + outputs: [ + { + internalType: 'uint256', + name: 'share', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'uint256', + name: 'share', + type: 'uint256', + }, + ], + name: 'removeCollateral', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'bool', + name: 'skim', + type: 'bool', + }, + { + internalType: 'uint256', + name: 'part', + type: 'uint256', + }, + ], + name: 'repay', + outputs: [ + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'newFeeTo', + type: 'address', + }, + ], + name: 'setFeeTo', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'contract ISwapper', + name: 'swapper', + type: 'address', + }, + { + internalType: 'bool', + name: 'enable', + type: 'bool', + }, + ], + name: 'setSwapper', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'contract ISwapper', + name: '', + type: 'address', + }, + ], + name: 'swappers', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'symbol', + outputs: [ + { + internalType: 'string', + name: '', + type: 'string', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'totalAsset', + outputs: [ + { + internalType: 'uint128', + name: 'elastic', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'base', + type: 'uint128', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'totalBorrow', + outputs: [ + { + internalType: 'uint128', + name: 'elastic', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'base', + type: 'uint128', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'totalCollateralShare', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'totalSupply', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'transfer', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'from', + type: 'address', + }, + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'transferFrom', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'newOwner', + type: 'address', + }, + { + internalType: 'bool', + name: 'direct', + type: 'bool', + }, + { + internalType: 'bool', + name: 'renounce', + type: 'bool', + }, + ], + name: 'transferOwnership', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'updateExchangeRate', + outputs: [ + { + internalType: 'bool', + name: 'updated', + type: 'bool', + }, + { + internalType: 'uint256', + name: 'rate', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + name: 'userBorrowPart', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + name: 'userCollateralShare', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'withdrawFees', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, +]; + +export class SushiswapKashiLendingToken__factory { + static readonly abi = _abi; + static createInterface(): SushiswapKashiLendingTokenInterface { + return new utils.Interface(_abi) as SushiswapKashiLendingTokenInterface; + } + static connect(address: string, signerOrProvider: Signer | Provider): SushiswapKashiLendingToken { + return new Contract(address, _abi, signerOrProvider) as SushiswapKashiLendingToken; + } +} diff --git a/src/apps/sushiswap-kashi/contracts/ethers/factories/index.ts b/src/apps/sushiswap-kashi/contracts/ethers/factories/index.ts new file mode 100644 index 000000000..b4a8a6633 --- /dev/null +++ b/src/apps/sushiswap-kashi/contracts/ethers/factories/index.ts @@ -0,0 +1,4 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +export { SushiswapKashiLendingToken__factory } from './SushiswapKashiLendingToken__factory'; diff --git a/src/apps/sushiswap-kashi/contracts/ethers/index.ts b/src/apps/sushiswap-kashi/contracts/ethers/index.ts new file mode 100644 index 000000000..c350b90b5 --- /dev/null +++ b/src/apps/sushiswap-kashi/contracts/ethers/index.ts @@ -0,0 +1,6 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +export type { SushiswapKashiLendingToken } from './SushiswapKashiLendingToken'; +export * as factories from './factories'; +export { SushiswapKashiLendingToken__factory } from './factories/SushiswapKashiLendingToken__factory'; diff --git a/src/apps/sushiswap-kashi/contracts/index.ts b/src/apps/sushiswap-kashi/contracts/index.ts new file mode 100644 index 000000000..36bf4847f --- /dev/null +++ b/src/apps/sushiswap-kashi/contracts/index.ts @@ -0,0 +1,23 @@ +import { Injectable, Inject } from '@nestjs/common'; + +import { IAppToolkit, APP_TOOLKIT } from '~app-toolkit/app-toolkit.interface'; +import { ContractFactory } from '~contract/contracts'; +import { Network } from '~types/network.interface'; + +import { SushiswapKashiLendingToken__factory } from './ethers'; + +// eslint-disable-next-line +type ContractOpts = { address: string; network: Network }; + +@Injectable() +export class SushiswapKashiContractFactory extends ContractFactory { + constructor(@Inject(APP_TOOLKIT) protected readonly appToolkit: IAppToolkit) { + super((network: Network) => appToolkit.getNetworkProvider(network)); + } + + sushiswapKashiLendingToken({ address, network }: ContractOpts) { + return SushiswapKashiLendingToken__factory.connect(address, this.appToolkit.getNetworkProvider(network)); + } +} + +export type { SushiswapKashiLendingToken } from './ethers'; diff --git a/src/apps/sushiswap-kashi/ethereum/sushiswap-kashi.balance-fetcher.ts b/src/apps/sushiswap-kashi/ethereum/sushiswap-kashi.balance-fetcher.ts new file mode 100644 index 000000000..092de1ffd --- /dev/null +++ b/src/apps/sushiswap-kashi/ethereum/sushiswap-kashi.balance-fetcher.ts @@ -0,0 +1,34 @@ +import { Inject } from '@nestjs/common'; + +import { Register } from '~app-toolkit/decorators'; +import { presentBalanceFetcherResponse } from '~app-toolkit/helpers/presentation/balance-fetcher-response.present'; +import { BalanceFetcher } from '~balance/balance-fetcher.interface'; +import { Network } from '~types/network.interface'; + +import { SushiSwapKashiLendingBalanceHelper } from '../helpers/sushiswap-kashi.lending.balance-helper'; +import { SUSHISWAP_KASHI_DEFINITION } from '../sushiswap-kashi.definition'; + +const appId = SUSHISWAP_KASHI_DEFINITION.id; +const network = Network.ETHEREUM_MAINNET; + +@Register.BalanceFetcher(appId, network) +export class EthereumSushiswapKashiBalanceFetcher implements BalanceFetcher { + constructor( + @Inject(SushiSwapKashiLendingBalanceHelper) + private readonly sushiSwapKashiLendingBalanceHelper: SushiSwapKashiLendingBalanceHelper, + ) {} + + async getBalances(address: string) { + const balances = await this.sushiSwapKashiLendingBalanceHelper.getBalances({ + network, + address, + }); + + return presentBalanceFetcherResponse([ + { + label: 'Lending', + assets: balances, + }, + ]); + } +} diff --git a/src/apps/sushiswap-kashi/ethereum/sushiswap-kashi.lending.token-fetcher.ts b/src/apps/sushiswap-kashi/ethereum/sushiswap-kashi.lending.token-fetcher.ts new file mode 100644 index 000000000..d93c0ab3f --- /dev/null +++ b/src/apps/sushiswap-kashi/ethereum/sushiswap-kashi.lending.token-fetcher.ts @@ -0,0 +1,29 @@ +import { Inject } from '@nestjs/common'; + +import { Register } from '~app-toolkit/decorators'; +import { PositionFetcher } from '~position/position-fetcher.interface'; +import { AppTokenPosition } from '~position/position.interface'; +import { Network } from '~types/network.interface'; + +import { SushiswapKashiLendingTokenHelper } from '../helpers/sushiswap-kashi.lending.token-helper'; +import { SUSHISWAP_KASHI_DEFINITION } from '../sushiswap-kashi.definition'; + +const appId = SUSHISWAP_KASHI_DEFINITION.id; +const groupId = SUSHISWAP_KASHI_DEFINITION.groups.lending.id; +const network = Network.ETHEREUM_MAINNET; + +@Register.TokenPositionFetcher({ appId, groupId, network }) +export class EthereumSushiswapKashiLendingTokenFetcher implements PositionFetcher { + constructor( + @Inject(SushiswapKashiLendingTokenHelper) private readonly lendingTokenHelper: SushiswapKashiLendingTokenHelper, + ) {} + + getPositions() { + return this.lendingTokenHelper.getTokens({ + network, + subgraphUrl: 'https://api.thegraph.com/subgraphs/name/sushiswap/bentobox', + subgraphVersion: 1, + first: 1000, + }); + } +} diff --git a/src/apps/sushiswap-kashi/helpers/sushiswap-kashi.lending.balance-helper.ts b/src/apps/sushiswap-kashi/helpers/sushiswap-kashi.lending.balance-helper.ts new file mode 100644 index 000000000..575ba8fa5 --- /dev/null +++ b/src/apps/sushiswap-kashi/helpers/sushiswap-kashi.lending.balance-helper.ts @@ -0,0 +1,80 @@ +import { Inject, Injectable } from '@nestjs/common'; +import { compact } from 'lodash'; + +import { APP_TOOLKIT, IAppToolkit } from '~app-toolkit/app-toolkit.interface'; +import { drillBalance } from '~app-toolkit/helpers/balance/token-balance.helper'; +import { ContractType } from '~position/contract.interface'; +import { ContractPositionBalance } from '~position/position-balance.interface'; +import { borrowed, supplied } from '~position/position.utils'; +import { Network } from '~types/network.interface'; + +import { SushiswapKashiContractFactory } from '../contracts'; +import { SUSHISWAP_KASHI_DEFINITION } from '../sushiswap-kashi.definition'; + +type SushiSwapKashiGetBalancesParams = { + address: string; + network: Network; +}; + +@Injectable() +export class SushiSwapKashiLendingBalanceHelper { + constructor( + @Inject(APP_TOOLKIT) private readonly appToolkit: IAppToolkit, + @Inject(SushiswapKashiContractFactory) private readonly contractFactory: SushiswapKashiContractFactory, + ) {} + + async getBalances({ address, network }: SushiSwapKashiGetBalancesParams) { + const multicall = this.appToolkit.getMulticall(network); + const baseTokens = await this.appToolkit.getBaseTokenPrices(network); + const sushiswapKashiTokens = await this.appToolkit.getAppTokenPositions({ + appId: SUSHISWAP_KASHI_DEFINITION.id, + groupIds: [SUSHISWAP_KASHI_DEFINITION.groups.lending.id], + network: network, + }); + + const balances = await Promise.all( + sushiswapKashiTokens + .filter(v => v.supply > 0) + .map(async kashiToken => { + const kashiTokenContract = this.contractFactory.sushiswapKashiLendingToken({ + address: kashiToken.address, + network, + }); + + const [balanceRaw, collateralTokenAddressRaw, collateralBalanceRaw, debtBalanceRaw] = await Promise.all([ + multicall.wrap(kashiTokenContract).balanceOf(address), + multicall.wrap(kashiTokenContract).collateral(), + multicall.wrap(kashiTokenContract).userCollateralShare(address), + multicall.wrap(kashiTokenContract).userBorrowPart(address), + ]); + + const tokenBalance = drillBalance(kashiToken, balanceRaw.toString()); + const collateralTokenAddress = collateralTokenAddressRaw.toLowerCase(); + const collateralToken = baseTokens.find(p => p.address === collateralTokenAddress); + const debtToken = baseTokens.find(p => p.address === kashiToken.tokens[0].address); + if (!collateralToken || !debtToken) return [tokenBalance]; + + const collateralTokenBalance = drillBalance(supplied(collateralToken), collateralBalanceRaw.toString()); + const debtTokenBalance = drillBalance(borrowed(debtToken), debtBalanceRaw.toString(), { isDebt: true }); + const tokens = [collateralTokenBalance, debtTokenBalance]; + const balanceUSD = collateralTokenBalance.balanceUSD + debtTokenBalance.balanceUSD; + + const leveragePosition: ContractPositionBalance = { + type: ContractType.POSITION, + appId: kashiToken.appId, + groupId: kashiToken.groupId, + address: kashiToken.address, + network: kashiToken.network, + tokens, + balanceUSD, + dataProps: kashiToken.dataProps, + displayProps: kashiToken.displayProps, + }; + + return [tokenBalance, leveragePosition]; + }), + ); + + return compact(balances.flat()); + } +} diff --git a/src/apps/sushiswap-kashi/helpers/sushiswap-kashi.lending.token-helper.ts b/src/apps/sushiswap-kashi/helpers/sushiswap-kashi.lending.token-helper.ts new file mode 100644 index 000000000..4184b3609 --- /dev/null +++ b/src/apps/sushiswap-kashi/helpers/sushiswap-kashi.lending.token-helper.ts @@ -0,0 +1,228 @@ +import { Inject, Injectable } from '@nestjs/common'; +import { gql } from 'graphql-request'; +import _ from 'lodash'; + +import { APP_TOOLKIT, IAppToolkit } from '~app-toolkit/app-toolkit.interface'; +import { + buildDollarDisplayItem, + buildPercentageDisplayItem, +} from '~app-toolkit/helpers/presentation/display-item.present'; +import { getTokenImg } from '~app-toolkit/helpers/presentation/image.present'; +import { ContractType } from '~position/contract.interface'; +import { AppTokenPosition } from '~position/position.interface'; +import { AppGroupsDefinition } from '~position/position.service'; +import { Network } from '~types/network.interface'; + +import { SushiswapKashiContractFactory } from '../contracts'; +import { SUSHISWAP_KASHI_DEFINITION } from '../sushiswap-kashi.definition'; + +type SushiswapKashiLendingTokenDataProps = { + liquidity: number; + supplyApr: number; + borrowApr: number; +}; + +type SushiswapKashiLendingTokenHelperParams = { + network: Network; + subgraphUrl: string; + subgraphVersion: 1 | 2; + first?: number; + dependencies?: AppGroupsDefinition[]; +}; + +type PairDetails = { + pairAddress: string; + assetAddress: string; + collateralAddress: string; + supplyAPR: string; + borrowAPR: string; +}; + +type KashiSubgraphV1PairsResponse = { + kashiPairs?: { + id: string; + supplyAPR: string; + borrowAPR: string; + asset: { + id: string; + }; + collateral: { + id: string; + }; + }[]; +}; + +const kashiSubgraphV1PairsQuery = gql` + query getPairs($first: Int) { + kashiPairs(first: $first) { + id + supplyAPR + borrowAPR + asset { + id + } + collateral { + id + } + } + } +`; + +type KashiSubgraphV2PairsResponse = { + kashiPairs?: { + id: string; + kpi: { + supplyAPR: string; + borrowAPR: string; + }; + asset: { + id: string; + }; + collateral: { + id: string; + }; + }[]; +}; + +const kashiSubgraphV2PairsQuery = gql` + query getPairs($first: Int) { + kashiPairs(first: $first) { + id + kpi { + supplyAPR + borrowAPR + } + asset { + id + } + collateral { + id + } + } + } +`; + +@Injectable() +export class SushiswapKashiLendingTokenHelper { + constructor( + @Inject(APP_TOOLKIT) private readonly appToolkit: IAppToolkit, + @Inject(SushiswapKashiContractFactory) private readonly contractFactory: SushiswapKashiContractFactory, + ) {} + + async getTokens({ + network, + subgraphUrl, + first, + subgraphVersion, + dependencies = [], + }: SushiswapKashiLendingTokenHelperParams) { + const multicall = this.appToolkit.getMulticall(network); + const baseTokens = await this.appToolkit.getBaseTokenPrices(network); + const appTokens = await this.appToolkit.getAppTokenPositions(...dependencies); + const allTokens = [...appTokens, ...baseTokens]; + + let pairs: PairDetails[] = []; + if (subgraphVersion === 1) { + const pairsData = await this.appToolkit.helpers.theGraphHelper.request({ + endpoint: subgraphUrl, + query: kashiSubgraphV1PairsQuery, + variables: { + first, + }, + }); + + pairs = (pairsData.kashiPairs ?? []).map(pair => ({ + pairAddress: pair.id.toLowerCase(), + collateralAddress: pair.collateral.id.toLowerCase(), + assetAddress: pair.asset.id.toLowerCase(), + supplyAPR: pair.supplyAPR, + borrowAPR: pair.borrowAPR, + })); + } else { + const pairsData = await this.appToolkit.helpers.theGraphHelper.request({ + endpoint: subgraphUrl, + query: kashiSubgraphV2PairsQuery, + variables: { + first, + }, + }); + + pairs = (pairsData.kashiPairs ?? []).map(pair => ({ + pairAddress: pair.id.toLowerCase(), + collateralAddress: pair.collateral.id.toLowerCase(), + assetAddress: pair.asset.id.toLowerCase(), + supplyAPR: pair.kpi.supplyAPR, + borrowAPR: pair.kpi.borrowAPR, + })); + } + + const tokens = await Promise.all( + pairs.map(async pair => { + const { pairAddress, collateralAddress, assetAddress } = pair; + const underlyingCollateralToken = allTokens.find(p => p.address === collateralAddress); + const underlyingAssetToken = allTokens.find(p => p.address === assetAddress); + if (!underlyingCollateralToken || !underlyingAssetToken) return null; + + const pairContract = this.contractFactory.sushiswapKashiLendingToken({ address: pairAddress, network }); + const [symbol, decimals, supplyRaw] = await Promise.all([ + multicall.wrap(pairContract).symbol(), + multicall.wrap(pairContract).decimals(), + multicall.wrap(pairContract).totalSupply(), + ]); + + // Data Props + const supply = Number(supplyRaw) / 10 ** decimals; + const tokens = [underlyingAssetToken]; + const supplyApr = (Number(pair.supplyAPR) / 1e17) * 100; + const borrowApr = (Number(pair.borrowAPR) / 1e17) * 100; + const price = underlyingAssetToken.price; + const pricePerShare = 1; + const liquidity = price * supply; + + // Display Props + const label = `${underlyingAssetToken.symbol} in Kashi ${underlyingAssetToken.symbol} / ${underlyingCollateralToken.symbol}`; + const secondaryLabel = buildDollarDisplayItem(underlyingAssetToken.price); + const images = [ + getTokenImg(underlyingAssetToken.address, network), + getTokenImg(underlyingCollateralToken.address, network), + ]; + const statsItems = [ + { label: 'Liquidity', value: buildDollarDisplayItem(liquidity) }, + { label: 'Borrow APR', value: buildPercentageDisplayItem(borrowApr) }, + { label: 'Supply APR', value: buildPercentageDisplayItem(supplyApr) }, + ]; + + const lendingToken: AppTokenPosition = { + type: ContractType.APP_TOKEN, + appId: SUSHISWAP_KASHI_DEFINITION.id, + groupId: SUSHISWAP_KASHI_DEFINITION.groups.lending.id, + address: pairAddress, + network, + symbol, + decimals, + supply, + price, + pricePerShare, + tokens, + + dataProps: { + liquidity, + supplyApr, + borrowApr, + }, + + displayProps: { + label, + secondaryLabel, + images, + statsItems, + }, + }; + + return lendingToken; + }), + ); + + return _.compact(tokens); + } +} diff --git a/src/apps/sushiswap-kashi/polygon/sushiswap-kashi.balance-fetcher.ts b/src/apps/sushiswap-kashi/polygon/sushiswap-kashi.balance-fetcher.ts new file mode 100644 index 000000000..ece4f41f1 --- /dev/null +++ b/src/apps/sushiswap-kashi/polygon/sushiswap-kashi.balance-fetcher.ts @@ -0,0 +1,34 @@ +import { Inject } from '@nestjs/common'; + +import { Register } from '~app-toolkit/decorators'; +import { presentBalanceFetcherResponse } from '~app-toolkit/helpers/presentation/balance-fetcher-response.present'; +import { BalanceFetcher } from '~balance/balance-fetcher.interface'; +import { Network } from '~types/network.interface'; + +import { SushiSwapKashiLendingBalanceHelper } from '../helpers/sushiswap-kashi.lending.balance-helper'; +import { SUSHISWAP_KASHI_DEFINITION } from '../sushiswap-kashi.definition'; + +const appId = SUSHISWAP_KASHI_DEFINITION.id; +const network = Network.POLYGON_MAINNET; + +@Register.BalanceFetcher(appId, network) +export class PolygonSushiswapKashiBalanceFetcher implements BalanceFetcher { + constructor( + @Inject(SushiSwapKashiLendingBalanceHelper) + private readonly sushiSwapKashiLendingBalanceHelper: SushiSwapKashiLendingBalanceHelper, + ) {} + + async getBalances(address: string) { + const balances = await this.sushiSwapKashiLendingBalanceHelper.getBalances({ + network, + address, + }); + + return presentBalanceFetcherResponse([ + { + label: 'Lending', + assets: balances, + }, + ]); + } +} diff --git a/src/apps/sushiswap-kashi/polygon/sushiswap-kashi.lending.token-fetcher.ts b/src/apps/sushiswap-kashi/polygon/sushiswap-kashi.lending.token-fetcher.ts new file mode 100644 index 000000000..e4f7c82d0 --- /dev/null +++ b/src/apps/sushiswap-kashi/polygon/sushiswap-kashi.lending.token-fetcher.ts @@ -0,0 +1,29 @@ +import { Inject } from '@nestjs/common'; + +import { Register } from '~app-toolkit/decorators'; +import { PositionFetcher } from '~position/position-fetcher.interface'; +import { AppTokenPosition } from '~position/position.interface'; +import { Network } from '~types/network.interface'; + +import { SushiswapKashiLendingTokenHelper } from '../helpers/sushiswap-kashi.lending.token-helper'; +import { SUSHISWAP_KASHI_DEFINITION } from '../sushiswap-kashi.definition'; + +const appId = SUSHISWAP_KASHI_DEFINITION.id; +const groupId = SUSHISWAP_KASHI_DEFINITION.groups.lending.id; +const network = Network.POLYGON_MAINNET; + +@Register.TokenPositionFetcher({ appId, groupId, network }) +export class PolygonSushiswapKashiLendingTokenFetcher implements PositionFetcher { + constructor( + @Inject(SushiswapKashiLendingTokenHelper) private readonly lendingTokenHelper: SushiswapKashiLendingTokenHelper, + ) {} + + getPositions() { + return this.lendingTokenHelper.getTokens({ + network, + subgraphUrl: 'https://api.thegraph.com/subgraphs/name/sushiswap/kashi-polygon', + subgraphVersion: 2, + first: 1000, + }); + } +} diff --git a/src/apps/sushiswap-kashi/sushiswap-kashi.definition.ts b/src/apps/sushiswap-kashi/sushiswap-kashi.definition.ts new file mode 100644 index 000000000..ddc694d3a --- /dev/null +++ b/src/apps/sushiswap-kashi/sushiswap-kashi.definition.ts @@ -0,0 +1,43 @@ +import { Register } from '~app-toolkit/decorators'; +import { AppDefinition, appDefinition } from '~app/app.definition'; +import { AppAction, AppTag, GroupType } from '~app/app.interface'; +import { Network } from '~types/network.interface'; + +export const SUSHISWAP_KASHI_DEFINITION = appDefinition({ + id: 'sushiswap-kashi', + name: 'SushiSwap Kashi', + description: `Gas efficient, isolated lending market`, + groups: { + lending: { + id: 'lending', + type: GroupType.TOKEN, + label: 'Lending', + }, + }, + url: 'https://sushi.com', + tags: [AppTag.LENDING], + links: { + github: 'https://github.com/sushiswap', + twitter: 'https://twitter.com/sushiswap', + discord: 'https://discord.com/invite/NVPXN4e', + medium: 'https://sushichef.medium.com/', + }, + supportedNetworks: { + [Network.ARBITRUM_MAINNET]: [AppAction.VIEW], + [Network.BINANCE_SMART_CHAIN_MAINNET]: [AppAction.VIEW], + [Network.ETHEREUM_MAINNET]: [AppAction.VIEW], + [Network.POLYGON_MAINNET]: [AppAction.VIEW], + }, + primaryColor: '#887eb3', + token: { + address: '0x6b3595068778dd592e39a122f4f5a5cf09c90fe2', + network: Network.ETHEREUM_MAINNET, + }, +}); + +@Register.AppDefinition(SUSHISWAP_KASHI_DEFINITION.id) +export class SushiswapKashiAppDefinition extends AppDefinition { + constructor() { + super(SUSHISWAP_KASHI_DEFINITION); + } +} diff --git a/src/apps/sushiswap-kashi/sushiswap-kashi.module.ts b/src/apps/sushiswap-kashi/sushiswap-kashi.module.ts new file mode 100644 index 000000000..356514d39 --- /dev/null +++ b/src/apps/sushiswap-kashi/sushiswap-kashi.module.ts @@ -0,0 +1,38 @@ +import { Register } from '~app-toolkit/decorators'; +import { AbstractApp } from '~app/app.dynamic-module'; + +import { ArbitrumSushiswapKashiBalanceFetcher } from './arbitrum/sushiswap-kashi.balance-fetcher'; +import { ArbitrumSushiswapKashiLendingTokenFetcher } from './arbitrum/sushiswap-kashi.lending.token-fetcher'; +import { BinanceSmartChainSushiswapKashiBalanceFetcher } from './binance-smart-chain/sushiswap-kashi.balance-fetcher'; +import { BinanceSmartChainSushiswapKashiLendingTokenFetcher } from './binance-smart-chain/sushiswap-kashi.lending.token-fetcher'; +import { SushiswapKashiContractFactory } from './contracts'; +import { EthereumSushiswapKashiBalanceFetcher } from './ethereum/sushiswap-kashi.balance-fetcher'; +import { EthereumSushiswapKashiLendingTokenFetcher } from './ethereum/sushiswap-kashi.lending.token-fetcher'; +import { SushiSwapKashiLendingBalanceHelper } from './helpers/sushiswap-kashi.lending.balance-helper'; +import { SushiswapKashiLendingTokenHelper } from './helpers/sushiswap-kashi.lending.token-helper'; +import { PolygonSushiswapKashiBalanceFetcher } from './polygon/sushiswap-kashi.balance-fetcher'; +import { PolygonSushiswapKashiLendingTokenFetcher } from './polygon/sushiswap-kashi.lending.token-fetcher'; +import { SushiswapKashiAppDefinition, SUSHISWAP_KASHI_DEFINITION } from './sushiswap-kashi.definition'; + +@Register.AppModule({ + appId: SUSHISWAP_KASHI_DEFINITION.id, + providers: [ + SushiswapKashiAppDefinition, + SushiswapKashiContractFactory, + SushiswapKashiLendingTokenHelper, + SushiSwapKashiLendingBalanceHelper, + // Arbitrum + ArbitrumSushiswapKashiBalanceFetcher, + ArbitrumSushiswapKashiLendingTokenFetcher, + // Binance Smart Chain + BinanceSmartChainSushiswapKashiBalanceFetcher, + BinanceSmartChainSushiswapKashiLendingTokenFetcher, + // Ethereum + EthereumSushiswapKashiBalanceFetcher, + EthereumSushiswapKashiLendingTokenFetcher, + // Polygon + PolygonSushiswapKashiBalanceFetcher, + PolygonSushiswapKashiLendingTokenFetcher, + ], +}) +export class SushiSwapKashiAppModule extends AbstractApp() {}