@dripfi/drip-sdk 1.4.28-silo-sdk-3 → 1.4.28-silo-sdk-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/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
@@ -53,14 +53,14 @@ class SiloVaultOperations {
53
53
  return this.extractTransactionHash(tx);
54
54
  }
55
55
  async withdraw(params) {
56
- const { sourceTokenAddress, vaultAddress, amount } = params;
57
- console.log(`🚀 ~ silo withdraw called with these params:`, { sourceTokenAddress, vaultAddress, amount });
56
+ const { amount, vaultAddress, tokenAddress } = params;
57
+ console.log(`🚀 ~ silo withdraw called with these params:`, { amount, vaultAddress, tokenAddress });
58
58
  if (!this.perqSdk.siloPackage) {
59
59
  throw new Error('Silo package not initialized. Please provide a signer.');
60
60
  }
61
- const parsedAmount = await this.perqSdk.tokenUtils.parseAmountWithDecimals(amount, sourceTokenAddress);
61
+ const parsedAmount = await this.perqSdk.tokenUtils.parseAmountWithDecimals(amount, tokenAddress);
62
62
  console.log('🚀 ~ parsedAmount:', parsedAmount.toString());
63
- return await this.handleSiloWithdraw(sourceTokenAddress, vaultAddress, parsedAmount.toString());
63
+ return await this.handleSiloWithdraw(tokenAddress, vaultAddress, parsedAmount.toString());
64
64
  }
65
65
  async getBalance(vaultAddress, tokenAddress) {
66
66
  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
  }
@@ -86,8 +86,6 @@ class YelayVaultOperations {
86
86
  if (!onChainProjectId || onChainProjectId === -1) {
87
87
  throw new Error('OnChainProjectId is required for Yelay vaults');
88
88
  }
89
- const parsedAmount = await this.perqSdk.tokenUtils.parseAmountWithDecimals(amount, sourceTokenAddress);
90
- console.log('🚀 ~ parsedAmount:', parsedAmount.toString());
91
89
  const depositType = this.determineDepositType(params);
92
90
  switch (depositType) {
93
91
  case 'direct':
@@ -95,51 +93,56 @@ class YelayVaultOperations {
95
93
  sourceTokenAddress,
96
94
  vaultAddress,
97
95
  onChainProjectId,
98
- parsedAmount: parsedAmount.toString(),
96
+ amount,
99
97
  });
100
- return await this.perqSdk.lite.deposit(sourceTokenAddress, vaultAddress, onChainProjectId, parsedAmount.toString());
98
+ return await this.perqSdk.lite.deposit(sourceTokenAddress, vaultAddress, onChainProjectId, amount);
101
99
  case 'wrap':
102
100
  console.log('🚀 ~ this.perqSdk.lite.wrapAndDepositEth called', {
103
101
  vaultAddress,
104
102
  onChainProjectId,
105
- parsedAmount: parsedAmount.toString(),
103
+ amount,
106
104
  });
107
105
  return await this.perqSdk.lite.wrapAndDepositEth(vaultAddress, onChainProjectId, amount);
108
106
  case 'swap':
109
107
  console.log('🚀 ~ this.perqSdk.lite.swapAndDeposit called', {
110
108
  sourceTokenAddress,
111
109
  vaultTokenAddress,
112
- parsedAmount: parsedAmount.toString(),
110
+ amount,
113
111
  vaultAddress,
114
112
  onChainProjectId,
115
113
  });
116
- return await this.perqSdk.lite.swapAndDeposit(sourceTokenAddress, vaultTokenAddress, parsedAmount.toString(), vaultAddress, onChainProjectId);
114
+ return await this.perqSdk.lite.swapAndDeposit(sourceTokenAddress, vaultTokenAddress, amount, vaultAddress, onChainProjectId);
117
115
  default:
118
116
  throw new Error(`Unsupported deposit type: ${depositType}`);
119
117
  }
120
118
  }
121
119
  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,
120
+ const { amount, tokenAddress, vaultAddress, onChainProjectId } = params;
121
+ console.log(`🚀 ~ yelay withdraw called with these params:`, {
122
+ amount,
123
+ tokenAddress,
126
124
  vaultAddress,
127
- parsedAmount: parsedAmount.toString(),
128
125
  onChainProjectId,
129
126
  });
130
127
  if (!onChainProjectId || onChainProjectId === -1) {
131
128
  throw new Error('OnChainProjectId is required for Yelay vaults');
132
129
  }
133
130
  console.log('🚀 ~ this.perqSdk.lite.withdraw called', {
134
- sourceTokenAddress,
131
+ tokenAddress,
135
132
  vaultAddress,
136
133
  onChainProjectId,
137
- parsedAmount: parsedAmount.toString(),
134
+ amount,
138
135
  });
139
- return await this.perqSdk.lite.withdraw(sourceTokenAddress, vaultAddress, onChainProjectId, parsedAmount.toString());
136
+ return await this.perqSdk.lite.withdraw(tokenAddress, vaultAddress, onChainProjectId, amount);
140
137
  }
141
- async getBalance(vaultAddress, tokenAddress, onChainProjectId) {
142
- return await this.perqSdk.pools.getUserPoolBalance(vaultAddress, onChainProjectId);
138
+ async getBalance(vaultAddress, _, onChainProjectId) {
139
+ console.log('🚀 ~ this.perqSdk.pools.getUserPoolBalance called with: ', {
140
+ vaultAddress,
141
+ onChainProjectId,
142
+ });
143
+ const balance = await this.perqSdk.pools.getUserPoolBalance(vaultAddress, onChainProjectId);
144
+ console.log('🚀 ~ balance: ', balance);
145
+ return balance;
143
146
  }
144
147
  determineDepositType(params) {
145
148
  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-4",
4
4
  "description": "Drip SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",