@dripfi/drip-sdk 1.4.28 → 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 +125 -23
- package/dist/PerqApi.d.ts +2 -0
- package/dist/PerqApi.js +33 -0
- package/dist/PerqSdk.d.ts +9 -2
- package/dist/PerqSdk.js +15 -1
- package/dist/abi/SlotBurnTokenAbi.json +130 -0
- package/dist/abi/index.d.ts +336 -0
- package/dist/abi/index.js +10 -4
- package/dist/abi/perq/BridgeMainnetPerqToSonicAbi.json +598 -0
- package/dist/abi/perq/BridgeSonicPerqToMainnetAbi.json +733 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +5 -0
- 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 +9 -0
- package/dist/contracts/BridgeMainnetPerqToSonicContract.js +48 -0
- package/dist/contracts/BridgeSonicPerqToMainnetContract.d.ts +9 -0
- package/dist/contracts/BridgeSonicPerqToMainnetContract.js +47 -0
- package/dist/contracts/SlotBurnTokenContract.d.ts +8 -0
- package/dist/contracts/SlotBurnTokenContract.js +26 -0
- package/dist/contracts/index.d.ts +9 -6
- package/dist/contracts/index.js +13 -7
- 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/BridgePerqPackage.d.ts +36 -0
- package/dist/subpackages/BridgePerqPackage.js +205 -0
- package/dist/subpackages/LoyaltyCardsPackage.d.ts +6 -0
- package/dist/subpackages/LoyaltyCardsPackage.js +75 -0
- 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/BridgePerq.d.ts +14 -0
- package/dist/types/BridgePerq.js +2 -0
- package/dist/types/DeployedProject.d.ts +1 -0
- package/dist/types/LoyaltyCard.d.ts +2 -0
- package/dist/types/PerqConfig.d.ts +3 -0
- package/dist/types/PerqConfig.js +6 -0
- package/dist/types/SdkType.d.ts +2 -0
- package/dist/types/SdkType.js +2 -0
- package/dist/types/SlotMachineSpinCost.d.ts +7 -0
- package/dist/types/SlotMachineSpinCost.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/{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,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SONIC_WS_TOKEN_ADDRESS = exports.SONIC_PERQ_TOKEN_ADDRESS = void 0;
|
|
4
|
+
exports.SONIC_PERQ_TOKEN_ADDRESS = '0x26c352304909cc7e59eeed39242eb7afbc706ad3';
|
|
5
|
+
exports.SONIC_WS_TOKEN_ADDRESS = '0x039e2fb66102314ce7b64ce5ce3e5183bc94ad38';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
|
-
export default abstract class
|
|
2
|
+
export default abstract class BaseContract {
|
|
3
3
|
protected contract: ethers.Contract;
|
|
4
4
|
constructor(address: string, abi: ethers.ContractInterface, signer?: ethers.Signer);
|
|
5
5
|
updateSigner(newSigner: ethers.Signer): void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const ethers_1 = require("ethers");
|
|
4
|
-
class
|
|
4
|
+
class BaseContract {
|
|
5
5
|
contract;
|
|
6
6
|
constructor(address, abi, signer) {
|
|
7
7
|
this.contract = new ethers_1.ethers.Contract(address, abi, signer);
|
|
@@ -13,4 +13,4 @@ class BasePerqContract {
|
|
|
13
13
|
return this.contract.address;
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
exports.default =
|
|
16
|
+
exports.default = BaseContract;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ContractTransaction, ethers } from 'ethers';
|
|
2
|
+
import BaseContract from './BaseContract';
|
|
3
|
+
import PerqSdk from '../PerqSdk';
|
|
4
|
+
import { MessagingFee, SendParam } from '../types/BridgePerq';
|
|
5
|
+
export default class BridgeMainnetPerqToSonicContract extends BaseContract {
|
|
6
|
+
constructor(perqSdk: PerqSdk);
|
|
7
|
+
send(sendParam: SendParam, fee: MessagingFee, refundAddress: string, overrides?: ethers.PayableOverrides): Promise<ContractTransaction>;
|
|
8
|
+
quoteSend(sendParam: SendParam, payInLzToken: boolean): Promise<MessagingFee>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
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/perq/BridgeMainnetPerqToSonicAbi.json"));
|
|
8
|
+
const BaseContract_1 = __importDefault(require("./BaseContract"));
|
|
9
|
+
class BridgeMainnetPerqToSonicContract extends BaseContract_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
|
+
// Used for getting the fee estimation for the send operation
|
|
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;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ContractTransaction, ethers } from 'ethers';
|
|
2
|
+
import BaseContract from './BaseContract';
|
|
3
|
+
import PerqSdk from '../PerqSdk';
|
|
4
|
+
import { MessagingFee, SendParam } from '../types/BridgePerq';
|
|
5
|
+
export default class BridgeSonicPerqToMainnetContract extends BaseContract {
|
|
6
|
+
constructor(perqSdk: PerqSdk);
|
|
7
|
+
send(sendParam: SendParam, fee: MessagingFee, refundAddress: string, overrides?: ethers.PayableOverrides): Promise<ContractTransaction>;
|
|
8
|
+
quoteSend(sendParam: SendParam, payInLzToken: boolean): Promise<MessagingFee>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
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/perq/BridgeSonicPerqToMainnetAbi.json"));
|
|
8
|
+
const BaseContract_1 = __importDefault(require("./BaseContract"));
|
|
9
|
+
class BridgeSonicPerqToMainnetContract extends BaseContract_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
|
+
const sendParamTuple = [
|
|
18
|
+
sendParam.dstEid,
|
|
19
|
+
sendParam.to,
|
|
20
|
+
sendParam.amountLD,
|
|
21
|
+
sendParam.minAmountLD,
|
|
22
|
+
sendParam.extraOptions,
|
|
23
|
+
sendParam.composeMsg,
|
|
24
|
+
sendParam.oftCmd,
|
|
25
|
+
];
|
|
26
|
+
const feeTuple = [fee.nativeFee, fee.lzTokenFee];
|
|
27
|
+
return await this.contract.send(sendParamTuple, feeTuple, refundAddress, overrides);
|
|
28
|
+
}
|
|
29
|
+
// Used for getting the fee estimation for the send operation
|
|
30
|
+
async quoteSend(sendParam, payInLzToken) {
|
|
31
|
+
const sendParamTuple = [
|
|
32
|
+
sendParam.dstEid,
|
|
33
|
+
sendParam.to,
|
|
34
|
+
sendParam.amountLD,
|
|
35
|
+
sendParam.minAmountLD,
|
|
36
|
+
sendParam.extraOptions,
|
|
37
|
+
sendParam.composeMsg,
|
|
38
|
+
sendParam.oftCmd,
|
|
39
|
+
];
|
|
40
|
+
const result = await this.contract.quoteSend(sendParamTuple, payInLzToken);
|
|
41
|
+
return {
|
|
42
|
+
nativeFee: result.nativeFee,
|
|
43
|
+
lzTokenFee: result.lzTokenFee,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.default = BridgeSonicPerqToMainnetContract;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ContractTransaction } from 'ethers';
|
|
2
|
+
import BaseContract from './BaseContract';
|
|
3
|
+
import PerqSdk from '../PerqSdk';
|
|
4
|
+
export default class SlotBurnTokenContract extends BaseContract {
|
|
5
|
+
constructor(perqSdk: PerqSdk);
|
|
6
|
+
deposit(tokenAddress: string, amount: string): Promise<ContractTransaction>;
|
|
7
|
+
depositNative(amount: string): Promise<ContractTransaction>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
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 SlotBurnTokenAbi_json_1 = __importDefault(require("../abi/SlotBurnTokenAbi.json"));
|
|
8
|
+
const BaseContract_1 = __importDefault(require("./BaseContract"));
|
|
9
|
+
class SlotBurnTokenContract extends BaseContract_1.default {
|
|
10
|
+
constructor(perqSdk) {
|
|
11
|
+
super(perqSdk.perqConfig.slotBurnTokenAddress, new ethers_1.ethers.utils.Interface(SlotBurnTokenAbi_json_1.default), perqSdk.signer);
|
|
12
|
+
}
|
|
13
|
+
async deposit(tokenAddress, amount) {
|
|
14
|
+
if (!this.contract.signer) {
|
|
15
|
+
throw Error('No signer provided');
|
|
16
|
+
}
|
|
17
|
+
return await this.contract.deposit(tokenAddress, amount.toString());
|
|
18
|
+
}
|
|
19
|
+
async depositNative(amount) {
|
|
20
|
+
if (!this.contract.signer) {
|
|
21
|
+
throw Error('No signer provided');
|
|
22
|
+
}
|
|
23
|
+
return await this.contract.depositNative({ value: amount.toString() });
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.default = SlotBurnTokenContract;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
1
|
+
import BaseContract from './BaseContract';
|
|
2
|
+
import BridgeMainnetPerqToSonicContract from './BridgeMainnetPerqToSonicContract';
|
|
3
|
+
import BridgeSonicPerqToMainnetContract from './BridgeSonicPerqToMainnetContract';
|
|
4
|
+
import SlotBurnTokenContract from './SlotBurnTokenContract';
|
|
5
|
+
import PerqSwapAndRecyclerContract from './perq/PerqSwapAndRecyclerContract';
|
|
6
|
+
import PerqTokenRecyclerContract from './perq/PerqTokenRecyclerContract';
|
|
7
|
+
import PerqTokenContract from './perq/PerqTokenContract';
|
|
8
|
+
import PerqVestingContract from './perq/PerqVestingContract';
|
|
9
|
+
export { BaseContract, BridgeMainnetPerqToSonicContract, BridgeSonicPerqToMainnetContract, PerqSwapAndRecyclerContract, PerqTokenRecyclerContract, PerqTokenContract, PerqVestingContract, SlotBurnTokenContract, };
|
package/dist/contracts/index.js
CHANGED
|
@@ -3,14 +3,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.PerqVestingContract = exports.PerqTokenContract = exports.PerqTokenRecyclerContract = exports.PerqSwapAndRecyclerContract = exports.
|
|
7
|
-
const
|
|
8
|
-
exports.
|
|
9
|
-
const
|
|
6
|
+
exports.SlotBurnTokenContract = exports.PerqVestingContract = exports.PerqTokenContract = exports.PerqTokenRecyclerContract = exports.PerqSwapAndRecyclerContract = exports.BridgeSonicPerqToMainnetContract = exports.BridgeMainnetPerqToSonicContract = exports.BaseContract = void 0;
|
|
7
|
+
const BaseContract_1 = __importDefault(require("./BaseContract"));
|
|
8
|
+
exports.BaseContract = BaseContract_1.default;
|
|
9
|
+
const BridgeMainnetPerqToSonicContract_1 = __importDefault(require("./BridgeMainnetPerqToSonicContract"));
|
|
10
|
+
exports.BridgeMainnetPerqToSonicContract = BridgeMainnetPerqToSonicContract_1.default;
|
|
11
|
+
const BridgeSonicPerqToMainnetContract_1 = __importDefault(require("./BridgeSonicPerqToMainnetContract"));
|
|
12
|
+
exports.BridgeSonicPerqToMainnetContract = BridgeSonicPerqToMainnetContract_1.default;
|
|
13
|
+
const SlotBurnTokenContract_1 = __importDefault(require("./SlotBurnTokenContract"));
|
|
14
|
+
exports.SlotBurnTokenContract = SlotBurnTokenContract_1.default;
|
|
15
|
+
const PerqSwapAndRecyclerContract_1 = __importDefault(require("./perq/PerqSwapAndRecyclerContract"));
|
|
10
16
|
exports.PerqSwapAndRecyclerContract = PerqSwapAndRecyclerContract_1.default;
|
|
11
|
-
const PerqTokenRecyclerContract_1 = __importDefault(require("./PerqTokenRecyclerContract"));
|
|
17
|
+
const PerqTokenRecyclerContract_1 = __importDefault(require("./perq/PerqTokenRecyclerContract"));
|
|
12
18
|
exports.PerqTokenRecyclerContract = PerqTokenRecyclerContract_1.default;
|
|
13
|
-
const PerqTokenContract_1 = __importDefault(require("./PerqTokenContract"));
|
|
19
|
+
const PerqTokenContract_1 = __importDefault(require("./perq/PerqTokenContract"));
|
|
14
20
|
exports.PerqTokenContract = PerqTokenContract_1.default;
|
|
15
|
-
const PerqVestingContract_1 = __importDefault(require("./PerqVestingContract"));
|
|
21
|
+
const PerqVestingContract_1 = __importDefault(require("./perq/PerqVestingContract"));
|
|
16
22
|
exports.PerqVestingContract = PerqVestingContract_1.default;
|
package/dist/contracts/{PerqSwapAndRecyclerContract.d.ts → perq/PerqSwapAndRecyclerContract.d.ts}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ContractTransaction } from 'ethers';
|
|
2
|
-
import
|
|
3
|
-
import PerqSdk from '
|
|
4
|
-
export default class PerqSwapAndRecyclerContract extends
|
|
2
|
+
import BaseContract from '../BaseContract';
|
|
3
|
+
import PerqSdk from '../../PerqSdk';
|
|
4
|
+
export default class PerqSwapAndRecyclerContract extends BaseContract {
|
|
5
5
|
constructor(perqSdk: PerqSdk);
|
|
6
6
|
swapAndRecycle(beneficiary: string | undefined, path: string[], amountInWithDecimals: string, minAmountOutWithDecimals: string, price: string, deadline: string, signature: string): Promise<ContractTransaction>;
|
|
7
7
|
swapETHAndRecycle(beneficiary: string | undefined, path: string[], minAmountOutWithDecimals: string, amountInEth: string, price: string, deadline: string, signature: string): Promise<ContractTransaction>;
|
package/dist/contracts/{PerqSwapAndRecyclerContract.js → perq/PerqSwapAndRecyclerContract.js}
RENAMED
|
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const ethers_1 = require("ethers");
|
|
7
|
-
const PerqSwapAndRecyclerAbi_json_1 = __importDefault(require("
|
|
8
|
-
const
|
|
9
|
-
class PerqSwapAndRecyclerContract extends
|
|
7
|
+
const PerqSwapAndRecyclerAbi_json_1 = __importDefault(require("../../abi/perq/PerqSwapAndRecyclerAbi.json"));
|
|
8
|
+
const BaseContract_1 = __importDefault(require("../BaseContract"));
|
|
9
|
+
class PerqSwapAndRecyclerContract extends BaseContract_1.default {
|
|
10
10
|
constructor(perqSdk) {
|
|
11
11
|
super(perqSdk.perqConfig.perqSwapAndRecyclerAddress, new ethers_1.ethers.utils.Interface(PerqSwapAndRecyclerAbi_json_1.default), perqSdk.signer);
|
|
12
12
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BigNumber, ContractTransaction, ethers } from 'ethers';
|
|
2
|
-
import
|
|
3
|
-
export default class PerqTokenContract extends
|
|
2
|
+
import BaseContract from '../BaseContract';
|
|
3
|
+
export default class PerqTokenContract extends BaseContract {
|
|
4
4
|
constructor(address: string, signer?: ethers.Signer);
|
|
5
5
|
getAllowance(spender: string): Promise<BigNumber>;
|
|
6
6
|
approve(spender: string, amount: BigNumber): Promise<ContractTransaction>;
|
|
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const ethers_1 = require("ethers");
|
|
7
|
-
const PerqTokenAbi_json_1 = __importDefault(require("
|
|
8
|
-
const
|
|
9
|
-
class PerqTokenContract extends
|
|
7
|
+
const PerqTokenAbi_json_1 = __importDefault(require("../../abi/perq/PerqTokenAbi.json"));
|
|
8
|
+
const BaseContract_1 = __importDefault(require("../BaseContract"));
|
|
9
|
+
class PerqTokenContract extends BaseContract_1.default {
|
|
10
10
|
constructor(address, signer) {
|
|
11
11
|
super(address, new ethers_1.ethers.utils.Interface(PerqTokenAbi_json_1.default), signer);
|
|
12
12
|
}
|
package/dist/contracts/{PerqTokenRecyclerContract.d.ts → perq/PerqTokenRecyclerContract.d.ts}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ContractTransaction } from 'ethers';
|
|
2
|
-
import
|
|
3
|
-
import PerqSdk from '
|
|
4
|
-
export default class PerqTokenRecyclerContract extends
|
|
2
|
+
import BaseContract from '../BaseContract';
|
|
3
|
+
import PerqSdk from '../../PerqSdk';
|
|
4
|
+
export default class PerqTokenRecyclerContract extends BaseContract {
|
|
5
5
|
constructor(perqSdk: PerqSdk);
|
|
6
6
|
recycle(amountToRecycle: string, beneficiary: string | undefined, price: string, deadline: string, signature: string): Promise<ContractTransaction>;
|
|
7
7
|
}
|
|
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const ethers_1 = require("ethers");
|
|
7
|
-
const TokenRecyclerAbi_json_1 = __importDefault(require("
|
|
8
|
-
const
|
|
9
|
-
class PerqTokenRecyclerContract extends
|
|
7
|
+
const TokenRecyclerAbi_json_1 = __importDefault(require("../../abi/perq/TokenRecyclerAbi.json"));
|
|
8
|
+
const BaseContract_1 = __importDefault(require("../BaseContract"));
|
|
9
|
+
class PerqTokenRecyclerContract extends BaseContract_1.default {
|
|
10
10
|
constructor(perqSdk) {
|
|
11
11
|
super(perqSdk.perqConfig.perqTokenRecyclerAddress, new ethers_1.ethers.utils.Interface(TokenRecyclerAbi_json_1.default), perqSdk.signer);
|
|
12
12
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BigNumber, ContractTransaction } from 'ethers';
|
|
2
|
-
import
|
|
3
|
-
import PerqSdk from '
|
|
4
|
-
export default class PerqVestingContract extends
|
|
2
|
+
import BaseContract from '../BaseContract';
|
|
3
|
+
import PerqSdk from '../../PerqSdk';
|
|
4
|
+
export default class PerqVestingContract extends BaseContract {
|
|
5
5
|
constructor(perqSdk: PerqSdk);
|
|
6
6
|
start(): Promise<BigNumber>;
|
|
7
7
|
end(): Promise<BigNumber>;
|
|
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const ethers_1 = require("ethers");
|
|
7
|
-
const PerqVestingAbi_json_1 = __importDefault(require("
|
|
8
|
-
const
|
|
9
|
-
class PerqVestingContract extends
|
|
7
|
+
const PerqVestingAbi_json_1 = __importDefault(require("../../abi/perq/PerqVestingAbi.json"));
|
|
8
|
+
const BaseContract_1 = __importDefault(require("../BaseContract"));
|
|
9
|
+
class PerqVestingContract extends BaseContract_1.default {
|
|
10
10
|
constructor(perqSdk) {
|
|
11
11
|
super(perqSdk.perqConfig.perqVestingAddress, new ethers_1.ethers.utils.Interface(PerqVestingAbi_json_1.default), perqSdk.signer);
|
|
12
12
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import PerqSdk from '../PerqSdk';
|
|
2
|
+
import { BridgeMainnetPerqToSonicContract, BridgeSonicPerqToMainnetContract } from '../contracts';
|
|
3
|
+
export interface BridgeQuote {
|
|
4
|
+
nativeFee: string;
|
|
5
|
+
lzTokenFee: string;
|
|
6
|
+
}
|
|
7
|
+
export default class BridgePerqPackage {
|
|
8
|
+
perqSdk: PerqSdk;
|
|
9
|
+
bridgeMainnetPerqToSonicContract: BridgeMainnetPerqToSonicContract;
|
|
10
|
+
bridgeSonicPerqToMainnetContract: BridgeSonicPerqToMainnetContract;
|
|
11
|
+
constructor(perqSdk: PerqSdk);
|
|
12
|
+
/**
|
|
13
|
+
* Bridge PERQ tokens from Mainnet to Sonic
|
|
14
|
+
*/
|
|
15
|
+
bridgeMainnetToSonic(amount: string): Promise<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Bridge PERQ tokens from Sonic to Mainnet
|
|
18
|
+
*/
|
|
19
|
+
bridgeSonicToMainnet(amount: string): Promise<string>;
|
|
20
|
+
/**
|
|
21
|
+
* Check if the Mainnet to Sonic bridge contract has approval to spend PERQ tokens
|
|
22
|
+
*/
|
|
23
|
+
checkMainnetToSonicBridgeApproval(amount: string): Promise<boolean>;
|
|
24
|
+
/**
|
|
25
|
+
* Approve the Mainnet to Sonic bridge contract to spend PERQ tokens
|
|
26
|
+
*/
|
|
27
|
+
approveMainnetToSonicBridge(amount: string): Promise<string>;
|
|
28
|
+
/**
|
|
29
|
+
* Quote the fees for bridging PERQ from Mainnet to Sonic
|
|
30
|
+
*/
|
|
31
|
+
private quoteMainnetToSonic;
|
|
32
|
+
/**
|
|
33
|
+
* Quote the fees for bridging PERQ from Sonic to Mainnet
|
|
34
|
+
*/
|
|
35
|
+
private quoteSonicToMainnet;
|
|
36
|
+
}
|
|
@@ -0,0 +1,205 @@
|
|
|
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
|
+
const contracts_1 = require("../contracts");
|
|
6
|
+
// Chain IDs for LayerZero
|
|
7
|
+
const ENDPOINT_IDS = {
|
|
8
|
+
ETHEREUM_MAINNET: 30101,
|
|
9
|
+
SONIC_MAINNET: 30332,
|
|
10
|
+
};
|
|
11
|
+
class BridgePerqPackage {
|
|
12
|
+
perqSdk;
|
|
13
|
+
bridgeMainnetPerqToSonicContract;
|
|
14
|
+
bridgeSonicPerqToMainnetContract;
|
|
15
|
+
constructor(perqSdk) {
|
|
16
|
+
this.perqSdk = perqSdk;
|
|
17
|
+
this.bridgeMainnetPerqToSonicContract = new contracts_1.BridgeMainnetPerqToSonicContract(perqSdk);
|
|
18
|
+
this.bridgeSonicPerqToMainnetContract = new contracts_1.BridgeSonicPerqToMainnetContract(perqSdk);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Bridge PERQ tokens from Mainnet to Sonic
|
|
22
|
+
*/
|
|
23
|
+
async bridgeMainnetToSonic(amount) {
|
|
24
|
+
try {
|
|
25
|
+
if (!this.perqSdk.signer) {
|
|
26
|
+
throw new Error('No signer provided');
|
|
27
|
+
}
|
|
28
|
+
// Get signer address for bridged tokens
|
|
29
|
+
const recipientAddress = await this.perqSdk.signer.getAddress();
|
|
30
|
+
// Check and handle approval first
|
|
31
|
+
const hasApproval = await this.checkMainnetToSonicBridgeApproval(amount);
|
|
32
|
+
if (!hasApproval) {
|
|
33
|
+
await this.approveMainnetToSonicBridge(amount);
|
|
34
|
+
}
|
|
35
|
+
const amountLD = (0, utils_1.parseUnits)(amount, 18);
|
|
36
|
+
const recipientBytes32 = ethers_1.ethers.utils.hexZeroPad(recipientAddress, 32);
|
|
37
|
+
const sendParam = {
|
|
38
|
+
dstEid: ENDPOINT_IDS.SONIC_MAINNET,
|
|
39
|
+
to: recipientBytes32,
|
|
40
|
+
amountLD,
|
|
41
|
+
minAmountLD: amountLD, // No slippage for now
|
|
42
|
+
extraOptions: '0x',
|
|
43
|
+
composeMsg: '0x',
|
|
44
|
+
oftCmd: '0x',
|
|
45
|
+
};
|
|
46
|
+
// Get fee quote first
|
|
47
|
+
const feeQuote = await this.quoteMainnetToSonic(amount, recipientAddress, false);
|
|
48
|
+
const fee = {
|
|
49
|
+
nativeFee: (0, utils_1.parseUnits)(feeQuote.nativeFee, 18),
|
|
50
|
+
lzTokenFee: (0, utils_1.parseUnits)(feeQuote.lzTokenFee, 18),
|
|
51
|
+
};
|
|
52
|
+
// Send the transaction
|
|
53
|
+
const tx = await this.bridgeMainnetPerqToSonicContract.send(sendParam, fee, recipientAddress, {
|
|
54
|
+
value: fee.nativeFee,
|
|
55
|
+
});
|
|
56
|
+
const txReceipt = await tx.wait();
|
|
57
|
+
return txReceipt.transactionHash;
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
if (error instanceof Error) {
|
|
61
|
+
throw new Error(`Failed to bridge Mainnet to Sonic: ${error.message}`);
|
|
62
|
+
}
|
|
63
|
+
throw new Error('Failed to bridge Mainnet to Sonic: Unknown error');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Bridge PERQ tokens from Sonic to Mainnet
|
|
68
|
+
*/
|
|
69
|
+
async bridgeSonicToMainnet(amount) {
|
|
70
|
+
try {
|
|
71
|
+
if (!this.perqSdk.signer) {
|
|
72
|
+
throw new Error('No signer provided');
|
|
73
|
+
}
|
|
74
|
+
// Get signer address for bridged tokens
|
|
75
|
+
const recipientAddress = await this.perqSdk.signer.getAddress();
|
|
76
|
+
const amountLD = (0, utils_1.parseUnits)(amount, 18);
|
|
77
|
+
const recipientBytes32 = ethers_1.ethers.utils.hexZeroPad(recipientAddress, 32);
|
|
78
|
+
const sendParam = {
|
|
79
|
+
dstEid: ENDPOINT_IDS.ETHEREUM_MAINNET,
|
|
80
|
+
to: recipientBytes32,
|
|
81
|
+
amountLD,
|
|
82
|
+
minAmountLD: amountLD, // No slippage for now
|
|
83
|
+
extraOptions: '0x',
|
|
84
|
+
composeMsg: '0x',
|
|
85
|
+
oftCmd: '0x',
|
|
86
|
+
};
|
|
87
|
+
// Get fee quote first
|
|
88
|
+
const feeQuote = await this.quoteSonicToMainnet(amount, recipientAddress, false);
|
|
89
|
+
const fee = {
|
|
90
|
+
nativeFee: (0, utils_1.parseUnits)(feeQuote.nativeFee, 18),
|
|
91
|
+
lzTokenFee: (0, utils_1.parseUnits)(feeQuote.lzTokenFee, 18),
|
|
92
|
+
};
|
|
93
|
+
const tx = await this.bridgeSonicPerqToMainnetContract.send(sendParam, fee, recipientAddress, {
|
|
94
|
+
value: fee.nativeFee,
|
|
95
|
+
});
|
|
96
|
+
const txReceipt = await tx.wait();
|
|
97
|
+
return txReceipt.transactionHash;
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
if (error instanceof Error) {
|
|
101
|
+
throw new Error(`Failed to bridge Sonic to Mainnet: ${error.message}`);
|
|
102
|
+
}
|
|
103
|
+
throw new Error('Failed to bridge Sonic to Mainnet: Unknown error');
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Check if the Mainnet to Sonic bridge contract has approval to spend PERQ tokens
|
|
108
|
+
*/
|
|
109
|
+
async checkMainnetToSonicBridgeApproval(amount) {
|
|
110
|
+
try {
|
|
111
|
+
if (!this.perqSdk.signer) {
|
|
112
|
+
throw new Error('No signer provided');
|
|
113
|
+
}
|
|
114
|
+
const perqTokenContract = new contracts_1.PerqTokenContract(this.perqSdk.perqConfig.perqTokenAddress, this.perqSdk.signer);
|
|
115
|
+
const bridgeAddress = this.bridgeMainnetPerqToSonicContract.getContractAddress();
|
|
116
|
+
const amountLD = (0, utils_1.parseUnits)(amount, 18);
|
|
117
|
+
const allowance = await perqTokenContract.getAllowance(bridgeAddress);
|
|
118
|
+
return allowance.gte(amountLD);
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
if (error instanceof Error) {
|
|
122
|
+
throw new Error(`Failed to check Mainnet to Sonic bridge approval: ${error.message}`);
|
|
123
|
+
}
|
|
124
|
+
throw new Error('Failed to check Mainnet to Sonic bridge approval: Unknown error');
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Approve the Mainnet to Sonic bridge contract to spend PERQ tokens
|
|
129
|
+
*/
|
|
130
|
+
async approveMainnetToSonicBridge(amount) {
|
|
131
|
+
try {
|
|
132
|
+
const bridgeAddress = this.bridgeMainnetPerqToSonicContract.getContractAddress();
|
|
133
|
+
const amountLD = (0, utils_1.parseUnits)(amount, 18);
|
|
134
|
+
const perqTokenContract = new contracts_1.PerqTokenContract(this.perqSdk.perqConfig.perqTokenAddress, this.perqSdk.signer);
|
|
135
|
+
const tx = await perqTokenContract.approve(bridgeAddress, amountLD);
|
|
136
|
+
const txReceipt = await tx.wait();
|
|
137
|
+
return txReceipt.transactionHash;
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
if (error instanceof Error) {
|
|
141
|
+
throw new Error(`Failed to approve Mainnet to Sonic bridge: ${error.message}`);
|
|
142
|
+
}
|
|
143
|
+
throw new Error('Failed to approve Mainnet to Sonic bridge: Unknown error');
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Quote the fees for bridging PERQ from Mainnet to Sonic
|
|
148
|
+
*/
|
|
149
|
+
async quoteMainnetToSonic(amount, recipientAddress, payInLzToken = false) {
|
|
150
|
+
try {
|
|
151
|
+
const amountLD = (0, utils_1.parseUnits)(amount, 18);
|
|
152
|
+
const recipientBytes32 = ethers_1.ethers.utils.hexZeroPad(recipientAddress, 32);
|
|
153
|
+
const sendParam = {
|
|
154
|
+
dstEid: ENDPOINT_IDS.SONIC_MAINNET,
|
|
155
|
+
to: recipientBytes32,
|
|
156
|
+
amountLD,
|
|
157
|
+
minAmountLD: amountLD, // No slippage for now
|
|
158
|
+
extraOptions: '0x',
|
|
159
|
+
composeMsg: '0x',
|
|
160
|
+
oftCmd: '0x',
|
|
161
|
+
};
|
|
162
|
+
const fee = await this.bridgeMainnetPerqToSonicContract.quoteSend(sendParam, payInLzToken);
|
|
163
|
+
return {
|
|
164
|
+
nativeFee: (0, utils_1.formatUnits)(fee.nativeFee, 18),
|
|
165
|
+
lzTokenFee: (0, utils_1.formatUnits)(fee.lzTokenFee, 18),
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
if (error instanceof Error) {
|
|
170
|
+
throw new Error(`Failed to quote Mainnet to Sonic bridge: ${error.message}`);
|
|
171
|
+
}
|
|
172
|
+
throw new Error('Failed to quote Mainnet to Sonic bridge: Unknown error');
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Quote the fees for bridging PERQ from Sonic to Mainnet
|
|
177
|
+
*/
|
|
178
|
+
async quoteSonicToMainnet(amount, recipientAddress, payInLzToken = false) {
|
|
179
|
+
try {
|
|
180
|
+
const amountLD = (0, utils_1.parseUnits)(amount, 18);
|
|
181
|
+
const recipientBytes32 = ethers_1.ethers.utils.hexZeroPad(recipientAddress, 32);
|
|
182
|
+
const sendParam = {
|
|
183
|
+
dstEid: ENDPOINT_IDS.ETHEREUM_MAINNET,
|
|
184
|
+
to: recipientBytes32,
|
|
185
|
+
amountLD,
|
|
186
|
+
minAmountLD: amountLD, // No slippage for now
|
|
187
|
+
extraOptions: '0x',
|
|
188
|
+
composeMsg: '0x',
|
|
189
|
+
oftCmd: '0x',
|
|
190
|
+
};
|
|
191
|
+
const fee = await this.bridgeSonicPerqToMainnetContract.quoteSend(sendParam, payInLzToken);
|
|
192
|
+
return {
|
|
193
|
+
nativeFee: (0, utils_1.formatUnits)(fee.nativeFee, 18),
|
|
194
|
+
lzTokenFee: (0, utils_1.formatUnits)(fee.lzTokenFee, 18),
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
catch (error) {
|
|
198
|
+
if (error instanceof Error) {
|
|
199
|
+
throw new Error(`Failed to quote Sonic to Mainnet bridge: ${error.message}`);
|
|
200
|
+
}
|
|
201
|
+
throw new Error('Failed to quote Sonic to Mainnet bridge: Unknown error');
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
exports.default = BridgePerqPackage;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BeansBalance, BeanEntry, PerqToBeansSwapInfo, LoyaltyCard, SpecialEditionLoyaltyCard } from '../types';
|
|
2
2
|
import PerqSdk from '../PerqSdk';
|
|
3
|
+
import SlotMachineSpinCost from '../types/SlotMachineSpinCost';
|
|
3
4
|
export default class LoyaltyPackage {
|
|
4
5
|
private perqSdk;
|
|
5
6
|
constructor(perqSdk: PerqSdk);
|
|
@@ -8,8 +9,13 @@ export default class LoyaltyPackage {
|
|
|
8
9
|
getSwapPerqForBeansInfo(): Promise<PerqToBeansSwapInfo>;
|
|
9
10
|
upgradeLoyaltyCard(index: number): Promise<LoyaltyCard>;
|
|
10
11
|
getOwnedLoyaltyCard(): Promise<LoyaltyCard>;
|
|
12
|
+
getNextLoyaltyCard(): Promise<LoyaltyCard>;
|
|
11
13
|
getAllLoyaltyCards(): Promise<LoyaltyCard[]>;
|
|
12
14
|
claimSpecialEditionCard(cardId: string): Promise<SpecialEditionLoyaltyCard>;
|
|
13
15
|
getOwnedSpecialEditionCards(): Promise<SpecialEditionLoyaltyCard[]>;
|
|
14
16
|
getAllSpecialEditionCards(): Promise<SpecialEditionLoyaltyCard[]>;
|
|
17
|
+
approveForSlotSpin(tokenAddress: string, amount: string): Promise<string>;
|
|
18
|
+
runSlotSpin(isDepositNative: boolean, tokenAddress?: string): Promise<LoyaltyCard | null>;
|
|
19
|
+
getSlotMachineCost(): Promise<SlotMachineSpinCost>;
|
|
20
|
+
private seededRandom;
|
|
15
21
|
}
|