Skip to content

Commit

Permalink
bump: Bump sdks (#257)
Browse files Browse the repository at this point in the history
Increase SEND_TRANSACTION_RETRY_COUNT_SVM to 30
Use Kamino sdk 0.7.1
Bump sdk versions to include the new bid status
  • Loading branch information
m30m authored Nov 22, 2024
1 parent f41a95d commit 91e282b
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 41 deletions.
2 changes: 1 addition & 1 deletion auction-server/src/auction/service/auction_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ impl AuctionManager<Svm> for Service<Svm> {
}
}

const SEND_TRANSACTION_RETRY_COUNT_SVM: i32 = 5;
const SEND_TRANSACTION_RETRY_COUNT_SVM: i32 = 30;

impl Service<Svm> {
pub fn add_relayer_signature(&self, bid: &mut entities::Bid<Svm>) {
Expand Down
2 changes: 1 addition & 1 deletion contracts/svm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
13 changes: 7 additions & 6 deletions sdk/js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions sdk/js/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand Down
44 changes: 18 additions & 26 deletions sdk/js/src/examples/simpleSearcherLimo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 6 additions & 3 deletions sdk/js/src/examples/testingSearcherLimo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<anchor.BN> {
Expand All @@ -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))
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit 91e282b

Please sign in to comment.