@dripfi/drip-sdk 1.4.28-slot-machine-4 → 1.4.29
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/README.md +88 -10
- package/dist/PerqSdk.d.ts +5 -1
- package/dist/PerqSdk.js +8 -1
- package/dist/abi/index.js +6 -6
- package/dist/constants.js +2 -2
- package/dist/contracts/{BasePerqContract.d.ts → BaseContract.d.ts} +1 -1
- package/dist/contracts/{BasePerqContract.js → BaseContract.js} +2 -2
- package/dist/contracts/BridgeMainnetPerqToSonicContract.d.ts +2 -2
- package/dist/contracts/BridgeMainnetPerqToSonicContract.js +3 -3
- package/dist/contracts/BridgeSonicPerqToMainnetContract.d.ts +2 -2
- package/dist/contracts/BridgeSonicPerqToMainnetContract.js +3 -3
- package/dist/contracts/SlotBurnTokenContract.d.ts +2 -2
- package/dist/contracts/SlotBurnTokenContract.js +2 -2
- package/dist/contracts/index.d.ts +6 -6
- package/dist/contracts/index.js +9 -9
- package/dist/contracts/{PerqSwapAndRecyclerContract.d.ts → perq/PerqSwapAndRecyclerContract.d.ts} +3 -3
- package/dist/contracts/{PerqSwapAndRecyclerContract.js → perq/PerqSwapAndRecyclerContract.js} +3 -3
- package/dist/contracts/{PerqTokenContract.d.ts → perq/PerqTokenContract.d.ts} +2 -2
- package/dist/contracts/{PerqTokenContract.js → perq/PerqTokenContract.js} +3 -3
- package/dist/contracts/{PerqTokenRecyclerContract.d.ts → perq/PerqTokenRecyclerContract.d.ts} +3 -3
- package/dist/contracts/{PerqTokenRecyclerContract.js → perq/PerqTokenRecyclerContract.js} +3 -3
- package/dist/contracts/{PerqVestingContract.d.ts → perq/PerqVestingContract.d.ts} +3 -3
- package/dist/contracts/{PerqVestingContract.js → perq/PerqVestingContract.js} +3 -3
- package/dist/subpackages/LoyaltyCardsPackage.js +4 -2
- package/dist/subpackages/SiloPackage.d.ts +18 -0
- package/dist/subpackages/SiloPackage.js +112 -0
- package/dist/subpackages/SiloVaultOperations.d.ts +31 -0
- package/dist/subpackages/SiloVaultOperations.js +138 -0
- package/dist/subpackages/TokenUtilsPackage.d.ts +14 -0
- package/dist/subpackages/TokenUtilsPackage.js +31 -4
- package/dist/subpackages/VaultHandlerPackage.d.ts +54 -0
- package/dist/subpackages/VaultHandlerPackage.js +107 -0
- package/dist/subpackages/YelayVaultOperations.d.ts +13 -0
- package/dist/subpackages/YelayVaultOperations.js +164 -0
- package/dist/types/DeployedProject.d.ts +1 -0
- package/dist/types/SdkType.d.ts +2 -0
- package/dist/types/SdkType.js +2 -0
- package/dist/types/VaultData.d.ts +2 -0
- package/dist/types/VaultOperationParams.d.ts +12 -0
- package/dist/types/VaultOperationParams.js +2 -0
- package/dist/types/index.d.ts +2 -1
- package/package.json +2 -1
- /package/dist/abi/{BridgeMainnetPerqToSonicAbi.json → perq/BridgeMainnetPerqToSonicAbi.json} +0 -0
- /package/dist/abi/{BridgeSonicPerqToMainnetAbi.json → perq/BridgeSonicPerqToMainnetAbi.json} +0 -0
- /package/dist/abi/{PerqSwapAndRecyclerAbi.json → perq/PerqSwapAndRecyclerAbi.json} +0 -0
- /package/dist/abi/{PerqTokenAbi.json → perq/PerqTokenAbi.json} +0 -0
- /package/dist/abi/{PerqVestingAbi.json → perq/PerqVestingAbi.json} +0 -0
- /package/dist/abi/{TokenRecyclerAbi.json → perq/TokenRecyclerAbi.json} +0 -0
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.YelayVaultOperations = void 0;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
5
|
+
class YelayVaultOperations {
|
|
6
|
+
perqSdk;
|
|
7
|
+
constructor(perqSdk) {
|
|
8
|
+
this.perqSdk = perqSdk;
|
|
9
|
+
}
|
|
10
|
+
async getAllowance(params) {
|
|
11
|
+
const { sourceTokenAddress, vaultAddress, onChainProjectId, amount } = params;
|
|
12
|
+
console.log(`🚀 ~ yelay getAllowance with these params: `, {
|
|
13
|
+
sourceTokenAddress,
|
|
14
|
+
vaultAddress,
|
|
15
|
+
onChainProjectId,
|
|
16
|
+
amount,
|
|
17
|
+
});
|
|
18
|
+
if (!onChainProjectId || onChainProjectId === -1) {
|
|
19
|
+
throw new Error('OnChainProjectId is required for Yelay vaults');
|
|
20
|
+
}
|
|
21
|
+
const depositType = this.determineDepositType(params);
|
|
22
|
+
console.log('🚀 ~ depositType: ', depositType);
|
|
23
|
+
try {
|
|
24
|
+
let allowance;
|
|
25
|
+
switch (depositType) {
|
|
26
|
+
case 'direct': {
|
|
27
|
+
allowance = await this.perqSdk.tokenUtils.getERC20TokenAllowance(vaultAddress, sourceTokenAddress);
|
|
28
|
+
console.log('🚀 ~ direct deposit allowance: ', allowance);
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
case 'swap': {
|
|
32
|
+
const allowanceString = await this.perqSdk.lite.getSwapAndDepositAllowance(sourceTokenAddress);
|
|
33
|
+
allowance = ethers_1.BigNumber.from(allowanceString);
|
|
34
|
+
console.log('🚀 ~ swapAndDeposit allowance: ', allowance);
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
case 'wrap': {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
default:
|
|
41
|
+
throw new Error(`Unsupported deposit type: ${depositType}`);
|
|
42
|
+
}
|
|
43
|
+
// Get required amount with correct decimals
|
|
44
|
+
const requiredAmount = await this.perqSdk.tokenUtils.parseAmountWithDecimals(amount, sourceTokenAddress);
|
|
45
|
+
return allowance.gte(requiredAmount);
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
console.error('Error checking allowance:', error);
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
async approveAllowance(params) {
|
|
53
|
+
const { sourceTokenAddress, vaultAddress, amount, onChainProjectId } = params;
|
|
54
|
+
console.log(`🚀 ~ yelay approveAllowance called with these params:`, {
|
|
55
|
+
sourceTokenAddress,
|
|
56
|
+
vaultAddress,
|
|
57
|
+
amount,
|
|
58
|
+
onChainProjectId,
|
|
59
|
+
});
|
|
60
|
+
if (!onChainProjectId || onChainProjectId === -1) {
|
|
61
|
+
throw new Error('OnChainProjectId is required for Yelay vaults');
|
|
62
|
+
}
|
|
63
|
+
const depositType = this.determineDepositType(params);
|
|
64
|
+
switch (depositType) {
|
|
65
|
+
case 'direct':
|
|
66
|
+
return await this.perqSdk.tokenUtils.approveAllowance(sourceTokenAddress, amount, vaultAddress);
|
|
67
|
+
case 'wrap':
|
|
68
|
+
throw new Error("Can't approve a native token");
|
|
69
|
+
case 'swap':
|
|
70
|
+
return await this.perqSdk.lite.approveSwapAndDeposit(sourceTokenAddress, amount);
|
|
71
|
+
default:
|
|
72
|
+
throw new Error(`Unsupported deposit type: ${depositType}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
async deposit(params) {
|
|
76
|
+
const { sourceTokenAddress, vaultTokenAddress, vaultAddress, amount, onChainProjectId } = params;
|
|
77
|
+
console.log(`🚀 ~ yelay deposit called with these params: `, {
|
|
78
|
+
sourceTokenAddress,
|
|
79
|
+
vaultTokenAddress,
|
|
80
|
+
vaultAddress,
|
|
81
|
+
amount,
|
|
82
|
+
onChainProjectId,
|
|
83
|
+
});
|
|
84
|
+
if (!onChainProjectId || onChainProjectId === -1) {
|
|
85
|
+
throw new Error('OnChainProjectId is required for Yelay vaults');
|
|
86
|
+
}
|
|
87
|
+
const depositType = this.determineDepositType(params);
|
|
88
|
+
switch (depositType) {
|
|
89
|
+
case 'direct':
|
|
90
|
+
console.log('🚀 ~ this.perqSdk.lite.deposit called', {
|
|
91
|
+
sourceTokenAddress,
|
|
92
|
+
vaultAddress,
|
|
93
|
+
onChainProjectId,
|
|
94
|
+
amount,
|
|
95
|
+
});
|
|
96
|
+
return await this.perqSdk.lite.deposit(sourceTokenAddress, vaultAddress, onChainProjectId, amount);
|
|
97
|
+
case 'wrap':
|
|
98
|
+
console.log('🚀 ~ this.perqSdk.lite.wrapAndDepositEth called', {
|
|
99
|
+
vaultAddress,
|
|
100
|
+
onChainProjectId,
|
|
101
|
+
amount,
|
|
102
|
+
});
|
|
103
|
+
return await this.perqSdk.lite.wrapAndDepositEth(vaultAddress, onChainProjectId, amount);
|
|
104
|
+
case 'swap':
|
|
105
|
+
console.log('🚀 ~ this.perqSdk.lite.swapAndDeposit called', {
|
|
106
|
+
sourceTokenAddress,
|
|
107
|
+
vaultTokenAddress,
|
|
108
|
+
amount,
|
|
109
|
+
vaultAddress,
|
|
110
|
+
onChainProjectId,
|
|
111
|
+
});
|
|
112
|
+
return await this.perqSdk.lite.swapAndDeposit(sourceTokenAddress, vaultTokenAddress, amount, vaultAddress, onChainProjectId);
|
|
113
|
+
default:
|
|
114
|
+
throw new Error(`Unsupported deposit type: ${depositType}`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
async withdraw(params) {
|
|
118
|
+
const { amount, tokenAddress, vaultAddress, onChainProjectId } = params;
|
|
119
|
+
console.log(`🚀 ~ yelay withdraw called with these params:`, {
|
|
120
|
+
amount,
|
|
121
|
+
tokenAddress,
|
|
122
|
+
vaultAddress,
|
|
123
|
+
onChainProjectId,
|
|
124
|
+
});
|
|
125
|
+
if (!onChainProjectId || onChainProjectId === -1) {
|
|
126
|
+
throw new Error('OnChainProjectId is required for Yelay vaults');
|
|
127
|
+
}
|
|
128
|
+
console.log('🚀 ~ this.perqSdk.lite.withdraw called', {
|
|
129
|
+
tokenAddress,
|
|
130
|
+
vaultAddress,
|
|
131
|
+
onChainProjectId,
|
|
132
|
+
amount,
|
|
133
|
+
});
|
|
134
|
+
return await this.perqSdk.lite.withdraw(tokenAddress, vaultAddress, onChainProjectId, amount);
|
|
135
|
+
}
|
|
136
|
+
async getBalance(vaultAddress, _, onChainProjectId) {
|
|
137
|
+
console.log('🚀 ~ this.perqSdk.pools.getUserPoolBalance called with: ', {
|
|
138
|
+
vaultAddress,
|
|
139
|
+
onChainProjectId,
|
|
140
|
+
});
|
|
141
|
+
const balance = await this.perqSdk.pools.getUserPoolBalance(vaultAddress, onChainProjectId);
|
|
142
|
+
console.log('🚀 ~ balance: ', balance);
|
|
143
|
+
return balance;
|
|
144
|
+
}
|
|
145
|
+
determineDepositType(params) {
|
|
146
|
+
const { sourceTokenSymbol, vaultTokenSymbol } = params;
|
|
147
|
+
if (!sourceTokenSymbol || !vaultTokenSymbol) {
|
|
148
|
+
return 'direct';
|
|
149
|
+
}
|
|
150
|
+
const lowerSourceToken = sourceTokenSymbol.toLowerCase();
|
|
151
|
+
const lowerVaultToken = vaultTokenSymbol.toLowerCase();
|
|
152
|
+
// Check if it's ETH wrap deposit
|
|
153
|
+
if (lowerSourceToken === 'eth' || lowerSourceToken === 's') {
|
|
154
|
+
return 'wrap';
|
|
155
|
+
}
|
|
156
|
+
// Check if it's a direct deposit (same token)
|
|
157
|
+
if (lowerSourceToken === lowerVaultToken) {
|
|
158
|
+
return 'direct';
|
|
159
|
+
}
|
|
160
|
+
// Otherwise it's a swap deposit
|
|
161
|
+
return 'swap';
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
exports.YelayVaultOperations = YelayVaultOperations;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ChainId } from './ChainId';
|
|
2
2
|
import DepositToken from './DepositToken';
|
|
3
|
+
import SdkType from './SdkType';
|
|
3
4
|
import Strategy from './Strategy';
|
|
4
5
|
import StretchGoal from './StretchGoal';
|
|
5
6
|
import VaultReward from './VaultReward';
|
|
@@ -26,5 +27,6 @@ type VaultData = {
|
|
|
26
27
|
stretchGoals: StretchGoal[];
|
|
27
28
|
rewards: VaultReward[];
|
|
28
29
|
rewardTooltipName: string;
|
|
30
|
+
sdkType: SdkType;
|
|
29
31
|
};
|
|
30
32
|
export default VaultData;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import SdkType from './SdkType';
|
|
2
|
+
export interface VaultOperationParams {
|
|
3
|
+
sourceTokenAddress: string;
|
|
4
|
+
vaultTokenAddress: string;
|
|
5
|
+
vaultAddress: string;
|
|
6
|
+
amount: string;
|
|
7
|
+
sdkType: SdkType;
|
|
8
|
+
onChainProjectId?: number;
|
|
9
|
+
sourceTokenSymbol?: string;
|
|
10
|
+
vaultTokenSymbol?: string;
|
|
11
|
+
}
|
|
12
|
+
export type DepositType = 'direct' | 'swap' | 'wrap';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -25,9 +25,10 @@ import VaultData from './VaultData';
|
|
|
25
25
|
import VaultReward, { RewardType } from './VaultReward';
|
|
26
26
|
import VaultStats from './VaultStats';
|
|
27
27
|
import VaultType from './VaultType';
|
|
28
|
+
import { VaultOperationParams, DepositType } from './VaultOperationParams';
|
|
28
29
|
import VestingInfo from './VestingInfo';
|
|
29
30
|
import YelayVersion from './YelayVersion';
|
|
30
31
|
import Earnings from './Earnings';
|
|
31
32
|
import LinkedPodWallets from './LinkedPodWallets';
|
|
32
33
|
import MigrationOption from './MigrationOption';
|
|
33
|
-
export { Asset, BasePayload, BeanEntry, BeansBalance, DeployedProject, DeployedVault, DepositToken, DetailedProjectData, ELoyaltyCardTier, NearWalletPayload, SuiWalletPayload, LinkedPodWallets, LoyaltyCard, MigrationOption, MyPerqData, NFTBoost, NonceEnrichedPayload, NonceEnrichedSignedPayload, PerqConfig, PerqToBeansSwapInfo, ProjectBacker, QLFastRedeem, ReducedProjectData, RewardType, SpecialEditionLoyaltyCard, Strategy, StretchGoal, SwapInfo, UpgradeLoyaltyCardPayload, UserRewards, VaultData, VaultReward, VaultStats, VaultType, VestingInfo, YelayVersion, Earnings, };
|
|
34
|
+
export { Asset, BasePayload, BeanEntry, BeansBalance, DeployedProject, DeployedVault, DepositToken, DetailedProjectData, ELoyaltyCardTier, NearWalletPayload, SuiWalletPayload, LinkedPodWallets, LoyaltyCard, MigrationOption, MyPerqData, NFTBoost, NonceEnrichedPayload, NonceEnrichedSignedPayload, PerqConfig, PerqToBeansSwapInfo, ProjectBacker, QLFastRedeem, ReducedProjectData, RewardType, SpecialEditionLoyaltyCard, Strategy, StretchGoal, SwapInfo, UpgradeLoyaltyCardPayload, UserRewards, VaultData, VaultReward, VaultStats, VaultType, VaultOperationParams, DepositType, VestingInfo, YelayVersion, Earnings, };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dripfi/drip-sdk",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.29",
|
|
4
4
|
"description": "Drip SDK",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"pretty": "prettier --write \"./**/*.{js,jsx,mjs,cjs,ts,tsx,json}\""
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
+
"@dripfi/silo-sdk": "^0.0.1",
|
|
16
17
|
"@yelay-lite/sdk": "1.0.7",
|
|
17
18
|
"ethers": "^5.7.2"
|
|
18
19
|
},
|
/package/dist/abi/{BridgeMainnetPerqToSonicAbi.json → perq/BridgeMainnetPerqToSonicAbi.json}
RENAMED
|
File without changes
|
/package/dist/abi/{BridgeSonicPerqToMainnetAbi.json → perq/BridgeSonicPerqToMainnetAbi.json}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|