Skip to content

Commit a7d7ee5

Browse files
committed
fix(doc): docs inaccuracy
1 parent 40a09fa commit a7d7ee5

File tree

3 files changed

+47
-112
lines changed

3 files changed

+47
-112
lines changed

src/auction-calculator/README.md

Lines changed: 44 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -5,120 +5,55 @@
55
### Real world example
66

77
```typescript
8-
import {AuctionCalculator} from '@1inch/fusion-sdk'
9-
10-
const limitOrderStruct = {
11-
allowedSender: '0x0000000000000000000000000000000000000000',
12-
interactions:
13-
'0x000c004e200000000000000000219ab540356cbb839cbe05303d7705faf486570009',
14-
maker: '0x00000000219ab540356cbb839cbe05303d7705fa',
15-
makerAsset: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
16-
makingAmount: '1000000000000000000',
17-
offsets: '0',
18-
receiver: '0x0000000000000000000000000000000000000000',
19-
salt: '45118768841948961586167738353692277076075522015101619148498725069326976558864',
20-
takerAsset: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
21-
takingAmount: '1420000000'
22-
}
23-
24-
const calculator = AuctionCalculator.fromLimitOrderV3Struct(limitOrderStruct)
25-
// #=> AuctionCalculator instance
26-
27-
const rate = calculator.calcRateBump(1673548209)
28-
// #=> 14285
8+
import {
9+
AuctionCalculator,
10+
SettlementPostInteractionData,
11+
AuctionDetails,
12+
Address,
13+
bpsToRatioFormat
14+
} from '@1inch/fusion-sdk'
15+
16+
const startTime = 1673548149n
17+
const settlementData = SettlementPostInteractionData.new({
18+
bankFee: 0n,
19+
auctionStartTime: startTime,
20+
whitelist: [
21+
{
22+
address: new Address('0x111111111117dc0aa78b770fa6a738034120c302'),
23+
delay: 0n
24+
}
25+
],
26+
integratorFee: {
27+
receiver: new Address('0x111111111117dc0aa78b770fa6a738034120c302'),
28+
ratio: bpsToRatioFormat(10)
29+
}
30+
})
31+
const details = new AuctionDetails({
32+
duration: 180n, // in seconds,
33+
startTime, // unix timestamp (in sec),
34+
initialRateBump: 50000,
35+
points: [
36+
{
37+
delay: 10, // relative to auction start time
38+
coefficient: 40000
39+
},
40+
41+
{
42+
delay: 10, // relative to previous point
43+
coefficient: 40000
44+
}
45+
]
46+
})
47+
const calculator = AuctionCalculator.fromAuctionData(settlementData, details) // #=> AuctionCalculator instance
48+
49+
const rate = calculator.calcRateBump(1673548160)
50+
// #=> 40000
2951

3052
const auctionTakingAmount = calculator.calcAuctionTakingAmount(
3153
'1420000000',
3254
rate
3355
)
34-
// #=> '1422028470'
35-
```
36-
37-
### static AuctionCalculator.fromLimitOrderV3Struct
38-
39-
**Description:** used to create auction instance from limit order
40-
41-
**Arguments:** accepts LimitOrderV3Struct as an argument
42-
43-
| Name | Type | Inner Solidity Type | Description |
44-
| ------------- | ------ | ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
45-
| salt | string | uint256 | some unique value. It is necessary to be able to create limit orders with the same parameters (so that they have a different hash) |
46-
| makerAsset | string | address | the address of the asset user want to sell (address of a token contract) |
47-
| takerAsset | string | address | the address of the asset user want to buy (address of a token contract) |
48-
| maker | string | address | the address of the limit order creator |
49-
| receiver | string | address | If it contains a zero address, which means that taker asset will be sent to the address of the creator of the limit order. If user set any other value, then taker asset will be sent to the specified address |
50-
| allowedSender | string | address | If it contains a zero address, which means that a limit order is available for everyone to fill. If user set any other value, then the limit order will be available for execution only for the specified address (private limit order) |
51-
| makingAmount | string | uint256 | amount of maker asset |
52-
| takingAmount | string | uint256 | amount of taker asset |
53-
| offsets | string | uint256 | every 32's bytes represents offset of the n'ths interaction |
54-
| interactions | string | bytes | used to encode fusion specific data |
55-
56-
**Order.interactions suffix structure:**
57-
58-
- M\*(1 + 3 bytes) - auction points coefficients with seconds delays
59-
- N\*(4 + 20 bytes) - resolver with corresponding time limit
60-
- 4 bytes - public time limit (started from this point of time an order can be full filled by anyone)
61-
- 32 bytes - taking fee (optional if flags has \_HAS_TAKING_FEE_FLAG)
62-
- 1 byte - flags
63-
64-
**Examples:**
65-
66-
```typescript
67-
import {AuctionCalculator} from '@1inch/fusion-sdk'
68-
69-
const limitOrderStruct = {
70-
allowedSender: '0x0000000000000000000000000000000000000000',
71-
interactions:
72-
'0x000c004e200000000000000000219ab540356cbb839cbe05303d7705faf486570009',
73-
maker: '0x00000000219ab540356cbb839cbe05303d7705fa',
74-
makerAsset: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
75-
makingAmount: '1000000000000000000',
76-
offsets: '0',
77-
receiver: '0x0000000000000000000000000000000000000000',
78-
salt: '45118768841948961586167738353692277076075522015101619148498725069326976558864',
79-
takerAsset: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
80-
takingAmount: '1420000000'
81-
}
82-
83-
AuctionCalculator.fromLimitOrderV3Struct(limitOrderStruct)
84-
// #=> AuctionCalculator instance
56+
// #=> '1427105680'
8557
```
8658

87-
### AuctionCalculator.calcRateBump
88-
89-
**Description:** used to calculate exchange rate in some point of time. user can read more about it [here](https://docs.1inch.io/docs/fusion-swap/introduction)
9059

91-
**Arguments**: time (unix timestamp)
92-
93-
### AuctionCalculator.calcAuctionTakingAmount
94-
95-
**Description:** used to calculate taker amount
96-
97-
**Arguments**:
98-
99-
- [0] takingAmount: string
100-
- [1] rate: number
101-
102-
### AuctionCalculator.fromAuctionData
103-
104-
**Description:** creates AuctionCalculator from suffix and salt
105-
106-
**Arguments:**
107-
108-
- [0] suffix: [AuctionSuffix](src/auction-suffix/readme.md)
109-
- [1] salt: [AuctionSalt](src/auction-salt/readme.md)
110-
111-
**Example:**
112-
113-
```typescript
114-
import {AuctionSuffix, AuctionSalt, AuctionCalculator} from '@1inch/fusion-sdk'
115-
116-
const suffix = AuctionSuffix.decode(
117-
'0x000c004e200000000000000000219ab540356cbb839cbe05303d7705faf486570009'
118-
)
119-
const salt = AuctionSalt.decode(
120-
'45118768841948961586167738353692277076075522015101619148498725069326976558864'
121-
)
122-
AuctionCalculator.fromAuctionData(suffix, salt)
123-
// #=> AuctionCalculator instance
124-
```

src/fusion-order/auction-details/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import {AuctionDetails} from '@1inch/fusion-sdk'
1414

1515
const details = new AuctionDetails({
16-
duration: 180, // in seconds,
16+
duration: 180n, // in seconds,
1717
startTime: 1673548149n, // unix timestamp (in sec),
1818
initialRateBump: 50000, // difference between max and min amount in percents, 10000000 = 100%
1919
/**

src/fusion-order/settlement-post-interaction-data/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ type SettlementSuffixData = {
3838
**Example:**
3939
4040
```typescript
41-
import {SettlementPostInteractionData} from '@1inch/fusion-sdk'
41+
import {SettlementPostInteractionData, Address, bpsToRatioFormat} from '@1inch/fusion-sdk'
4242

4343
const data = SettlementPostInteractionData.new({
4444
bankFee: 0n,
4545
auctionStartTime: 1708117482n,
4646
whitelist: [
4747
{
4848
address: new Address('0x111111111117dc0aa78b770fa6a738034120c302'),
49-
allowance: 0
49+
delay: 0n
5050
}
5151
],
5252
integratorFee: {

0 commit comments

Comments
 (0)