@dripfi/drip-sdk 1.4.28-silo-sdk-3 → 1.4.28-silo-sdk-5

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 CHANGED
@@ -71,13 +71,13 @@ The SDK automatically determines the deposit type based on the provided paramete
71
71
 
72
72
  Access vault methods through `sdk.vault`:
73
73
 
74
- | Method | Description |
75
- | --- | --- |
76
- | `getAllowance(params: VaultOperationParams): Promise<boolean>` | Checks if the user's allowance is sufficient for the `depositAmount` |
77
- | `approveAllowance(params: VaultOperationParams): Promise<string>` | Approves the allowance for the `depositAmount` for the selected Vault |
78
- | `deposit(params: VaultOperationParams): Promise<string>` | Deposits the `depositAmount` into the selected `vault` |
79
- | `withdraw(params: VaultOperationParams): Promise<string>` | Withdraws the specified amount from the selected vault |
80
- | `getBalance(vaultAddress: string, tokenAddress?: string, onChainProjectId?: number): Promise<string>` | Gets the user's balance for the specified vault |
74
+ | Method | Description |
75
+ | ----------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
76
+ | `getAllowance(params: VaultOperationParams): Promise<boolean>` | Checks if the user's allowance is sufficient for the `depositAmount` |
77
+ | `approveAllowance(params: VaultOperationParams): Promise<string>` | Approves the allowance for the `depositAmount` for the selected Vault |
78
+ | `deposit(params: VaultOperationParams): Promise<string>` | Deposits the `depositAmount` into the selected `vault` |
79
+ | `withdraw(params: VaultOperationParams): Promise<string>` | Withdraws the specified amount from the selected vault |
80
+ | `getBalance(vaultAddress: string, tokenAddress?: string, onChainProjectId?: number): Promise<string>` | Gets the user's balance for the specified vault |
81
81
 
82
82
  ## Legacy Methods
83
83
 
@@ -426,11 +426,11 @@ enum ELoyaltyCardTier {
426
426
  Black = 'Black',
427
427
  }
428
428
 
429
- interface IVaultOperations {
429
+ interface VaultOperations {
430
430
  getAllowance(params: VaultOperationParams): Promise<boolean>;
431
431
  approveAllowance(params: VaultOperationParams): Promise<string>;
432
432
  deposit(params: VaultOperationParams): Promise<string>;
433
- withdraw(params: VaultOperationParams): Promise<string>;
433
+ withdraw(params: WithdrawParams): Promise<string>;
434
434
  getBalance(vaultAddress: string, tokenAddress?: string, onChainProjectId?: number): Promise<string>;
435
435
  }
436
436
 
@@ -649,6 +649,15 @@ type VaultStats = {
649
649
 
650
650
  type VaultType = 'launch' | 'earn' | 'airdrop';
651
651
 
652
+ interface WithdrawParams {
653
+ amount: string;
654
+ sdkType: SdkType;
655
+ tokenAddress: string;
656
+ vaultAddress: string;
657
+ // Optional parameters that may be needed for specific SDK implementations
658
+ onChainProjectId?: number; // needed for yelay SDK
659
+ }
660
+
652
661
  interface VaultOperationParams {
653
662
  sourceTokenAddress: string;
654
663
  vaultTokenAddress: string;
@@ -760,6 +769,7 @@ type OverallStats = {
760
769
  totalUsers: number;
761
770
  };
762
771
 
772
+
763
773
  ```
764
774
 
765
775
  ## Abis
@@ -1,16 +1,16 @@
1
1
  import PerqSdk from '../PerqSdk';
2
2
  import { VaultOperationParams } from '../types/VaultOperationParams';
3
- import { IVaultOperations } from './VaultHandlerPackage';
3
+ import { VaultOperations, WithdrawParams } from './VaultHandlerPackage';
4
4
  /**
5
5
  * Silo SDK vault operations implementation
6
6
  */
7
- export declare class SiloVaultOperations implements IVaultOperations {
7
+ export declare class SiloVaultOperations implements VaultOperations {
8
8
  private perqSdk;
9
9
  constructor(perqSdk: PerqSdk);
10
10
  getAllowance(params: VaultOperationParams): Promise<boolean>;
11
11
  approveAllowance(params: VaultOperationParams): Promise<string>;
12
12
  deposit(params: VaultOperationParams): Promise<string>;
13
- withdraw(params: VaultOperationParams): Promise<string>;
13
+ withdraw(params: WithdrawParams): Promise<string>;
14
14
  getBalance(vaultAddress: string, tokenAddress: string): Promise<string>;
15
15
  /**
16
16
  * Handles Silo withdraw with automatic full/partial withdraw detection
@@ -36,10 +36,8 @@ class SiloVaultOperations {
36
36
  if (!this.perqSdk.siloPackage) {
37
37
  throw new Error('Silo package not initialized. Please provide a signer.');
38
38
  }
39
- const amountToApprove = await this.perqSdk.tokenUtils.parseAmountWithDecimals(amount, sourceTokenAddress);
40
- console.log('🚀 ~ amountToApprove:', amountToApprove.toString());
41
39
  // For Silo, we use the standard ERC20 approval
42
- return await this.perqSdk.tokenUtils.approveAllowance(sourceTokenAddress, amountToApprove.toString(), vaultAddress);
40
+ return await this.perqSdk.tokenUtils.approveAllowance(sourceTokenAddress, amount, vaultAddress);
43
41
  }
44
42
  async deposit(params) {
45
43
  const { amount, vaultAddress, sourceTokenAddress } = params;
@@ -53,14 +51,14 @@ class SiloVaultOperations {
53
51
  return this.extractTransactionHash(tx);
54
52
  }
55
53
  async withdraw(params) {
56
- const { sourceTokenAddress, vaultAddress, amount } = params;
57
- console.log(`🚀 ~ silo withdraw called with these params:`, { sourceTokenAddress, vaultAddress, amount });
54
+ const { amount, vaultAddress, tokenAddress } = params;
55
+ console.log(`🚀 ~ silo withdraw called with these params:`, { amount, vaultAddress, tokenAddress });
58
56
  if (!this.perqSdk.siloPackage) {
59
57
  throw new Error('Silo package not initialized. Please provide a signer.');
60
58
  }
61
- const parsedAmount = await this.perqSdk.tokenUtils.parseAmountWithDecimals(amount, sourceTokenAddress);
59
+ const parsedAmount = await this.perqSdk.tokenUtils.parseAmountWithDecimals(amount, tokenAddress);
62
60
  console.log('🚀 ~ parsedAmount:', parsedAmount.toString());
63
- return await this.handleSiloWithdraw(sourceTokenAddress, vaultAddress, parsedAmount.toString());
61
+ return await this.handleSiloWithdraw(tokenAddress, vaultAddress, parsedAmount.toString());
64
62
  }
65
63
  async getBalance(vaultAddress, tokenAddress) {
66
64
  if (!this.perqSdk.signer) {
@@ -1,10 +1,18 @@
1
1
  import PerqSdk from '../PerqSdk';
2
+ import SdkType from '../types/SdkType';
2
3
  import { VaultOperationParams } from '../types/VaultOperationParams';
3
- export interface IVaultOperations {
4
+ export interface WithdrawParams {
5
+ amount: string;
6
+ sdkType: SdkType;
7
+ tokenAddress: string;
8
+ vaultAddress: string;
9
+ onChainProjectId?: number;
10
+ }
11
+ export interface VaultOperations {
4
12
  getAllowance(params: VaultOperationParams): Promise<boolean>;
5
13
  approveAllowance(params: VaultOperationParams): Promise<string>;
6
14
  deposit(params: VaultOperationParams): Promise<string>;
7
- withdraw(params: VaultOperationParams): Promise<string>;
15
+ withdraw(params: WithdrawParams): Promise<string>;
8
16
  getBalance(vaultAddress: string, tokenAddress?: string, onChainProjectId?: number): Promise<string>;
9
17
  }
10
18
  export default class VaultHandler {
@@ -28,7 +36,7 @@ export default class VaultHandler {
28
36
  /**
29
37
  * Withdraw from vault
30
38
  */
31
- withdraw(params: VaultOperationParams): Promise<string>;
39
+ withdraw(params: WithdrawParams): Promise<string>;
32
40
  /**
33
41
  * Get the balance of the vault
34
42
  */
@@ -1,13 +1,13 @@
1
1
  import PerqSdk from '../PerqSdk';
2
2
  import { VaultOperationParams } from '../types/VaultOperationParams';
3
- import { IVaultOperations } from './VaultHandlerPackage';
4
- export declare class YelayVaultOperations implements IVaultOperations {
3
+ import { VaultOperations, WithdrawParams } from './VaultHandlerPackage';
4
+ export declare class YelayVaultOperations implements VaultOperations {
5
5
  private perqSdk;
6
6
  constructor(perqSdk: PerqSdk);
7
7
  getAllowance(params: VaultOperationParams): Promise<boolean>;
8
8
  approveAllowance(params: VaultOperationParams): Promise<string>;
9
9
  deposit(params: VaultOperationParams): Promise<string>;
10
- withdraw(params: VaultOperationParams): Promise<string>;
11
- getBalance(vaultAddress: string, tokenAddress: string, onChainProjectId: number): Promise<string>;
10
+ withdraw(params: WithdrawParams): Promise<string>;
11
+ getBalance(vaultAddress: string, _: string, onChainProjectId: number): Promise<string>;
12
12
  private determineDepositType;
13
13
  }
@@ -61,15 +61,13 @@ class YelayVaultOperations {
61
61
  throw new Error('OnChainProjectId is required for Yelay vaults');
62
62
  }
63
63
  const depositType = this.determineDepositType(params);
64
- const parsedAmount = await this.perqSdk.tokenUtils.parseAmountWithDecimals(amount, sourceTokenAddress);
65
- console.log('🚀 ~ parsedAmount:', parsedAmount.toString());
66
64
  switch (depositType) {
67
65
  case 'direct':
68
- return await this.perqSdk.tokenUtils.approveAllowance(sourceTokenAddress, parsedAmount.toString(), vaultAddress);
66
+ return await this.perqSdk.tokenUtils.approveAllowance(sourceTokenAddress, amount, vaultAddress);
69
67
  case 'wrap':
70
68
  throw new Error("Can't approve a native token");
71
69
  case 'swap':
72
- return await this.perqSdk.lite.approveSwapAndDeposit(sourceTokenAddress, parsedAmount.toString());
70
+ return await this.perqSdk.lite.approveSwapAndDeposit(sourceTokenAddress, amount);
73
71
  default:
74
72
  throw new Error(`Unsupported deposit type: ${depositType}`);
75
73
  }
@@ -86,8 +84,6 @@ class YelayVaultOperations {
86
84
  if (!onChainProjectId || onChainProjectId === -1) {
87
85
  throw new Error('OnChainProjectId is required for Yelay vaults');
88
86
  }
89
- const parsedAmount = await this.perqSdk.tokenUtils.parseAmountWithDecimals(amount, sourceTokenAddress);
90
- console.log('🚀 ~ parsedAmount:', parsedAmount.toString());
91
87
  const depositType = this.determineDepositType(params);
92
88
  switch (depositType) {
93
89
  case 'direct':
@@ -95,51 +91,56 @@ class YelayVaultOperations {
95
91
  sourceTokenAddress,
96
92
  vaultAddress,
97
93
  onChainProjectId,
98
- parsedAmount: parsedAmount.toString(),
94
+ amount,
99
95
  });
100
- return await this.perqSdk.lite.deposit(sourceTokenAddress, vaultAddress, onChainProjectId, parsedAmount.toString());
96
+ return await this.perqSdk.lite.deposit(sourceTokenAddress, vaultAddress, onChainProjectId, amount);
101
97
  case 'wrap':
102
98
  console.log('🚀 ~ this.perqSdk.lite.wrapAndDepositEth called', {
103
99
  vaultAddress,
104
100
  onChainProjectId,
105
- parsedAmount: parsedAmount.toString(),
101
+ amount,
106
102
  });
107
103
  return await this.perqSdk.lite.wrapAndDepositEth(vaultAddress, onChainProjectId, amount);
108
104
  case 'swap':
109
105
  console.log('🚀 ~ this.perqSdk.lite.swapAndDeposit called', {
110
106
  sourceTokenAddress,
111
107
  vaultTokenAddress,
112
- parsedAmount: parsedAmount.toString(),
108
+ amount,
113
109
  vaultAddress,
114
110
  onChainProjectId,
115
111
  });
116
- return await this.perqSdk.lite.swapAndDeposit(sourceTokenAddress, vaultTokenAddress, parsedAmount.toString(), vaultAddress, onChainProjectId);
112
+ return await this.perqSdk.lite.swapAndDeposit(sourceTokenAddress, vaultTokenAddress, amount, vaultAddress, onChainProjectId);
117
113
  default:
118
114
  throw new Error(`Unsupported deposit type: ${depositType}`);
119
115
  }
120
116
  }
121
117
  async withdraw(params) {
122
- const { sourceTokenAddress, vaultAddress, amount, onChainProjectId } = params;
123
- const parsedAmount = await this.perqSdk.tokenUtils.parseAmountWithDecimals(amount, sourceTokenAddress);
124
- console.log(`🚀 ~ yelay withdraw called with these params: `, {
125
- sourceTokenAddress,
118
+ const { amount, tokenAddress, vaultAddress, onChainProjectId } = params;
119
+ console.log(`🚀 ~ yelay withdraw called with these params:`, {
120
+ amount,
121
+ tokenAddress,
126
122
  vaultAddress,
127
- parsedAmount: parsedAmount.toString(),
128
123
  onChainProjectId,
129
124
  });
130
125
  if (!onChainProjectId || onChainProjectId === -1) {
131
126
  throw new Error('OnChainProjectId is required for Yelay vaults');
132
127
  }
133
128
  console.log('🚀 ~ this.perqSdk.lite.withdraw called', {
134
- sourceTokenAddress,
129
+ tokenAddress,
135
130
  vaultAddress,
136
131
  onChainProjectId,
137
- parsedAmount: parsedAmount.toString(),
132
+ amount,
138
133
  });
139
- return await this.perqSdk.lite.withdraw(sourceTokenAddress, vaultAddress, onChainProjectId, parsedAmount.toString());
134
+ return await this.perqSdk.lite.withdraw(tokenAddress, vaultAddress, onChainProjectId, amount);
140
135
  }
141
- async getBalance(vaultAddress, tokenAddress, onChainProjectId) {
142
- return await this.perqSdk.pools.getUserPoolBalance(vaultAddress, onChainProjectId);
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;
143
144
  }
144
145
  determineDepositType(params) {
145
146
  const { sourceTokenSymbol, vaultTokenSymbol } = params;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dripfi/drip-sdk",
3
- "version": "1.4.28-silo-sdk-3",
3
+ "version": "1.4.28-silo-sdk-5",
4
4
  "description": "Drip SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",