@kasufinance/kasu-sdk 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +3 -0
- package/.eslintrc.json +90 -0
- package/.github/workflows/ci.yml +0 -0
- package/.github/workflows/main.yml +43 -0
- package/.prettierignore +3 -0
- package/.prettierrc +28 -0
- package/abis/IClearingCoordinator.abi.json +410 -0
- package/abis/IERC20Metadata.abi.json +224 -0
- package/abis/IFeeManager.abi.json +66 -0
- package/abis/IKSULocking.abi.json +754 -0
- package/abis/IKasuAllowList.abi.json +455 -0
- package/abis/IKasuController.abi.json +423 -0
- package/abis/IKasuNFTs.abi.json +1523 -0
- package/abis/IKsuPrice.abi.json +15 -0
- package/abis/ILendingPool.abi.json +1431 -0
- package/abis/ILendingPoolFactory.abi.json +97 -0
- package/abis/ILendingPoolManager.abi.json +1347 -0
- package/abis/ILendingPoolTranche.abi.json +1317 -0
- package/abis/IPriceFeed.abi.json +1 -0
- package/abis/ISystemVariables.abi.json +431 -0
- package/abis/IUserLoyaltyRewards.abi.json +288 -0
- package/abis/IUserManager.abi.json +321 -0
- package/abis/KSULockBonus.abi.json +91 -0
- package/abis/KasuPoolExternalTVL.abi.json +812 -0
- package/abis/Swapper.abi.json +146 -0
- package/copy-abi.ps1 +15 -0
- package/dist/bundle.cjs.js +21646 -0
- package/dist/bundle.esm.js +21644 -0
- package/dist/contracts/IClearingCoordinatorAbi.d.ts +169 -0
- package/dist/contracts/IClearingCoordinatorAbi.js +1 -0
- package/dist/contracts/IERC20MetadataAbi.d.ts +162 -0
- package/dist/contracts/IERC20MetadataAbi.js +1 -0
- package/dist/contracts/IFeeManagerAbi.d.ts +96 -0
- package/dist/contracts/IFeeManagerAbi.js +1 -0
- package/dist/contracts/IKSULockingAbi.d.ts +466 -0
- package/dist/contracts/IKSULockingAbi.js +1 -0
- package/dist/contracts/IKasuAllowListAbi.d.ts +304 -0
- package/dist/contracts/IKasuAllowListAbi.js +1 -0
- package/dist/contracts/IKasuControllerAbi.d.ts +309 -0
- package/dist/contracts/IKasuControllerAbi.js +1 -0
- package/dist/contracts/IKasuNFTsAbi.d.ts +1121 -0
- package/dist/contracts/IKasuNFTsAbi.js +1 -0
- package/dist/contracts/IKsuPriceAbi.d.ts +42 -0
- package/dist/contracts/IKsuPriceAbi.js +1 -0
- package/dist/contracts/ILendingPoolAbi.d.ts +968 -0
- package/dist/contracts/ILendingPoolAbi.js +1 -0
- package/dist/contracts/ILendingPoolFactoryAbi.d.ts +103 -0
- package/dist/contracts/ILendingPoolFactoryAbi.js +1 -0
- package/dist/contracts/ILendingPoolManagerAbi.d.ts +779 -0
- package/dist/contracts/ILendingPoolManagerAbi.js +1 -0
- package/dist/contracts/ILendingPoolTrancheAbi.d.ts +752 -0
- package/dist/contracts/ILendingPoolTrancheAbi.js +1 -0
- package/dist/contracts/ISystemVariablesAbi.d.ts +378 -0
- package/dist/contracts/ISystemVariablesAbi.js +1 -0
- package/dist/contracts/IUserLoyaltyRewardsAbi.d.ts +248 -0
- package/dist/contracts/IUserLoyaltyRewardsAbi.js +1 -0
- package/dist/contracts/IUserManagerAbi.d.ts +270 -0
- package/dist/contracts/IUserManagerAbi.js +1 -0
- package/dist/contracts/KSULockBonusAbi.d.ts +61 -0
- package/dist/contracts/KSULockBonusAbi.js +1 -0
- package/dist/contracts/KasuPoolExternalTVLAbi.d.ts +411 -0
- package/dist/contracts/KasuPoolExternalTVLAbi.js +1 -0
- package/dist/contracts/SwapperAbi.d.ts +120 -0
- package/dist/contracts/SwapperAbi.js +1 -0
- package/dist/contracts/common.d.ts +21 -0
- package/dist/contracts/common.js +1 -0
- package/dist/contracts/factories/IClearingCoordinatorAbi__factory.d.ts +320 -0
- package/dist/contracts/factories/IClearingCoordinatorAbi__factory.js +423 -0
- package/dist/contracts/factories/IERC20MetadataAbi__factory.d.ts +178 -0
- package/dist/contracts/factories/IERC20MetadataAbi__factory.js +237 -0
- package/dist/contracts/factories/IFeeManagerAbi__factory.d.ts +59 -0
- package/dist/contracts/factories/IFeeManagerAbi__factory.js +79 -0
- package/dist/contracts/factories/IKSULockingAbi__factory.d.ts +588 -0
- package/dist/contracts/factories/IKSULockingAbi__factory.js +767 -0
- package/dist/contracts/factories/IKasuAllowListAbi__factory.d.ts +354 -0
- package/dist/contracts/factories/IKasuAllowListAbi__factory.js +468 -0
- package/dist/contracts/factories/IKasuControllerAbi__factory.d.ts +339 -0
- package/dist/contracts/factories/IKasuControllerAbi__factory.js +436 -0
- package/dist/contracts/factories/IKasuNFTsAbi__factory.d.ts +1629 -0
- package/dist/contracts/factories/IKasuNFTsAbi__factory.js +2108 -0
- package/dist/contracts/factories/IKsuPriceAbi__factory.d.ts +18 -0
- package/dist/contracts/factories/IKsuPriceAbi__factory.js +28 -0
- package/dist/contracts/factories/ILendingPoolAbi__factory.d.ts +1109 -0
- package/dist/contracts/factories/ILendingPoolAbi__factory.js +1444 -0
- package/dist/contracts/factories/ILendingPoolFactoryAbi__factory.d.ts +81 -0
- package/dist/contracts/factories/ILendingPoolFactoryAbi__factory.js +110 -0
- package/dist/contracts/factories/ILendingPoolManagerAbi__factory.d.ts +1045 -0
- package/dist/contracts/factories/ILendingPoolManagerAbi__factory.js +1360 -0
- package/dist/contracts/factories/ILendingPoolTrancheAbi__factory.d.ts +1015 -0
- package/dist/contracts/factories/ILendingPoolTrancheAbi__factory.js +1330 -0
- package/dist/contracts/factories/ISystemVariablesAbi__factory.d.ts +338 -0
- package/dist/contracts/factories/ISystemVariablesAbi__factory.js +444 -0
- package/dist/contracts/factories/IUserLoyaltyRewardsAbi__factory.d.ts +230 -0
- package/dist/contracts/factories/IUserLoyaltyRewardsAbi__factory.js +301 -0
- package/dist/contracts/factories/IUserManagerAbi__factory.d.ts +250 -0
- package/dist/contracts/factories/IUserManagerAbi__factory.js +334 -0
- package/dist/contracts/factories/KSULockBonusAbi__factory.d.ts +76 -0
- package/dist/contracts/factories/KSULockBonusAbi__factory.js +104 -0
- package/dist/contracts/factories/KasuPoolExternalTVLAbi__factory.d.ts +631 -0
- package/dist/contracts/factories/KasuPoolExternalTVLAbi__factory.js +825 -0
- package/dist/contracts/factories/SwapperAbi__factory.d.ts +120 -0
- package/dist/contracts/factories/SwapperAbi__factory.js +159 -0
- package/dist/contracts/factories/index.d.ts +18 -0
- package/dist/contracts/factories/index.js +21 -0
- package/dist/contracts/index.d.ts +37 -0
- package/dist/contracts/index.js +19 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +16 -0
- package/dist/sdk-config.d.ts +22 -0
- package/dist/sdk-config.js +9 -0
- package/dist/services/DataService/data-service.d.ts +37 -0
- package/dist/services/DataService/data-service.js +586 -0
- package/dist/services/DataService/directus-types.d.ts +187 -0
- package/dist/services/DataService/directus-types.js +1 -0
- package/dist/services/DataService/queries.d.ts +7 -0
- package/dist/services/DataService/queries.js +158 -0
- package/dist/services/DataService/subgraph-types.d.ts +95 -0
- package/dist/services/DataService/subgraph-types.js +1 -0
- package/dist/services/DataService/types.d.ts +169 -0
- package/dist/services/DataService/types.js +1 -0
- package/dist/services/Locking/locking.d.ts +61 -0
- package/dist/services/Locking/locking.js +344 -0
- package/dist/services/Locking/queries.d.ts +10 -0
- package/dist/services/Locking/queries.js +108 -0
- package/dist/services/Locking/types.d.ts +117 -0
- package/dist/services/Locking/types.js +1 -0
- package/dist/services/Portfolio/portfolio.d.ts +22 -0
- package/dist/services/Portfolio/portfolio.js +325 -0
- package/dist/services/Portfolio/queries.d.ts +2 -0
- package/dist/services/Portfolio/queries.js +164 -0
- package/dist/services/Portfolio/types.d.ts +206 -0
- package/dist/services/Portfolio/types.js +1 -0
- package/dist/services/Swapper/swapper.d.ts +11 -0
- package/dist/services/Swapper/swapper.js +97 -0
- package/dist/services/Swapper/types.d.ts +51 -0
- package/dist/services/Swapper/types.js +1 -0
- package/dist/services/UserLending/helper.d.ts +2 -0
- package/dist/services/UserLending/helper.js +16 -0
- package/dist/services/UserLending/queries.d.ts +8 -0
- package/dist/services/UserLending/queries.js +188 -0
- package/dist/services/UserLending/subgraph-types.d.ts +147 -0
- package/dist/services/UserLending/subgraph-types.js +6 -0
- package/dist/services/UserLending/types.d.ts +102 -0
- package/dist/services/UserLending/types.js +13 -0
- package/dist/services/UserLending/user-lending.d.ts +55 -0
- package/dist/services/UserLending/user-lending.js +490 -0
- package/dist/services/shared.d.ts +1 -0
- package/dist/services/shared.js +11 -0
- package/dist/tests/sample.test.d.ts +1 -0
- package/dist/tests/sample.test.js +32 -0
- package/index.ts +2 -0
- package/jest-config.ts +9 -0
- package/jest.config.js +8 -0
- package/package.json +49 -0
- package/rollup.config.js +45 -0
- 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/index.ts +27 -0
- package/src/sdk-config.ts +35 -0
- package/src/services/DataService/data-service.ts +1017 -0
- package/src/services/DataService/directus-types.ts +199 -0
- package/src/services/DataService/queries.ts +165 -0
- package/src/services/DataService/subgraph-types.ts +104 -0
- package/src/services/DataService/types.ts +184 -0
- package/src/services/Locking/locking.ts +541 -0
- package/src/services/Locking/queries.ts +118 -0
- package/src/services/Locking/types.ts +141 -0
- package/src/services/Portfolio/portfolio.ts +593 -0
- package/src/services/Portfolio/queries.ts +166 -0
- package/src/services/Portfolio/types.ts +220 -0
- package/src/services/Swapper/swapper.ts +158 -0
- package/src/services/Swapper/types.ts +54 -0
- package/src/services/UserLending/helper.ts +28 -0
- package/src/services/UserLending/queries.ts +196 -0
- package/src/services/UserLending/subgraph-types.ts +173 -0
- package/src/services/UserLending/types.ts +123 -0
- package/src/services/UserLending/user-lending.ts +933 -0
- package/src/services/shared.ts +11 -0
- package/src/tests/sample.test.ts +44 -0
- package/tsconfig.json +27 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/versioner.sh +6 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { PoolOverview, TrancheData } from '../DataService/types';
|
|
2
|
+
export interface PortfolioRewards {
|
|
3
|
+
bonusYieldEarnings: {
|
|
4
|
+
claimableBalance: {
|
|
5
|
+
ksuAmount: string;
|
|
6
|
+
};
|
|
7
|
+
lifeTime: {
|
|
8
|
+
ksuAmount: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
ksuLaunchBonus: {
|
|
12
|
+
lifeTime: {
|
|
13
|
+
ksuAmount: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
protocolFees: {
|
|
17
|
+
claimableBalance: {
|
|
18
|
+
usdcAmount: string;
|
|
19
|
+
};
|
|
20
|
+
lifeTime: {
|
|
21
|
+
usdcAmount: string;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export interface PortfolioSummary {
|
|
26
|
+
current: {
|
|
27
|
+
totalKsuLocked: string;
|
|
28
|
+
totalLendingPoolInvestments: string;
|
|
29
|
+
weightedAverageApy: string;
|
|
30
|
+
};
|
|
31
|
+
daily: {
|
|
32
|
+
yieldEarnings: string;
|
|
33
|
+
};
|
|
34
|
+
weekly: {
|
|
35
|
+
yieldEarnings: string;
|
|
36
|
+
protocolFeesEarned: string;
|
|
37
|
+
ksuBonusRewards: string;
|
|
38
|
+
};
|
|
39
|
+
lifetime: {
|
|
40
|
+
yieldEarnings: string;
|
|
41
|
+
ksuBonusRewards: string;
|
|
42
|
+
protocolFeesEarned: string;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export interface PortfolioTrancheDepositDetails {
|
|
46
|
+
timestamp: EpochTimeStamp;
|
|
47
|
+
id: string;
|
|
48
|
+
depositAmount: string;
|
|
49
|
+
acceptedAmount: string;
|
|
50
|
+
}
|
|
51
|
+
export interface PortfolioTranche extends TrancheData {
|
|
52
|
+
investedAmount: string;
|
|
53
|
+
yieldEarnings: {
|
|
54
|
+
lastEpoch: string;
|
|
55
|
+
lifetime: string;
|
|
56
|
+
};
|
|
57
|
+
depositDetails: PortfolioTrancheDepositDetails[];
|
|
58
|
+
fixedLoans: {
|
|
59
|
+
isLocked: boolean;
|
|
60
|
+
lockId: string;
|
|
61
|
+
configId: string;
|
|
62
|
+
epochInterestRate: string;
|
|
63
|
+
epochLockStart: string;
|
|
64
|
+
epochLockEnd: string;
|
|
65
|
+
epochLockDuration: string;
|
|
66
|
+
isWithdrawalRequested: boolean;
|
|
67
|
+
startTime: EpochTimeStamp;
|
|
68
|
+
amount: string;
|
|
69
|
+
endTime: EpochTimeStamp;
|
|
70
|
+
yieldEarnings: {
|
|
71
|
+
lastEpoch: string;
|
|
72
|
+
lifetime: string;
|
|
73
|
+
};
|
|
74
|
+
depositDetails: PortfolioTrancheDepositDetails[];
|
|
75
|
+
}[];
|
|
76
|
+
}
|
|
77
|
+
export interface PortfolioLendingPool extends Omit<PoolOverview, 'tranches'> {
|
|
78
|
+
totalInvestedAmount: string;
|
|
79
|
+
totalYieldEarningsLastEpoch: string;
|
|
80
|
+
totalYieldEarningsLifetime: string;
|
|
81
|
+
isActive: boolean;
|
|
82
|
+
tranches: PortfolioTranche[];
|
|
83
|
+
requestEpochsInAdvance: string;
|
|
84
|
+
}
|
|
85
|
+
export interface LendingPortfolioData {
|
|
86
|
+
lendingPools: PortfolioLendingPool[];
|
|
87
|
+
}
|
|
88
|
+
export interface UserLendingPoolTrancheFixedTermDepositLock {
|
|
89
|
+
isLocked: boolean;
|
|
90
|
+
lockId: string;
|
|
91
|
+
createdOn: string;
|
|
92
|
+
isWithdrawalRequested: boolean;
|
|
93
|
+
initialTrancheShares: string;
|
|
94
|
+
epochLockStart: string;
|
|
95
|
+
epochLockEnd: string;
|
|
96
|
+
lendingPoolTrancheFixedTermConfig: {
|
|
97
|
+
epochLockDuration: string;
|
|
98
|
+
configId: string;
|
|
99
|
+
epochInterestRate: string;
|
|
100
|
+
};
|
|
101
|
+
unlockAmount: string | null;
|
|
102
|
+
initialAmount: string;
|
|
103
|
+
trancheShares: string;
|
|
104
|
+
userLendingPoolTrancheFixedTermDepositLockShareUpdate: {
|
|
105
|
+
shares: string;
|
|
106
|
+
}[] | undefined;
|
|
107
|
+
}
|
|
108
|
+
export interface LastEpochQueryResult {
|
|
109
|
+
user: {
|
|
110
|
+
lendingPoolUserDetails: {
|
|
111
|
+
id: string;
|
|
112
|
+
lendingPool: {
|
|
113
|
+
id: string;
|
|
114
|
+
name: string;
|
|
115
|
+
balance: string;
|
|
116
|
+
configuration: {
|
|
117
|
+
lendingPoolWithdrawalConfig: {
|
|
118
|
+
requestEpochsInAdvance: string;
|
|
119
|
+
cancelRequestEpochsInAdvance: string;
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
tranches: {
|
|
123
|
+
shares: string;
|
|
124
|
+
}[];
|
|
125
|
+
};
|
|
126
|
+
lendingPoolTrancheUserDetails: {
|
|
127
|
+
userLendingPoolTrancheFixedTermDepositLocks: {
|
|
128
|
+
lockId: string;
|
|
129
|
+
createdOn: string;
|
|
130
|
+
isWithdrawalRequested: boolean;
|
|
131
|
+
initialTrancheShares: string;
|
|
132
|
+
epochLockStart: string;
|
|
133
|
+
epochLockEnd: string;
|
|
134
|
+
lendingPoolTrancheFixedTermConfig: {
|
|
135
|
+
epochLockDuration: string;
|
|
136
|
+
};
|
|
137
|
+
}[];
|
|
138
|
+
lendingPoolTrancheUserEpochSharesUpdates: {
|
|
139
|
+
shares: string;
|
|
140
|
+
}[];
|
|
141
|
+
tranche: {
|
|
142
|
+
id: string;
|
|
143
|
+
lendingPoolTrancheShareUpdates: {
|
|
144
|
+
shares: string;
|
|
145
|
+
}[];
|
|
146
|
+
lendingPoolTrancheEpochInterest: {
|
|
147
|
+
epochInterestAmount: string;
|
|
148
|
+
}[];
|
|
149
|
+
};
|
|
150
|
+
}[];
|
|
151
|
+
}[];
|
|
152
|
+
} | null;
|
|
153
|
+
}
|
|
154
|
+
export interface LendingPortfolioQueryResult {
|
|
155
|
+
user: {
|
|
156
|
+
lendingPoolUserDetails: {
|
|
157
|
+
id: string;
|
|
158
|
+
lendingPool: {
|
|
159
|
+
id: string;
|
|
160
|
+
name: string;
|
|
161
|
+
balance: string;
|
|
162
|
+
configuration: {
|
|
163
|
+
lendingPoolWithdrawalConfig: {
|
|
164
|
+
requestEpochsInAdvance: string;
|
|
165
|
+
cancelRequestEpochsInAdvance: string;
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
tranches: {
|
|
169
|
+
shares: string;
|
|
170
|
+
}[];
|
|
171
|
+
};
|
|
172
|
+
lendingPoolTrancheUserDetails: {
|
|
173
|
+
shares: string;
|
|
174
|
+
userLendingPoolTrancheFixedTermDepositLocks: UserLendingPoolTrancheFixedTermDepositLock[];
|
|
175
|
+
lendingPoolTrancheUserEpochSharesUpdates: {
|
|
176
|
+
shares: string;
|
|
177
|
+
}[] | undefined;
|
|
178
|
+
totalAcceptedDeposits: string;
|
|
179
|
+
totalAcceptedWithdrawnAmount: string;
|
|
180
|
+
tranche: {
|
|
181
|
+
id: string;
|
|
182
|
+
shares: string;
|
|
183
|
+
balance: string;
|
|
184
|
+
lendingPoolTrancheShareUpdates: {
|
|
185
|
+
shares: string;
|
|
186
|
+
}[] | undefined;
|
|
187
|
+
lendingPoolTrancheEpochInterest: {
|
|
188
|
+
epochInterestAmount: string;
|
|
189
|
+
}[] | undefined;
|
|
190
|
+
};
|
|
191
|
+
}[];
|
|
192
|
+
}[];
|
|
193
|
+
} | null;
|
|
194
|
+
userRequests: {
|
|
195
|
+
createdOn: string;
|
|
196
|
+
amountAccepted: string;
|
|
197
|
+
tranche: {
|
|
198
|
+
id: string;
|
|
199
|
+
};
|
|
200
|
+
fixedTermConfigId: string;
|
|
201
|
+
userRequestEvents: {
|
|
202
|
+
id: string;
|
|
203
|
+
assetAmount: string;
|
|
204
|
+
}[];
|
|
205
|
+
}[];
|
|
206
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BigNumber } from 'ethers';
|
|
2
|
+
import { OneInchQuoteRes, OneInchSwapRes, SwapDepositBagStruct } from './types';
|
|
3
|
+
export declare class Swapper {
|
|
4
|
+
private readonly PRECISION_DECIMALS;
|
|
5
|
+
private readonly PRECISION;
|
|
6
|
+
getSwapData(url: string, fromTokenAddress: string, toTokenAddress: string, amountInDecimals: string, fromAddress: string, slippage: string): Promise<OneInchSwapRes>;
|
|
7
|
+
getConversionData(url: string, fromTokenAddress: string, toTokenAddress: string, amountInDecimals: string): Promise<OneInchQuoteRes>;
|
|
8
|
+
private getTokenRatioAtMax;
|
|
9
|
+
getSwap(swapUrl: string, inTokens: string[], inAmounts: BigNumber[], inDecimals: BigNumber[], outToken: string, userAddress: string, swapperAddress: string, slippage: string): Promise<SwapDepositBagStruct>;
|
|
10
|
+
getSwapInfo(swapUrl: string, inTokens: string[], inAmounts: BigNumber[], inDecimals: BigNumber[], outToken: string, userAddress: string, swapperAddress: string, slippage: string): Promise<Awaited<OneInchSwapRes>[]>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import axios from 'axios';
|
|
11
|
+
import { BigNumber, ethers } from 'ethers';
|
|
12
|
+
export class Swapper {
|
|
13
|
+
constructor() {
|
|
14
|
+
this.PRECISION_DECIMALS = 18;
|
|
15
|
+
this.PRECISION = BigNumber.from(10).pow(this.PRECISION_DECIMALS);
|
|
16
|
+
}
|
|
17
|
+
getSwapData(url, fromTokenAddress, toTokenAddress, amountInDecimals, fromAddress, slippage) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
const res = yield axios.get(url, {
|
|
20
|
+
params: {
|
|
21
|
+
getRequest: `/swap/v5.2/1/swap?fromTokenAddress=${fromTokenAddress}&toTokenAddress=${toTokenAddress}&amount=${amountInDecimals}&fromAddress=${fromAddress}&slippage=${slippage}&disableEstimate=true&allowPartialFill=false&includeTokensInfo=true`,
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
return res.data;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
getConversionData(url, fromTokenAddress, toTokenAddress, amountInDecimals) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
const res = yield axios.get(url, {
|
|
30
|
+
params: {
|
|
31
|
+
getRequest: `/swap/v5.2/1/quote?fromTokenAddress=${fromTokenAddress}&toTokenAddress=${toTokenAddress}&amount=${amountInDecimals}&includeTokensInfo=true&includeGas=true`,
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
return res.data;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
getTokenRatioAtMax(swapUrl, inToken, inAmount, outToken) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
const data = yield this.getConversionData(swapUrl, inToken, outToken, inAmount.toString());
|
|
40
|
+
return inAmount
|
|
41
|
+
.mul(this.PRECISION)
|
|
42
|
+
.div(ethers.utils.parseUnits(data.toAmount, this.PRECISION_DECIMALS - data.toToken.decimals));
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
getSwap(swapUrl, inTokens, inAmounts, inDecimals, outToken, userAddress, swapperAddress, slippage) {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
if (inTokens.length !== inAmounts.length ||
|
|
48
|
+
inTokens.length !== inDecimals.length) {
|
|
49
|
+
throw new Error('Invalid input');
|
|
50
|
+
}
|
|
51
|
+
const transaction = {
|
|
52
|
+
tokensIn: inTokens,
|
|
53
|
+
swapInfo: [],
|
|
54
|
+
tokenOut: outToken,
|
|
55
|
+
receiver: userAddress,
|
|
56
|
+
};
|
|
57
|
+
const swapDataPromises = [];
|
|
58
|
+
for (let i = 0; i < inTokens.length; i++) {
|
|
59
|
+
swapDataPromises[i] = this.getSwapData(swapUrl, inTokens[i], outToken, ethers.utils.formatUnits(inAmounts[i], 0).split('.')[0], swapperAddress, slippage);
|
|
60
|
+
}
|
|
61
|
+
const promiseSwapData2D = Promise.all(swapDataPromises);
|
|
62
|
+
yield promiseSwapData2D.then((values) => {
|
|
63
|
+
for (let i = 0; i < inTokens.length; i++) {
|
|
64
|
+
if (inTokens[i] !== outToken) {
|
|
65
|
+
const swapInfo = {
|
|
66
|
+
swapTarget: values[i].tx.to,
|
|
67
|
+
token: inTokens[i],
|
|
68
|
+
swapCallData: values[i].tx.data,
|
|
69
|
+
};
|
|
70
|
+
transaction.swapInfo.push(swapInfo);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
return transaction;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
getSwapInfo(swapUrl, inTokens, inAmounts, inDecimals, outToken, userAddress, swapperAddress, slippage) {
|
|
78
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
+
if (inTokens.length !== inAmounts.length ||
|
|
80
|
+
inTokens.length !== inDecimals.length) {
|
|
81
|
+
throw new Error('Invalid input');
|
|
82
|
+
}
|
|
83
|
+
// const transaction: SwapDepositBagStruct = {
|
|
84
|
+
// tokensIn: inTokens,
|
|
85
|
+
// swapInfo: [],
|
|
86
|
+
// tokenOut: outToken,
|
|
87
|
+
// receiver: userAddress,
|
|
88
|
+
// }
|
|
89
|
+
const swapDataPromises = [];
|
|
90
|
+
for (let i = 0; i < inTokens.length; i++) {
|
|
91
|
+
swapDataPromises[i] = this.getSwapData(swapUrl, inTokens[i], outToken, ethers.utils.formatUnits(inAmounts[i], 0).split('.')[0], swapperAddress, slippage);
|
|
92
|
+
}
|
|
93
|
+
const promiseSwapData2D = Promise.all(swapDataPromises);
|
|
94
|
+
return promiseSwapData2D;
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { SwapInfoStruct } from '../../contracts/SwapperAbi';
|
|
2
|
+
export interface SwapDepositBagStruct {
|
|
3
|
+
tokensIn: string[];
|
|
4
|
+
swapInfo: SwapInfoStruct[];
|
|
5
|
+
tokenOut: string;
|
|
6
|
+
receiver: string;
|
|
7
|
+
}
|
|
8
|
+
export interface OneInchQuoteRes {
|
|
9
|
+
fromToken: {
|
|
10
|
+
symbol: string;
|
|
11
|
+
name: string;
|
|
12
|
+
address: string;
|
|
13
|
+
decimals: number;
|
|
14
|
+
logoURI: string;
|
|
15
|
+
};
|
|
16
|
+
toToken: {
|
|
17
|
+
symbol: string;
|
|
18
|
+
name: string;
|
|
19
|
+
address: string;
|
|
20
|
+
decimals: number;
|
|
21
|
+
logoURI: string;
|
|
22
|
+
};
|
|
23
|
+
toAmount: string;
|
|
24
|
+
gas: number;
|
|
25
|
+
}
|
|
26
|
+
export interface OneInchSwapRes {
|
|
27
|
+
fromToken: {
|
|
28
|
+
symbol: string;
|
|
29
|
+
name: string;
|
|
30
|
+
address: string;
|
|
31
|
+
decimals: number;
|
|
32
|
+
logoURI: string;
|
|
33
|
+
};
|
|
34
|
+
toToken: {
|
|
35
|
+
symbol: string;
|
|
36
|
+
name: string;
|
|
37
|
+
address: string;
|
|
38
|
+
decimals: number;
|
|
39
|
+
logoURI: string;
|
|
40
|
+
};
|
|
41
|
+
toAmount: string;
|
|
42
|
+
protocols: string[];
|
|
43
|
+
tx: {
|
|
44
|
+
from: string;
|
|
45
|
+
to: string;
|
|
46
|
+
data: string;
|
|
47
|
+
value: string;
|
|
48
|
+
gasPrice: string;
|
|
49
|
+
gas: number;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const USER_REQUEST_EVENT_MAP = {
|
|
2
|
+
DepositAccepted: 'Accepted',
|
|
3
|
+
DepositCancelled: 'Cancelled',
|
|
4
|
+
DepositIncreased: 'Increased',
|
|
5
|
+
DepositInitiated: 'Initiated',
|
|
6
|
+
DepositRejected: 'Rejected',
|
|
7
|
+
DepositReallocated: 'Reallocated',
|
|
8
|
+
WithdrawalAccepted: 'Accepted',
|
|
9
|
+
WithdrawalCancelled: 'Cancelled',
|
|
10
|
+
WithdrawalIncreased: 'Increased',
|
|
11
|
+
WithdrawalInitiated: 'Initiated',
|
|
12
|
+
ImmediateWithdrawalExecuted: 'Forced',
|
|
13
|
+
};
|
|
14
|
+
export const mapUserRequestEventType = (requestType) => {
|
|
15
|
+
return USER_REQUEST_EVENT_MAP[requestType];
|
|
16
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const userRequestsQuery: string;
|
|
2
|
+
export declare const lendingPoolUserDetailsQuery: string;
|
|
3
|
+
export declare const portfolioUserTrancheDetailsQuery: string;
|
|
4
|
+
export declare const trancheUserDetailsQuery: string;
|
|
5
|
+
export declare const totalUserLoyaltyRewardsQuery: string;
|
|
6
|
+
export declare const currentEpochDepositedAmountQuery: string;
|
|
7
|
+
export declare const currentEpochFtdAmountQuery: string;
|
|
8
|
+
export declare const currentFtdBalanceQuery: string;
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { gql } from 'graphql-request';
|
|
2
|
+
export const userRequestsQuery = gql `
|
|
3
|
+
query userRequestsQuery(
|
|
4
|
+
$userAddress: String!
|
|
5
|
+
$unusedPools: [String]!
|
|
6
|
+
$epochId: BigInt!
|
|
7
|
+
) {
|
|
8
|
+
userRequests(
|
|
9
|
+
where: { user: $userAddress, lendingPool_not_in: $unusedPools }
|
|
10
|
+
) {
|
|
11
|
+
amountAccepted
|
|
12
|
+
amountRejected
|
|
13
|
+
epochId
|
|
14
|
+
amountRequested
|
|
15
|
+
createdOn
|
|
16
|
+
id
|
|
17
|
+
nftId
|
|
18
|
+
status
|
|
19
|
+
type
|
|
20
|
+
updatedOn
|
|
21
|
+
fixedTermConfigId
|
|
22
|
+
lendingPool {
|
|
23
|
+
id
|
|
24
|
+
name
|
|
25
|
+
balance
|
|
26
|
+
tranches {
|
|
27
|
+
orderId
|
|
28
|
+
shares
|
|
29
|
+
}
|
|
30
|
+
configuration {
|
|
31
|
+
tranchesConfig {
|
|
32
|
+
interestRate
|
|
33
|
+
lendingPoolTrancheInterestRateUpdates(
|
|
34
|
+
orderDirection: desc
|
|
35
|
+
orderBy: epochId
|
|
36
|
+
first: 1
|
|
37
|
+
where: { epochId_lte: $epochId }
|
|
38
|
+
) {
|
|
39
|
+
epochInterestRate
|
|
40
|
+
}
|
|
41
|
+
id
|
|
42
|
+
lendingPoolTrancheFixedTermConfigs {
|
|
43
|
+
epochLockDuration
|
|
44
|
+
epochInterestRate
|
|
45
|
+
configId
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
tranche {
|
|
51
|
+
id
|
|
52
|
+
orderId
|
|
53
|
+
shares
|
|
54
|
+
balance
|
|
55
|
+
}
|
|
56
|
+
user {
|
|
57
|
+
id
|
|
58
|
+
}
|
|
59
|
+
userRequestEvents {
|
|
60
|
+
tranche {
|
|
61
|
+
orderId
|
|
62
|
+
id
|
|
63
|
+
}
|
|
64
|
+
epochId
|
|
65
|
+
sharesAmount
|
|
66
|
+
index
|
|
67
|
+
id
|
|
68
|
+
createdOn
|
|
69
|
+
assetAmount
|
|
70
|
+
transactionHash
|
|
71
|
+
type
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
`;
|
|
76
|
+
export const lendingPoolUserDetailsQuery = gql `
|
|
77
|
+
query LendingPoolUserDetailsQuery($userAddress: String!) {
|
|
78
|
+
user(id: $userAddress) {
|
|
79
|
+
lendingPoolUserDetails {
|
|
80
|
+
id
|
|
81
|
+
lendingPool {
|
|
82
|
+
id
|
|
83
|
+
}
|
|
84
|
+
totalAcceptedDeposits
|
|
85
|
+
totalAcceptedWithdrawnAmount
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
`;
|
|
90
|
+
export const portfolioUserTrancheDetailsQuery = gql `
|
|
91
|
+
query TrancheUserDetailsQuery($userAddress: String!) {
|
|
92
|
+
user(id: $userAddress) {
|
|
93
|
+
lendingPoolUserDetails {
|
|
94
|
+
lendingPool {
|
|
95
|
+
id
|
|
96
|
+
}
|
|
97
|
+
lendingPoolTrancheUserDetails {
|
|
98
|
+
id
|
|
99
|
+
totalAcceptedDeposits
|
|
100
|
+
totalAcceptedWithdrawnAmount
|
|
101
|
+
shares
|
|
102
|
+
tranche {
|
|
103
|
+
id
|
|
104
|
+
shares
|
|
105
|
+
balance
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
`;
|
|
112
|
+
export const trancheUserDetailsQuery = gql `
|
|
113
|
+
query TrancheUserDetailsQuery($userAddress: String!) {
|
|
114
|
+
lendingPoolTrancheUserDetails(id: $userAddress) {
|
|
115
|
+
id
|
|
116
|
+
totalAcceptedDeposits
|
|
117
|
+
totalAcceptedWithdrawnAmount
|
|
118
|
+
shares
|
|
119
|
+
tranche {
|
|
120
|
+
shares
|
|
121
|
+
balance
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
`;
|
|
126
|
+
export const totalUserLoyaltyRewardsQuery = gql `
|
|
127
|
+
query TotalUserLoyaltyRewardsQuery($userAddress: String!) {
|
|
128
|
+
user(id: $userAddress) {
|
|
129
|
+
totalUserLoyaltyRewards
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
`;
|
|
133
|
+
export const currentEpochDepositedAmountQuery = gql `
|
|
134
|
+
query CurrentEpochDepositedAmountQuery($ids: [ID!]) {
|
|
135
|
+
lendingPoolUserDetails_collection(where: { id_in: $ids }) {
|
|
136
|
+
lendingPoolTrancheUserDetails {
|
|
137
|
+
tranche {
|
|
138
|
+
id
|
|
139
|
+
}
|
|
140
|
+
totalPendingDepositAmount
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
`;
|
|
145
|
+
export const currentEpochFtdAmountQuery = gql `
|
|
146
|
+
query CurrentEpochFtdAmountQuery(
|
|
147
|
+
$userId: String
|
|
148
|
+
$poolIds: [String!]
|
|
149
|
+
$currentEpoch: BigInt
|
|
150
|
+
) {
|
|
151
|
+
userRequests(
|
|
152
|
+
where: {
|
|
153
|
+
user: $userId
|
|
154
|
+
lendingPool_in: $poolIds
|
|
155
|
+
epochId: $currentEpoch
|
|
156
|
+
}
|
|
157
|
+
) {
|
|
158
|
+
fixedTermConfigId
|
|
159
|
+
amountRequested
|
|
160
|
+
tranche {
|
|
161
|
+
id
|
|
162
|
+
balance
|
|
163
|
+
shares
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
`;
|
|
168
|
+
export const currentFtdBalanceQuery = gql `
|
|
169
|
+
query CurrentFtdBalanceQuery($userId: String, $poolId: String) {
|
|
170
|
+
userLendingPoolTrancheFixedTermDepositLocks(
|
|
171
|
+
where: { user: $userId, lendingPool: $poolId, isLocked: true }
|
|
172
|
+
) {
|
|
173
|
+
trancheShares
|
|
174
|
+
lendingPoolTrancheFixedTermConfig {
|
|
175
|
+
configId
|
|
176
|
+
lendingPoolTranche {
|
|
177
|
+
id
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
lendingPool {
|
|
181
|
+
balance
|
|
182
|
+
tranches {
|
|
183
|
+
shares
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
`;
|