@kasufinance/kasu-sdk 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.cjs.js +133 -32
- package/dist/bundle.esm.js +133 -32
- package/dist/contracts/IClearingCoordinatorAbi.js +1 -0
- package/dist/contracts/IClearingCoordinatorAbi.js.map +1 -0
- package/dist/contracts/IERC20MetadataAbi.js +1 -0
- package/dist/contracts/IERC20MetadataAbi.js.map +1 -0
- package/dist/contracts/IFeeManagerAbi.js +1 -0
- package/dist/contracts/IFeeManagerAbi.js.map +1 -0
- package/dist/contracts/IKSULockingAbi.js +1 -0
- package/dist/contracts/IKSULockingAbi.js.map +1 -0
- package/dist/contracts/IKasuAllowListAbi.js +1 -0
- package/dist/contracts/IKasuAllowListAbi.js.map +1 -0
- package/dist/contracts/IKasuControllerAbi.js +1 -0
- package/dist/contracts/IKasuControllerAbi.js.map +1 -0
- package/dist/contracts/IKasuNFTsAbi.js +1 -0
- package/dist/contracts/IKasuNFTsAbi.js.map +1 -0
- package/dist/contracts/IKsuPriceAbi.js +1 -0
- package/dist/contracts/IKsuPriceAbi.js.map +1 -0
- package/dist/contracts/ILendingPoolAbi.js +1 -0
- package/dist/contracts/ILendingPoolAbi.js.map +1 -0
- package/dist/contracts/ILendingPoolFactoryAbi.js +1 -0
- package/dist/contracts/ILendingPoolFactoryAbi.js.map +1 -0
- package/dist/contracts/ILendingPoolManagerAbi.js +1 -0
- package/dist/contracts/ILendingPoolManagerAbi.js.map +1 -0
- package/dist/contracts/ILendingPoolTrancheAbi.js +1 -0
- package/dist/contracts/ILendingPoolTrancheAbi.js.map +1 -0
- package/dist/contracts/ISystemVariablesAbi.js +1 -0
- package/dist/contracts/ISystemVariablesAbi.js.map +1 -0
- package/dist/contracts/IUserLoyaltyRewardsAbi.js +1 -0
- package/dist/contracts/IUserLoyaltyRewardsAbi.js.map +1 -0
- package/dist/contracts/IUserManagerAbi.js +1 -0
- package/dist/contracts/IUserManagerAbi.js.map +1 -0
- package/dist/contracts/KSULockBonusAbi.js +1 -0
- package/dist/contracts/KSULockBonusAbi.js.map +1 -0
- package/dist/contracts/KasuPoolExternalTVLAbi.js +1 -0
- package/dist/contracts/KasuPoolExternalTVLAbi.js.map +1 -0
- package/dist/contracts/SwapperAbi.js +1 -0
- package/dist/contracts/SwapperAbi.js.map +1 -0
- package/dist/contracts/common.js +1 -0
- package/dist/contracts/common.js.map +1 -0
- package/dist/contracts/factories/IClearingCoordinatorAbi__factory.js +1 -0
- package/dist/contracts/factories/IClearingCoordinatorAbi__factory.js.map +1 -0
- package/dist/contracts/factories/IERC20MetadataAbi__factory.js +1 -0
- package/dist/contracts/factories/IERC20MetadataAbi__factory.js.map +1 -0
- package/dist/contracts/factories/IFeeManagerAbi__factory.js +1 -0
- package/dist/contracts/factories/IFeeManagerAbi__factory.js.map +1 -0
- package/dist/contracts/factories/IKSULockingAbi__factory.js +1 -0
- package/dist/contracts/factories/IKSULockingAbi__factory.js.map +1 -0
- package/dist/contracts/factories/IKasuAllowListAbi__factory.js +1 -0
- package/dist/contracts/factories/IKasuAllowListAbi__factory.js.map +1 -0
- package/dist/contracts/factories/IKasuControllerAbi__factory.js +1 -0
- package/dist/contracts/factories/IKasuControllerAbi__factory.js.map +1 -0
- package/dist/contracts/factories/IKasuNFTsAbi__factory.js +1 -0
- package/dist/contracts/factories/IKasuNFTsAbi__factory.js.map +1 -0
- package/dist/contracts/factories/IKsuPriceAbi__factory.js +1 -0
- package/dist/contracts/factories/IKsuPriceAbi__factory.js.map +1 -0
- package/dist/contracts/factories/ILendingPoolAbi__factory.js +1 -0
- package/dist/contracts/factories/ILendingPoolAbi__factory.js.map +1 -0
- package/dist/contracts/factories/ILendingPoolFactoryAbi__factory.js +1 -0
- package/dist/contracts/factories/ILendingPoolFactoryAbi__factory.js.map +1 -0
- package/dist/contracts/factories/ILendingPoolManagerAbi__factory.js +1 -0
- package/dist/contracts/factories/ILendingPoolManagerAbi__factory.js.map +1 -0
- package/dist/contracts/factories/ILendingPoolTrancheAbi__factory.js +1 -0
- package/dist/contracts/factories/ILendingPoolTrancheAbi__factory.js.map +1 -0
- package/dist/contracts/factories/ISystemVariablesAbi__factory.js +1 -0
- package/dist/contracts/factories/ISystemVariablesAbi__factory.js.map +1 -0
- package/dist/contracts/factories/IUserLoyaltyRewardsAbi__factory.js +1 -0
- package/dist/contracts/factories/IUserLoyaltyRewardsAbi__factory.js.map +1 -0
- package/dist/contracts/factories/IUserManagerAbi__factory.js +1 -0
- package/dist/contracts/factories/IUserManagerAbi__factory.js.map +1 -0
- package/dist/contracts/factories/KSULockBonusAbi__factory.js +1 -0
- package/dist/contracts/factories/KSULockBonusAbi__factory.js.map +1 -0
- package/dist/contracts/factories/KasuPoolExternalTVLAbi__factory.js +1 -0
- package/dist/contracts/factories/KasuPoolExternalTVLAbi__factory.js.map +1 -0
- package/dist/contracts/factories/SwapperAbi__factory.js +1 -0
- package/dist/contracts/factories/SwapperAbi__factory.js.map +1 -0
- package/dist/contracts/factories/index.js +1 -0
- package/dist/contracts/factories/index.js.map +1 -0
- package/dist/contracts/index.js +1 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/dist/sdk-config.js +1 -0
- package/dist/sdk-config.js.map +1 -0
- package/dist/services/DataService/data-service.js +1 -0
- package/dist/services/DataService/data-service.js.map +1 -0
- package/dist/services/DataService/directus-types.js +1 -0
- package/dist/services/DataService/directus-types.js.map +1 -0
- package/dist/services/DataService/queries.js +1 -0
- package/dist/services/DataService/queries.js.map +1 -0
- package/dist/services/DataService/subgraph-types.js +1 -0
- package/dist/services/DataService/subgraph-types.js.map +1 -0
- package/dist/services/DataService/types.js +1 -0
- package/dist/services/DataService/types.js.map +1 -0
- package/dist/services/Locking/locking.js +1 -0
- package/dist/services/Locking/locking.js.map +1 -0
- package/dist/services/Locking/queries.js +1 -0
- package/dist/services/Locking/queries.js.map +1 -0
- package/dist/services/Locking/types.js +1 -0
- package/dist/services/Locking/types.js.map +1 -0
- package/dist/services/Portfolio/portfolio.d.ts +40 -2
- package/dist/services/Portfolio/portfolio.js +137 -33
- package/dist/services/Portfolio/portfolio.js.map +1 -0
- package/dist/services/Portfolio/queries.js +1 -0
- package/dist/services/Portfolio/queries.js.map +1 -0
- package/dist/services/Portfolio/types.js +1 -0
- package/dist/services/Portfolio/types.js.map +1 -0
- package/dist/services/Swapper/swapper.js +1 -0
- package/dist/services/Swapper/swapper.js.map +1 -0
- package/dist/services/Swapper/types.js +1 -0
- package/dist/services/Swapper/types.js.map +1 -0
- package/dist/services/UserLending/helper.js +1 -0
- package/dist/services/UserLending/helper.js.map +1 -0
- package/dist/services/UserLending/queries.js +1 -0
- package/dist/services/UserLending/queries.js.map +1 -0
- package/dist/services/UserLending/subgraph-types.js +1 -0
- package/dist/services/UserLending/subgraph-types.js.map +1 -0
- package/dist/services/UserLending/types.js +1 -0
- package/dist/services/UserLending/types.js.map +1 -0
- package/dist/services/UserLending/user-lending.js +1 -0
- package/dist/services/UserLending/user-lending.js.map +1 -0
- package/dist/services/shared.js +1 -0
- package/dist/services/shared.js.map +1 -0
- package/dist/tests/sample.test.js +1 -0
- package/dist/tests/sample.test.js.map +1 -0
- package/package.json +2 -1
- package/src/contracts/IClearingCoordinatorAbi.ts +406 -0
- package/src/contracts/IERC20MetadataAbi.ts +364 -0
- package/src/contracts/IFeeManagerAbi.ts +182 -0
- package/src/contracts/IKSULockingAbi.ts +965 -0
- package/src/contracts/IKasuAllowListAbi.ts +605 -0
- package/src/contracts/IKasuControllerAbi.ts +703 -0
- package/src/contracts/IKasuNFTsAbi.ts +2744 -0
- package/src/contracts/IKsuPriceAbi.ts +87 -0
- package/src/contracts/ILendingPoolAbi.ts +2081 -0
- package/src/contracts/ILendingPoolFactoryAbi.ts +161 -0
- package/src/contracts/ILendingPoolManagerAbi.ts +1917 -0
- package/src/contracts/ILendingPoolTrancheAbi.ts +1911 -0
- package/src/contracts/ISystemVariablesAbi.ts +908 -0
- package/src/contracts/IUserLoyaltyRewardsAbi.ts +544 -0
- package/src/contracts/IUserManagerAbi.ts +612 -0
- package/src/contracts/KSULockBonusAbi.ts +124 -0
- package/src/contracts/KasuPoolExternalTVLAbi.ts +1071 -0
- package/src/contracts/SwapperAbi.ts +266 -0
- package/src/contracts/common.ts +44 -0
- package/src/contracts/factories/IClearingCoordinatorAbi__factory.ts +438 -0
- package/src/contracts/factories/IERC20MetadataAbi__factory.ts +248 -0
- package/src/contracts/factories/IFeeManagerAbi__factory.ts +90 -0
- package/src/contracts/factories/IKSULockingAbi__factory.ts +778 -0
- package/src/contracts/factories/IKasuAllowListAbi__factory.ts +479 -0
- package/src/contracts/factories/IKasuControllerAbi__factory.ts +447 -0
- package/src/contracts/factories/IKasuNFTsAbi__factory.ts +2116 -0
- package/src/contracts/factories/IKsuPriceAbi__factory.ts +36 -0
- package/src/contracts/factories/ILendingPoolAbi__factory.ts +1455 -0
- package/src/contracts/factories/ILendingPoolFactoryAbi__factory.ts +125 -0
- package/src/contracts/factories/ILendingPoolManagerAbi__factory.ts +1375 -0
- package/src/contracts/factories/ILendingPoolTrancheAbi__factory.ts +1345 -0
- package/src/contracts/factories/ISystemVariablesAbi__factory.ts +455 -0
- package/src/contracts/factories/IUserLoyaltyRewardsAbi__factory.ts +316 -0
- package/src/contracts/factories/IUserManagerAbi__factory.ts +345 -0
- package/src/contracts/factories/KSULockBonusAbi__factory.ts +115 -0
- package/src/contracts/factories/KasuPoolExternalTVLAbi__factory.ts +840 -0
- package/src/contracts/factories/SwapperAbi__factory.ts +167 -0
- package/src/contracts/factories/index.ts +21 -0
- package/src/contracts/index.ts +40 -0
- package/src/services/Portfolio/portfolio.ts +261 -45
- package/tsconfig.json +1 -1
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/* Autogenerated file. Do not edit manually. */
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
|
|
5
|
+
import { Contract, Signer, utils } from "ethers";
|
|
6
|
+
import type { Provider } from "@ethersproject/providers";
|
|
7
|
+
import type { SwapperAbi, SwapperAbiInterface } from "../SwapperAbi";
|
|
8
|
+
|
|
9
|
+
const _abi = [
|
|
10
|
+
{
|
|
11
|
+
anonymous: false,
|
|
12
|
+
inputs: [
|
|
13
|
+
{
|
|
14
|
+
indexed: true,
|
|
15
|
+
internalType: "address",
|
|
16
|
+
name: "exchange",
|
|
17
|
+
type: "address",
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
indexed: false,
|
|
21
|
+
internalType: "bool",
|
|
22
|
+
name: "isAllowed",
|
|
23
|
+
type: "bool",
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
name: "ExchangeAllowlistUpdated",
|
|
27
|
+
type: "event",
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
anonymous: false,
|
|
31
|
+
inputs: [
|
|
32
|
+
{
|
|
33
|
+
indexed: true,
|
|
34
|
+
internalType: "address",
|
|
35
|
+
name: "receiver",
|
|
36
|
+
type: "address",
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
indexed: false,
|
|
40
|
+
internalType: "address[]",
|
|
41
|
+
name: "tokensIn",
|
|
42
|
+
type: "address[]",
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
indexed: false,
|
|
46
|
+
internalType: "address",
|
|
47
|
+
name: "tokenOut",
|
|
48
|
+
type: "address",
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
indexed: false,
|
|
52
|
+
internalType: "uint256[]",
|
|
53
|
+
name: "amountsIn",
|
|
54
|
+
type: "uint256[]",
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
indexed: false,
|
|
58
|
+
internalType: "uint256",
|
|
59
|
+
name: "amountOut",
|
|
60
|
+
type: "uint256",
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
name: "Swapped",
|
|
64
|
+
type: "event",
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
inputs: [
|
|
68
|
+
{
|
|
69
|
+
internalType: "address",
|
|
70
|
+
name: "exchange",
|
|
71
|
+
type: "address",
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
name: "isExchangeAllowed",
|
|
75
|
+
outputs: [
|
|
76
|
+
{
|
|
77
|
+
internalType: "bool",
|
|
78
|
+
name: "isAllowed",
|
|
79
|
+
type: "bool",
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
stateMutability: "view",
|
|
83
|
+
type: "function",
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
inputs: [
|
|
87
|
+
{
|
|
88
|
+
internalType: "address[]",
|
|
89
|
+
name: "tokensIn",
|
|
90
|
+
type: "address[]",
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
components: [
|
|
94
|
+
{
|
|
95
|
+
internalType: "address",
|
|
96
|
+
name: "swapTarget",
|
|
97
|
+
type: "address",
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
internalType: "address",
|
|
101
|
+
name: "token",
|
|
102
|
+
type: "address",
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
internalType: "bytes",
|
|
106
|
+
name: "swapCallData",
|
|
107
|
+
type: "bytes",
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
internalType: "struct SwapInfo[]",
|
|
111
|
+
name: "swapInfo",
|
|
112
|
+
type: "tuple[]",
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
internalType: "address",
|
|
116
|
+
name: "tokenOut",
|
|
117
|
+
type: "address",
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
internalType: "address",
|
|
121
|
+
name: "receiver",
|
|
122
|
+
type: "address",
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
name: "swap",
|
|
126
|
+
outputs: [
|
|
127
|
+
{
|
|
128
|
+
internalType: "uint256",
|
|
129
|
+
name: "amountOut",
|
|
130
|
+
type: "uint256",
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
stateMutability: "nonpayable",
|
|
134
|
+
type: "function",
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
inputs: [
|
|
138
|
+
{
|
|
139
|
+
internalType: "address[]",
|
|
140
|
+
name: "exchanges",
|
|
141
|
+
type: "address[]",
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
internalType: "bool[]",
|
|
145
|
+
name: "allowed",
|
|
146
|
+
type: "bool[]",
|
|
147
|
+
},
|
|
148
|
+
],
|
|
149
|
+
name: "updateExchangeAllowlist",
|
|
150
|
+
outputs: [],
|
|
151
|
+
stateMutability: "nonpayable",
|
|
152
|
+
type: "function",
|
|
153
|
+
},
|
|
154
|
+
] as const;
|
|
155
|
+
|
|
156
|
+
export class SwapperAbi__factory {
|
|
157
|
+
static readonly abi = _abi;
|
|
158
|
+
static createInterface(): SwapperAbiInterface {
|
|
159
|
+
return new utils.Interface(_abi) as SwapperAbiInterface;
|
|
160
|
+
}
|
|
161
|
+
static connect(
|
|
162
|
+
address: string,
|
|
163
|
+
signerOrProvider: Signer | Provider
|
|
164
|
+
): SwapperAbi {
|
|
165
|
+
return new Contract(address, _abi, signerOrProvider) as SwapperAbi;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/* Autogenerated file. Do not edit manually. */
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
export { IClearingCoordinatorAbi__factory } from "./IClearingCoordinatorAbi__factory";
|
|
5
|
+
export { IERC20MetadataAbi__factory } from "./IERC20MetadataAbi__factory";
|
|
6
|
+
export { IFeeManagerAbi__factory } from "./IFeeManagerAbi__factory";
|
|
7
|
+
export { IKSULockingAbi__factory } from "./IKSULockingAbi__factory";
|
|
8
|
+
export { IKasuAllowListAbi__factory } from "./IKasuAllowListAbi__factory";
|
|
9
|
+
export { IKasuControllerAbi__factory } from "./IKasuControllerAbi__factory";
|
|
10
|
+
export { IKasuNFTsAbi__factory } from "./IKasuNFTsAbi__factory";
|
|
11
|
+
export { IKsuPriceAbi__factory } from "./IKsuPriceAbi__factory";
|
|
12
|
+
export { ILendingPoolAbi__factory } from "./ILendingPoolAbi__factory";
|
|
13
|
+
export { ILendingPoolFactoryAbi__factory } from "./ILendingPoolFactoryAbi__factory";
|
|
14
|
+
export { ILendingPoolManagerAbi__factory } from "./ILendingPoolManagerAbi__factory";
|
|
15
|
+
export { ILendingPoolTrancheAbi__factory } from "./ILendingPoolTrancheAbi__factory";
|
|
16
|
+
export { ISystemVariablesAbi__factory } from "./ISystemVariablesAbi__factory";
|
|
17
|
+
export { IUserLoyaltyRewardsAbi__factory } from "./IUserLoyaltyRewardsAbi__factory";
|
|
18
|
+
export { IUserManagerAbi__factory } from "./IUserManagerAbi__factory";
|
|
19
|
+
export { KSULockBonusAbi__factory } from "./KSULockBonusAbi__factory";
|
|
20
|
+
export { KasuPoolExternalTVLAbi__factory } from "./KasuPoolExternalTVLAbi__factory";
|
|
21
|
+
export { SwapperAbi__factory } from "./SwapperAbi__factory";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/* Autogenerated file. Do not edit manually. */
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
export type { IClearingCoordinatorAbi } from "./IClearingCoordinatorAbi";
|
|
5
|
+
export type { IERC20MetadataAbi } from "./IERC20MetadataAbi";
|
|
6
|
+
export type { IFeeManagerAbi } from "./IFeeManagerAbi";
|
|
7
|
+
export type { IKSULockingAbi } from "./IKSULockingAbi";
|
|
8
|
+
export type { IKasuAllowListAbi } from "./IKasuAllowListAbi";
|
|
9
|
+
export type { IKasuControllerAbi } from "./IKasuControllerAbi";
|
|
10
|
+
export type { IKasuNFTsAbi } from "./IKasuNFTsAbi";
|
|
11
|
+
export type { IKsuPriceAbi } from "./IKsuPriceAbi";
|
|
12
|
+
export type { ILendingPoolAbi } from "./ILendingPoolAbi";
|
|
13
|
+
export type { ILendingPoolFactoryAbi } from "./ILendingPoolFactoryAbi";
|
|
14
|
+
export type { ILendingPoolManagerAbi } from "./ILendingPoolManagerAbi";
|
|
15
|
+
export type { ILendingPoolTrancheAbi } from "./ILendingPoolTrancheAbi";
|
|
16
|
+
export type { ISystemVariablesAbi } from "./ISystemVariablesAbi";
|
|
17
|
+
export type { IUserLoyaltyRewardsAbi } from "./IUserLoyaltyRewardsAbi";
|
|
18
|
+
export type { IUserManagerAbi } from "./IUserManagerAbi";
|
|
19
|
+
export type { KSULockBonusAbi } from "./KSULockBonusAbi";
|
|
20
|
+
export type { KasuPoolExternalTVLAbi } from "./KasuPoolExternalTVLAbi";
|
|
21
|
+
export type { SwapperAbi } from "./SwapperAbi";
|
|
22
|
+
export * as factories from "./factories";
|
|
23
|
+
export { IClearingCoordinatorAbi__factory } from "./factories/IClearingCoordinatorAbi__factory";
|
|
24
|
+
export { IERC20MetadataAbi__factory } from "./factories/IERC20MetadataAbi__factory";
|
|
25
|
+
export { IFeeManagerAbi__factory } from "./factories/IFeeManagerAbi__factory";
|
|
26
|
+
export { IKasuAllowListAbi__factory } from "./factories/IKasuAllowListAbi__factory";
|
|
27
|
+
export { IKasuControllerAbi__factory } from "./factories/IKasuControllerAbi__factory";
|
|
28
|
+
export { IKasuNFTsAbi__factory } from "./factories/IKasuNFTsAbi__factory";
|
|
29
|
+
export { IKSULockingAbi__factory } from "./factories/IKSULockingAbi__factory";
|
|
30
|
+
export { IKsuPriceAbi__factory } from "./factories/IKsuPriceAbi__factory";
|
|
31
|
+
export { ILendingPoolAbi__factory } from "./factories/ILendingPoolAbi__factory";
|
|
32
|
+
export { ILendingPoolFactoryAbi__factory } from "./factories/ILendingPoolFactoryAbi__factory";
|
|
33
|
+
export { ILendingPoolManagerAbi__factory } from "./factories/ILendingPoolManagerAbi__factory";
|
|
34
|
+
export { ILendingPoolTrancheAbi__factory } from "./factories/ILendingPoolTrancheAbi__factory";
|
|
35
|
+
export { ISystemVariablesAbi__factory } from "./factories/ISystemVariablesAbi__factory";
|
|
36
|
+
export { IUserLoyaltyRewardsAbi__factory } from "./factories/IUserLoyaltyRewardsAbi__factory";
|
|
37
|
+
export { IUserManagerAbi__factory } from "./factories/IUserManagerAbi__factory";
|
|
38
|
+
export { KasuPoolExternalTVLAbi__factory } from "./factories/KasuPoolExternalTVLAbi__factory";
|
|
39
|
+
export { KSULockBonusAbi__factory } from "./factories/KSULockBonusAbi__factory";
|
|
40
|
+
export { SwapperAbi__factory } from "./factories/SwapperAbi__factory";
|
|
@@ -8,11 +8,28 @@ import {
|
|
|
8
8
|
IKasuNFTsAbi__factory,
|
|
9
9
|
ISystemVariablesAbi,
|
|
10
10
|
ISystemVariablesAbi__factory,
|
|
11
|
+
IUserLoyaltyRewardsAbi__factory,
|
|
11
12
|
} from '../../contracts';
|
|
12
13
|
import { SdkConfig } from '../../sdk-config';
|
|
13
14
|
import { DataService } from '../DataService/data-service';
|
|
15
|
+
import {
|
|
16
|
+
getAllTrancheConfigurationsQuery,
|
|
17
|
+
getAllTranchesQuery,
|
|
18
|
+
} from '../DataService/queries';
|
|
19
|
+
import {
|
|
20
|
+
TrancheConfigurationSubgraphResult,
|
|
21
|
+
TrancheSubgraphResult,
|
|
22
|
+
} from '../DataService/subgraph-types';
|
|
14
23
|
import { PoolOverview } from '../DataService/types';
|
|
15
24
|
import { KSULocking } from '../Locking/locking';
|
|
25
|
+
import {
|
|
26
|
+
getSystemVariablesQuery,
|
|
27
|
+
lockingSummariesQuery,
|
|
28
|
+
} from '../Locking/queries';
|
|
29
|
+
import {
|
|
30
|
+
LockingSummarySubgraphResult,
|
|
31
|
+
SystemVariables,
|
|
32
|
+
} from '../Locking/types';
|
|
16
33
|
import { UserLending } from '../UserLending/user-lending';
|
|
17
34
|
|
|
18
35
|
import { lendingPortfolioQuery } from './queries';
|
|
@@ -33,6 +50,9 @@ export class Portfolio {
|
|
|
33
50
|
private readonly _graph: GraphQLClient;
|
|
34
51
|
|
|
35
52
|
private _systemVariablesAbi: ISystemVariablesAbi;
|
|
53
|
+
private _userLoyaltyRewardsAbi: ReturnType<
|
|
54
|
+
typeof IUserLoyaltyRewardsAbi__factory.connect
|
|
55
|
+
>;
|
|
36
56
|
private _kasuNftContract: IKasuNFTsAbi;
|
|
37
57
|
readonly _signerOrProvider: Signer | Provider;
|
|
38
58
|
|
|
@@ -47,6 +67,10 @@ export class Portfolio {
|
|
|
47
67
|
_kasuConfig.contracts.SystemVariables,
|
|
48
68
|
signerOrProvider,
|
|
49
69
|
);
|
|
70
|
+
this._userLoyaltyRewardsAbi = IUserLoyaltyRewardsAbi__factory.connect(
|
|
71
|
+
_kasuConfig.contracts.UserLoyaltyRewards,
|
|
72
|
+
signerOrProvider,
|
|
73
|
+
);
|
|
50
74
|
this._userLendingService = new UserLending(
|
|
51
75
|
_kasuConfig,
|
|
52
76
|
signerOrProvider,
|
|
@@ -58,49 +82,17 @@ export class Portfolio {
|
|
|
58
82
|
this._graph = new GraphQLClient(_kasuConfig.subgraphUrl);
|
|
59
83
|
}
|
|
60
84
|
|
|
61
|
-
|
|
62
|
-
const userLockingData =
|
|
63
|
-
await this._lockingService.getUserBonusData(userAddress);
|
|
64
|
-
const lockingRewards =
|
|
65
|
-
await this._lockingService.getLockingRewards(userAddress);
|
|
66
|
-
const ksuLaunchBonus =
|
|
67
|
-
await this._lockingService.getUserTotalBonusAmount(userAddress);
|
|
68
|
-
return {
|
|
69
|
-
bonusYieldEarnings: {
|
|
70
|
-
claimableBalance: {
|
|
71
|
-
ksuAmount: userLockingData.ksuBonusAndRewards,
|
|
72
|
-
},
|
|
73
|
-
lifeTime: {
|
|
74
|
-
ksuAmount: userLockingData.ksuBonusAndRewardsLifetime,
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
protocolFees: {
|
|
78
|
-
claimableBalance: {
|
|
79
|
-
usdcAmount: lockingRewards.claimableRewards,
|
|
80
|
-
},
|
|
81
|
-
lifeTime: { usdcAmount: lockingRewards.lifeTimeRewards },
|
|
82
|
-
},
|
|
83
|
-
ksuLaunchBonus: { lifeTime: { ksuAmount: ksuLaunchBonus } },
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
async getUserNfts(userAddress: string): Promise<number[]> {
|
|
88
|
-
const usernfts = await this._kasuNftContract.tokensOfOwner(userAddress);
|
|
89
|
-
|
|
90
|
-
return usernfts.map((nft) => nft.toNumber());
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
async getPortfolioSummary(
|
|
94
|
-
userAddress: string,
|
|
85
|
+
private computeYieldMetrics(
|
|
95
86
|
portfolioLendingPools: PortfolioLendingPool[],
|
|
96
|
-
):
|
|
97
|
-
|
|
98
|
-
|
|
87
|
+
): {
|
|
88
|
+
totalInvestments: number;
|
|
89
|
+
totalYieldEarned: number;
|
|
90
|
+
weightedApy: number;
|
|
91
|
+
weeklyYieldEarnings: number;
|
|
92
|
+
} {
|
|
99
93
|
let totalInvestments = 0;
|
|
100
|
-
|
|
101
|
-
let weightedApy = 0;
|
|
102
94
|
let totalYieldEarned = 0;
|
|
103
|
-
|
|
95
|
+
let weightedApy = 0;
|
|
104
96
|
let weeklyYieldEarnings = 0;
|
|
105
97
|
|
|
106
98
|
for (const pool of portfolioLendingPools) {
|
|
@@ -139,6 +131,233 @@ export class Portfolio {
|
|
|
139
131
|
}
|
|
140
132
|
}
|
|
141
133
|
|
|
134
|
+
return {
|
|
135
|
+
totalInvestments,
|
|
136
|
+
totalYieldEarned,
|
|
137
|
+
weightedApy,
|
|
138
|
+
weeklyYieldEarnings,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Calculate aggregate yield metrics for a set of portfolio lending pools.
|
|
144
|
+
* Accepts pre-fetched pool data and returns totals without performing any network calls.
|
|
145
|
+
*/
|
|
146
|
+
public calculateYieldMetrics(
|
|
147
|
+
portfolioLendingPools: PortfolioLendingPool[],
|
|
148
|
+
): {
|
|
149
|
+
totalInvestments: number;
|
|
150
|
+
totalYieldEarned: number;
|
|
151
|
+
weightedApy: number;
|
|
152
|
+
weeklyYieldEarnings: number;
|
|
153
|
+
} {
|
|
154
|
+
return this.computeYieldMetrics(portfolioLendingPools);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Calculate the user's weekly protocol fee share (USDC) given tranche balances/configs,
|
|
159
|
+
* system variables and locking summary. All inputs are expected to be pre-fetched.
|
|
160
|
+
*/
|
|
161
|
+
public calculateWeeklyProtocolFees(params: {
|
|
162
|
+
trancheBalances: TrancheSubgraphResult;
|
|
163
|
+
trancheConfigurations: TrancheConfigurationSubgraphResult;
|
|
164
|
+
systemVariables: SystemVariables;
|
|
165
|
+
lockingSummary: LockingSummarySubgraphResult;
|
|
166
|
+
userRksuAmount: string;
|
|
167
|
+
}): number {
|
|
168
|
+
const {
|
|
169
|
+
trancheBalances,
|
|
170
|
+
trancheConfigurations,
|
|
171
|
+
systemVariables,
|
|
172
|
+
lockingSummary,
|
|
173
|
+
userRksuAmount,
|
|
174
|
+
} = params;
|
|
175
|
+
|
|
176
|
+
const totalRKsuAmount = parseFloat(
|
|
177
|
+
lockingSummary.lockingSummaries[0]?.totalRKsuAmount ?? '0',
|
|
178
|
+
);
|
|
179
|
+
const userRKsuAmount = parseFloat(userRksuAmount || '0');
|
|
180
|
+
|
|
181
|
+
const performanceFee =
|
|
182
|
+
parseFloat(systemVariables.systemVariables.performanceFee) / 100;
|
|
183
|
+
const ecosystemFeeRate =
|
|
184
|
+
parseFloat(systemVariables.systemVariables.ecosystemFeeRate) / 100;
|
|
185
|
+
|
|
186
|
+
if (
|
|
187
|
+
totalRKsuAmount <= 0 ||
|
|
188
|
+
userRKsuAmount <= 0 ||
|
|
189
|
+
performanceFee <= 0 ||
|
|
190
|
+
ecosystemFeeRate <= 0
|
|
191
|
+
) {
|
|
192
|
+
return 0;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
let totalWeeklyEcosystemFees = 0;
|
|
196
|
+
|
|
197
|
+
for (const tranche of trancheBalances.lendingPoolTranches) {
|
|
198
|
+
const trancheConfig =
|
|
199
|
+
trancheConfigurations.lendingPoolTrancheConfigurations.find(
|
|
200
|
+
(config) => config.id === tranche.id,
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
if (!trancheConfig) continue;
|
|
204
|
+
|
|
205
|
+
const interestUpdates =
|
|
206
|
+
trancheConfig.lendingPoolTrancheInterestRateUpdates;
|
|
207
|
+
|
|
208
|
+
const interestRate = interestUpdates.length
|
|
209
|
+
? interestUpdates[0].epochInterestRate
|
|
210
|
+
: trancheConfig.interestRate;
|
|
211
|
+
|
|
212
|
+
totalWeeklyEcosystemFees +=
|
|
213
|
+
parseFloat(tranche.balance) *
|
|
214
|
+
parseFloat(interestRate) *
|
|
215
|
+
performanceFee *
|
|
216
|
+
ecosystemFeeRate;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return (
|
|
220
|
+
(totalWeeklyEcosystemFees * userRKsuAmount) / totalRKsuAmount
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Calculate the user's weekly KASU bonus rewards (KASU) based on current deposits,
|
|
226
|
+
* loyalty level, reward rate, and KSU epoch price. Inputs should be pre-fetched.
|
|
227
|
+
*/
|
|
228
|
+
public async calculateWeeklyKsuBonusRewards(params: {
|
|
229
|
+
userAddress: string;
|
|
230
|
+
userRksuAmount: string;
|
|
231
|
+
userDepositAmounts: [BigNumber, BigNumber];
|
|
232
|
+
ksuEpochPrice: { price: BigNumber; decimals: number };
|
|
233
|
+
}): Promise<number> {
|
|
234
|
+
const { userAddress, userRksuAmount, userDepositAmounts, ksuEpochPrice } =
|
|
235
|
+
params;
|
|
236
|
+
|
|
237
|
+
const totalUserDeposits = userDepositAmounts[0].add(
|
|
238
|
+
userDepositAmounts[1],
|
|
239
|
+
);
|
|
240
|
+
|
|
241
|
+
if (totalUserDeposits.isZero()) return 0;
|
|
242
|
+
|
|
243
|
+
const rKSUtoUSDCRatio = await this._lockingService.getRKSUvsUSDCRatio(
|
|
244
|
+
userRksuAmount,
|
|
245
|
+
userAddress,
|
|
246
|
+
);
|
|
247
|
+
const { loyaltyLevel } =
|
|
248
|
+
this._lockingService.getLoyaltyLevelAndApyBonusFromRatio(
|
|
249
|
+
rKSUtoUSDCRatio,
|
|
250
|
+
);
|
|
251
|
+
|
|
252
|
+
const loyaltyRewardRate =
|
|
253
|
+
await this._userLoyaltyRewardsAbi.loyaltyEpochRewardRates(
|
|
254
|
+
loyaltyLevel,
|
|
255
|
+
);
|
|
256
|
+
|
|
257
|
+
if (loyaltyRewardRate.isZero() || ksuEpochPrice.price.isZero()) {
|
|
258
|
+
return 0;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
const reward = totalUserDeposits
|
|
262
|
+
.mul(loyaltyRewardRate)
|
|
263
|
+
.mul(BigNumber.from(10).pow(12))
|
|
264
|
+
.div(ksuEpochPrice.price);
|
|
265
|
+
|
|
266
|
+
return parseFloat(formatEther(reward));
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
async getPortfolioRewards(userAddress: string): Promise<PortfolioRewards> {
|
|
270
|
+
const userLockingData =
|
|
271
|
+
await this._lockingService.getUserBonusData(userAddress);
|
|
272
|
+
const lockingRewards =
|
|
273
|
+
await this._lockingService.getLockingRewards(userAddress);
|
|
274
|
+
const ksuLaunchBonus =
|
|
275
|
+
await this._lockingService.getUserTotalBonusAmount(userAddress);
|
|
276
|
+
return {
|
|
277
|
+
bonusYieldEarnings: {
|
|
278
|
+
claimableBalance: {
|
|
279
|
+
ksuAmount: userLockingData.ksuBonusAndRewards,
|
|
280
|
+
},
|
|
281
|
+
lifeTime: {
|
|
282
|
+
ksuAmount: userLockingData.ksuBonusAndRewardsLifetime,
|
|
283
|
+
},
|
|
284
|
+
},
|
|
285
|
+
protocolFees: {
|
|
286
|
+
claimableBalance: {
|
|
287
|
+
usdcAmount: lockingRewards.claimableRewards,
|
|
288
|
+
},
|
|
289
|
+
lifeTime: { usdcAmount: lockingRewards.lifeTimeRewards },
|
|
290
|
+
},
|
|
291
|
+
ksuLaunchBonus: { lifeTime: { ksuAmount: ksuLaunchBonus } },
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
async getUserNfts(userAddress: string): Promise<number[]> {
|
|
296
|
+
const usernfts = await this._kasuNftContract.tokensOfOwner(userAddress);
|
|
297
|
+
|
|
298
|
+
return usernfts.map((nft) => nft.toNumber());
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
async getPortfolioSummary(
|
|
302
|
+
userAddress: string,
|
|
303
|
+
portfolioLendingPools: PortfolioLendingPool[],
|
|
304
|
+
currentEpoch: string,
|
|
305
|
+
): Promise<PortfolioSummary> {
|
|
306
|
+
const epochId = currentEpoch.toString();
|
|
307
|
+
const [
|
|
308
|
+
userLockingData,
|
|
309
|
+
userRksuAmount,
|
|
310
|
+
lockingSummary,
|
|
311
|
+
systemVariables,
|
|
312
|
+
trancheBalances,
|
|
313
|
+
trancheConfigurations,
|
|
314
|
+
userDepositAmounts,
|
|
315
|
+
ksuEpochPrice,
|
|
316
|
+
] = await Promise.all([
|
|
317
|
+
this._lockingService.getUserBonusData(userAddress),
|
|
318
|
+
this._lockingService.getUserEarnedrKsu(userAddress),
|
|
319
|
+
this._graph.request<LockingSummarySubgraphResult>(
|
|
320
|
+
lockingSummariesQuery,
|
|
321
|
+
),
|
|
322
|
+
this._graph.request<SystemVariables>(getSystemVariablesQuery),
|
|
323
|
+
this._graph.request<TrancheSubgraphResult>(getAllTranchesQuery, {
|
|
324
|
+
unusedPools: this._kasuConfig.UNUSED_LENDING_POOL_IDS,
|
|
325
|
+
}),
|
|
326
|
+
this._graph.request<TrancheConfigurationSubgraphResult>(
|
|
327
|
+
getAllTrancheConfigurationsQuery,
|
|
328
|
+
{
|
|
329
|
+
unusedPools: this._kasuConfig.UNUSED_LENDING_POOL_IDS,
|
|
330
|
+
epochId,
|
|
331
|
+
},
|
|
332
|
+
),
|
|
333
|
+
this._userLendingService.getUserTotalPendingAndActiveDepositedAmountForCurrentEpoch(
|
|
334
|
+
userAddress,
|
|
335
|
+
),
|
|
336
|
+
this._lockingService.getKasuEpochTokenPrice(),
|
|
337
|
+
]);
|
|
338
|
+
const {
|
|
339
|
+
totalInvestments,
|
|
340
|
+
totalYieldEarned,
|
|
341
|
+
weightedApy,
|
|
342
|
+
weeklyYieldEarnings,
|
|
343
|
+
} = this.computeYieldMetrics(portfolioLendingPools);
|
|
344
|
+
|
|
345
|
+
const weeklyProtocolFeesEarned = this.calculateWeeklyProtocolFees({
|
|
346
|
+
trancheBalances,
|
|
347
|
+
trancheConfigurations,
|
|
348
|
+
systemVariables,
|
|
349
|
+
lockingSummary,
|
|
350
|
+
userRksuAmount,
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
const weeklyKsuBonusRewards =
|
|
354
|
+
await this.calculateWeeklyKsuBonusRewards({
|
|
355
|
+
userAddress,
|
|
356
|
+
userRksuAmount,
|
|
357
|
+
userDepositAmounts,
|
|
358
|
+
ksuEpochPrice,
|
|
359
|
+
});
|
|
360
|
+
|
|
142
361
|
return {
|
|
143
362
|
current: {
|
|
144
363
|
totalKsuLocked: userLockingData.totalLockedAmount,
|
|
@@ -153,8 +372,8 @@ export class Portfolio {
|
|
|
153
372
|
},
|
|
154
373
|
weekly: {
|
|
155
374
|
yieldEarnings: weeklyYieldEarnings.toString(),
|
|
156
|
-
protocolFeesEarned:
|
|
157
|
-
ksuBonusRewards:
|
|
375
|
+
protocolFeesEarned: weeklyProtocolFeesEarned.toString(),
|
|
376
|
+
ksuBonusRewards: weeklyKsuBonusRewards.toString(),
|
|
158
377
|
},
|
|
159
378
|
lifetime: {
|
|
160
379
|
yieldEarnings: totalYieldEarned.toString(),
|
|
@@ -269,9 +488,6 @@ export class Portfolio {
|
|
|
269
488
|
({ poolId }) => poolId === poolOverview.id,
|
|
270
489
|
);
|
|
271
490
|
if (!userPoolBalance) {
|
|
272
|
-
console.warn(
|
|
273
|
-
`Could not find user pool balance for ${poolOverview.id}`,
|
|
274
|
-
);
|
|
275
491
|
continue;
|
|
276
492
|
}
|
|
277
493
|
totalInvestments = userPoolBalance.balance.add(totalInvestments);
|