@dripfi/drip-sdk 1.4.28-bridge-perq → 1.4.28-silo-sdk

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.
Files changed (40) hide show
  1. package/README.md +45 -16
  2. package/dist/PerqSdk.d.ts +6 -7
  3. package/dist/PerqSdk.js +8 -13
  4. package/dist/abi/index.d.ts +0 -286
  5. package/dist/abi/index.js +4 -8
  6. package/dist/contracts/{BasePerqContract.d.ts → BaseContract.d.ts} +1 -1
  7. package/dist/contracts/{BasePerqContract.js → BaseContract.js} +2 -2
  8. package/dist/contracts/index.d.ts +6 -8
  9. package/dist/contracts/index.js +7 -11
  10. package/dist/contracts/{PerqSwapAndRecyclerContract.d.ts → perq/PerqSwapAndRecyclerContract.d.ts} +3 -3
  11. package/dist/contracts/{PerqSwapAndRecyclerContract.js → perq/PerqSwapAndRecyclerContract.js} +3 -3
  12. package/dist/contracts/{PerqTokenContract.d.ts → perq/PerqTokenContract.d.ts} +2 -2
  13. package/dist/contracts/{PerqTokenContract.js → perq/PerqTokenContract.js} +3 -3
  14. package/dist/contracts/{PerqTokenRecyclerContract.d.ts → perq/PerqTokenRecyclerContract.d.ts} +3 -3
  15. package/dist/contracts/{PerqTokenRecyclerContract.js → perq/PerqTokenRecyclerContract.js} +3 -3
  16. package/dist/contracts/{PerqVestingContract.d.ts → perq/PerqVestingContract.d.ts} +3 -3
  17. package/dist/contracts/{PerqVestingContract.js → perq/PerqVestingContract.js} +3 -3
  18. package/dist/subpackages/SiloPackage.d.ts +18 -0
  19. package/dist/subpackages/SiloPackage.js +115 -0
  20. package/dist/subpackages/VaultHandlerPackage.d.ts +37 -0
  21. package/dist/subpackages/VaultHandlerPackage.js +154 -0
  22. package/dist/types/DeployedProject.d.ts +1 -0
  23. package/dist/types/PerqConfig.d.ts +0 -2
  24. package/dist/types/PerqConfig.js +0 -4
  25. package/dist/types/SdkType.d.ts +2 -0
  26. package/dist/types/SdkType.js +2 -0
  27. package/dist/types/VaultData.d.ts +2 -0
  28. package/package.json +2 -1
  29. package/dist/abi/BridgeMainnetPerqToSonicAbi.json +0 -598
  30. package/dist/abi/BridgeSonicPerqToMainnetAbi.json +0 -733
  31. package/dist/contracts/BridgeMainnetPerqToSonicContract.d.ts +0 -26
  32. package/dist/contracts/BridgeMainnetPerqToSonicContract.js +0 -48
  33. package/dist/contracts/BridgeSonicPerqToMainnetContract.d.ts +0 -26
  34. package/dist/contracts/BridgeSonicPerqToMainnetContract.js +0 -48
  35. package/dist/subpackages/BridgePerqPackage.d.ts +0 -33
  36. package/dist/subpackages/BridgePerqPackage.js +0 -201
  37. /package/dist/abi/{PerqSwapAndRecyclerAbi.json → perq/PerqSwapAndRecyclerAbi.json} +0 -0
  38. /package/dist/abi/{PerqTokenAbi.json → perq/PerqTokenAbi.json} +0 -0
  39. /package/dist/abi/{PerqVestingAbi.json → perq/PerqVestingAbi.json} +0 -0
  40. /package/dist/abi/{TokenRecyclerAbi.json → perq/TokenRecyclerAbi.json} +0 -0
@@ -1,26 +0,0 @@
1
- import { ContractTransaction, ethers } from 'ethers';
2
- import BasePerqContract from './BasePerqContract';
3
- export interface SendParam {
4
- dstEid: number;
5
- to: string;
6
- amountLD: ethers.BigNumber;
7
- minAmountLD: ethers.BigNumber;
8
- extraOptions: string;
9
- composeMsg: string;
10
- oftCmd: string;
11
- }
12
- export interface MessagingFee {
13
- nativeFee: ethers.BigNumber;
14
- lzTokenFee: ethers.BigNumber;
15
- }
16
- export interface MessagingReceipt {
17
- guid: string;
18
- nonce: number;
19
- fee: MessagingFee;
20
- }
21
- import PerqSdk from '../PerqSdk';
22
- export default class BridgeMainnetPerqToSonicContract extends BasePerqContract {
23
- constructor(perqSdk: PerqSdk);
24
- send(sendParam: SendParam, fee: MessagingFee, refundAddress: string, overrides?: ethers.PayableOverrides): Promise<ContractTransaction>;
25
- quoteSend(sendParam: SendParam, payInLzToken: boolean): Promise<MessagingFee>;
26
- }
@@ -1,48 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const ethers_1 = require("ethers");
7
- const BridgeMainnetPerqToSonicAbi_json_1 = __importDefault(require("../abi/BridgeMainnetPerqToSonicAbi.json"));
8
- const BasePerqContract_1 = __importDefault(require("./BasePerqContract"));
9
- class BridgeMainnetPerqToSonicContract extends BasePerqContract_1.default {
10
- constructor(perqSdk) {
11
- super(perqSdk.perqConfig.bridgeMainnetPerqToSonicAddress, new ethers_1.ethers.utils.Interface(BridgeMainnetPerqToSonicAbi_json_1.default), perqSdk.signer);
12
- }
13
- async send(sendParam, fee, refundAddress, overrides) {
14
- if (!this.contract.signer) {
15
- throw Error('No signer provided');
16
- }
17
- // Convert the parameters to the format expected by the contract
18
- const sendParamTuple = [
19
- sendParam.dstEid,
20
- sendParam.to,
21
- sendParam.amountLD,
22
- sendParam.minAmountLD,
23
- sendParam.extraOptions,
24
- sendParam.composeMsg,
25
- sendParam.oftCmd,
26
- ];
27
- const feeTuple = [fee.nativeFee, fee.lzTokenFee];
28
- return await this.contract.send(sendParamTuple, feeTuple, refundAddress, overrides);
29
- }
30
- // Helper method to quote the send operation (useful for getting fee estimates)
31
- async quoteSend(sendParam, payInLzToken) {
32
- const sendParamTuple = [
33
- sendParam.dstEid,
34
- sendParam.to,
35
- sendParam.amountLD,
36
- sendParam.minAmountLD,
37
- sendParam.extraOptions,
38
- sendParam.composeMsg,
39
- sendParam.oftCmd,
40
- ];
41
- const result = await this.contract.quoteSend(sendParamTuple, payInLzToken);
42
- return {
43
- nativeFee: result.nativeFee,
44
- lzTokenFee: result.lzTokenFee,
45
- };
46
- }
47
- }
48
- exports.default = BridgeMainnetPerqToSonicContract;
@@ -1,26 +0,0 @@
1
- import { ContractTransaction, ethers } from 'ethers';
2
- import BasePerqContract from './BasePerqContract';
3
- export interface SendParam {
4
- dstEid: number;
5
- to: string;
6
- amountLD: ethers.BigNumber;
7
- minAmountLD: ethers.BigNumber;
8
- extraOptions: string;
9
- composeMsg: string;
10
- oftCmd: string;
11
- }
12
- export interface MessagingFee {
13
- nativeFee: ethers.BigNumber;
14
- lzTokenFee: ethers.BigNumber;
15
- }
16
- export interface MessagingReceipt {
17
- guid: string;
18
- nonce: number;
19
- fee: MessagingFee;
20
- }
21
- import PerqSdk from '../PerqSdk';
22
- export default class BridgeSonicPerqToMainnetContract extends BasePerqContract {
23
- constructor(perqSdk: PerqSdk);
24
- send(sendParam: SendParam, fee: MessagingFee, refundAddress: string, overrides?: ethers.PayableOverrides): Promise<ContractTransaction>;
25
- quoteSend(sendParam: SendParam, payInLzToken: boolean): Promise<MessagingFee>;
26
- }
@@ -1,48 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const ethers_1 = require("ethers");
7
- const BridgeSonicPerqToMainnetAbi_json_1 = __importDefault(require("../abi/BridgeSonicPerqToMainnetAbi.json"));
8
- const BasePerqContract_1 = __importDefault(require("./BasePerqContract"));
9
- class BridgeSonicPerqToMainnetContract extends BasePerqContract_1.default {
10
- constructor(perqSdk) {
11
- super(perqSdk.perqConfig.bridgeSonicPerqToMainnetAddress, new ethers_1.ethers.utils.Interface(BridgeSonicPerqToMainnetAbi_json_1.default), perqSdk.signer);
12
- }
13
- async send(sendParam, fee, refundAddress, overrides) {
14
- if (!this.contract.signer) {
15
- throw Error('No signer provided');
16
- }
17
- // Convert the parameters to the format expected by the contract
18
- const sendParamTuple = [
19
- sendParam.dstEid,
20
- sendParam.to,
21
- sendParam.amountLD,
22
- sendParam.minAmountLD,
23
- sendParam.extraOptions,
24
- sendParam.composeMsg,
25
- sendParam.oftCmd,
26
- ];
27
- const feeTuple = [fee.nativeFee, fee.lzTokenFee];
28
- return await this.contract.send(sendParamTuple, feeTuple, refundAddress, overrides);
29
- }
30
- // Helper method to quote the send operation (useful for getting fee estimates)
31
- async quoteSend(sendParam, payInLzToken) {
32
- const sendParamTuple = [
33
- sendParam.dstEid,
34
- sendParam.to,
35
- sendParam.amountLD,
36
- sendParam.minAmountLD,
37
- sendParam.extraOptions,
38
- sendParam.composeMsg,
39
- sendParam.oftCmd,
40
- ];
41
- const result = await this.contract.quoteSend(sendParamTuple, payInLzToken);
42
- return {
43
- nativeFee: result.nativeFee,
44
- lzTokenFee: result.lzTokenFee,
45
- };
46
- }
47
- }
48
- exports.default = BridgeSonicPerqToMainnetContract;
@@ -1,33 +0,0 @@
1
- import PerqSdk from '../PerqSdk';
2
- export interface BridgeQuote {
3
- nativeFee: string;
4
- lzTokenFee: string;
5
- }
6
- export default class BridgePerqPackage {
7
- perqSdk: PerqSdk;
8
- constructor(perqSdk: PerqSdk);
9
- /**
10
- * Bridge PERQ tokens from Mainnet to Sonic
11
- */
12
- bridgeMainnetToSonic(amount: string): Promise<string>;
13
- /**
14
- * Bridge PERQ tokens from Sonic to Mainnet
15
- */
16
- bridgeSonicToMainnet(amount: string): Promise<string>;
17
- /**
18
- * Check if the Mainnet to Sonic bridge contract has approval to spend PERQ tokens
19
- */
20
- checkMainnetToSonicBridgeApproval(amount: string): Promise<boolean>;
21
- /**
22
- * Approve the Mainnet to Sonic bridge contract to spend PERQ tokens
23
- */
24
- approveMainnetToSonicBridge(amount: string): Promise<string>;
25
- /**
26
- * Quote the fees for bridging PERQ from Mainnet to Sonic
27
- */
28
- private quoteMainnetToSonic;
29
- /**
30
- * Quote the fees for bridging PERQ from Sonic to Mainnet
31
- */
32
- private quoteSonicToMainnet;
33
- }
@@ -1,201 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const ethers_1 = require("ethers");
4
- const utils_1 = require("ethers/lib/utils");
5
- // Chain IDs for LayerZero
6
- const ENDPOINT_IDS = {
7
- ETHEREUM_MAINNET: 30101,
8
- SONIC_MAINNET: 30332,
9
- };
10
- class BridgePerqPackage {
11
- perqSdk;
12
- constructor(perqSdk) {
13
- this.perqSdk = perqSdk;
14
- }
15
- /**
16
- * Bridge PERQ tokens from Mainnet to Sonic
17
- */
18
- async bridgeMainnetToSonic(amount) {
19
- try {
20
- if (!this.perqSdk.signer) {
21
- throw new Error('No signer provided');
22
- }
23
- // Get signer address for bridged tokens
24
- const recipientAddress = await this.perqSdk.signer.getAddress();
25
- // Check and handle approval first
26
- const hasApproval = await this.checkMainnetToSonicBridgeApproval(amount);
27
- if (!hasApproval) {
28
- await this.approveMainnetToSonicBridge(amount);
29
- }
30
- const amountLD = (0, utils_1.parseUnits)(amount, 18);
31
- const recipientBytes32 = ethers_1.ethers.utils.hexZeroPad(recipientAddress, 32);
32
- const sendParam = {
33
- dstEid: ENDPOINT_IDS.SONIC_MAINNET,
34
- to: recipientBytes32,
35
- amountLD,
36
- minAmountLD: amountLD, // No slippage for now
37
- extraOptions: '0x',
38
- composeMsg: '0x',
39
- oftCmd: '0x',
40
- };
41
- // Get fee quote first
42
- const feeQuote = await this.quoteMainnetToSonic(amount, recipientAddress, false);
43
- const fee = {
44
- nativeFee: (0, utils_1.parseUnits)(feeQuote.nativeFee, 18),
45
- lzTokenFee: (0, utils_1.parseUnits)(feeQuote.lzTokenFee, 18),
46
- };
47
- // Send the transaction
48
- const tx = await this.perqSdk.bridgeMainnetPerqToSonicContract.send(sendParam, fee, recipientAddress, {
49
- value: fee.nativeFee,
50
- });
51
- const txReceipt = await tx.wait();
52
- return txReceipt.transactionHash;
53
- }
54
- catch (error) {
55
- if (error instanceof Error) {
56
- throw new Error(`Failed to bridge Mainnet to Sonic: ${error.message}`);
57
- }
58
- throw new Error('Failed to bridge Mainnet to Sonic: Unknown error');
59
- }
60
- }
61
- /**
62
- * Bridge PERQ tokens from Sonic to Mainnet
63
- */
64
- async bridgeSonicToMainnet(amount) {
65
- try {
66
- if (!this.perqSdk.signer) {
67
- throw new Error('No signer provided');
68
- }
69
- // Get signer address for bridged tokens
70
- const recipientAddress = await this.perqSdk.signer.getAddress();
71
- const amountLD = (0, utils_1.parseUnits)(amount, 18);
72
- const recipientBytes32 = ethers_1.ethers.utils.hexZeroPad(recipientAddress, 32);
73
- const sendParam = {
74
- dstEid: ENDPOINT_IDS.ETHEREUM_MAINNET,
75
- to: recipientBytes32,
76
- amountLD,
77
- minAmountLD: amountLD, // No slippage for now
78
- extraOptions: '0x',
79
- composeMsg: '0x',
80
- oftCmd: '0x',
81
- };
82
- // Get fee quote first
83
- const feeQuote = await this.quoteSonicToMainnet(amount, recipientAddress, false);
84
- const fee = {
85
- nativeFee: (0, utils_1.parseUnits)(feeQuote.nativeFee, 18),
86
- lzTokenFee: (0, utils_1.parseUnits)(feeQuote.lzTokenFee, 18),
87
- };
88
- // Send the transaction
89
- const tx = await this.perqSdk.bridgeSonicPerqToMainnetContract.send(sendParam, fee, recipientAddress, {
90
- value: fee.nativeFee,
91
- });
92
- const txReceipt = await tx.wait();
93
- return txReceipt.transactionHash;
94
- }
95
- catch (error) {
96
- if (error instanceof Error) {
97
- throw new Error(`Failed to bridge Sonic to Mainnet: ${error.message}`);
98
- }
99
- throw new Error('Failed to bridge Sonic to Mainnet: Unknown error');
100
- }
101
- }
102
- /**
103
- * Check if the Mainnet to Sonic bridge contract has approval to spend PERQ tokens
104
- */
105
- async checkMainnetToSonicBridgeApproval(amount) {
106
- try {
107
- if (!this.perqSdk.signer) {
108
- throw new Error('No signer provided');
109
- }
110
- const bridgeAddress = this.perqSdk.bridgeMainnetPerqToSonicContract.getContractAddress();
111
- const amountLD = (0, utils_1.parseUnits)(amount, 18);
112
- const allowance = await this.perqSdk.perqTokenContract.getAllowance(bridgeAddress);
113
- return allowance.gte(amountLD);
114
- }
115
- catch (error) {
116
- if (error instanceof Error) {
117
- throw new Error(`Failed to check Mainnet to Sonic bridge approval: ${error.message}`);
118
- }
119
- throw new Error('Failed to check Mainnet to Sonic bridge approval: Unknown error');
120
- }
121
- }
122
- /**
123
- * Approve the Mainnet to Sonic bridge contract to spend PERQ tokens
124
- */
125
- async approveMainnetToSonicBridge(amount) {
126
- try {
127
- const bridgeAddress = this.perqSdk.bridgeMainnetPerqToSonicContract.getContractAddress();
128
- const amountLD = (0, utils_1.parseUnits)(amount, 18);
129
- const tx = await this.perqSdk.perqTokenContract.approve(bridgeAddress, amountLD);
130
- const txReceipt = await tx.wait();
131
- return txReceipt.transactionHash;
132
- }
133
- catch (error) {
134
- if (error instanceof Error) {
135
- throw new Error(`Failed to approve Mainnet to Sonic bridge: ${error.message}`);
136
- }
137
- throw new Error('Failed to approve Mainnet to Sonic bridge: Unknown error');
138
- }
139
- }
140
- /**
141
- * Quote the fees for bridging PERQ from Mainnet to Sonic
142
- */
143
- async quoteMainnetToSonic(amount, recipientAddress, payInLzToken = false) {
144
- try {
145
- const amountLD = (0, utils_1.parseUnits)(amount, 18);
146
- const recipientBytes32 = ethers_1.ethers.utils.hexZeroPad(recipientAddress, 32);
147
- const sendParam = {
148
- dstEid: ENDPOINT_IDS.SONIC_MAINNET,
149
- to: recipientBytes32,
150
- amountLD,
151
- minAmountLD: amountLD, // No slippage for now
152
- extraOptions: '0x',
153
- composeMsg: '0x',
154
- oftCmd: '0x',
155
- };
156
- console.log('trying to quoteSend from mainnet to sonic with sendParam:', sendParam, ' and payInLzToken:', payInLzToken);
157
- const fee = await this.perqSdk.bridgeMainnetPerqToSonicContract.quoteSend(sendParam, payInLzToken);
158
- return {
159
- nativeFee: (0, utils_1.formatUnits)(fee.nativeFee, 18),
160
- lzTokenFee: (0, utils_1.formatUnits)(fee.lzTokenFee, 18),
161
- };
162
- }
163
- catch (error) {
164
- if (error instanceof Error) {
165
- throw new Error(`Failed to quote Mainnet to Sonic bridge: ${error.message}`);
166
- }
167
- throw new Error('Failed to quote Mainnet to Sonic bridge: Unknown error');
168
- }
169
- }
170
- /**
171
- * Quote the fees for bridging PERQ from Sonic to Mainnet
172
- */
173
- async quoteSonicToMainnet(amount, recipientAddress, payInLzToken = false) {
174
- try {
175
- const amountLD = (0, utils_1.parseUnits)(amount, 18);
176
- const recipientBytes32 = ethers_1.ethers.utils.hexZeroPad(recipientAddress, 32);
177
- const sendParam = {
178
- dstEid: ENDPOINT_IDS.ETHEREUM_MAINNET,
179
- to: recipientBytes32,
180
- amountLD,
181
- minAmountLD: amountLD, // No slippage for now
182
- extraOptions: '0x',
183
- composeMsg: '0x',
184
- oftCmd: '0x',
185
- };
186
- console.log('trying to quoteSend from sonic to mainnet with sendParam:', sendParam, ' and payInLzToken:', payInLzToken);
187
- const fee = await this.perqSdk.bridgeSonicPerqToMainnetContract.quoteSend(sendParam, payInLzToken);
188
- return {
189
- nativeFee: (0, utils_1.formatUnits)(fee.nativeFee, 18),
190
- lzTokenFee: (0, utils_1.formatUnits)(fee.lzTokenFee, 18),
191
- };
192
- }
193
- catch (error) {
194
- if (error instanceof Error) {
195
- throw new Error(`Failed to quote Sonic to Mainnet bridge: ${error.message}`);
196
- }
197
- throw new Error('Failed to quote Sonic to Mainnet bridge: Unknown error');
198
- }
199
- }
200
- }
201
- exports.default = BridgePerqPackage;