@aspan/sdk 0.4.8 → 0.4.9
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 +1 -1
- package/dist/index.d.mts +31 -12
- package/dist/index.d.ts +31 -12
- package/dist/index.js +21 -11
- package/dist/index.mjs +21 -11
- package/package.json +1 -1
- package/src/__tests__/risk.test.ts +3 -3
- package/src/abi/diamond.ts +14 -4
- package/src/client.ts +7 -7
- package/src/index.ts +2 -2
- package/src/types.ts +6 -3
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ import { BSC_ADDRESSES } from "@aspan/sdk";
|
|
|
22
22
|
| Contract | Address |
|
|
23
23
|
|----------|---------|
|
|
24
24
|
| **Diamond (Main Entry)** | `0x6a11B30d3a70727d5477D6d8090e144443fA1c78` |
|
|
25
|
-
| **Router** | `
|
|
25
|
+
| **Router** | `0x1Ca976d2043dfb785c7F3A17535B3A38c50113f3` |
|
|
26
26
|
| **ApUSD** | `0x4570047eeB5aDb4081c5d470494EB5134e34A287` |
|
|
27
27
|
| **XBNB** | `0x0A0c9CD826e747D99F90D63e780B3727Da4D0d43` |
|
|
28
28
|
| **SApUSD** | `0xE2BE739C4aA4126ee72D612d9548C38B1B0e5A1b` |
|
package/dist/index.d.mts
CHANGED
|
@@ -97,11 +97,14 @@ interface RedeemXBNBParams {
|
|
|
97
97
|
}
|
|
98
98
|
/** Parameters for depositing to stability pool */
|
|
99
99
|
interface DepositParams {
|
|
100
|
-
|
|
100
|
+
assets: bigint;
|
|
101
|
+
receiver: Address;
|
|
101
102
|
}
|
|
102
|
-
/** Parameters for
|
|
103
|
-
interface
|
|
103
|
+
/** Parameters for redeeming from stability pool */
|
|
104
|
+
interface RedeemParams {
|
|
104
105
|
shares: bigint;
|
|
106
|
+
receiver: Address;
|
|
107
|
+
owner: Address;
|
|
105
108
|
}
|
|
106
109
|
/** Overall protocol statistics */
|
|
107
110
|
interface ProtocolStats {
|
|
@@ -577,11 +580,11 @@ declare class AspanClient extends AspanReadClient {
|
|
|
577
580
|
*/
|
|
578
581
|
deposit(params: DepositParams): Promise<Hash>;
|
|
579
582
|
/**
|
|
580
|
-
*
|
|
581
|
-
* @param params
|
|
583
|
+
* Redeem from stability pool by shares
|
|
584
|
+
* @param params Redeem parameters
|
|
582
585
|
* @returns Transaction hash
|
|
583
586
|
*/
|
|
584
|
-
|
|
587
|
+
redeem(params: RedeemParams): Promise<Hash>;
|
|
585
588
|
/**
|
|
586
589
|
* Harvest yield from LSTs
|
|
587
590
|
* @returns Transaction hash
|
|
@@ -1331,9 +1334,13 @@ declare const DiamondABI: readonly [{
|
|
|
1331
1334
|
readonly type: "function";
|
|
1332
1335
|
readonly name: "deposit";
|
|
1333
1336
|
readonly inputs: readonly [{
|
|
1334
|
-
readonly name: "
|
|
1337
|
+
readonly name: "assets";
|
|
1335
1338
|
readonly type: "uint256";
|
|
1336
1339
|
readonly internalType: "uint256";
|
|
1340
|
+
}, {
|
|
1341
|
+
readonly name: "receiver";
|
|
1342
|
+
readonly type: "address";
|
|
1343
|
+
readonly internalType: "address";
|
|
1337
1344
|
}];
|
|
1338
1345
|
readonly outputs: readonly [{
|
|
1339
1346
|
readonly name: "shares";
|
|
@@ -1343,14 +1350,26 @@ declare const DiamondABI: readonly [{
|
|
|
1343
1350
|
readonly stateMutability: "nonpayable";
|
|
1344
1351
|
}, {
|
|
1345
1352
|
readonly type: "function";
|
|
1346
|
-
readonly name: "
|
|
1353
|
+
readonly name: "redeem";
|
|
1347
1354
|
readonly inputs: readonly [{
|
|
1348
|
-
readonly name: "
|
|
1355
|
+
readonly name: "shares";
|
|
1349
1356
|
readonly type: "uint256";
|
|
1350
1357
|
readonly internalType: "uint256";
|
|
1358
|
+
}, {
|
|
1359
|
+
readonly name: "receiver";
|
|
1360
|
+
readonly type: "address";
|
|
1361
|
+
readonly internalType: "address";
|
|
1362
|
+
}, {
|
|
1363
|
+
readonly name: "owner";
|
|
1364
|
+
readonly type: "address";
|
|
1365
|
+
readonly internalType: "address";
|
|
1351
1366
|
}];
|
|
1352
1367
|
readonly outputs: readonly [{
|
|
1353
|
-
readonly name: "
|
|
1368
|
+
readonly name: "apUSDOut";
|
|
1369
|
+
readonly type: "uint256";
|
|
1370
|
+
readonly internalType: "uint256";
|
|
1371
|
+
}, {
|
|
1372
|
+
readonly name: "xBNBOut";
|
|
1354
1373
|
readonly type: "uint256";
|
|
1355
1374
|
readonly internalType: "uint256";
|
|
1356
1375
|
}];
|
|
@@ -2809,7 +2828,7 @@ declare const BPS_PRECISION = 10000n;
|
|
|
2809
2828
|
declare const PRICE_PRECISION: bigint;
|
|
2810
2829
|
declare const BSC_ADDRESSES: {
|
|
2811
2830
|
readonly diamond: "0x6a11B30d3a70727d5477D6d8090e144443fA1c78";
|
|
2812
|
-
readonly router: "
|
|
2831
|
+
readonly router: "0x1Ca976d2043dfb785c7F3A17535B3A38c50113f3";
|
|
2813
2832
|
readonly apUSD: "0x4570047eeB5aDb4081c5d470494EB5134e34A287";
|
|
2814
2833
|
readonly xBNB: "0x0A0c9CD826e747D99F90D63e780B3727Da4D0d43";
|
|
2815
2834
|
readonly sApUSD: "0x896770Dba7c0481539E25aaB56bE285ECF6D65eB";
|
|
@@ -2869,4 +2888,4 @@ declare function formatPriceUSD(price: bigint): string;
|
|
|
2869
2888
|
*/
|
|
2870
2889
|
declare function calculateAPY(previousRate: bigint, currentRate: bigint, periodDays: number): number;
|
|
2871
2890
|
|
|
2872
|
-
export { type ApUSDMintedEvent, type ApUSDRedeemedEvent, AspanClient, type AspanClientConfig, AspanReadClient, AspanRouterClient, type AspanRouterClientConfig, AspanRouterReadClient, type AspanRouterWriteClientConfig, type AspanWriteClientConfig, BPS_PRECISION, BSC_ADDRESSES, type BigIntString, CHAIN_IDS, type CurrentFeeTier, type CurrentFees, type DepositParams, type DepositedEvent, DiamondABI, type ExpectedOutput, type FeeTier, type LSTInfo, type LSTYieldInfo, type MintApUSDParams, type MintXBNBParams, type OracleBounds, PHAROS_ADDRESSES, PRECISION, PRICE_PRECISION, type ProtocolStats, type RedeemAndSwapEvent, type RedeemApUSDParams, type RedeemXBNBParams, RouterABI, type RouterMintEvent, type RouterMintParams, type RouterMintParams2, type RouterRedeemAndSwapParams, type RouterRedeemAndUnstakeParams, type RouterRedeemEvent, type RouterRedeemParams, type RouterSwapParams, type StabilityMode2Info, type StabilityModeInfo, type StabilityPoolStats, type StakeAndMintEvent, type StakeAndMintParams, type SwapAndMintDefaultParams, type SwapAndMintEvent, type SwapAndMintParams, type TokenAddresses, type TransactionReceipt, type TransactionResult, type UnstakeClaimedEvent, type UnstakeRequestedEvent, type UserStabilityPoolPosition, type
|
|
2891
|
+
export { type ApUSDMintedEvent, type ApUSDRedeemedEvent, AspanClient, type AspanClientConfig, AspanReadClient, AspanRouterClient, type AspanRouterClientConfig, AspanRouterReadClient, type AspanRouterWriteClientConfig, type AspanWriteClientConfig, BPS_PRECISION, BSC_ADDRESSES, type BigIntString, CHAIN_IDS, type CurrentFeeTier, type CurrentFees, type DepositParams, type DepositedEvent, DiamondABI, type ExpectedOutput, type FeeTier, type LSTInfo, type LSTYieldInfo, type MintApUSDParams, type MintXBNBParams, type OracleBounds, PHAROS_ADDRESSES, PRECISION, PRICE_PRECISION, type ProtocolStats, type RedeemAndSwapEvent, type RedeemApUSDParams, type RedeemParams, type RedeemXBNBParams, RouterABI, type RouterMintEvent, type RouterMintParams, type RouterMintParams2, type RouterRedeemAndSwapParams, type RouterRedeemAndUnstakeParams, type RouterRedeemEvent, type RouterRedeemParams, type RouterSwapParams, type StabilityMode2Info, type StabilityModeInfo, type StabilityPoolStats, type StakeAndMintEvent, type StakeAndMintParams, type SwapAndMintDefaultParams, type SwapAndMintEvent, type SwapAndMintParams, type TokenAddresses, type TransactionReceipt, type TransactionResult, type UnstakeClaimedEvent, type UnstakeRequestedEvent, type UserStabilityPoolPosition, type WithdrawalRequestInfo, type WithdrawnEvent, type XBNBMintedEvent, type XBNBRedeemedEvent, type YieldHarvestedEvent, type YieldStats, calculateAPY, createAspanClient, createAspanPharosClient, createAspanPharosReadClient, createAspanReadClient, createAspanReadClientForChain, createAspanTestnetClient, createAspanTestnetReadClient, createAspanWriteClientForChain, createRouterClient, createRouterPharosClient, createRouterPharosReadClient, createRouterReadClient, createRouterReadClientForChain, createRouterTestnetClient, createRouterTestnetReadClient, createRouterWriteClientForChain, encodeV3Path, formatAmount, formatCR, formatFeeBPS, formatPriceUSD, getChainById, parseAmount, pharosTestnet };
|
package/dist/index.d.ts
CHANGED
|
@@ -97,11 +97,14 @@ interface RedeemXBNBParams {
|
|
|
97
97
|
}
|
|
98
98
|
/** Parameters for depositing to stability pool */
|
|
99
99
|
interface DepositParams {
|
|
100
|
-
|
|
100
|
+
assets: bigint;
|
|
101
|
+
receiver: Address;
|
|
101
102
|
}
|
|
102
|
-
/** Parameters for
|
|
103
|
-
interface
|
|
103
|
+
/** Parameters for redeeming from stability pool */
|
|
104
|
+
interface RedeemParams {
|
|
104
105
|
shares: bigint;
|
|
106
|
+
receiver: Address;
|
|
107
|
+
owner: Address;
|
|
105
108
|
}
|
|
106
109
|
/** Overall protocol statistics */
|
|
107
110
|
interface ProtocolStats {
|
|
@@ -577,11 +580,11 @@ declare class AspanClient extends AspanReadClient {
|
|
|
577
580
|
*/
|
|
578
581
|
deposit(params: DepositParams): Promise<Hash>;
|
|
579
582
|
/**
|
|
580
|
-
*
|
|
581
|
-
* @param params
|
|
583
|
+
* Redeem from stability pool by shares
|
|
584
|
+
* @param params Redeem parameters
|
|
582
585
|
* @returns Transaction hash
|
|
583
586
|
*/
|
|
584
|
-
|
|
587
|
+
redeem(params: RedeemParams): Promise<Hash>;
|
|
585
588
|
/**
|
|
586
589
|
* Harvest yield from LSTs
|
|
587
590
|
* @returns Transaction hash
|
|
@@ -1331,9 +1334,13 @@ declare const DiamondABI: readonly [{
|
|
|
1331
1334
|
readonly type: "function";
|
|
1332
1335
|
readonly name: "deposit";
|
|
1333
1336
|
readonly inputs: readonly [{
|
|
1334
|
-
readonly name: "
|
|
1337
|
+
readonly name: "assets";
|
|
1335
1338
|
readonly type: "uint256";
|
|
1336
1339
|
readonly internalType: "uint256";
|
|
1340
|
+
}, {
|
|
1341
|
+
readonly name: "receiver";
|
|
1342
|
+
readonly type: "address";
|
|
1343
|
+
readonly internalType: "address";
|
|
1337
1344
|
}];
|
|
1338
1345
|
readonly outputs: readonly [{
|
|
1339
1346
|
readonly name: "shares";
|
|
@@ -1343,14 +1350,26 @@ declare const DiamondABI: readonly [{
|
|
|
1343
1350
|
readonly stateMutability: "nonpayable";
|
|
1344
1351
|
}, {
|
|
1345
1352
|
readonly type: "function";
|
|
1346
|
-
readonly name: "
|
|
1353
|
+
readonly name: "redeem";
|
|
1347
1354
|
readonly inputs: readonly [{
|
|
1348
|
-
readonly name: "
|
|
1355
|
+
readonly name: "shares";
|
|
1349
1356
|
readonly type: "uint256";
|
|
1350
1357
|
readonly internalType: "uint256";
|
|
1358
|
+
}, {
|
|
1359
|
+
readonly name: "receiver";
|
|
1360
|
+
readonly type: "address";
|
|
1361
|
+
readonly internalType: "address";
|
|
1362
|
+
}, {
|
|
1363
|
+
readonly name: "owner";
|
|
1364
|
+
readonly type: "address";
|
|
1365
|
+
readonly internalType: "address";
|
|
1351
1366
|
}];
|
|
1352
1367
|
readonly outputs: readonly [{
|
|
1353
|
-
readonly name: "
|
|
1368
|
+
readonly name: "apUSDOut";
|
|
1369
|
+
readonly type: "uint256";
|
|
1370
|
+
readonly internalType: "uint256";
|
|
1371
|
+
}, {
|
|
1372
|
+
readonly name: "xBNBOut";
|
|
1354
1373
|
readonly type: "uint256";
|
|
1355
1374
|
readonly internalType: "uint256";
|
|
1356
1375
|
}];
|
|
@@ -2809,7 +2828,7 @@ declare const BPS_PRECISION = 10000n;
|
|
|
2809
2828
|
declare const PRICE_PRECISION: bigint;
|
|
2810
2829
|
declare const BSC_ADDRESSES: {
|
|
2811
2830
|
readonly diamond: "0x6a11B30d3a70727d5477D6d8090e144443fA1c78";
|
|
2812
|
-
readonly router: "
|
|
2831
|
+
readonly router: "0x1Ca976d2043dfb785c7F3A17535B3A38c50113f3";
|
|
2813
2832
|
readonly apUSD: "0x4570047eeB5aDb4081c5d470494EB5134e34A287";
|
|
2814
2833
|
readonly xBNB: "0x0A0c9CD826e747D99F90D63e780B3727Da4D0d43";
|
|
2815
2834
|
readonly sApUSD: "0x896770Dba7c0481539E25aaB56bE285ECF6D65eB";
|
|
@@ -2869,4 +2888,4 @@ declare function formatPriceUSD(price: bigint): string;
|
|
|
2869
2888
|
*/
|
|
2870
2889
|
declare function calculateAPY(previousRate: bigint, currentRate: bigint, periodDays: number): number;
|
|
2871
2890
|
|
|
2872
|
-
export { type ApUSDMintedEvent, type ApUSDRedeemedEvent, AspanClient, type AspanClientConfig, AspanReadClient, AspanRouterClient, type AspanRouterClientConfig, AspanRouterReadClient, type AspanRouterWriteClientConfig, type AspanWriteClientConfig, BPS_PRECISION, BSC_ADDRESSES, type BigIntString, CHAIN_IDS, type CurrentFeeTier, type CurrentFees, type DepositParams, type DepositedEvent, DiamondABI, type ExpectedOutput, type FeeTier, type LSTInfo, type LSTYieldInfo, type MintApUSDParams, type MintXBNBParams, type OracleBounds, PHAROS_ADDRESSES, PRECISION, PRICE_PRECISION, type ProtocolStats, type RedeemAndSwapEvent, type RedeemApUSDParams, type RedeemXBNBParams, RouterABI, type RouterMintEvent, type RouterMintParams, type RouterMintParams2, type RouterRedeemAndSwapParams, type RouterRedeemAndUnstakeParams, type RouterRedeemEvent, type RouterRedeemParams, type RouterSwapParams, type StabilityMode2Info, type StabilityModeInfo, type StabilityPoolStats, type StakeAndMintEvent, type StakeAndMintParams, type SwapAndMintDefaultParams, type SwapAndMintEvent, type SwapAndMintParams, type TokenAddresses, type TransactionReceipt, type TransactionResult, type UnstakeClaimedEvent, type UnstakeRequestedEvent, type UserStabilityPoolPosition, type
|
|
2891
|
+
export { type ApUSDMintedEvent, type ApUSDRedeemedEvent, AspanClient, type AspanClientConfig, AspanReadClient, AspanRouterClient, type AspanRouterClientConfig, AspanRouterReadClient, type AspanRouterWriteClientConfig, type AspanWriteClientConfig, BPS_PRECISION, BSC_ADDRESSES, type BigIntString, CHAIN_IDS, type CurrentFeeTier, type CurrentFees, type DepositParams, type DepositedEvent, DiamondABI, type ExpectedOutput, type FeeTier, type LSTInfo, type LSTYieldInfo, type MintApUSDParams, type MintXBNBParams, type OracleBounds, PHAROS_ADDRESSES, PRECISION, PRICE_PRECISION, type ProtocolStats, type RedeemAndSwapEvent, type RedeemApUSDParams, type RedeemParams, type RedeemXBNBParams, RouterABI, type RouterMintEvent, type RouterMintParams, type RouterMintParams2, type RouterRedeemAndSwapParams, type RouterRedeemAndUnstakeParams, type RouterRedeemEvent, type RouterRedeemParams, type RouterSwapParams, type StabilityMode2Info, type StabilityModeInfo, type StabilityPoolStats, type StakeAndMintEvent, type StakeAndMintParams, type SwapAndMintDefaultParams, type SwapAndMintEvent, type SwapAndMintParams, type TokenAddresses, type TransactionReceipt, type TransactionResult, type UnstakeClaimedEvent, type UnstakeRequestedEvent, type UserStabilityPoolPosition, type WithdrawalRequestInfo, type WithdrawnEvent, type XBNBMintedEvent, type XBNBRedeemedEvent, type YieldHarvestedEvent, type YieldStats, calculateAPY, createAspanClient, createAspanPharosClient, createAspanPharosReadClient, createAspanReadClient, createAspanReadClientForChain, createAspanTestnetClient, createAspanTestnetReadClient, createAspanWriteClientForChain, createRouterClient, createRouterPharosClient, createRouterPharosReadClient, createRouterReadClient, createRouterReadClientForChain, createRouterTestnetClient, createRouterTestnetReadClient, createRouterWriteClientForChain, encodeV3Path, formatAmount, formatCR, formatFeeBPS, formatPriceUSD, getChainById, parseAmount, pharosTestnet };
|
package/dist/index.js
CHANGED
|
@@ -303,15 +303,25 @@ var DiamondABI = [
|
|
|
303
303
|
{
|
|
304
304
|
type: "function",
|
|
305
305
|
name: "deposit",
|
|
306
|
-
inputs: [
|
|
306
|
+
inputs: [
|
|
307
|
+
{ name: "assets", type: "uint256", internalType: "uint256" },
|
|
308
|
+
{ name: "receiver", type: "address", internalType: "address" }
|
|
309
|
+
],
|
|
307
310
|
outputs: [{ name: "shares", type: "uint256", internalType: "uint256" }],
|
|
308
311
|
stateMutability: "nonpayable"
|
|
309
312
|
},
|
|
310
313
|
{
|
|
311
314
|
type: "function",
|
|
312
|
-
name: "
|
|
313
|
-
inputs: [
|
|
314
|
-
|
|
315
|
+
name: "redeem",
|
|
316
|
+
inputs: [
|
|
317
|
+
{ name: "shares", type: "uint256", internalType: "uint256" },
|
|
318
|
+
{ name: "receiver", type: "address", internalType: "address" },
|
|
319
|
+
{ name: "owner", type: "address", internalType: "address" }
|
|
320
|
+
],
|
|
321
|
+
outputs: [
|
|
322
|
+
{ name: "apUSDOut", type: "uint256", internalType: "uint256" },
|
|
323
|
+
{ name: "xBNBOut", type: "uint256", internalType: "uint256" }
|
|
324
|
+
],
|
|
315
325
|
stateMutability: "nonpayable"
|
|
316
326
|
},
|
|
317
327
|
{
|
|
@@ -1802,22 +1812,22 @@ var AspanClient = class extends AspanReadClient {
|
|
|
1802
1812
|
address: this.diamondAddress,
|
|
1803
1813
|
abi: DiamondABI,
|
|
1804
1814
|
functionName: "deposit",
|
|
1805
|
-
args: [params.
|
|
1815
|
+
args: [params.assets, params.receiver]
|
|
1806
1816
|
});
|
|
1807
1817
|
}
|
|
1808
1818
|
/**
|
|
1809
|
-
*
|
|
1810
|
-
* @param params
|
|
1819
|
+
* Redeem from stability pool by shares
|
|
1820
|
+
* @param params Redeem parameters
|
|
1811
1821
|
* @returns Transaction hash
|
|
1812
1822
|
*/
|
|
1813
|
-
async
|
|
1823
|
+
async redeem(params) {
|
|
1814
1824
|
return this.walletClient.writeContract({
|
|
1815
1825
|
chain: this.chain,
|
|
1816
1826
|
account: this.walletClient.account,
|
|
1817
1827
|
address: this.diamondAddress,
|
|
1818
1828
|
abi: DiamondABI,
|
|
1819
|
-
functionName: "
|
|
1820
|
-
args: [params.shares]
|
|
1829
|
+
functionName: "redeem",
|
|
1830
|
+
args: [params.shares, params.receiver, params.owner]
|
|
1821
1831
|
});
|
|
1822
1832
|
}
|
|
1823
1833
|
/**
|
|
@@ -2950,7 +2960,7 @@ var BPS_PRECISION = 10000n;
|
|
|
2950
2960
|
var PRICE_PRECISION = 10n ** 8n;
|
|
2951
2961
|
var BSC_ADDRESSES = {
|
|
2952
2962
|
diamond: "0x6a11B30d3a70727d5477D6d8090e144443fA1c78",
|
|
2953
|
-
router: "
|
|
2963
|
+
router: "0x1Ca976d2043dfb785c7F3A17535B3A38c50113f3",
|
|
2954
2964
|
apUSD: "0x4570047eeB5aDb4081c5d470494EB5134e34A287",
|
|
2955
2965
|
xBNB: "0x0A0c9CD826e747D99F90D63e780B3727Da4D0d43",
|
|
2956
2966
|
sApUSD: "0x896770Dba7c0481539E25aaB56bE285ECF6D65eB",
|
package/dist/index.mjs
CHANGED
|
@@ -245,15 +245,25 @@ var DiamondABI = [
|
|
|
245
245
|
{
|
|
246
246
|
type: "function",
|
|
247
247
|
name: "deposit",
|
|
248
|
-
inputs: [
|
|
248
|
+
inputs: [
|
|
249
|
+
{ name: "assets", type: "uint256", internalType: "uint256" },
|
|
250
|
+
{ name: "receiver", type: "address", internalType: "address" }
|
|
251
|
+
],
|
|
249
252
|
outputs: [{ name: "shares", type: "uint256", internalType: "uint256" }],
|
|
250
253
|
stateMutability: "nonpayable"
|
|
251
254
|
},
|
|
252
255
|
{
|
|
253
256
|
type: "function",
|
|
254
|
-
name: "
|
|
255
|
-
inputs: [
|
|
256
|
-
|
|
257
|
+
name: "redeem",
|
|
258
|
+
inputs: [
|
|
259
|
+
{ name: "shares", type: "uint256", internalType: "uint256" },
|
|
260
|
+
{ name: "receiver", type: "address", internalType: "address" },
|
|
261
|
+
{ name: "owner", type: "address", internalType: "address" }
|
|
262
|
+
],
|
|
263
|
+
outputs: [
|
|
264
|
+
{ name: "apUSDOut", type: "uint256", internalType: "uint256" },
|
|
265
|
+
{ name: "xBNBOut", type: "uint256", internalType: "uint256" }
|
|
266
|
+
],
|
|
257
267
|
stateMutability: "nonpayable"
|
|
258
268
|
},
|
|
259
269
|
{
|
|
@@ -1744,22 +1754,22 @@ var AspanClient = class extends AspanReadClient {
|
|
|
1744
1754
|
address: this.diamondAddress,
|
|
1745
1755
|
abi: DiamondABI,
|
|
1746
1756
|
functionName: "deposit",
|
|
1747
|
-
args: [params.
|
|
1757
|
+
args: [params.assets, params.receiver]
|
|
1748
1758
|
});
|
|
1749
1759
|
}
|
|
1750
1760
|
/**
|
|
1751
|
-
*
|
|
1752
|
-
* @param params
|
|
1761
|
+
* Redeem from stability pool by shares
|
|
1762
|
+
* @param params Redeem parameters
|
|
1753
1763
|
* @returns Transaction hash
|
|
1754
1764
|
*/
|
|
1755
|
-
async
|
|
1765
|
+
async redeem(params) {
|
|
1756
1766
|
return this.walletClient.writeContract({
|
|
1757
1767
|
chain: this.chain,
|
|
1758
1768
|
account: this.walletClient.account,
|
|
1759
1769
|
address: this.diamondAddress,
|
|
1760
1770
|
abi: DiamondABI,
|
|
1761
|
-
functionName: "
|
|
1762
|
-
args: [params.shares]
|
|
1771
|
+
functionName: "redeem",
|
|
1772
|
+
args: [params.shares, params.receiver, params.owner]
|
|
1763
1773
|
});
|
|
1764
1774
|
}
|
|
1765
1775
|
/**
|
|
@@ -2897,7 +2907,7 @@ var BPS_PRECISION = 10000n;
|
|
|
2897
2907
|
var PRICE_PRECISION = 10n ** 8n;
|
|
2898
2908
|
var BSC_ADDRESSES = {
|
|
2899
2909
|
diamond: "0x6a11B30d3a70727d5477D6d8090e144443fA1c78",
|
|
2900
|
-
router: "
|
|
2910
|
+
router: "0x1Ca976d2043dfb785c7F3A17535B3A38c50113f3",
|
|
2901
2911
|
apUSD: "0x4570047eeB5aDb4081c5d470494EB5134e34A287",
|
|
2902
2912
|
xBNB: "0x0A0c9CD826e747D99F90D63e780B3727Da4D0d43",
|
|
2903
2913
|
sApUSD: "0x896770Dba7c0481539E25aaB56bE285ECF6D65eB",
|
package/package.json
CHANGED
|
@@ -61,7 +61,7 @@ const BSC_RPC_URL = process.env.BSC_RPC_URL || "https://bsc-dataseed.binance.org
|
|
|
61
61
|
const ANVIL_DEFAULT_KEY = "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80";
|
|
62
62
|
|
|
63
63
|
const DIAMOND = "0x6a11B30d3a70727d5477D6d8090e144443fA1c78" as Address;
|
|
64
|
-
const ROUTER = "
|
|
64
|
+
const ROUTER = "0x1Ca976d2043dfb785c7F3A17535B3A38c50113f3" as Address;
|
|
65
65
|
|
|
66
66
|
const TOKENS = {
|
|
67
67
|
WBNB: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c" as Address,
|
|
@@ -1224,7 +1224,7 @@ describe.skipIf(!IS_FORK && !IS_LIVE)("Risk Control Tests", () => {
|
|
|
1224
1224
|
|
|
1225
1225
|
await approve(TOKENS.apUSD, DIAMOND, depositedApUSD);
|
|
1226
1226
|
try {
|
|
1227
|
-
await waitTx(await diamondWrite.deposit({
|
|
1227
|
+
await waitTx(await diamondWrite.deposit({ assets: depositedApUSD, receiver: account.address }));
|
|
1228
1228
|
} catch (err: any) {
|
|
1229
1229
|
console.log(` ⚠️ Deposit failed (AccessControl or not configured): ${err.shortMessage || err.message?.slice(0, 100)}`);
|
|
1230
1230
|
console.log(` Skipping remaining FC-02 tests`);
|
|
@@ -1351,7 +1351,7 @@ describe.skipIf(!IS_FORK && !IS_LIVE)("Risk Control Tests", () => {
|
|
|
1351
1351
|
|
|
1352
1352
|
console.log(` Withdrawing ${formatAmount(currentShares)} shares...`);
|
|
1353
1353
|
try {
|
|
1354
|
-
await waitTx(await diamondWrite.
|
|
1354
|
+
await waitTx(await diamondWrite.redeem({ shares: currentShares, receiver: account.address, owner: account.address }));
|
|
1355
1355
|
} catch (err: any) {
|
|
1356
1356
|
console.log(` ⚠️ Withdraw failed: ${err.shortMessage || err.message?.slice(0, 100)}`);
|
|
1357
1357
|
return;
|
package/src/abi/diamond.ts
CHANGED
|
@@ -243,15 +243,25 @@ export const DiamondABI = [
|
|
|
243
243
|
{
|
|
244
244
|
type: "function",
|
|
245
245
|
name: "deposit",
|
|
246
|
-
inputs: [
|
|
246
|
+
inputs: [
|
|
247
|
+
{ name: "assets", type: "uint256", internalType: "uint256" },
|
|
248
|
+
{ name: "receiver", type: "address", internalType: "address" }
|
|
249
|
+
],
|
|
247
250
|
outputs: [{ name: "shares", type: "uint256", internalType: "uint256" }],
|
|
248
251
|
stateMutability: "nonpayable"
|
|
249
252
|
},
|
|
250
253
|
{
|
|
251
254
|
type: "function",
|
|
252
|
-
name: "
|
|
253
|
-
inputs: [
|
|
254
|
-
|
|
255
|
+
name: "redeem",
|
|
256
|
+
inputs: [
|
|
257
|
+
{ name: "shares", type: "uint256", internalType: "uint256" },
|
|
258
|
+
{ name: "receiver", type: "address", internalType: "address" },
|
|
259
|
+
{ name: "owner", type: "address", internalType: "address" }
|
|
260
|
+
],
|
|
261
|
+
outputs: [
|
|
262
|
+
{ name: "apUSDOut", type: "uint256", internalType: "uint256" },
|
|
263
|
+
{ name: "xBNBOut", type: "uint256", internalType: "uint256" }
|
|
264
|
+
],
|
|
255
265
|
stateMutability: "nonpayable"
|
|
256
266
|
},
|
|
257
267
|
{
|
package/src/client.ts
CHANGED
|
@@ -74,7 +74,7 @@ import type {
|
|
|
74
74
|
MintXBNBParams,
|
|
75
75
|
RedeemXBNBParams,
|
|
76
76
|
DepositParams,
|
|
77
|
-
|
|
77
|
+
RedeemParams,
|
|
78
78
|
} from "./types";
|
|
79
79
|
|
|
80
80
|
// ============ Configuration ============
|
|
@@ -1190,23 +1190,23 @@ export class AspanClient extends AspanReadClient {
|
|
|
1190
1190
|
address: this.diamondAddress,
|
|
1191
1191
|
abi: DiamondABI,
|
|
1192
1192
|
functionName: "deposit",
|
|
1193
|
-
args: [params.
|
|
1193
|
+
args: [params.assets, params.receiver],
|
|
1194
1194
|
});
|
|
1195
1195
|
}
|
|
1196
1196
|
|
|
1197
1197
|
/**
|
|
1198
|
-
*
|
|
1199
|
-
* @param params
|
|
1198
|
+
* Redeem from stability pool by shares
|
|
1199
|
+
* @param params Redeem parameters
|
|
1200
1200
|
* @returns Transaction hash
|
|
1201
1201
|
*/
|
|
1202
|
-
async
|
|
1202
|
+
async redeem(params: RedeemParams): Promise<Hash> {
|
|
1203
1203
|
return this.walletClient.writeContract({
|
|
1204
1204
|
chain: this.chain,
|
|
1205
1205
|
account: this.walletClient.account!,
|
|
1206
1206
|
address: this.diamondAddress,
|
|
1207
1207
|
abi: DiamondABI,
|
|
1208
|
-
functionName: "
|
|
1209
|
-
args: [params.shares],
|
|
1208
|
+
functionName: "redeem",
|
|
1209
|
+
args: [params.shares, params.receiver, params.owner],
|
|
1210
1210
|
});
|
|
1211
1211
|
}
|
|
1212
1212
|
|
package/src/index.ts
CHANGED
|
@@ -67,7 +67,7 @@ export type {
|
|
|
67
67
|
MintXBNBParams,
|
|
68
68
|
RedeemXBNBParams,
|
|
69
69
|
DepositParams,
|
|
70
|
-
|
|
70
|
+
RedeemParams,
|
|
71
71
|
// Events
|
|
72
72
|
ApUSDMintedEvent,
|
|
73
73
|
ApUSDRedeemedEvent,
|
|
@@ -116,7 +116,7 @@ export const PRICE_PRECISION = 10n ** 8n; // Chainlink price precision
|
|
|
116
116
|
// ============ Contract Addresses (BSC Mainnet) ============
|
|
117
117
|
export const BSC_ADDRESSES = {
|
|
118
118
|
diamond: "0x6a11B30d3a70727d5477D6d8090e144443fA1c78" as const,
|
|
119
|
-
router: "
|
|
119
|
+
router: "0x1Ca976d2043dfb785c7F3A17535B3A38c50113f3" as const,
|
|
120
120
|
apUSD: "0x4570047eeB5aDb4081c5d470494EB5134e34A287" as const,
|
|
121
121
|
xBNB: "0x0A0c9CD826e747D99F90D63e780B3727Da4D0d43" as const,
|
|
122
122
|
sApUSD: "0x896770Dba7c0481539E25aaB56bE285ECF6D65eB" as const,
|
package/src/types.ts
CHANGED
|
@@ -120,12 +120,15 @@ export interface RedeemXBNBParams {
|
|
|
120
120
|
|
|
121
121
|
/** Parameters for depositing to stability pool */
|
|
122
122
|
export interface DepositParams {
|
|
123
|
-
|
|
123
|
+
assets: bigint;
|
|
124
|
+
receiver: Address;
|
|
124
125
|
}
|
|
125
126
|
|
|
126
|
-
/** Parameters for
|
|
127
|
-
export interface
|
|
127
|
+
/** Parameters for redeeming from stability pool */
|
|
128
|
+
export interface RedeemParams {
|
|
128
129
|
shares: bigint;
|
|
130
|
+
receiver: Address;
|
|
131
|
+
owner: Address;
|
|
129
132
|
}
|
|
130
133
|
|
|
131
134
|
// ============ Protocol Stats ============
|