0

In the program, OracleType enum is defined as

#[derive(Copy, Clone, AnchorSerialize, AnchorDeserialize, Debug)]
pub enum OracleType {
    None,
    Test,
    Pyth,
}

When I use

let tx = await program.methods
        .initTokenPair({
            allowDeposits: false,
            allowWithdrawals: false,
            allowCranks: false,
            allowSettlements: false,
            feeNumerator: new anchor.BN(1),
            feeDenominator: new anchor.BN(10),
            settleFeeNumerator: new anchor.BN(0),
            settleFeeDenominator: new anchor.BN(1),
            crankRewardTokenA: new anchor.BN(2),
            crankRewardTokenB: new anchor.BN(3),
            minSwapAmountTokenA: new anchor.BN(4),
            minSwapAmountTokenB: new anchor.BN(5),
            maxSwapPriceDiff: 0.1,
            maxUnsettledAmount: 0.3,
            minTimeTillExpiration: 0.3,
            maxOraclePriceErrorTokenA: 123.0,
            maxOraclePriceErrorTokenB: 456.0,
            maxOraclePriceAgeSecTokenA: 8,
            maxOraclePriceAgeSecTokenB: 9,
            oracleTypeTokenA: { none: {} },
            oracleTypeTokenB: { none: {} },
            oracleAccountTokenA: PublicKey.default,
            oracleAccountTokenB: PublicKey.default,
            crankAuthority: PublicKey.default,
            timeInForceIntervals: [0, 2, 3, 0, 0, 0, 0, 0, 0, 10],
        })
        ....

following error log appears

Types of property 'oracleTypeTokenA' are incompatible.
        Type '{ none: {}; }' is not assignable to type 'never'.

 60         .initTokenPair({
                           ~
 61             allowDeposits: false,
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
... 
 85             timeInForceIntervals: [0, 2, 3, 0, 0, 0, 0, 0, 0, 10],
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 86         })

Also, TWAMM tag is not available on Stack exchange atm.

1 Answer 1

1

I assigned the value to never and worked.

let nonOracle = { none: {} } as never;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.