Skip to content

Commit bdba0cd

Browse files
authored
Fusion and Limit Order updated to latest versions (#101)
1 parent 740391e commit bdba0cd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+3522
-1916
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) starting with the *v1.0.0-beta.1* release.
66

7+
## [v2.0.0-preview] - 2025-1-22
8+
[v2.0.0-preview release page](https://github.com/1inch/1inch-sdk-go/releases/tag/v2.0.0-preview)
9+
10+
### Breaking Changes
11+
- a new `surplus=true` query parameter must be added to Fusion quote requests
12+
13+
### Changed
14+
- Fusion implementation updated to support new Fusion backend
15+
- Fusion+ is disabled until refactor is complete
16+
717
## [v1.0.0-beta.3] - 2025-1-22
818
[v1.0.0-beta.3 release page](https://github.com/1inch/1inch-sdk-go/releases/tag/v1.0.0-beta.3)
919
### Changed

MIGRATIONS.md

Whitespace-only changes.

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ Jump To:
1717
## Supported APIs
1818

1919
### Token Swaps
20-
*Swap API* - [[Docs](https://portal.1inch.dev/documentation/apis/swap/classic-swap/introduction) | [SDK Example](https://github.com/1inch/1inch-sdk-go/blob/main/sdk-clients/aggregation/examples/quote/main.go)]
20+
*Classic Swap API* - [[Docs](https://portal.1inch.dev/documentation/apis/swap/classic-swap/introduction) | [SDK Example](https://github.com/1inch/1inch-sdk-go/blob/main/sdk-clients/aggregation/examples/quote/main.go)]
2121

22-
*Fusion API* - [[Docs](https://portal.1inch.dev/documentation/apis/swap/intent-swap/introduction) | [SDK Example](https://github.com/1inch/1inch-sdk-go/blob/main/sdk-clients/fusion/examples/place_order/main.go)] (now called Intent Swap)
22+
*Intent-based Swap (Fusion) API* - [[Docs](https://portal.1inch.dev/documentation/apis/swap/intent-swap/introduction) | [SDK Example](https://github.com/1inch/1inch-sdk-go/blob/main/sdk-clients/fusion/examples/place_order/main.go)]
2323

24-
*Fusion Plus API* - [[Docs](https://portal.1inch.dev/documentation/apis/swap/fusion-plus/introduction) | [SDK Example](https://github.com/1inch/1inch-sdk-go/blob/main/sdk-clients/fusionplus/examples/place_order/main.go)]
24+
*Cross-chain Swap (Fusion+) API* - [[Docs](https://portal.1inch.dev/documentation/apis/swap/fusion-plus/introduction) | [SDK Example](https://github.com/1inch/1inch-sdk-go/blob/main/sdk-clients/fusionplus/examples/place_order/main.go)]
2525

2626
*Orderbook API* - [[Docs](https://portal.1inch.dev/documentation/apis/orderbook/introduction) | [SDK Example](https://github.com/1inch/1inch-sdk-go/blob/main/sdk-clients/orderbook/examples/create_order/main.go)]
2727

@@ -147,4 +147,4 @@ an [issue](https://github.com/1inch/1inch-sdk/issues) here on GitHub
147147
## Development
148148

149149
Please see our [SDK Developer Guide](https://github.com/1inch/1inch-sdk-go/blob/main/DEVELOPMENT.md) if you would
150-
like to contribute
150+
like to contribute

internal/addresses/addresses.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package addresses
2+
3+
const ZeroAddress string = "0x0000000000000000000000000000000000000000"

internal/bigint/bigint.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import (
55
"math/big"
66
)
77

8+
var Base1E5 = big.NewInt(100000)
9+
var Base1E2 = big.NewInt(100)
10+
811
func FromString(s string) (*big.Int, error) {
912
bigInt, ok := new(big.Int).SetString(s, 10) // base 10 for decimal
1013
if !ok {

internal/bytesbuilder/bytesbuilder.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,19 @@ func New() *BytesBuilder {
1616
return &BytesBuilder{data: []byte{}}
1717
}
1818

19+
func (b *BytesBuilder) AddUint256(val *big.Int) {
20+
bytes := val.Bytes()
21+
if len(bytes) < 32 {
22+
// Pad on the left (big-endian) to 32 bytes
23+
padded := make([]byte, 32-len(bytes))
24+
bytes = append(padded, bytes...)
25+
} else if len(bytes) > 32 {
26+
// Truncate to last 32 bytes if larger (high bits ignored)
27+
bytes = bytes[len(bytes)-32:]
28+
}
29+
b.data = append(b.data, bytes...)
30+
}
31+
1932
func (b *BytesBuilder) AddUint24(val *big.Int) {
2033
bytes := val.Bytes()
2134
switch {

internal/times/time.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package times
2+
3+
import "time"
4+
5+
var Now func() int64 = NowImpl
6+
7+
func NowImpl() int64 {
8+
return time.Now().Unix()
9+
}
10+
11+
var CalculateAuctionStartTime func(uint32, uint32) uint32 = CalculateAuctionStartTimeImpl
12+
13+
func CalculateAuctionStartTimeImpl(startAuctionIn uint32, additionalWaitPeriod uint32) uint32 {
14+
currentTime := time.Now().Unix()
15+
return uint32(currentTime) + additionalWaitPeriod + startAuctionIn
16+
}

internal/validate/integration_check_cleanup_test.go

Lines changed: 0 additions & 66 deletions
This file was deleted.

internal/validate/validate.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"math/big"
66
"regexp"
77
"strings"
8-
"time"
98

109
"github.com/1inch/1inch-sdk-go/constants"
1110
"github.com/1inch/1inch-sdk-go/internal/bigint"
@@ -460,21 +459,6 @@ func CheckPermitHash(parameter interface{}, variableName string) error {
460459
return nil
461460
}
462461

463-
func CheckExpireAfterUnix(parameter interface{}, variableName string) error {
464-
value, ok := parameter.(int64)
465-
if !ok {
466-
return fmt.Errorf("for parameter '%v' to be validated as '%v', it must be a string", variableName, "ExpireAfterUnix")
467-
}
468-
if value == 0 {
469-
return nil
470-
}
471-
472-
if value < time.Now().Unix() {
473-
return NewParameterValidationError(variableName, "must be a future timestamp")
474-
}
475-
return nil
476-
}
477-
478462
func CheckFiatCurrency(parameter interface{}, variableName string) error {
479463
value, ok := parameter.(string)
480464
if !ok {

internal/validate/validate_test.go

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -955,39 +955,6 @@ func TestCheckPermitHash(t *testing.T) {
955955
}
956956
}
957957

958-
func TestExpireAfter(t *testing.T) {
959-
testcases := []struct {
960-
description string
961-
value int64
962-
expectError bool
963-
}{
964-
{
965-
description: "Valid timestamp - empty",
966-
value: 0,
967-
},
968-
{
969-
description: "Valid timestamp - year 2030",
970-
value: 1897205247,
971-
},
972-
{
973-
description: "Invalid timestamp - past",
974-
value: 1707791247,
975-
expectError: true,
976-
},
977-
}
978-
979-
for _, tc := range testcases {
980-
t.Run(tc.description, func(t *testing.T) {
981-
err := CheckExpireAfterUnix(tc.value, "testValue")
982-
if tc.expectError {
983-
require.Error(t, err, fmt.Sprintf("%s should have caused an error", tc.description))
984-
} else {
985-
require.NoError(t, err, fmt.Sprintf("%s should not have caused an error", tc.description))
986-
}
987-
})
988-
}
989-
}
990-
991958
func TestIsBigInt(t *testing.T) {
992959
testCases := []struct {
993960
description string

0 commit comments

Comments
 (0)