From 91e282b4de99ed72ec4d400c0e4ddbc2586759c7 Mon Sep 17 00:00:00 2001 From: Amin Moghaddam Date: Fri, 22 Nov 2024 18:59:18 +0000 Subject: [PATCH] bump: Bump sdks (#257) Increase SEND_TRANSACTION_RETRY_COUNT_SVM to 30 Use Kamino sdk 0.7.1 Bump sdk versions to include the new bid status --- .../src/auction/service/auction_manager.rs | 2 +- contracts/svm/package.json | 2 +- sdk/js/package-lock.json | 13 +++--- sdk/js/package.json | 4 +- sdk/js/src/examples/simpleSearcherLimo.ts | 44 ++++++++----------- sdk/js/src/examples/testingSearcherLimo.ts | 9 ++-- .../searcher/examples/simple_searcher_svm.py | 2 +- sdk/python/pyproject.toml | 2 +- 8 files changed, 37 insertions(+), 41 deletions(-) diff --git a/auction-server/src/auction/service/auction_manager.rs b/auction-server/src/auction/service/auction_manager.rs index 244db6f1..7291ded5 100644 --- a/auction-server/src/auction/service/auction_manager.rs +++ b/auction-server/src/auction/service/auction_manager.rs @@ -504,7 +504,7 @@ impl AuctionManager for Service { } } -const SEND_TRANSACTION_RETRY_COUNT_SVM: i32 = 5; +const SEND_TRANSACTION_RETRY_COUNT_SVM: i32 = 30; impl Service { pub fn add_relayer_signature(&self, bid: &mut entities::Bid) { diff --git a/contracts/svm/package.json b/contracts/svm/package.json index 47da64a9..0135a572 100644 --- a/contracts/svm/package.json +++ b/contracts/svm/package.json @@ -7,7 +7,7 @@ "@coral-xyz/anchor": "^0.30.1" }, "devDependencies": { - "@kamino-finance/limo-sdk": "^0.7.0", + "@kamino-finance/limo-sdk": "^0.7.1", "@types/bn.js": "^5.1.0", "@types/chai": "^4.3.0", "@types/mocha": "^9.0.0", diff --git a/sdk/js/package-lock.json b/sdk/js/package-lock.json index e06bf5c6..c1987fd7 100644 --- a/sdk/js/package-lock.json +++ b/sdk/js/package-lock.json @@ -1,16 +1,16 @@ { "name": "@pythnetwork/express-relay-js", - "version": "0.14.3", + "version": "0.15.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@pythnetwork/express-relay-js", - "version": "0.14.3", + "version": "0.15.0", "license": "Apache-2.0", "dependencies": { "@coral-xyz/anchor": "^0.30.1", - "@kamino-finance/limo-sdk": "^0.7.0", + "@kamino-finance/limo-sdk": "^0.7.1", "@solana/web3.js": "^1.95.3", "decimal.js": "^10.4.3", "isomorphic-ws": "^5.0.0", @@ -1425,9 +1425,10 @@ } }, "node_modules/@kamino-finance/limo-sdk": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/@kamino-finance/limo-sdk/-/limo-sdk-0.7.0.tgz", - "integrity": "sha512-VOqdA7whD1gmrm6bFyM+eauMBJVm8i8qAx8cH3K8H9UH9BvFDKbQKORMseMZlAHPOmQreV6NnH90lNrObyHSJQ==", + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/@kamino-finance/limo-sdk/-/limo-sdk-0.7.1.tgz", + "integrity": "sha512-rSAwHNctBHSh0OB2rfV3b5KEa24ey/0wkJAsNty9ksQbZIz7a4kw2tGpM0CkGi6zijJ7nwtUCBpc/zfmLuDnDw==", + "license": "Apache-2.0", "dependencies": { "@coral-xyz/anchor": "^0.28.0", "@coral-xyz/borsh": "^0.28.0", diff --git a/sdk/js/package.json b/sdk/js/package.json index ec0c6d3f..2348392c 100644 --- a/sdk/js/package.json +++ b/sdk/js/package.json @@ -1,6 +1,6 @@ { "name": "@pythnetwork/express-relay-js", - "version": "0.14.3", + "version": "0.15.0", "description": "Utilities for interacting with the express relay protocol", "homepage": "https://github.com/pyth-network/per/tree/main/sdk/js", "author": "Douro Labs", @@ -38,7 +38,7 @@ }, "dependencies": { "@coral-xyz/anchor": "^0.30.1", - "@kamino-finance/limo-sdk": "^0.7.0", + "@kamino-finance/limo-sdk": "^0.7.1", "@solana/web3.js": "^1.95.3", "decimal.js": "^10.4.3", "isomorphic-ws": "^5.0.0", diff --git a/sdk/js/src/examples/simpleSearcherLimo.ts b/sdk/js/src/examples/simpleSearcherLimo.ts index d18359f1..7cd5b598 100644 --- a/sdk/js/src/examples/simpleSearcherLimo.ts +++ b/sdk/js/src/examples/simpleSearcherLimo.ts @@ -168,51 +168,43 @@ export class SimpleSearcherLimo { const outputMintDecimals = await this.getMintDecimalsCached( order.state.outputMint ); - const effectiveFillRate = this.getEffectiveFillRate(order); - const inputAmountDecimals = new Decimal( - order.state.initialInputAmount.toNumber() - ) - .mul(effectiveFillRate) - .floor() - .div(new Decimal(10).pow(inputMintDecimals)); - - const outputAmountDecimals = new Decimal( - order.state.expectedOutputAmount.toNumber() - ) - .mul(effectiveFillRate) - .ceil() - .div(new Decimal(10).pow(outputMintDecimals)); + const inputAmount = this.getInputAmount(order); + // take the ceiling of the division by adding order.state.initialInputAmount - 1 + const outputAmount = inputAmount + .mul(order.state.expectedOutputAmount) + .add(order.state.initialInputAmount) + .sub(new anchor.BN(1)) + .div(order.state.initialInputAmount); console.log("Order address", order.address.toBase58()); - console.log("Fill rate", effectiveFillRate); + console.log( + "Fill rate", + inputAmount.toNumber() / order.state.initialInputAmount.toNumber() + ); console.log( "Sell token", order.state.inputMint.toBase58(), "amount:", - inputAmountDecimals.toString() + inputAmount.toNumber() / 10 ** inputMintDecimals ); console.log( "Buy token", order.state.outputMint.toBase58(), "amount:", - outputAmountDecimals.toString() + outputAmount.toNumber() / 10 ** outputMintDecimals ); return limoClient.takeOrderIx( this.searcher.publicKey, order, - inputAmountDecimals, - outputAmountDecimals, - SVM_CONSTANTS[this.chainId].expressRelayProgram, - inputMintDecimals, - outputMintDecimals + inputAmount, + outputAmount, + SVM_CONSTANTS[this.chainId].expressRelayProgram ); } - protected getEffectiveFillRate(order: OrderStateAndAddress): Decimal { - return new Decimal(order.state.remainingInputAmount.toNumber()).div( - new Decimal(order.state.initialInputAmount.toNumber()) - ); + protected getInputAmount(order: OrderStateAndAddress): anchor.BN { + return order.state.remainingInputAmount; } async opportunityHandler(opportunity: Opportunity) { diff --git a/sdk/js/src/examples/testingSearcherLimo.ts b/sdk/js/src/examples/testingSearcherLimo.ts index 879018eb..2f1b3863 100644 --- a/sdk/js/src/examples/testingSearcherLimo.ts +++ b/sdk/js/src/examples/testingSearcherLimo.ts @@ -25,7 +25,7 @@ class SearcherLimo extends SimpleSearcherLimo { public apiKey?: string ) { super(endpointExpressRelay, chainId, searcher, endpointSvm, bid, apiKey); - this.fillRate = new Decimal(fillRate).div(new Decimal(100)); + this.fillRate = new anchor.BN(fillRate); } async getBidAmount(): Promise { @@ -44,8 +44,11 @@ class SearcherLimo extends SimpleSearcherLimo { return super.opportunityHandler(opportunity); } - protected getEffectiveFillRate(order: OrderStateAndAddress): Decimal { - return Decimal.min(this.fillRate, super.getEffectiveFillRate(order)); + protected getInputAmount(order: OrderStateAndAddress): anchor.BN { + return anchor.BN.min( + super.getInputAmount(order), + order.state.initialInputAmount.mul(this.fillRate).div(new anchor.BN(100)) + ); } } diff --git a/sdk/python/express_relay/searcher/examples/simple_searcher_svm.py b/sdk/python/express_relay/searcher/examples/simple_searcher_svm.py index 2c850573..d07bb30a 100644 --- a/sdk/python/express_relay/searcher/examples/simple_searcher_svm.py +++ b/sdk/python/express_relay/searcher/examples/simple_searcher_svm.py @@ -180,7 +180,7 @@ async def generate_take_order_ixs( output_amount = ( order["state"].expected_output_amount * input_amount + order["state"].initial_input_amount - - 1 # take the ceiling of the divison by adding order[state].initial_input_amount - 1 + - 1 # take the ceiling of the division by adding order[state].initial_input_amount - 1 ) // order["state"].initial_input_amount input_mint_decimals = await self.get_mint_decimals(order["state"].input_mint) diff --git a/sdk/python/pyproject.toml b/sdk/python/pyproject.toml index 343a5995..d51b5a4f 100644 --- a/sdk/python/pyproject.toml +++ b/sdk/python/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "express-relay" -version = "0.14.1" +version = "0.15.0" description = "Utilities for searchers and protocols to interact with the Express Relay protocol." authors = ["dourolabs"] license = "Apache-2.0"