Skip to content

Commit

Permalink
Merge branch 'develop' into remove-infura-dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
benwolski authored Dec 24, 2024
2 parents 130f282 + cb7694c commit 173b175
Show file tree
Hide file tree
Showing 16 changed files with 53 additions and 65 deletions.
23 changes: 11 additions & 12 deletions src/__tests__/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
// import { sum } from "../index";
import { fromDisplayQty } from "../utils/token";
import { toDisplayQty } from "../utils/token";
// import { sum } from "../index";
import {
// fromDisplayPrice,
// encodeCrocPrice,
pinTickUpper,
pinTickLower,
calcRangeTilt,
// truncateRightBits,
// liquidityForBaseQty,
toDisplayPrice,
fromDisplayPrice,
calcRangeTilt,
fromDisplayPrice,
pinTickLower,
// fromDisplayPrice,
// encodeCrocPrice,
pinTickUpper,
// truncateRightBits,
// liquidityForBaseQty,
toDisplayPrice,
} from "../utils";
import { fromDisplayQty, toDisplayQty } from "../utils/token";

test("1 is 1?", () => {
expect(1).toBe(1);
Expand Down
6 changes: 3 additions & 3 deletions src/__tests__/pos-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ describe('Placeholder Test Suite', () => {
});
});

/*import { queryClaim, AmbientClaim, RangeClaim, queryPos, AmbientLiqPos, RangeLiqPos, queryPosAnchors } from "../position";
import { ethers } from "ethers";
import { NODE_URL } from "..";
/*import { queryClaim, AmbientClaim, RangeClaim, queryPos, AmbientLiqPos, RangeLiqPos, queryPosAnchors } from "../position";
import { ethers } from "ethers";
import { NODE_URL } from "..";
let ropstenProvider = new ethers.providers.JsonRpcProvider(NODE_URL);
const ambPos = "0x83143c5d6e1dadd337e7d8618d6c0bf50bdfd154f08c7f9310dda845cf77ad53"
Expand Down
6 changes: 3 additions & 3 deletions src/__tests__/token.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ZeroAddress } from "ethers";
import {
getQuoteTokenAddress,
getBaseTokenAddress,
sortBaseQuoteTokens,
getBaseTokenAddress,
getQuoteTokenAddress,
sortBaseQuoteTokens,
} from "../utils/token";

test("getQuoteTokenAddress returns correct address when ETH compared with Dai on Kovan", () => {
Expand Down
10 changes: 4 additions & 6 deletions src/context.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { Provider, JsonRpcProvider } from "ethers";
import { Contract, ethers, Signer } from "ethers";
import { ChainSpec, CHAIN_SPECS } from "./constants";
import { CROC_ABI, QUERY_ABI, ERC20_ABI } from "./abis";
import { ZeroAddress } from "ethers";
import { IMPACT_ABI } from "./abis/impact";
import { Contract, ethers, JsonRpcProvider, Provider, Signer, ZeroAddress } from "ethers";
import { CROC_ABI, ERC20_ABI, QUERY_ABI } from "./abis";
import { ERC20_READ_ABI } from "./abis/erc20.read";
import { IMPACT_ABI } from "./abis/impact";
import { CHAIN_SPECS, ChainSpec } from "./constants";

export interface CrocContext {
provider: Provider;
Expand Down
10 changes: 4 additions & 6 deletions src/croc.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { Signer, TransactionResponse, ZeroAddress } from 'ethers';
import { ConnectArg, CrocContext, connectCroc } from './context';
import { CrocPoolView } from './pool';
import { ZeroAddress } from 'ethers';
import { TokenQty, CrocTokenView } from './tokens';
import { CrocSwapPlan, CrocSwapPlanOpts } from './swap';
import { Signer } from 'ethers';
import { CrocKnockoutHandle } from './knockout';
import { CrocPoolView } from './pool';
import { CrocPositionView } from './position';
import { CrocSlotReader } from './slots';
import { TransactionResponse } from 'ethers';
import { CrocSwapPlan, CrocSwapPlanOpts } from './swap';
import { CrocTokenView, TokenQty } from './tokens';
import { TempestStrategy, TempestVault } from './vaults/tempest';

/* This is the main entry point for the Croc SDK. It provides a high-level interface
Expand Down
3 changes: 1 addition & 2 deletions src/encoding/liquidity.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ethers } from "ethers";
import { ethers, ZeroAddress } from "ethers";
import { MAX_LIQ } from "../constants";
import { encodeCrocPrice } from "../utils/price";
import { ZeroAddress } from "ethers";

type Address = string;
type PoolType = number;
Expand Down
2 changes: 1 addition & 1 deletion src/examples/demo.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CrocEnv } from '../croc';
import { ethers } from 'ethers';
import { CrocEnv } from '../croc';

//const ETH = ethers.constants.ZeroAddress
//const DAI = "0xdc31Ee1784292379Fbb2964b3B9C4124D8F89C60"
Expand Down
12 changes: 5 additions & 7 deletions src/knockout.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { TransactionResponse } from 'ethers';
import { CrocContext, ensureChain } from './context';
import { CrocEthView, CrocTokenView, sortBaseQuoteViews, TokenQty } from './tokens';
import { ZeroAddress } from 'ethers';
import { KnockoutEncoder } from "./encoding/knockout";
import { TransactionResponse, ZeroAddress } from 'ethers';
import { ChainSpec } from "./constants";
import { CrocContext, ensureChain } from './context';
import { CrocSurplusFlags, decodeSurplusFlag, encodeSurplusArg } from "./encoding/flags";
import { baseTokenForQuoteConc, bigIntToFloat, floatToBigInt, quoteTokenForBaseConc, roundForConcLiq } from "./utils";
import { GAS_PADDING } from "./utils";
import { KnockoutEncoder } from "./encoding/knockout";
import { CrocEthView, CrocTokenView, sortBaseQuoteViews, TokenQty } from './tokens';
import { baseTokenForQuoteConc, bigIntToFloat, floatToBigInt, GAS_PADDING, quoteTokenForBaseConc, roundForConcLiq } from "./utils";


export class CrocKnockoutHandle {
Expand Down
12 changes: 5 additions & 7 deletions src/pool.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { TransactionResponse, ZeroAddress } from 'ethers';
import { CrocContext, ensureChain } from "./context";
import { decodeCrocPrice, toDisplayPrice, bigIntToFloat, toDisplayQty, fromDisplayPrice, roundForConcLiq, concDepositSkew, pinTickLower, pinTickUpper, neighborTicks, pinTickOutside, tickToPrice, concBaseSlippagePrice, concQuoteSlippagePrice } from './utils';
import { CrocEthView, CrocTokenView, sortBaseQuoteViews, TokenQty } from './tokens';
import { TransactionResponse } from 'ethers';
import { WarmPathEncoder } from './encoding/liquidity';
import { ZeroAddress } from 'ethers';
import { PoolInitEncoder } from "./encoding/init";
import { CrocSurplusFlags, decodeSurplusFlag, encodeSurplusArg } from "./encoding/flags";
import { GAS_PADDING } from "./utils";
import { PoolInitEncoder } from "./encoding/init";
import { WarmPathEncoder } from './encoding/liquidity';
import { CrocEthView, CrocTokenView, sortBaseQuoteViews, TokenQty } from './tokens';
import { bigIntToFloat, concBaseSlippagePrice, concDepositSkew, concQuoteSlippagePrice, decodeCrocPrice, fromDisplayPrice, GAS_PADDING, neighborTicks, pinTickLower, pinTickOutside, pinTickUpper, roundForConcLiq, tickToPrice, toDisplayPrice, toDisplayQty } from './utils';

type PriceRange = [number, number]
type TickRange = [number, number]
Expand Down
5 changes: 2 additions & 3 deletions src/recipes/reposition.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { TransactionResponse } from "ethers";
import { ensureChain } from "../context";
import { OrderDirective, PoolDirective } from "../encoding/longform";
import { CrocPoolView } from "../pool";
import { CrocSwapPlan } from "../swap";
import { CrocTokenView } from "../tokens";
import { encodeCrocPrice, tickToPrice } from "../utils";
import { encodeCrocPrice, GAS_PADDING, tickToPrice } from "../utils";
import { baseTokenForConcLiq, concDepositBalance, quoteTokenForConcLiq } from "../utils/liquidity";
import { GAS_PADDING } from "../utils";
import { ensureChain } from "../context";


interface RepositionTarget {
Expand Down
11 changes: 5 additions & 6 deletions src/swap.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { TransactionResponse, ZeroAddress, ethers } from "ethers";
import { ethers, TransactionResponse, ZeroAddress } from "ethers";
import { MAX_SQRT_PRICE, MIN_SQRT_PRICE } from "./constants";
import { CrocContext, ensureChain } from './context';
import { CrocPoolView } from './pool';
import { decodeCrocPrice, getUnsignedRawTransaction } from './utils';
import { CrocEthView, CrocTokenView, sortBaseQuoteViews, TokenQty } from './tokens';
import { CrocSurplusFlags, decodeSurplusFlag, encodeSurplusArg } from "./encoding/flags";
import { MAX_SQRT_PRICE, MIN_SQRT_PRICE } from "./constants";
import { CrocPoolView } from './pool';
import { CrocSlotReader } from "./slots";
import { GAS_PADDING } from "./utils";
import { CrocEthView, CrocTokenView, sortBaseQuoteViews, TokenQty } from './tokens';
import { decodeCrocPrice, GAS_PADDING, getUnsignedRawTransaction } from './utils';

/* Describes the predicted impact of a given swap.
* @property sellQty The total quantity of tokens predicted to be sold by the swapper to the dex.
Expand Down
6 changes: 3 additions & 3 deletions src/tokens.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { CrocContext, ensureChain } from "./context";
import { ethers, TransactionResponse, ZeroAddress, MaxUint256, Contract } from "ethers";
import { Contract, ethers, MaxUint256, TransactionResponse, ZeroAddress } from "ethers";
import { MAX_LIQ } from "./constants";
import { toDisplayQty, fromDisplayQty } from "./utils/token";
import { CrocContext, ensureChain } from "./context";
import { BlockTag } from "./position";
import { GAS_PADDING } from "./utils";
import { fromDisplayQty, toDisplayQty } from "./utils/token";

/* Type representing specified token quantities. This type can either represent the raw non-decimalized
* on-chain value in wei, if passed as a BigNuber. Or it can represent the decimalized value if passed
Expand Down
2 changes: 1 addition & 1 deletion src/utils/gas.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Contract, ContractTransaction, Transaction, keccak256 } from "ethers";
import { CrocEnv } from "../croc";
import { L1_GAS_PRICE_ORACLE_ABI } from "../abis/external/L1GasPriceOracle";
import { CrocEnv } from "../croc";

// Applied to all gas estimates.
export const GAS_PADDING = BigInt(30000);
Expand Down
6 changes: 3 additions & 3 deletions src/utils/liquidity.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
bigIntToFloat,
floatToBigInt,
truncateRightBits,
bigIntToFloat,
floatToBigInt,
truncateRightBits,
} from "./";

/* Converts a fixed base token collateral amount to pool liquidity units. This conversion only applies
Expand Down
2 changes: 1 addition & 1 deletion src/utils/price.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MIN_TICK, MAX_TICK } from "../constants";
import { MAX_TICK, MIN_TICK } from "../constants";

type Tick = number;

Expand Down
2 changes: 1 addition & 1 deletion src/vaults/tempest.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Contract, Signer, TransactionResponse, Typed } from "ethers";
import { TEMPEST_VAULT_ABI } from "../abis/external/TempestVaultAbi";
import { CrocContext } from "../context";
import { CrocTokenView, TokenQty } from "../tokens";
import { TEMPEST_VAULT_ABI } from "../abis/external/TempestVaultAbi";

export type TempestStrategy = 'rswEth' | 'symetricAmbient'

Expand Down

0 comments on commit 173b175

Please sign in to comment.